Add Ticket Creation Notifications for Nonprofits
This commit is contained in:
parent
1fa53e65f2
commit
4b8bb49d76
6 changed files with 5 additions and 38 deletions
|
@ -1,7 +1,8 @@
|
||||||
class TicketCreateJob < ApplicationJob
|
class TicketCreateJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
|
||||||
def perform(ticket_ids, charge)
|
def perform(ticket_ids, charge, user=nil)
|
||||||
TicketMailer.followup(ticket_ids, charge_id).deliver_now
|
TicketMailer.followup(ticket_ids, charge_id).deliver_later
|
||||||
|
TicketMailer.receipt_admin(ticket_ids, user.id).deliver_later
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ class PaymentMailer < BaseMailer
|
||||||
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
||||||
PaymentNotificationEmailNonprofitJob.perform_later(payment.donation, User.find(user_id))
|
PaymentNotificationEmailNonprofitJob.perform_later(payment.donation, User.find(user_id))
|
||||||
elsif payment.kind == 'Ticket'
|
elsif payment.kind == 'Ticket'
|
||||||
return TicketMailer.receipt_admin(payment.donation.id, user_id).deliver
|
return TicketMailer.receipt_admin(payment.donation.id, user_id).deliver_later
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class PaymentMailer < BaseMailer
|
||||||
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
||||||
PaymentNotificationEmailDonorJob.perform_later payment.donation
|
PaymentNotificationEmailDonorJob.perform_later payment.donation
|
||||||
elsif payment.kind == 'Ticket'
|
elsif payment.kind == 'Ticket'
|
||||||
return TicketMailer.followup(payment.tickets.pluck(:id), payment.charge.id).deliver
|
return TicketMailer.followup(payment.tickets.pluck(:id), payment.charge).deliver_later
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -101,7 +101,6 @@ module InsertTickets
|
||||||
charge_id = result['charge'] ? result['charge'].id : nil
|
charge_id = result['charge'] ? result['charge'].id : nil
|
||||||
|
|
||||||
TicketCreateJob.perform_later(ticket_ids, charge_id && Charge.find(result['charge']&.id))
|
TicketCreateJob.perform_later(ticket_ids, charge_id && Charge.find(result['charge']&.id))
|
||||||
EmailJobQueue.queue(JobTypes::TicketMailerReceiptAdminJob, ticket_ids)
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,17 +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 TicketMailerReceiptAdminJob < EmailJob
|
|
||||||
attr_reader :ticket_ids
|
|
||||||
|
|
||||||
def initialize(ticket_ids, user_id = nil)
|
|
||||||
@ticket_ids = ticket_ids
|
|
||||||
@user_id = user_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
TicketMailer.receipt_admin(@ticket_ids, @user_id).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -105,7 +105,6 @@ describe InsertTickets do
|
||||||
tickets = m.call(*args)
|
tickets = m.call(*args)
|
||||||
ticket_ids = tickets.map(&:id)
|
ticket_ids = tickets.map(&:id)
|
||||||
expect(InsertActivities).to receive(:for_tickets).with(ticket_ids)
|
expect(InsertActivities).to receive(:for_tickets).with(ticket_ids)
|
||||||
expect_email_queued.with(JobTypes::TicketMailerReceiptAdminJob, ticket_ids).once
|
|
||||||
tickets
|
tickets
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -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::TicketMailerReceiptAdminJob do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(TicketMailer).to receive(:receipt_admin).with(1, 2).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::TicketMailerReceiptAdminJob.new(1, 2)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue