diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-11-24 12:00:37 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-11-24 13:41:45 +0300 |
commit | 101cde38cf6d5506ea37c5f912fb4c37af50c541 (patch) | |
tree | b2af01436928dd612b2115dcda5cd2e12c372a0a | |
parent | 6192ea53fad0ea04e356e5a79a5a0e5359ba46ce (diff) |
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.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/badge/build/status_spec.rb | 4 |
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 |