summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Sanford <alex.sanford1@gmail.com>2016-11-10 20:04:28 -0400
committerAlex Sanford <alex.sanford1@gmail.com>2016-11-11 14:06:43 -0400
commit317c3883477c1af3db96fdbd7caeed46ceb67d72 (patch)
tree9f931d6375325670709b5db1b97cdc0828b2e52b
parent8458f53c6922c0c4d160df2fc929e08060c28f60 (diff)
downloadgitlab-ce-317c3883477c1af3db96fdbd7caeed46ceb67d72.tar.gz
Ensure labels are loaded on "show" methods of MR
Previously, they were only being loaded on the actual `show` action, but not the actions representing the tabs (commits, builds, etc).
-rw-r--r--app/controllers/projects/merge_requests_controller.rb1
-rw-r--r--changelogs/unreleased/24397-load-labels-on-mr-tabs.yml4
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb25
3 files changed, 30 insertions, 0 deletions
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 9f104d903cc..dff0213411c 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -507,6 +507,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.close
end
+ labels
define_pipelines_vars
end
diff --git a/changelogs/unreleased/24397-load-labels-on-mr-tabs.yml b/changelogs/unreleased/24397-load-labels-on-mr-tabs.yml
new file mode 100644
index 00000000000..6bfa7fa1a49
--- /dev/null
+++ b/changelogs/unreleased/24397-load-labels-on-mr-tabs.yml
@@ -0,0 +1,4 @@
+---
+title: Fix issue causing Labels not to appear in sidebar on MR page
+merge_request: 7416
+author: Alex Sanford
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 49127aecc63..1d0750d1719 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -39,6 +39,17 @@ describe Projects::MergeRequestsController do
end
end
+ shared_examples "loads labels" do |action|
+ it "loads labels into the @labels variable" do
+ get action,
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: merge_request.iid,
+ format: 'html'
+ expect(assigns(:labels)).not_to be_nil
+ end
+ end
+
describe "GET show" do
shared_examples "export merge as" do |format|
it "does generally work" do
@@ -51,6 +62,8 @@ describe Projects::MergeRequestsController do
expect(response).to be_success
end
+ it_behaves_like "loads labels", :show
+
it "generates it" do
expect_any_instance_of(MergeRequest).to receive(:"to_#{format}")
@@ -406,6 +419,8 @@ describe Projects::MergeRequestsController do
get :diffs, params.merge(extra_params)
end
+ it_behaves_like "loads labels", :diffs
+
context 'with default params' do
context 'as html' do
before { go(format: 'html') }
@@ -612,6 +627,8 @@ describe Projects::MergeRequestsController do
format: format
end
+ it_behaves_like "loads labels", :commits
+
context 'as html' do
it 'renders the show template' do
go
@@ -630,6 +647,14 @@ describe Projects::MergeRequestsController do
end
end
+ describe 'GET builds' do
+ it_behaves_like "loads labels", :builds
+ end
+
+ describe 'GET pipelines' do
+ it_behaves_like "loads labels", :pipelines
+ end
+
describe 'GET conflicts' do
let(:json_response) { JSON.parse(response.body) }