Created
July 21, 2014 13:25
-
-
Save zekus/80c3e0b53442ad1358a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe ReportsMailer do | |
describe 'sending a report' do | |
let(:user) { build(:user) } | |
let(:report_mailing) { build(:report_mailing_with_contact) } | |
describe 'sends the PDF report to the selected contacts' do | |
let(:email) { ReportsMailer.visit_report(report_mailing, user, false) } | |
it { expect(email.to.size).to eq(report_mailing.mailing_contacts.size) } | |
it { expect(email.cc).to be_empty } | |
it { expect(email.bcc).to include('[email protected]') } | |
it { expect(email.reply_to).to include(user.email) } | |
it { expect(email.subject).to eq("Visit report: #{report_mailing.visit_unique_id}") } | |
it { expect(email.attachments.size).to eq(1) } | |
it { expect(email.attachments.first.mime_type).to eq('application/pdf') } | |
it { expect(email.attachments.first.content_disposition).to include("#{report_mailing.visit.report_filename}") } | |
it { expect(email.metadata[:report_mailing_id]).to eq(report_mailing.id) } | |
end | |
context 'when the user wants to receive a copy of the report' do | |
describe 'takes care of including the user in the CC list' do | |
let(:email) { ReportsMailer.visit_report(report_mailing, user, true) } | |
it { expect(email.cc.size).to eq(1) } | |
it { expect(email.cc).to include(user.email) } | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment