ticket_create event working
This commit is contained in:
parent
6f087c76b8
commit
2a20b9f381
5 changed files with 11 additions and 12 deletions
|
@ -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
|
|
@ -16,4 +16,5 @@ class CreditCardPaymentListener
|
|||
def refund_create(refund)
|
||||
RefundNotificationJob.perform_later refund
|
||||
end
|
||||
|
||||
end
|
||||
|
|
6
app/listeners/ticket_listener.rb
Normal file
6
app/listeners/ticket_listener.rb
Normal 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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 {
|
||||
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)
|
||||
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)
|
||||
|
||||
expected = generate_expected_tickets(payment_id: result['payment'].id,
|
||||
nonprofit: nonprofit,
|
||||
supporter: supporter,
|
||||
|
|
Loading…
Reference in a new issue