From 57df84d2fc5a03e0bf25a289dca715d6f0990d62 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 9 Aug 2016 13:33:19 +0200 Subject: Extend build badge specs to cover multiple pipelines --- spec/lib/gitlab/badge/build_spec.rb | 40 ++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'spec/lib/gitlab/badge') diff --git a/spec/lib/gitlab/badge/build_spec.rb b/spec/lib/gitlab/badge/build_spec.rb index f9abbdaf585..ef9d9e7fef4 100644 --- a/spec/lib/gitlab/badge/build_spec.rb +++ b/spec/lib/gitlab/badge/build_spec.rb @@ -53,6 +53,32 @@ describe Gitlab::Badge::Build do end end end + + context 'when outdated pipeline for given ref exists' do + before do + build.success! + + old_build = create_build(project, '11eeffdd', branch) + old_build.drop! + end + + it 'does not take outdated pipeline into account' do + expect(badge.status).to eq 'success' + end + end + + context 'when multiple pipelines exist for given sha' do + before do + build.drop! + + new_build = create_build(project, sha, branch) + new_build.success! + end + + it 'reports the compound status' do + expect(badge.status).to eq 'failed' + end + end end context 'build does not exist' do @@ -69,20 +95,6 @@ describe Gitlab::Badge::Build do end end - context 'when outdated pipeline for given ref exists' do - before do - build = create_build(project, sha, branch) - build.success! - - old_build = create_build(project, '11eeffdd', branch) - old_build.drop! - end - - it 'does not take outdated pipeline into account' do - expect(badge.status).to eq 'success' - end - end - def create_build(project, sha, branch) pipeline = create(:ci_pipeline, project: project, sha: sha, -- cgit v1.2.3