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

Issues CSV exports additional fields

parent 7503d439
module Issues
class ExportCsvService
include Rails.application.routes.url_helpers
include GitlabRoutingHelper
# Target attachment size before base64 encoding
TARGET_FILESIZE = 15000000
......@@ -26,12 +29,15 @@ module Issues
def header_to_value_hash
{
'Issue ID' => 'iid',
'URL' => -> (issue) { issue_url(issue) },
'Title' => 'title',
'State' => 'state',
'State' => -> (issue) { issue.closed? ? 'Closed' : 'Open' },
'Description' => 'description',
'Author' => 'author_name',
'Author Username' => -> (issue) { issue.author&.username },
'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) },
'Created At (UTC)' => -> (issue) { issue.created_at&.to_s(:csv) },
'Updated At (UTC)' => -> (issue) { issue.updated_at&.to_s(:csv) },
......
......@@ -60,9 +60,8 @@
= @project.full_name
has been added to this email as an attachment.
- if @truncated
%br
%br
This attachment has been truncated due to exceeding the maximum attachment size. Consider re-exporting with a narrower selection of issues.
%p
This attachment has been truncated due to exceeding the maximum attachment size. Consider re-exporting with a narrower selection of issues.
%tr.footer
%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" }/
......
......@@ -13,7 +13,8 @@
#{@issues_count} issues selected
.modal-body
%div
After we finish preparing your .csv export, we'll email it to
%strong= @current_user.email
The CSV export will be created in the background. Once it is finished, it will be attached to an email sent to
= succeed '.' do
%strong= @current_user.notification_email
.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'
......@@ -35,16 +35,29 @@ describe Issues::ExportCsvService, services: true do
issue.update!(milestone: milestone,
assignee: user,
description: 'Issue with details',
state: :reopened,
due_date: DateTime.new(2014, 3, 2),
created_at: DateTime.new(2015, 4, 3, 2, 1, 0),
updated_at: DateTime.new(2016, 5, 4, 3, 2, 1),
labels: [feature_label, idea_label])
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
expect(csv[0]['Title']).to eq issue.title
end
specify 'state' do
expect(csv[0]['State']).to eq 'Open'
end
specify 'description' do
expect(csv[0]['Description']).to eq issue.description
end
......@@ -53,12 +66,20 @@ describe Issues::ExportCsvService, services: true do
expect(csv[0]['Author']).to eq issue.author_name
end
specify 'author username' do
expect(csv[0]['Author Username']).to eq issue.author.username
end
specify 'assignee name' do
expect(csv[0]['Assignee']).to eq issue.assignee_name
end
specify 'assignee username' do
expect(csv[0]['Assignee Username']).to eq issue.assignee.username
end
specify 'confidential' do
expect(csv[0]['Confidential']).to eq 'false'
expect(csv[0]['Confidential']).to eq 'No'
end
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