Commit 572a21ff authored by James Edwards-Jones's avatar James Edwards-Jones

Issues CSV exports additional fields

parent 7503d439
module Issues module Issues
class ExportCsvService class ExportCsvService
include Rails.application.routes.url_helpers
include GitlabRoutingHelper
# Target attachment size before base64 encoding # Target attachment size before base64 encoding
TARGET_FILESIZE = 15000000 TARGET_FILESIZE = 15000000
...@@ -26,12 +29,15 @@ module Issues ...@@ -26,12 +29,15 @@ module Issues
def header_to_value_hash def header_to_value_hash
{ {
'Issue ID' => 'iid', 'Issue ID' => 'iid',
'URL' => -> (issue) { issue_url(issue) },
'Title' => 'title', 'Title' => 'title',
'State' => 'state', 'State' => -> (issue) { issue.closed? ? 'Closed' : 'Open' },
'Description' => 'description', 'Description' => 'description',
'Author' => 'author_name', 'Author' => 'author_name',
'Author Username' => -> (issue) { issue.author&.username },
'Assignee' => 'assignee_name', 'Assignee' => 'assignee_name',
'Confidential' => 'confidential', 'Assignee Username' => -> (issue) { issue.assignee&.username },
'Confidential' => -> (issue) { issue.confidential? ? 'Yes' : 'No' },
'Due Date' => -> (issue) { issue.due_date&.to_s(:csv) }, 'Due Date' => -> (issue) { issue.due_date&.to_s(:csv) },
'Created At (UTC)' => -> (issue) { issue.created_at&.to_s(:csv) }, 'Created At (UTC)' => -> (issue) { issue.created_at&.to_s(:csv) },
'Updated At (UTC)' => -> (issue) { issue.updated_at&.to_s(:csv) }, 'Updated At (UTC)' => -> (issue) { issue.updated_at&.to_s(:csv) },
......
...@@ -60,9 +60,8 @@ ...@@ -60,9 +60,8 @@
= @project.full_name = @project.full_name
has been added to this email as an attachment. has been added to this email as an attachment.
- if @truncated - if @truncated
%br %p
%br This attachment has been truncated due to exceeding the maximum attachment size. Consider re-exporting with a narrower selection of issues.
This attachment has been truncated due to exceeding the maximum attachment size. Consider re-exporting with a narrower selection of issues.
%tr.footer %tr.footer
%td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding:25px 0;font-size:13px;line-height:1.6;color:#5c5c5c;" } %td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding:25px 0;font-size:13px;line-height:1.6;color:#5c5c5c;" }
%img{ alt: "GitLab", height: "33", src: image_url('mailers/ci_pipeline_notif_v1/gitlab-logo-full-horizontal.gif'), style: "display:block;margin:0 auto 1em;", width: "90" }/ %img{ alt: "GitLab", height: "33", src: image_url('mailers/ci_pipeline_notif_v1/gitlab-logo-full-horizontal.gif'), style: "display:block;margin:0 auto 1em;", width: "90" }/
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#{@issues_count} issues selected #{@issues_count} issues selected
.modal-body .modal-body
%div %div
After we finish preparing your .csv export, we'll email it to The CSV export will be created in the background. Once it is finished, it will be attached to an email sent to
%strong= @current_user.email = succeed '.' do
%strong= @current_user.notification_email
.modal-footer .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, params.permit(IssuableFinder::VALID_PARAMS)), method: :post, class: 'btn btn-success pull-left', title: 'Export issues'
...@@ -35,16 +35,29 @@ describe Issues::ExportCsvService, services: true do ...@@ -35,16 +35,29 @@ describe Issues::ExportCsvService, services: true do
issue.update!(milestone: milestone, issue.update!(milestone: milestone,
assignee: user, assignee: user,
description: 'Issue with details', description: 'Issue with details',
state: :reopened,
due_date: DateTime.new(2014, 3, 2), due_date: DateTime.new(2014, 3, 2),
created_at: DateTime.new(2015, 4, 3, 2, 1, 0), created_at: DateTime.new(2015, 4, 3, 2, 1, 0),
updated_at: DateTime.new(2016, 5, 4, 3, 2, 1), updated_at: DateTime.new(2016, 5, 4, 3, 2, 1),
labels: [feature_label, idea_label]) labels: [feature_label, idea_label])
end end
specify 'iid' do
expect(csv[0]['Issue ID']).to eq issue.iid.to_s
end
specify 'url' do
expect(csv[0]['URL']).to match(/http.*#{project.full_path}.*#{issue.iid}/)
end
specify 'title' do specify 'title' do
expect(csv[0]['Title']).to eq issue.title expect(csv[0]['Title']).to eq issue.title
end end
specify 'state' do
expect(csv[0]['State']).to eq 'Open'
end
specify 'description' do specify 'description' do
expect(csv[0]['Description']).to eq issue.description expect(csv[0]['Description']).to eq issue.description
end end
...@@ -53,12 +66,20 @@ describe Issues::ExportCsvService, services: true do ...@@ -53,12 +66,20 @@ describe Issues::ExportCsvService, services: true do
expect(csv[0]['Author']).to eq issue.author_name expect(csv[0]['Author']).to eq issue.author_name
end end
specify 'author username' do
expect(csv[0]['Author Username']).to eq issue.author.username
end
specify 'assignee name' do specify 'assignee name' do
expect(csv[0]['Assignee']).to eq issue.assignee_name expect(csv[0]['Assignee']).to eq issue.assignee_name
end end
specify 'assignee username' do
expect(csv[0]['Assignee Username']).to eq issue.assignee.username
end
specify 'confidential' do specify 'confidential' do
expect(csv[0]['Confidential']).to eq 'false' expect(csv[0]['Confidential']).to eq 'No'
end end
specify 'milestone' do specify 'milestone' do
......
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