diff --git a/app/jobs/campaign_create_job.rb b/app/jobs/campaign_create_job.rb index d166f2f3..d338bdce 100644 --- a/app/jobs/campaign_create_job.rb +++ b/app/jobs/campaign_create_job.rb @@ -8,6 +8,6 @@ class CampaignCreateJob < ApplicationJob CampaignMailer.creation_followup(campaign).deliver_later end - FundraiserCreateJob.perform_later(campaign) + SupporterFundraiserCreateJob.perform_later(campaign) end end diff --git a/app/jobs/payment_notification_job.rb b/app/jobs/payment_notification_job.rb index 56305f9b..6dccecc2 100644 --- a/app/jobs/payment_notification_job.rb +++ b/app/jobs/payment_notification_job.rb @@ -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 diff --git a/app/models/campaign.rb b/app/models/campaign.rb index e60cdd82..3656facf 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -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 diff --git a/spec/lib/export/export_recurring_donations_spec.rb b/spec/lib/export/export_recurring_donations_spec.rb index 95007d38..756366f5 100644 --- a/spec/lib/export/export_recurring_donations_spec.rb +++ b/spec/lib/export/export_recurring_donations_spec.rb @@ -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 diff --git a/spec/models/campaign_spec.rb b/spec/models/campaign_spec.rb index 917aa951..93ec00f3 100644 --- a/spec/models/campaign_spec.rb +++ b/spec/models/campaign_spec.rb @@ -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