summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-09-14 01:25:26 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-09-14 01:25:26 +0800
commit50e62b3eb8ab030e123e990d1335f68478cc4a4b (patch)
treeb25b5c199d2df8a64f271000d57236eb687f86e3
parent05faeec708824bf97c3114b23235859663631b27 (diff)
downloadgitlab-ce-fix-multiple-pipeline-events.tar.gz
Fix Commit#status, feedback:fix-multiple-pipeline-events
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6305#note_15230024
-rw-r--r--app/models/commit.rb2
-rw-r--r--app/models/concerns/has_status.rb2
-rw-r--r--spec/requests/api/commits_spec.rb2
3 files changed, 3 insertions, 3 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 0e2ab76d347..e64fd1e0c1b 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -231,7 +231,7 @@ class Commit
def status
return @status if defined?(@status)
- @status ||= pipelines.order(:id).last.try(:status)
+ @status ||= pipelines.status
end
def revert_branch_name
diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb
index 77fc66a7105..d658552f695 100644
--- a/app/models/concerns/has_status.rb
+++ b/app/models/concerns/has_status.rb
@@ -20,7 +20,7 @@ module HasStatus
skipped = scope.skipped.select('count(*)').to_sql
deduce_status = "(CASE
- WHEN (#{builds})=0 THEN NULL
+ WHEN (#{builds})=(#{created}) THEN NULL
WHEN (#{builds})=(#{skipped}) THEN 'skipped'
WHEN (#{builds})=(#{success})+(#{ignored})+(#{skipped}) THEN 'success'
WHEN (#{builds})=(#{created})+(#{pending})+(#{skipped}) THEN 'pending'
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index e24e92e063c..5b3dc60aba2 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -110,7 +110,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response).to have_http_status(200)
- expect(json_response['status']).to eq('created')
+ expect(json_response['status']).to be_nil
end
end