Commit 7503d439 authored by James Edwards-Jones's avatar James Edwards-Jones

CSV export review improvements & CHANGELOG entry

parent 60b3e7bd
......@@ -54,8 +54,9 @@ module Emails
@issues_count = issues_count
@truncated = truncated
attachments['issues.csv'] = { content: csv_data, mime_type: 'text/csv' }
mail(to: user.notification_email, subject: subject("Issues exported as CSV"))
filename = "#{project.full_path.parameterize}_issues_#{Date.today.iso8601}.csv"
attachments[filename] = { content: csv_data, mime_type: 'text/csv' }
mail(to: user.notification_email, subject: subject("Exported issues"))
end
private
......
......@@ -57,7 +57,7 @@
%td{ style: "font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;background-color:#ffffff;text-align:left;padding:18px 25px;border:1px solid #ededed;border-radius:3px;overflow:hidden;font-size:18px;" }
Your CSV export of #{ @issues_count } issues from project
%a{ href: project_url(@project), style: "color:#3777b0;text-decoration:none;" }
= @project.name
= @project.full_name
has been added to this email as an attachment.
- if @truncated
%br
......
Your CSV export of <%= @issues_count %> issues from project <%= @project.name %> ( <%= project_url(@project) %> ) has been added to this email as an attachment.
Your CSV export of <%= @issues_count %> issues from project <%= @project.full_name %> ( <%= project_url(@project) %> ) has been added to this email as an attachment.
<% if @truncated %>
This attachment has been truncated due to exceeding the maximum attachment size. Consider re-exporting with a narrower selection of issues.
......
......@@ -16,4 +16,4 @@
After we finish preparing your .csv export, we'll email it to
%strong= @current_user.email
.modal-footer
= link_to 'Request export', export_csv_namespace_project_issues_path(@project.namespace, @project, params.permit(IssuableFinder::VALID_PARAMS)), method: :post, class: 'btn btn-success pull-left', title: 'Request export'
= 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'
---
title: Issues can be exported as CSV, via email
merge_request: 1126
author:
......@@ -27,7 +27,7 @@ class CsvBuilder
# Renders the csv to a string
def render(truncate_after_bytes = nil)
tempfile = Tempfile.new('issues_csv')
tempfile = Tempfile.new('csv_export')
csv = CSV.new(tempfile)
write_csv(csv) do
......@@ -60,7 +60,7 @@ class CsvBuilder
if attribute.respond_to?(:call)
attribute.call(object)
else
object.send(attribute)
object.public_send(attribute)
end
end
end
......
......@@ -13,7 +13,7 @@ describe 'Issues csv', feature: true do
def request_csv(params = {})
visit namespace_project_issues_path(project.namespace, project, params)
click_on 'Download CSV'
click_on 'Request export'
click_on 'Export issues'
end
def attachment
......
......@@ -7,15 +7,22 @@ describe Notify do
describe 'csv export email' do
let(:user) { create(:user) }
let(:empty_project) { create(:empty_project) }
let(:empty_project) { create(:empty_project, path: 'myproject') }
let(:truncated) { false }
subject { Notify.issues_csv_email(user, empty_project, "dummy content", 3, truncated) }
let(:attachment) { subject.attachments.first }
it 'attachment has csv mime type' do
attachment = subject.attachments.first
expect(attachment.mime_type).to eq 'text/csv'
end
it 'generates a useful filename' do
expect(attachment.filename).to include(Date.today.year.to_s)
expect(attachment.filename).to include('issues')
expect(attachment.filename).to include('myproject')
expect(attachment.filename).to end_with('.csv')
end
it 'mentions number of issues and project name' do
expect(subject).to have_content '3'
expect(subject).to have_content empty_project.name
......
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