summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-06 13:35:27 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-06 13:35:27 +0200
commitc9941dee39d6059079b90762ad45b617bc66a31e (patch)
tree2b0bbc212d3c38cd0758399ed2bc2375599c5cc8
parent9604bc598bf58ec34b1a55d02bd0fda168260117 (diff)
downloadgitlab-ce-c9941dee39d6059079b90762ad45b617bc66a31e.tar.gz
Add specs for grouping method in `Ci::Stages` class
-rw-r--r--spec/models/ci/stage_spec.rb28
1 files changed, 26 insertions, 2 deletions
diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb
index c38faf32f7d..429abacdb78 100644
--- a/spec/models/ci/stage_spec.rb
+++ b/spec/models/ci/stage_spec.rb
@@ -28,6 +28,30 @@ describe Ci::Stage, models: true do
end
end
+ describe '#groups' do
+ before do
+ create_job(:ci_build, name: 'rspec 0 2')
+ create_job(:ci_build, name: 'rspec 0 1')
+ create_job(:ci_build, name: 'spinach 0 1')
+ create_job(:commit_status, name: 'aaaaa')
+ end
+
+ it 'returns an array of three groups' do
+ expect(stage.groups).to be_a Array
+ expect(stage.groups).to all(be_a Ci::Group)
+ expect(stage.groups.size).to eq 3
+ end
+
+ it 'returns groups with correctly ordered statuses' do
+ expect(stage.groups.first.jobs.map(&:name))
+ .to eq ['aaaaa']
+ expect(stage.groups.second.jobs.map(&:name))
+ .to eq ['rspec 0 1', 'rspec 0 2']
+ expect(stage.groups.third.jobs.map(&:name))
+ .to eq ['spinach 0 1']
+ end
+ end
+
describe '#statuses_count' do
before do
create_job(:ci_build)
@@ -223,7 +247,7 @@ describe Ci::Stage, models: true do
end
end
- def create_job(type, status: 'success', stage: stage_name)
- create(type, pipeline: pipeline, stage: stage, status: status)
+ def create_job(type, status: 'success', stage: stage_name, **opts)
+ create(type, pipeline: pipeline, stage: stage, status: status, **opts)
end
end