Commit c89e5784 authored by Shinya Maeda's avatar Shinya Maeda

Use shared examples for populate spec

parent c418d687
...@@ -157,6 +157,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do ...@@ -157,6 +157,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
end end
context 'when variables policy is specified' do context 'when variables policy is specified' do
shared_examples_for 'populates pipeline according to used policies' do
it 'populates pipeline according to used policies' do
step.perform!
expect(pipeline.stages.size).to eq 1
expect(pipeline.stages.first.builds.size).to eq 1
expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
end
end
context 'when using only/except build policies' do context 'when using only/except build policies' do
let(:config) do let(:config) do
{ rspec: { script: 'rspec', stage: 'test', only: ['master'] }, { rspec: { script: 'rspec', stage: 'test', only: ['master'] },
...@@ -167,28 +177,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do ...@@ -167,28 +177,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
build(:ci_pipeline, ref: 'master', config: config) build(:ci_pipeline, ref: 'master', config: config)
end end
it 'populates pipeline according to used policies' do it_behaves_like 'populates pipeline according to used policies'
step.perform!
expect(pipeline.stages.size).to eq 1
expect(pipeline.stages.first.builds.size).to eq 1
expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
end
context 'when variables expression is specified' do context 'when variables expression is specified' do
context 'when pipeline iid is the subject' do
let(:config) do let(:config) do
{ rspec: { script: 'rspec', only: { variables: ["$CI_PIPELINE_IID == '1'"] } }, { rspec: { script: 'rspec', only: { variables: ["$CI_PIPELINE_IID == '1'"] } },
prod: { script: 'cap prod', only: { variables: ["$CI_PIPELINE_IID == '1000'"] } } } prod: { script: 'cap prod', only: { variables: ["$CI_PIPELINE_IID == '1000'"] } } }
end end
context 'when pipeline iid is the subject' do it_behaves_like 'populates pipeline according to used policies'
it 'populates pipeline according to used policies' do
step.perform!
expect(pipeline.stages.size).to eq 1
expect(pipeline.stages.first.builds.size).to eq 1
expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
end
end end
end end
end end
......
...@@ -15,7 +15,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true| ...@@ -15,7 +15,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
instance.valid? instance.valid?
end end
context 'when presence validattion is required' do context 'when presence validation is required' do
before do before do
skip unless validate_presence skip unless validate_presence
end end
...@@ -25,7 +25,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true| ...@@ -25,7 +25,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
end end
end end
context 'when presence validattion is not required' do context 'when presence validation is not required' do
before do before do
skip if validate_presence skip if validate_presence
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment