summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2018-02-19 14:30:57 -0600
committerRobert Speicher <rspeicher@gmail.com>2018-02-19 14:30:57 -0600
commitd023a99562fa34c926bd1ab17175773aac05dd40 (patch)
treee76b461d9d8e4e59516447722d69aa4ba806ee0a
parent8cfa5ccf5342f98aaf6b0a292d337d3211d5e7ff (diff)
downloadgitlab-ce-rs-default-dashboard-assignee.tar.gz
Set a default assignee_id on dashboard actions when none is providedrs-default-dashboard-assignee
Prior, the dashboard would attempt to load _all_ issues or merge requests across the entire instance. On one the size of GitLab.com, for example, this would always result in a timeout.
-rw-r--r--app/controllers/dashboard_controller.rb10
-rw-r--r--spec/controllers/dashboard_controller_spec.rb16
-rw-r--r--spec/support/issuables_list_metadata_shared_examples.rb4
3 files changed, 27 insertions, 3 deletions
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 280ed93faf8..7249938937a 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -5,6 +5,7 @@ class DashboardController < Dashboard::ApplicationController
before_action :event_filter, only: :activity
before_action :projects, only: [:issues, :merge_requests]
before_action :set_show_full_reference, only: [:issues, :merge_requests]
+ before_action :set_default_params, only: [:issues, :merge_requests]
respond_to :html
@@ -39,4 +40,13 @@ class DashboardController < Dashboard::ApplicationController
def set_show_full_reference
@show_full_reference = true
end
+
+ private
+
+ def set_default_params
+ return unless current_user
+ return if params[:assignee_id].present?
+
+ params[:assignee_id] = current_user.id
+ end
end
diff --git a/spec/controllers/dashboard_controller_spec.rb b/spec/controllers/dashboard_controller_spec.rb
index 97c2c3fb940..5e439915c52 100644
--- a/spec/controllers/dashboard_controller_spec.rb
+++ b/spec/controllers/dashboard_controller_spec.rb
@@ -11,9 +11,23 @@ describe DashboardController do
describe 'GET issues' do
it_behaves_like 'issuables list meta-data', :issue, :issues
+
+ it 'sets assignee_id when not provided' do
+ get :issues
+
+ expect(controller.params.keys).to include('assignee_id')
+ expect(controller.params['assignee_id']).to eq user.id
+ end
end
- describe 'GET merge requests' do
+ describe 'GET merge_requests' do
it_behaves_like 'issuables list meta-data', :merge_request, :merge_requests
+
+ it 'sets assignee_id when not provided' do
+ get :merge_requests
+
+ expect(controller.params.keys).to include('assignee_id')
+ expect(controller.params['assignee_id']).to eq user.id
+ end
end
end
diff --git a/spec/support/issuables_list_metadata_shared_examples.rb b/spec/support/issuables_list_metadata_shared_examples.rb
index 75982432ab4..181afa76004 100644
--- a/spec/support/issuables_list_metadata_shared_examples.rb
+++ b/spec/support/issuables_list_metadata_shared_examples.rb
@@ -5,9 +5,9 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
%w[fix improve/awesome].each do |source_branch|
issuable =
if issuable_type == :issue
- create(issuable_type, project: project)
+ create(issuable_type, project: project, assignees: [user])
else
- create(issuable_type, source_project: project, source_branch: source_branch)
+ create(issuable_type, source_project: project, source_branch: source_branch, assignee: user)
end
@issuable_ids << issuable.id