Skip to content

Instantly share code, notes, and snippets.

@zekus
Created July 21, 2014 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zekus/80c3e0b53442ad1358a1 to your computer and use it in GitHub Desktop.
Save zekus/80c3e0b53442ad1358a1 to your computer and use it in GitHub Desktop.
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('zorros.web@gmail.com') }
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