summaryrefslogtreecommitdiff
path: root/spec/models/ci/pipeline_spec.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-06-29 21:14:47 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-06-29 21:14:47 +0800
commitc6bed065339ff33c069225be7dc90268629d228e (patch)
treedf7498cbda881704a7c1a68a7fca8274508a4e63 /spec/models/ci/pipeline_spec.rb
parent25f930fbb34f285c2c4bde97c1e85d57a9e771d3 (diff)
parent83ae38f6523c8628444de18e0a432349b6813909 (diff)
downloadgitlab-ce-c6bed065339ff33c069225be7dc90268629d228e.tar.gz
Merge remote-tracking branch 'upstream/master' into 30634-protected-pipeline
* upstream/master: (1168 commits) Job details won't scroll horizontally to show long lines Bring back branches badge to main project page Limit OpenGraph image size to 64x64 Improve changelog Split up MergeRequestsController Add parent_id back to the tests Make changelog more descriptive Improve tests text Rename members_count to members_count_with_descendants and expose only to group admins Fix a bug where an invalid sort param value was passed to Gitaly Drop default ORDER scope when calling a find method on a Sortable model Add tests for project import state transition: [:started] => [:finished] Add CHANGELOG Perform housekeeping only when an import of a fresh project is completed Strip trailing whitespace in relative submodule URL Adjust projects spec on namespace fields Add "members_count" and "parent_id" data on namespaces API Removes redundant pending delete checks Fix gitaly ref encoding bugs Add ProjectWiki#ensure_repository ...
Diffstat (limited to 'spec/models/ci/pipeline_spec.rb')
-rw-r--r--spec/models/ci/pipeline_spec.rb61
1 files changed, 44 insertions, 17 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 72af8130481..f36b5ca09ec 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -321,8 +321,19 @@ describe Ci::Pipeline, models: true do
status: 'success')
end
- describe '#stages' do
- subject { pipeline.stages }
+ 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 all(be_a Gitlab::Ci::Stage::Seed)
+ expect(pipeline.stage_seeds.count).to eq 1
+ end
+ end
+
+ describe '#legacy_stages' do
+ subject { pipeline.legacy_stages }
context 'stages list' do
it 'returns ordered list of stages' do
@@ -371,7 +382,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
@@ -385,22 +396,22 @@ 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
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
@@ -621,6 +632,20 @@ describe Ci::Pipeline, models: true do
end
end
+ describe '#has_stage_seeds?' do
+ context 'when pipeline has stage seeds' do
+ subject { build(:ci_pipeline_with_one_job) }
+
+ it { is_expected.to have_stage_seeds }
+ end
+
+ context 'when pipeline does not have stage seeds' do
+ subject { create(:ci_pipeline_without_jobs) }
+
+ it { is_expected.not_to have_stage_seeds }
+ end
+ end
+
describe '#has_warnings?' do
subject { pipeline.has_warnings? }
@@ -680,8 +705,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
@@ -690,8 +715,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
@@ -726,8 +751,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
@@ -1228,7 +1253,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
@@ -1271,8 +1298,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!