Commit 4074cb3b authored by James Edwards-Jones's avatar James Edwards-Jones

Fixed filter by label for issues CSV export

parent 31bde06d
......@@ -81,7 +81,7 @@ module IssuableCollections
# @filter_params[:authorized_only] = true
end
@filter_params
@filter_params.permit(IssuableFinder::VALID_PARAMS)
end
def set_default_scope
......
......@@ -146,8 +146,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
def export_csv
csv_params = filter_params.permit(IssuableFinder::VALID_PARAMS)
ExportCsvWorker.perform_async(@current_user.id, @project.id, csv_params)
ExportCsvWorker.perform_async(@current_user.id, @project.id, filter_params)
index_path = namespace_project_issues_path(@project.namespace, @project)
redirect_to(index_path, notice: "Your CSV export has started. It will be emailed to #{current_user.notification_email} when complete.")
......
......@@ -20,7 +20,10 @@
#
class IssuableFinder
NONE = '0'.freeze
VALID_PARAMS = %i(scope state group_id project_id milestone_title assignee_id search label_name sort assignee_username author_id author_username authorized_only due_date iids non_archived weight).freeze
SCALAR_PARAMS = %i(scope state group_id project_id milestone_title assignee_id search label_name sort assignee_username author_id author_username authorized_only due_date iids non_archived weight).freeze
ARRAY_PARAMS = { label_name: [], iids: [] }.freeze
VALID_PARAMS = (SCALAR_PARAMS + [ARRAY_PARAMS]).freeze
attr_accessor :current_user, :params
......
......@@ -17,4 +17,4 @@
%strong= @current_user.notification_email
in an attachment.
.modal-footer
= link_to 'Export issues', export_csv_namespace_project_issues_path(@project.namespace, @project, params.permit(IssuableFinder::VALID_PARAMS)), method: :post, class: 'btn btn-success pull-left', title: 'Export issues'
= link_to 'Export issues', export_csv_namespace_project_issues_path(@project.namespace, @project, request.query_parameters), method: :post, class: 'btn btn-success pull-left', title: 'Export issues'
......@@ -63,6 +63,14 @@ describe 'Issues csv', feature: true do
expect(csv.count).to eq 0
end
it 'uses array filters, such as label_name' do
issue.update!(labels: [idea_label])
request_csv("label_name[]" => 'Bug')
expect(csv.count).to eq 0
end
it 'avoids excessive database calls' do
control_count = ActiveRecord::QueryRecorder.new{ request_csv }.count
create_list(:labeled_issue,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment