diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-29 15:06:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-29 15:06:43 +0000 |
commit | eac0da9a47f0c7b8b970833d7d5b96cfee057bf7 (patch) | |
tree | 7b7865053435c6dcb4e2d945fcf45e309331c91b /app/models/environment_status.rb | |
parent | b860c6ba2607541e3b5bdf0fc2daaa9ed41a8726 (diff) | |
download | gitlab-ce-eac0da9a47f0c7b8b970833d7d5b96cfee057bf7.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/environment_status.rb')
-rw-r--r-- | app/models/environment_status.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/environment_status.rb b/app/models/environment_status.rb index 3eca8c91e40..5fdb5af2d9b 100644 --- a/app/models/environment_status.rb +++ b/app/models/environment_status.rb @@ -20,6 +20,28 @@ class EnvironmentStatus build_environments_status(mr, user, mr.merge_pipeline) end + def self.for_deployed_merge_request(mr, user) + statuses = [] + + mr.recent_visible_deployments.each do |deploy| + env = deploy.environment + + next unless Ability.allowed?(user, :read_environment, env) + + statuses << + EnvironmentStatus.new(deploy.project, env, mr, deploy.sha) + end + + # Existing projects that used deployments prior to the introduction of + # explicitly linked merge requests won't have any data using this new + # approach, so we fall back to retrieving deployments based on CI pipelines. + if statuses.any? + statuses + else + after_merge_request(mr, user) + end + end + def initialize(project, environment, merge_request, sha) @project = project @environment = environment |