Add NonprofitCreateJob
This commit is contained in:
parent
94398f8bdf
commit
f68a432ee5
4 changed files with 8 additions and 32 deletions
7
app/jobs/nonprofit_create_job.rb
Normal file
7
app/jobs/nonprofit_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class NonprofitCreateJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(nonprofit)
|
||||||
|
NonprofitMailer.welcome(nonprofit.id).deliver
|
||||||
|
end
|
||||||
|
end
|
|
@ -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 NonprofitWelcomeJob < EmailJob
|
|
||||||
attr_reader :nonprofit_id
|
|
||||||
|
|
||||||
def initialize(nonprofit_id)
|
|
||||||
@nonprofit_id = nonprofit_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
NonprofitMailer.welcome(@nonprofit_id).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -124,7 +124,7 @@ module OnboardAccounts
|
||||||
# user_data and extra_info are additional data hashes sent from the onboarding form
|
# user_data and extra_info are additional data hashes sent from the onboarding form
|
||||||
def self.send_onboard_email(np, nonprofit_data, user_data, extra_info)
|
def self.send_onboard_email(np, nonprofit_data, user_data, extra_info)
|
||||||
# Send the welcome email to the nonprofit
|
# Send the welcome email to the nonprofit
|
||||||
NonprofitMailer.welcome(np['id']).deliver
|
NonprofitCreateJob.perform_later(Nonprofit.find(np['id']))
|
||||||
# Send an email notifying people internal folks of the new nonporfit, with the above info and extra_info
|
# Send an email notifying people internal folks of the new nonporfit, with the above info and extra_info
|
||||||
to_emails = ['support@commitchange.com']
|
to_emails = ['support@commitchange.com']
|
||||||
message = %(
|
message = %(
|
||||||
|
|
|
@ -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::NonprofitWelcomeJob do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(NonprofitMailer).to receive(:welcome).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::NonprofitWelcomeJob.new(1)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue