diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-01-13 16:35:33 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-01-23 17:45:53 +0300 |
commit | 4eb39e43a855cdf0e60b1d450a99bbae2e963b36 (patch) | |
tree | 715b6f1ae424d32edd90d39eb9bde68b79ec33f4 /app/services/merge_requests/base_service.rb | |
parent | 4b999ccd57c45ea8f30317c1ebde4623d67bf6f0 (diff) |
Backport EE changes on approvals reset for closed MRs
Diffstat (limited to 'app/services/merge_requests/base_service.rb')
-rw-r--r-- | app/services/merge_requests/base_service.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index 70e25956dc7..5a53b973059 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -38,15 +38,13 @@ module MergeRequests private - def merge_requests_for(branch) - origin_merge_requests = @project.origin_merge_requests - .opened.where(source_branch: branch).to_a - - fork_merge_requests = @project.fork_merge_requests - .opened.where(source_branch: branch).to_a - - (origin_merge_requests + fork_merge_requests) - .uniq.select(&:source_project) + # Returns all origin and fork merge requests from `@project` satisfying passed arguments. + def merge_requests_for(source_branch, mr_states: [:opened]) + MergeRequest + .with_state(mr_states) + .where(source_branch: source_branch, source_project_id: @project.id) + .preload(:source_project) # we don't need a #includes since we're just preloading for the #select + .select(&:source_project) end def pipeline_merge_requests(pipeline) |