ticket_create event working

This commit is contained in:
Eric Schultz 2020-01-07 11:20:28 -06:00
parent 6f087c76b8
commit 2a20b9f381
5 changed files with 11 additions and 12 deletions

View file

@ -1,8 +0,0 @@
class TicketCreateJob < ApplicationJob
queue_as :default
def perform(ticket_ids, charge, user=nil)
TicketMailer.followup(ticket_ids, charge_id).deliver_later
TicketMailer.receipt_admin(ticket_ids, user.id).deliver_later
end
end

View file

@ -16,4 +16,5 @@ class CreditCardPaymentListener
def refund_create(refund)
RefundNotificationJob.perform_later refund
end
end

View file

@ -0,0 +1,6 @@
class TicketListener
def ticket_create(tickets, charge, user=nil)
TicketMailer.followup(tickets.map{|i| i.id}, charge && charge.id).deliver_later
TicketMailer.receipt_admin(tickets.map{|i| i.id}, user && user.id).deliver_later
end
end

View file

@ -100,7 +100,7 @@ module InsertTickets
ticket_ids = result['tickets'].map(&:id)
charge_id = result['charge'] ? result['charge'].id : nil
TicketCreateJob.perform_later(ticket_ids, charge_id && Charge.find(result['charge']&.id))
HoudiniEventPublisher.call(:ticket_create, result['tickets'], result['charge'])
result
end

View file

@ -285,9 +285,9 @@ describe InsertTickets do
success_expectations
expect(QueryRoles).to receive(:is_authorized_for_nonprofit?).with(user.id, nonprofit.id).and_return true
result = nil
expect {
expect(HoudiniEventPublisher).to receive(:call).with(:ticket_create, any_args)
result = InsertTickets.create(tickets: [{ quantity: 1, ticket_level_id: ticket_level.id }], nonprofit_id: nonprofit.id, supporter_id: supporter.id, token: source_token.token, event_id: event.id, kind: 'offsite', offsite_payment: { kind: 'check', check_number: 'fake_checknumber' }, current_user: user)
}.to have_enqueued_job(TicketCreateJob)
expected = generate_expected_tickets(payment_id: result['payment'].id,
nonprofit: nonprofit,
supporter: supporter,