summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2019-07-17 01:36:49 +0200
committerMatija Čupić <matteeyah@gmail.com>2019-07-23 12:02:07 +0200
commit41b8dca877ba790cd56677dc6405e16b631f9854 (patch)
tree4d76c25f84ebb75b3a62f086ea559921b6f290b9 /app/models/project.rb
parent4e814c257b74ac78a50f54ec57b1e1c7f78d43b7 (diff)
downloadgitlab-ce-41b8dca877ba790cd56677dc6405e16b631f9854.tar.gz
Add specs for specifying pipeline behavior
Adds specs for testing the new behavior of specifying a pipeline when POSTing a status.
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 2906aca75fc..aad24a5534c 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1496,12 +1496,20 @@ class Project < ApplicationRecord
!namespace.share_with_group_lock
end
- def pipeline_for(ref, sha = nil)
+ def pipeline_for(ref, sha = nil, id = nil)
+ if id.present?
+ pipelines_for(ref, sha).find_by(id: id)
+ else
+ pipelines_for(ref, sha).take
+ end
+ end
+
+ def pipelines_for(ref, sha = nil)
sha ||= commit(ref).try(:sha)
return unless sha
- ci_pipelines.order(id: :desc).find_by(sha: sha, ref: ref)
+ ci_pipelines.order(id: :desc).where(sha: sha, ref: ref)
end
def latest_successful_pipeline_for_default_branch