summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-06-06 14:59:26 +0000
committerRémy Coutable <remy@rymai.me>2016-06-06 14:59:26 +0000
commitac4e3e8cf016f2c2b3dcf3997673310a5df658a9 (patch)
tree4624449871e97d6c3edfa5350fd37d8a030ad5c2
parent316630ad2c7f654024d7ea10cd5c2f978f37357e (diff)
parenta63ea487f7b949b43ab0c1790e9c640288a88649 (diff)
downloadgitlab-ce-ac4e3e8cf016f2c2b3dcf3997673310a5df658a9.tar.gz
Merge branch 'tests/extend-specs-for-build-badge' into 'master'
Extend specs for builds badge ## What does this MR do? This MR extends specs for builds badge. ## Why was this MR needed? We added an edge case to specs, while trying to reproduce problem described in #17549 ## What are the relevant issue numbers? #17549 See merge request !4401
-rw-r--r--spec/lib/gitlab/badge/build_spec.rb26
1 files changed, 23 insertions, 3 deletions
diff --git a/spec/lib/gitlab/badge/build_spec.rb b/spec/lib/gitlab/badge/build_spec.rb
index b6f7a2e7ec4..6b2b335d4fc 100644
--- a/spec/lib/gitlab/badge/build_spec.rb
+++ b/spec/lib/gitlab/badge/build_spec.rb
@@ -42,9 +42,7 @@ describe Gitlab::Badge::Build do
end
context 'build exists' do
- let(:ci_commit) { create(:ci_commit, project: project, sha: sha, ref: branch) }
- let!(:build) { create(:ci_build, commit: ci_commit) }
-
+ let!(:build) { create_build(project, sha, branch) }
context 'build success' do
before { build.success! }
@@ -96,6 +94,28 @@ 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.to_s).to eq 'build-success'
+ end
+ end
+
+ def create_build(project, sha, branch)
+ ci_commit = create(:ci_commit, project: project,
+ sha: sha,
+ ref: branch)
+
+ create(:ci_build, commit: ci_commit)
+ end
+
def status_node(data, status)
xml = Nokogiri::XML.parse(data)
xml.at(%Q{text:contains("#{status}")})