Fixes to ExpectRecurringDonations spec
This commit is contained in:
parent
3f04f70171
commit
afae51ab4e
5 changed files with 15 additions and 17 deletions
|
@ -8,6 +8,6 @@ class CampaignCreateJob < ApplicationJob
|
||||||
CampaignMailer.creation_followup(campaign).deliver_later
|
CampaignMailer.creation_followup(campaign).deliver_later
|
||||||
end
|
end
|
||||||
|
|
||||||
FundraiserCreateJob.perform_later(campaign)
|
SupporterFundraiserCreateJob.perform_later(campaign)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
class PaymentNotificationJob < ApplicationJob
|
class PaymentNotificationJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
|
||||||
def perform(donation, locale)
|
def perform(donation, locale, user=nil)
|
||||||
PaymentNotificationEmailDonorJob.perform_later donation, locale
|
PaymentNotificationEmailDonorJob.perform_later donation, locale
|
||||||
PaymentNotificaitonEmailNonprofitJob.
|
PaymentNotificationEmailNonprofitJob.perform_later donation, user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,7 +100,6 @@ class Campaign < ApplicationRecord
|
||||||
user = profile.user
|
user = profile.user
|
||||||
Role.create(name: :campaign_editor, user_id: user.id, host: self)
|
Role.create(name: :campaign_editor, user_id: user.id, host: self)
|
||||||
CampaignCreateJob.perform_later(self)
|
CampaignCreateJob.perform_later(self)
|
||||||
SupporterFundraiserCreateJob.perform_later(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ describe ExportRecurringDonations do
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
ExportRecurringDonations.initiate_export(@nonprofit.id, params, @user.id)
|
ExportRecurringDonations.initiate_export(@nonprofit.id, params, @user.id)
|
||||||
}.to have_enqueued_job(RecurringDonationExportCreateJob)
|
}.to have_enqueued_job(RecurringDonationsExportCreateJob)
|
||||||
export = Export.first
|
export = Export.first
|
||||||
expected_export = { id: export.id,
|
expected_export = { id: export.id,
|
||||||
user_id: @user.id,
|
user_id: @user.id,
|
||||||
|
@ -121,8 +121,6 @@ describe ExportRecurringDonations do
|
||||||
expect(@export.exception).to eq error.to_s
|
expect(@export.exception).to eq error.to_s
|
||||||
expect(@export.ended).to eq Time.now
|
expect(@export.ended).to eq Time.now
|
||||||
expect(@export.updated_at).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
|
end
|
||||||
end
|
end
|
||||||
|
@ -162,9 +160,9 @@ describe ExportRecurringDonations do
|
||||||
expect(@export.exception).to eq error.to_s
|
expect(@export.exception).to eq error.to_s
|
||||||
expect(@export.ended).to eq Time.now
|
expect(@export.ended).to eq Time.now
|
||||||
expect(@export.updated_at).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)
|
end)
|
||||||
|
|
||||||
|
expect(ExportRecurringDonationsFailedJob).to have_been_enqueued.with(@export)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -174,7 +172,7 @@ describe ExportRecurringDonations do
|
||||||
@export = create(:export, user: @user, created_at: Time.now, updated_at: Time.now)
|
@export = create(:export, user: @user, created_at: Time.now, updated_at: Time.now)
|
||||||
Timecop.freeze(2020, 4, 6, 1, 2, 3) do
|
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)
|
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
|
@export.reload
|
||||||
|
|
||||||
expect(@export.url).to eq 'http://fake.url/tmp/csv-exports/recurring_donations-04-06-2020--01-02-03.csv'
|
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_type]).to eq 'text/csv'
|
||||||
expect(TestChunkedUploader.options[:content_disposition]).to eq 'attachment'
|
expect(TestChunkedUploader.options[:content_disposition]).to eq 'attachment'
|
||||||
expect(@user).to have_received_email(subject: 'Your recurring donations export is available!')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,14 +15,16 @@ RSpec.describe Campaign, type: :model do
|
||||||
goal_amount_dollars: '1000', nonprofit: nonprofit)
|
goal_amount_dollars: '1000', nonprofit: nonprofit)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'parent campaign sends out general campaign email' do
|
it 'parent campaign sends out a create job' do
|
||||||
expect { parent_campaign }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
parent_campaign
|
||||||
expect(ActionMailer::Base.deliveries.last.body.include?('Create one-time or recurring')).to be_truthy
|
expect(CampaignCreateJob).to have_been_enqueued.exactly(:once)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'child campaign sends out federated campaign email' do
|
it 'child campaign sends out federated create job' do
|
||||||
expect { child_campaign }.to change { ActionMailer::Base.deliveries.count }.by(2)
|
parent_campaign
|
||||||
expect(ActionMailer::Base.deliveries.last.body.include?('including a testimonial')).to be_truthy
|
expect(CampaignCreateJob).to have_been_enqueued.exactly(:once)
|
||||||
|
child_campaign
|
||||||
|
expect(CampaignCreateJob).to have_been_enqueued.exactly(:twice)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue