summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-11-24 17:00:37 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-11-24 18:41:45 +0800
commit101cde38cf6d5506ea37c5f912fb4c37af50c541 (patch)
treeb2af01436928dd612b2115dcda5cd2e12c372a0a
parent6192ea53fad0ea04e356e5a79a5a0e5359ba46ce (diff)
downloadgitlab-ce-101cde38cf6d5506ea37c5f912fb4c37af50c541.tar.gz
Use Ci::Pipeline#latest for finding pipelines
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7333#note_18861407
-rw-r--r--lib/gitlab/badge/build/status.rb3
-rw-r--r--spec/lib/gitlab/badge/build/status_spec.rb4
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/gitlab/badge/build/status.rb b/lib/gitlab/badge/build/status.rb
index 50aa45e5406..f78dfd5b83a 100644
--- a/lib/gitlab/badge/build/status.rb
+++ b/lib/gitlab/badge/build/status.rb
@@ -20,7 +20,8 @@ module Gitlab
def status
@project.pipelines
- .where(sha: @sha, ref: @ref)
+ .where(sha: @sha)
+ .latest(@ref)
.status || 'unknown'
end
diff --git a/spec/lib/gitlab/badge/build/status_spec.rb b/spec/lib/gitlab/badge/build/status_spec.rb
index 38eebb2a176..70f03021d36 100644
--- a/spec/lib/gitlab/badge/build/status_spec.rb
+++ b/spec/lib/gitlab/badge/build/status_spec.rb
@@ -69,8 +69,8 @@ describe Gitlab::Badge::Build::Status do
new_build.success!
end
- it 'reports the compound status' do
- expect(badge.status).to eq 'failed'
+ it 'does not take outdated pipeline into account' do
+ expect(badge.status).to eq 'success'
end
end
end