Add SupporterFundraiserCreateJob
This commit is contained in:
parent
00e9cb972d
commit
b2aaf30a14
7 changed files with 9 additions and 39 deletions
7
app/jobs/supporter_fundraiser_create_job.rb
Normal file
7
app/jobs/supporter_fundraiser_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class SupporterFundraiserCreateJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(fundraiser)
|
||||||
|
NonprofitAdminMailer.supporter_fundraiser(fundraiser).deliver_now
|
||||||
|
end
|
||||||
|
end
|
|
@ -105,7 +105,7 @@ class Campaign < ApplicationRecord
|
||||||
CampaignMailer.delay.creation_followup(self)
|
CampaignMailer.delay.creation_followup(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
NonprofitAdminMailer.delay.supporter_fundraiser(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
|
SupporterFundraiserCreateJob.perform_later(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module CreateCampaign
|
||||||
user = campaign.profile.user
|
user = campaign.profile.user
|
||||||
Role.create(name: :campaign_editor, user_id: user.id, host: self)
|
Role.create(name: :campaign_editor, user_id: user.id, host: self)
|
||||||
CampaignMailer.delay.creation_followup(self)
|
CampaignMailer.delay.creation_followup(self)
|
||||||
NonprofitAdminMailer.delay.supporter_fundraiser(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
|
SupporterFundraiserCreateJob.perform_later(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
|
||||||
|
|
||||||
return { errors: campaign.errors.messages }.as_json unless campaign.errors.empty?
|
return { errors: campaign.errors.messages }.as_json unless campaign.errors.empty?
|
||||||
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
module JobTypes
|
|
||||||
class NonprofitAdminSupporterFundraiserJob < EmailJob
|
|
||||||
attr_reader :event_or_campaign
|
|
||||||
|
|
||||||
def initialize(event_or_campaign)
|
|
||||||
@event_or_campaign = event_or_campaign
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
NonprofitAdminMailer.supporter_fundraiser(@event_or_campaign).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -9,10 +9,7 @@ describe CreateCampaignGift do
|
||||||
# #stub out the mailing stuff used by campaign creation
|
# #stub out the mailing stuff used by campaign creation
|
||||||
cm = double(CampaignMailer)
|
cm = double(CampaignMailer)
|
||||||
allow(cm).to receive(:creation_followup)
|
allow(cm).to receive(:creation_followup)
|
||||||
nam = double(NonprofitAdminMailer)
|
|
||||||
allow(nam).to receive(:supporter_fundraiser)
|
|
||||||
allow(CampaignMailer).to receive(:delay).and_return(cm)
|
allow(CampaignMailer).to receive(:delay).and_return(cm)
|
||||||
allow(NonprofitAdminMailer).to receive(:delay).and_return(nam)
|
|
||||||
end
|
end
|
||||||
describe 'param validation' do
|
describe 'param validation' do
|
||||||
let (:donation) { force_create(:donation) }
|
let (:donation) { force_create(:donation) }
|
||||||
|
|
|
@ -8,10 +8,7 @@ describe DeleteCampaignGiftOption do
|
||||||
# #stub out the mailing stuff used by campaign creation
|
# #stub out the mailing stuff used by campaign creation
|
||||||
cm = double(CampaignMailer)
|
cm = double(CampaignMailer)
|
||||||
allow(cm).to receive(:creation_followup)
|
allow(cm).to receive(:creation_followup)
|
||||||
nam = double(NonprofitAdminMailer)
|
|
||||||
allow(nam).to receive(:supporter_fundraiser)
|
|
||||||
allow(CampaignMailer).to receive(:delay).and_return(cm)
|
allow(CampaignMailer).to receive(:delay).and_return(cm)
|
||||||
allow(NonprofitAdminMailer).to receive(:delay).and_return(nam)
|
|
||||||
end
|
end
|
||||||
describe '.delete' do
|
describe '.delete' do
|
||||||
let(:profile) { force_create(:profile, user: force_create(:user)) }
|
let(:profile) { force_create(:profile, user: force_create(:user)) }
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
require 'rails_helper.rb'
|
|
||||||
|
|
||||||
describe JobTypes::NonprofitAdminSupporterFundraiserJob do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(NonprofitAdminMailer).to receive(:supporter_fundraiser).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::NonprofitAdminSupporterFundraiserJob.new(1)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue