6772312ea7
The primary license of the project is changing to: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later with some specific files to be licensed under the one of two licenses: CC0-1.0 LGPL-3.0-or-later This commit is one of the many steps to relicense the entire codebase. Documentation granting permission for this relicensing (from all past contributors who hold copyrights) is on file with Software Freedom Conservancy, Inc.
72 lines
No EOL
2.7 KiB
Ruby
72 lines
No EOL
2.7 KiB
Ruby
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
require "rails_helper"
|
|
|
|
RSpec.describe DonationMailer, :type => :mailer do
|
|
describe "donor_recurring_donation_change_amount" do
|
|
let(:np) { force_create(:nonprofit, name: "nonprofit", email: 'blah')}
|
|
let(:s) { force_create(:supporter, email: 'supporter.email@mail.teha')}
|
|
let(:oldcard) { force_create(:card)}
|
|
let(:donation) {create(:donation, nonprofit_id: np.id, supporter_id: s.id, card_id: oldcard.id, amount:999)}
|
|
let(:default_message) { 'You have successfully changed your recurring donation amount. Please see the receipt and details below.'}
|
|
|
|
let(:rd) {
|
|
inner_rd = create(:recurring_donation, amount:999, active:true, supporter_id: s.id, donation_id: donation.id, nonprofit_id: np.id, start_date: Date.today, interval:1, time_unit:'month')}
|
|
|
|
before(:each) {
|
|
np
|
|
s
|
|
oldcard
|
|
donation
|
|
default_message
|
|
}
|
|
describe 'with custom' do
|
|
let(:custom_message) { 'custom_message'}
|
|
let!(:custom_donor_amount) { create(:miscellaneous_np_info, :change_amount_message => custom_message, :nonprofit => np)}
|
|
|
|
let!(:mail) { DonationMailer.donor_recurring_donation_change_amount(rd.id, 1000) }
|
|
it "renders the headers" do
|
|
expect(mail.subject).to eq( "Recurring donation amount changed for #{np.name}")
|
|
expect(mail.to).to eq(['supporter.email@mail.teha'])
|
|
expect(mail.reply_to).to eq([np.email])
|
|
end
|
|
|
|
it "renders the body" do
|
|
expect(mail.body.encoded).to match "#{custom_message}"
|
|
expect(mail.body.encoded).to_not match "#{default_message}"
|
|
end
|
|
end
|
|
|
|
|
|
describe 'without custom message' do
|
|
let!(:custom_donor_amount) { create(:miscellaneous_np_info, :nonprofit => np)}
|
|
|
|
let!(:mail) { DonationMailer.donor_recurring_donation_change_amount(rd.id, 1000) }
|
|
it "renders the headers" do
|
|
expect(mail.subject).to eq( "Recurring donation amount changed for #{np.name}")
|
|
expect(mail.to).to eq(['supporter.email@mail.teha'])
|
|
expect(mail.reply_to).to eq([np.email])
|
|
end
|
|
|
|
it "renders the body" do
|
|
expect(mail.body.encoded).to match "#{default_message}"
|
|
end
|
|
end
|
|
|
|
describe 'without miscinfo' do
|
|
|
|
let!(:mail) { DonationMailer.donor_recurring_donation_change_amount(rd.id, 1000) }
|
|
it "renders the headers" do
|
|
expect(mail.subject).to eq( "Recurring donation amount changed for #{np.name}")
|
|
expect(mail.to).to eq(['supporter.email@mail.teha'])
|
|
expect(mail.reply_to).to eq([np.email])
|
|
end
|
|
|
|
it "renders the body" do
|
|
expect(mail.body.encoded).to match "#{default_message}"
|
|
end
|
|
end
|
|
|
|
|
|
|
|
end
|
|
end |