Fixes to ExpectRecurringDonations spec

This commit is contained in:
Eric Schultz 2019-11-08 13:12:55 -06:00
parent 3f04f70171
commit afae51ab4e
5 changed files with 15 additions and 17 deletions

View file

@ -8,6 +8,6 @@ class CampaignCreateJob < ApplicationJob
CampaignMailer.creation_followup(campaign).deliver_later
end
FundraiserCreateJob.perform_later(campaign)
SupporterFundraiserCreateJob.perform_later(campaign)
end
end

View file

@ -1,8 +1,8 @@
class PaymentNotificationJob < ApplicationJob
queue_as :default
def perform(donation, locale)
def perform(donation, locale, user=nil)
PaymentNotificationEmailDonorJob.perform_later donation, locale
PaymentNotificaitonEmailNonprofitJob.
PaymentNotificationEmailNonprofitJob.perform_later donation, user
end
end

View file

@ -100,7 +100,6 @@ class Campaign < ApplicationRecord
user = profile.user
Role.create(name: :campaign_editor, user_id: user.id, host: self)
CampaignCreateJob.perform_later(self)
SupporterFundraiserCreateJob.perform_later(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
self
end

View file

@ -57,7 +57,7 @@ describe ExportRecurringDonations do
expect {
ExportRecurringDonations.initiate_export(@nonprofit.id, params, @user.id)
}.to have_enqueued_job(RecurringDonationExportCreateJob)
}.to have_enqueued_job(RecurringDonationsExportCreateJob)
export = Export.first
expected_export = { id: export.id,
user_id: @user.id,
@ -121,8 +121,6 @@ describe ExportRecurringDonations do
expect(@export.exception).to eq error.to_s
expect(@export.ended).to eq Time.now
expect(@export.updated_at).to eq Time.now
# expect(@user).to have_received_email(subject: "Your payment export has failed")
end)
end
end
@ -162,9 +160,9 @@ describe ExportRecurringDonations do
expect(@export.exception).to eq error.to_s
expect(@export.ended).to eq Time.now
expect(@export.updated_at).to eq Time.now
expect(@user).to have_received_email(subject: 'Your recurring donations export has failed')
end)
expect(ExportRecurringDonationsFailedJob).to have_been_enqueued.with(@export)
end
end
end
@ -174,7 +172,7 @@ describe ExportRecurringDonations do
@export = create(:export, user: @user, created_at: Time.now, updated_at: Time.now)
Timecop.freeze(2020, 4, 6, 1, 2, 3) do
ExportRecurringDonations.run_export(@nonprofit.id, { root_url: 'https://localhost:8080/' }.to_json, @user.id, @export.id)
expect(ExportRecurringDonationsCompletedJob).to have_been_enqueued.with(@export)
@export.reload
expect(@export.url).to eq 'http://fake.url/tmp/csv-exports/recurring_donations-04-06-2020--01-02-03.csv'
@ -189,7 +187,6 @@ describe ExportRecurringDonations do
expect(TestChunkedUploader.options[:content_type]).to eq 'text/csv'
expect(TestChunkedUploader.options[:content_disposition]).to eq 'attachment'
expect(@user).to have_received_email(subject: 'Your recurring donations export is available!')
end
end
end

View file

@ -15,14 +15,16 @@ RSpec.describe Campaign, type: :model do
goal_amount_dollars: '1000', nonprofit: nonprofit)
end
it 'parent campaign sends out general campaign email' do
expect { parent_campaign }.to change { ActionMailer::Base.deliveries.count }.by(1)
expect(ActionMailer::Base.deliveries.last.body.include?('Create one-time or recurring')).to be_truthy
it 'parent campaign sends out a create job' do
parent_campaign
expect(CampaignCreateJob).to have_been_enqueued.exactly(:once)
end
it 'child campaign sends out federated campaign email' do
expect { child_campaign }.to change { ActionMailer::Base.deliveries.count }.by(2)
expect(ActionMailer::Base.deliveries.last.body.include?('including a testimonial')).to be_truthy
it 'child campaign sends out federated create job' do
parent_campaign
expect(CampaignCreateJob).to have_been_enqueued.exactly(:once)
child_campaign
expect(CampaignCreateJob).to have_been_enqueued.exactly(:twice)
end
end
end