Commit ac4e3e8c authored by Rémy Coutable's avatar Rémy Coutable

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
parents 316630ad a63ea487
...@@ -42,9 +42,7 @@ describe Gitlab::Badge::Build do ...@@ -42,9 +42,7 @@ describe Gitlab::Badge::Build do
end end
context 'build exists' do context 'build exists' do
let(:ci_commit) { create(:ci_commit, project: project, sha: sha, ref: branch) } let!(:build) { create_build(project, sha, branch) }
let!(:build) { create(:ci_build, commit: ci_commit) }
context 'build success' do context 'build success' do
before { build.success! } before { build.success! }
...@@ -96,6 +94,28 @@ describe Gitlab::Badge::Build do ...@@ -96,6 +94,28 @@ describe Gitlab::Badge::Build do
end end
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) def status_node(data, status)
xml = Nokogiri::XML.parse(data) xml = Nokogiri::XML.parse(data)
xml.at(%Q{text:contains("#{status}")}) xml.at(%Q{text:contains("#{status}")})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment