summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-12-14 21:00:06 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-12-14 23:37:49 +0800
commit7cced60069c248156decf6ceabc4d1f447e47ff7 (patch)
tree1c7c6f52745c3b2066094dcd6edec3fd99e91f62 /app/models
parent3ce6ba7db9bcdeb9a642e7020fb736ebe54f88aa (diff)
downloadgitlab-ce-7cced60069c248156decf6ceabc4d1f447e47ff7.tar.gz
Introduce latest_status and add a few tests
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7333#note_20003268
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/pipeline.rb4
-rw-r--r--app/models/commit.rb4
2 files changed, 6 insertions, 2 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index aa0367227a8..9edfc75eac7 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -98,6 +98,10 @@ module Ci
end.where(id: max_id.group(:ref, :sha))
end
+ def self.latest_status(ref = nil)
+ latest(ref).status
+ end
+
def self.latest_successful_for(ref)
success.latest(ref).first
end
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 91c7970fca6..69cfc47f5bf 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -230,7 +230,7 @@ class Commit
return @statuses[ref] if @statuses.key?(ref)
- @statuses[ref] = pipelines.latest(ref).status
+ @statuses[ref] = pipelines.latest_status(ref)
end
def revert_branch_name
@@ -266,7 +266,7 @@ class Commit
@merged_merge_request_hash ||= Hash.new do |hash, user|
hash[user] = merged_merge_request_no_cache(user)
end
-
+
@merged_merge_request_hash[current_user]
end