summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-09-21 13:13:50 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-09-21 13:19:34 +0200
commit9410599391edfb1b16472fbfaad362bb4e14eb55 (patch)
tree074792ba5c26702ab6a52cd2e14827a5d93d11a9
parent29a64950dd9417452707cb8677a480a35f8da876 (diff)
downloadgitlab-ce-limit-number-of-shown-environments.tar.gz
Scope environments to projectlimit-number-of-shown-environments
-rw-r--r--app/helpers/gitlab_routing_helper.rb4
-rw-r--r--app/models/project.rb2
-rw-r--r--app/views/projects/merge_requests/widget/_heading.html.haml2
-rw-r--r--spec/views/projects/merge_requests/_heading.html.haml_spec.rb2
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