From 6113ff992c9a494ea8c657f20fa92f7f7f2365c4 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 30 May 2017 13:27:46 +0200 Subject: Expose stage model attributes from pipeline object --- spec/models/ci/pipeline_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 56b24ce62f3..c4f07c4a693 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -502,6 +502,20 @@ describe Ci::Pipeline, models: true do end end + describe '#has_stages?' do + context 'when pipeline has stages' do + subject { create(:ci_pipeline_with_one_job) } + + it { is_expected.to have_stages } + end + + context 'when pipeline does not have stages' do + subject { create(:ci_pipeline_without_jobs) } + + it { is_expected.not_to have_stages } + end + end + describe '#has_warnings?' do subject { pipeline.has_warnings? } -- cgit v1.2.1 From 5c2ce44baf5205c038759c4779a74e3381183e8a Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 31 May 2017 15:25:36 +0200 Subject: Expose pipeline stage seeds from pipeline instance --- spec/models/ci/pipeline_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index c4f07c4a693..3a1fe666ff0 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -202,6 +202,17 @@ describe Ci::Pipeline, models: true do status: 'success') end + describe '#stage_seeds' do + let(:pipeline) do + create(:ci_pipeline, config: { rspec: { script: 'rake' } }) + end + + it 'returns preseeded stage seeds object' do + expect(pipeline.stage_seeds).to be_a Gitlab::Ci::Stage::Seeds + expect(pipeline.stage_seeds.stages).to all(include(pipeline: pipeline)) + end + end + describe '#stages' do subject { pipeline.stages } -- cgit v1.2.1 From c00d72b6f33d50b1c5cd6948d54b3addf11f9104 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 1 Jun 2017 11:55:18 +0200 Subject: Rename pipeline methods related to legacy stages --- spec/models/ci/pipeline_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 3a1fe666ff0..46dfa90218d 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -213,8 +213,8 @@ describe Ci::Pipeline, models: true do end end - describe '#stages' do - subject { pipeline.stages } + describe '#legacy_stages' do + subject { pipeline.legacy_stages } context 'stages list' do it 'returns ordered list of stages' do @@ -263,7 +263,7 @@ describe Ci::Pipeline, models: true do end it 'populates stage with correct number of warnings' do - deploy_stage = pipeline.stages.third + deploy_stage = pipeline.legacy_stages.third expect(deploy_stage).not_to receive(:statuses) expect(deploy_stage).to have_warnings @@ -277,15 +277,15 @@ describe Ci::Pipeline, models: true do end end - describe '#stages_name' do + describe '#stages_names' do it 'returns a valid names of stages' do - expect(pipeline.stages_name).to eq(%w(build test deploy)) + expect(pipeline.stages_names).to eq(%w(build test deploy)) end end end - describe '#stage' do - subject { pipeline.stage('test') } + describe '#legacy_stage' do + subject { pipeline.legacy_stage('test') } context 'with status in stage' do before do -- cgit v1.2.1 From 78b2f65cb5320a6a28c1e26bb6ee792a54e1b674 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 1 Jun 2017 12:00:37 +0200 Subject: Rename `Ci::Stage` class to `Ci::LegacyStage` --- spec/models/ci/pipeline_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 46dfa90218d..17e10a5322e 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -292,7 +292,7 @@ describe Ci::Pipeline, models: true do create(:commit_status, pipeline: pipeline, stage: 'test') end - it { expect(subject).to be_a Ci::Stage } + it { expect(subject).to be_a Ci::LegacyStage } it { expect(subject.name).to eq 'test' } it { expect(subject.statuses).not_to be_empty } end -- cgit v1.2.1 From fe0b2f81c7c9680a11288e0cdffc3e80dc1e8d58 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 2 Jun 2017 12:16:11 +0200 Subject: Refine implementation of pipeline stage seeds --- spec/models/ci/pipeline_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 17e10a5322e..63dbf1e9d8b 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -208,8 +208,8 @@ describe Ci::Pipeline, models: true do end it 'returns preseeded stage seeds object' do - expect(pipeline.stage_seeds).to be_a Gitlab::Ci::Stage::Seeds - expect(pipeline.stage_seeds.stages).to all(include(pipeline: pipeline)) + expect(pipeline.stage_seeds).to all(be_a Gitlab::Ci::Stage::Seed) + expect(pipeline.stage_seeds.count).to eq 1 end end @@ -513,17 +513,17 @@ describe Ci::Pipeline, models: true do end end - describe '#has_stages?' do - context 'when pipeline has stages' do + describe '#has_stage_seedss?' do + context 'when pipeline has stage seeds' do subject { create(:ci_pipeline_with_one_job) } - it { is_expected.to have_stages } + it { is_expected.to have_stage_seeds } end - context 'when pipeline does not have stages' do + context 'when pipeline does not have stage seeds' do subject { create(:ci_pipeline_without_jobs) } - it { is_expected.not_to have_stages } + it { is_expected.not_to have_stage_seeds } end end -- cgit v1.2.1 From da0852e08aa07354706be1e0be9251ccf02e85be Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 5 Jun 2017 15:23:09 +0200 Subject: Improve specs for pipeline and pipeline seeds --- spec/models/ci/pipeline_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index a4392ed073a..b50c7700bd3 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -535,9 +535,9 @@ describe Ci::Pipeline, models: true do end end - describe '#has_stage_seedss?' do + describe '#has_stage_seeds?' do context 'when pipeline has stage seeds' do - subject { create(:ci_pipeline_with_one_job) } + subject { build(:ci_pipeline_with_one_job) } it { is_expected.to have_stage_seeds } end -- cgit v1.2.1 From a6ec5121f0c844786c84c568a3200562ec58a9c2 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 14 Jun 2017 13:18:56 -0500 Subject: Correct RSpec/SingleLineHook cop offenses --- spec/models/ci/pipeline_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index b50c7700bd3..e86cbe8498a 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -1156,7 +1156,9 @@ describe Ci::Pipeline, models: true do end context 'when pipeline is not stuck' do - before { create(:ci_runner, :shared, :online) } + before do + create(:ci_runner, :shared, :online) + end it 'is not stuck' do expect(pipeline).not_to be_stuck -- cgit v1.2.1 From 0430b7644101fc70ed4be6bf69ccf05b900f4cdf Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 21 Jun 2017 13:48:12 +0000 Subject: Enable Style/DotPosition Rubocop :cop: --- spec/models/ci/pipeline_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index e86cbe8498a..dab8e8ca432 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -608,8 +608,8 @@ describe Ci::Pipeline, models: true do it 'returns the latest pipeline for the same ref and different sha' do expect(pipelines.map(&:sha)).to contain_exactly('A', 'B', 'C') - expect(pipelines.map(&:status)). - to contain_exactly('success', 'failed', 'skipped') + expect(pipelines.map(&:status)) + .to contain_exactly('success', 'failed', 'skipped') end end @@ -618,8 +618,8 @@ describe Ci::Pipeline, models: true do it 'returns the latest pipeline for ref and different sha' do expect(pipelines.map(&:sha)).to contain_exactly('A', 'B') - expect(pipelines.map(&:status)). - to contain_exactly('success', 'failed') + expect(pipelines.map(&:status)) + .to contain_exactly('success', 'failed') end end end @@ -654,8 +654,8 @@ describe Ci::Pipeline, models: true do end it 'returns the latest successful pipeline' do - expect(described_class.latest_successful_for('ref')). - to eq(latest_successful_pipeline) + expect(described_class.latest_successful_for('ref')) + .to eq(latest_successful_pipeline) end end @@ -1201,8 +1201,8 @@ describe Ci::Pipeline, models: true do before do project.team << [pipeline.user, Gitlab::Access::DEVELOPER] - pipeline.user.global_notification_setting. - update(level: 'custom', failed_pipeline: true, success_pipeline: true) + pipeline.user.global_notification_setting + .update(level: 'custom', failed_pipeline: true, success_pipeline: true) reset_delivered_emails! -- cgit v1.2.1