Commit 5bcd626f authored by James Edwards-Jones's avatar James Edwards-Jones

Mailer to deliver issues csv as attachment

parent 44bc526b
......@@ -49,6 +49,13 @@ module Emails
mail_answer_thread(issue, issue_thread_options(updated_by_user.id, recipient.id))
end
def issues_csv_email(user, project, content)#, issues) file_name: or content: or issues:
@project = project
attachments['issues.csv'] = { content: content, mime_type: 'text/csv' }
mail(to: user.notification_email, subject: subject("Issues exported as CSV"))
end
private
def setup_issue_mail(issue_id, recipient_id)
......
%p
Your issues for #{@project.name} have been attached as a CSV.
\ No newline at end of file
Your issues for <%= @project.name %> have been attached as a CSV.
\ No newline at end of file
require 'spec_helper'
require 'email_spec'
require 'mailers/shared/notify'
describe Notify do
include EmailSpec::Matchers
include_context 'gitlab email notification'
describe 'csv export email' do
let(:user) { create(:user) }
let(:empty_project) { create(:empty_project) }
subject { Notify.issues_csv_email(user, project, "dummy content") }
it 'attachment has csv mime type' do
attachment = subject.attachments.first
expect(attachment.mime_type).to eq 'text/csv'
end
end
end
class IssuesCsvMailerPreview < ActionMailer::Preview
def issues_csv_export
user = OpenStruct.new(notification_email: 'a@example.com')
project = OpenStruct.new(name: 'Judolint')
Notify.issues_csv_email(user, project, "Dummy,Csv\n0,1")
end
end
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