From 9410599391edfb1b16472fbfaad362bb4e14eb55 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 21 Sep 2016 13:13:50 +0200 Subject: Scope environments to project --- app/helpers/gitlab_routing_helper.rb | 4 ++++ app/models/project.rb | 2 +- app/views/projects/merge_requests/widget/_heading.html.haml | 2 +- spec/views/projects/merge_requests/_heading.html.haml_spec.rb | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 5b71113feb9..2ab0bac95bc 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -70,6 +70,10 @@ module GitlabRoutingHelper namespace_project_runner_path(@project.namespace, @project, runner, *args) end + def environment_path(environment, *args) + namespace_project_environment_path(environment.project.namespace, environment.project, environment, *args) + end + def issue_path(entity, *args) namespace_project_issue_path(entity.project.namespace, entity.project, entity, *args) end diff --git a/app/models/project.rb b/app/models/project.rb index 0fe18e41cce..7265cb55594 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1304,7 +1304,7 @@ class Project < ActiveRecord::Base environment_ids.where(ref: ref) end - Environment.where(id: environment_ids).select do |environment| + environments.where(id: environment_ids).select do |environment| environment.includes_commit?(commit) end end diff --git a/app/views/projects/merge_requests/widget/_heading.html.haml b/app/views/projects/merge_requests/widget/_heading.html.haml index 8681226ab8b..44e645a7e81 100644 --- a/app/views/projects/merge_requests/widget/_heading.html.haml +++ b/app/views/projects/merge_requests/widget/_heading.html.haml @@ -51,7 +51,7 @@ %span.hidden-sm Deployed to = succeed '.' do - = link_to environment.name, namespace_project_environment_path(environment.project.namespace, environment.project, environment), class: 'environment' + = link_to environment.name, environment_path(environment), class: 'environment' - external_url = environment.external_url - if external_url = link_to external_url, target: '_blank' do diff --git a/spec/views/projects/merge_requests/_heading.html.haml_spec.rb b/spec/views/projects/merge_requests/_heading.html.haml_spec.rb index 733b2dfa7ff..21f49d396e7 100644 --- a/spec/views/projects/merge_requests/_heading.html.haml_spec.rb +++ b/spec/views/projects/merge_requests/_heading.html.haml_spec.rb @@ -15,6 +15,8 @@ describe 'projects/merge_requests/widget/_heading' do assign(:merge_request, merge_request) assign(:project, project) + allow(view).to receive(:can?).and_return(true) + render end -- cgit v1.2.1