summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-02-23 10:07:55 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2016-02-23 10:07:55 +0000
commit884094a77e19b225345b028e64a5355747e716dd (patch)
treea86d6ce0c5e6fc8c57809a8d5b8655dc6e12ed7c /spec
parente6195b859f03c14b4a1b5510f14bbf41740efd79 (diff)
parentc8b4c874d7b6752149e7eb37ab61771c016f132a (diff)
downloadgitlab-ce-884094a77e19b225345b028e64a5355747e716dd.tar.gz
Merge branch 'ci/extend-summary-status-specs' into 'master'
Extend specs for summary build status Additional specs cover a case when one of the builds is running but allowed to fail. Previous implementation returned `running` status, which is wrong. This behavior has been changed in 8.5, this commit adds missing specs. See merge request !2904
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/ci/status_spec.rb72
1 files changed, 51 insertions, 21 deletions
diff --git a/spec/lib/ci/status_spec.rb b/spec/lib/ci/status_spec.rb
index a2eb14f3a97..1539720bb8d 100644
--- a/spec/lib/ci/status_spec.rb
+++ b/spec/lib/ci/status_spec.rb
@@ -4,38 +4,68 @@ describe Ci::Status do
describe '.get_status' do
subject { described_class.get_status(statuses) }
- [:ci_build, :generic_commit_status].each do |type|
- context "for #{type}" do
- context 'all successful' do
- let(:statuses) { Array.new(2) { create(type, status: :success) } }
- it { is_expected.to eq 'success' }
- end
+ shared_examples 'build status summary' do
+ context 'all successful' do
+ let(:statuses) { Array.new(2) { create(type, status: :success) } }
+ it { is_expected.to eq 'success' }
+ end
- context 'at least one failed' do
- let(:statuses) { [create(type, status: :success), create(type, status: :failed)] }
- it { is_expected.to eq 'failed' }
+ context 'at least one failed' do
+ let(:statuses) do
+ [create(type, status: :success), create(type, status: :failed)]
end
- context 'at least one running' do
- let(:statuses) { [create(type, status: :success), create(type, status: :running)] }
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq 'failed' }
+ end
+
+ context 'at least one running' do
+ let(:statuses) do
+ [create(type, status: :success), create(type, status: :running)]
end
- context 'at least one pending' do
- let(:statuses) { [create(type, status: :success), create(type, status: :pending)] }
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq 'running' }
+ end
+
+ context 'at least one pending' do
+ let(:statuses) do
+ [create(type, status: :success), create(type, status: :pending)]
end
- context 'success and failed but allowed to fail' do
- let(:statuses) { [create(type, status: :success), create(type, status: :failed, allow_failure: true)] }
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq 'running' }
+ end
+
+ context 'success and failed but allowed to fail' do
+ let(:statuses) do
+ [create(type, status: :success),
+ create(type, status: :failed, allow_failure: true)]
end
- context 'one failed but allowed to fail' do
- let(:statuses) { [create(type, status: :failed, allow_failure: true)] }
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq 'success' }
+ end
+
+ context 'one failed but allowed to fail' do
+ let(:statuses) { [create(type, status: :failed, allow_failure: true)] }
+ it { is_expected.to eq 'success' }
+ end
+
+ context 'one finished and second running but allowed to fail' do
+ let(:statuses) do
+ [create(type, status: :success),
+ create(type, status: :running, allow_failure: true)]
end
+
+ it { is_expected.to eq 'running' }
end
end
+
+ context 'ci build statuses' do
+ let(:type) { :ci_build }
+ it_behaves_like 'build status summary'
+ end
+
+ context 'generic commit statuses' do
+ let(:type) { :generic_commit_status }
+ it_behaves_like 'build status summary'
+ end
end
end