diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-07 03:06:46 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-02-07 03:06:46 +0300 |
commit | 9d7c5e75841eff48217487b3acda56cf265a2aef (patch) | |
tree | d90819e572eab930a8729ed767f6565620922e8a /app/models/merge_request.rb | |
parent | b0279cc2239e0b24d59bc80085a9ba42fcf6226a (diff) |
Address feedback
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 965315c42a8..43085f69105 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -715,18 +715,22 @@ class MergeRequest < ActiveRecord::Base !head_pipeline || head_pipeline.success? || head_pipeline.skipped? end - def environments + def environments_for(current_user) return [] unless diff_head_commit - @environments ||= begin - target_envs = target_project.environments_for( - ref: target_branch, commit: diff_head_commit, with_tags: true) + @environments ||= Hash.new do |h, current_user| + envs = EnvironmentsFinder.new(target_project, current_user, + ref: target_branch, commit: diff_head_commit, with_tags: true).execute - source_envs = source_project.environments_for( - ref: source_branch, commit: diff_head_commit) if source_project + if source_project + envs.concat EnvironmentsFinder.new(source_project, current_user, + ref: source_branch, commit: diff_head_commit).execute + end - (target_envs.to_a + source_envs.to_a).uniq + h[current_user] = envs.uniq end + + @environments[current_user] end def state_human_name |