Commit 54b704ab authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ee-jprovazn-fix-csv-labels2' into 'master'

Ignore sorting parameter when exporting issues to CSV

Closes #4159

See merge request gitlab-org/gitlab-ee!6702
parents 7a610b64 c3e93f86
......@@ -36,6 +36,10 @@ You will be asked to confirm the number of issues and email address for the expo
![CSV export modal dialog](img/csv_export_modal.png)
## Sorting
Exported issues are always sorted by `Issue ID`.
## Format
> **Time Estimate** and **Time Spent** columns were [introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2627) in GitLab Starter 10.0.
......
......@@ -5,9 +5,11 @@ class ExportCsvWorker
@current_user = User.find(current_user_id)
@project = Project.find(project_id)
params.symbolize_keys!
params[:project_id] = project_id
params.delete(:sort)
issues = IssuesFinder.new(@current_user, params.symbolize_keys).execute
issues = IssuesFinder.new(@current_user, params).execute
Issues::ExportCsvService.new(issues).email(@current_user, @project)
end
......
---
title: Fix exporting issues to CSV when sorting by label priority is used.
merge_request:
author:
type: fixed
......@@ -5,7 +5,7 @@ describe 'Issues csv' do
let(:project) { create(:project, :public) }
let(:milestone) { create(:milestone, title: 'v1.0', project: project) }
let(:idea_label) { create(:label, project: project, title: 'Idea') }
let(:feature_label) { create(:label, project: project, title: 'Feature') }
let(:feature_label) { create(:label, project: project, title: 'Feature', priority: 10) }
let!(:issue) { create(:issue, project: project, author: user) }
before do
......@@ -67,6 +67,15 @@ describe 'Issues csv' do
expect(csv.count).to eq 0
end
it 'ignores sorting from issue index' do
issue2 = create(:labeled_issue, project: project, author: user, labels: [feature_label])
request_csv(sort: :label_priority)
expected = [issue.iid.to_s, issue2.iid.to_s]
expect(csv.map { |row| row['Issue ID'] }).to eq expected
end
it 'uses array filters, such as label_name' do
issue.update!(labels: [idea_label])
......
......@@ -18,6 +18,12 @@ describe ExportCsvWorker do
perform
end
it 'removes sort parameter' do
expect(IssuesFinder).to receive(:new).with(anything, hash_not_including(:sort)).and_call_original
perform
end
it 'converts controller string keys to symbol keys for IssuesFinder' do
expect(IssuesFinder).to receive(:new).with(anything, hash_including(test_key: true)).and_call_original
......
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