Fix bug preventing the addition of tickets via Event Attendee Dashboard
This commit is contained in:
parent
44ce86901b
commit
70b4e7bf76
3 changed files with 28 additions and 21 deletions
|
@ -10,6 +10,7 @@ class TicketsController < ApplicationController
|
||||||
def create
|
def create
|
||||||
authenticate_event_editor! if params[:kind] == 'offsite'
|
authenticate_event_editor! if params[:kind] == 'offsite'
|
||||||
render_json do
|
render_json do
|
||||||
|
params[:current_user] = current_user
|
||||||
InsertTickets.create(params)
|
InsertTickets.create(params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ module InsertTickets
|
||||||
ParamValidation.new(t, {quantity: {is_integer: true, required: true, min: 1}, ticket_level_id: {is_reference: true, required: true}})
|
ParamValidation.new(t, {quantity: {is_integer: true, required: true, min: 1}, ticket_level_id: {is_reference: true, required: true}})
|
||||||
}
|
}
|
||||||
|
|
||||||
ParamValidation.new(data[:offsite_payment], {kind: {included_in: %w(cash check)}}) if data[:offsite_payment]
|
ParamValidation.new(data[:offsite_payment], {kind: {included_in: %w(cash check)}}) if data[:offsite_payment] && !data[:offsite_payment][:kind].blank?
|
||||||
|
|
||||||
entities = RetrieveActiveRecordItems.retrieve_from_keys(data, {Supporter => :supporter_id, Nonprofit => :nonprofit_id, Event => :event_id})
|
entities = RetrieveActiveRecordItems.retrieve_from_keys(data, {Supporter => :supporter_id, Nonprofit => :nonprofit_id, Event => :event_id})
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,14 @@ describe InsertTickets do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
|
success()
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'succeeds if offsite_donation is there with empty kind' do
|
||||||
|
success({offsite_donation: {kind: nil}})
|
||||||
|
end
|
||||||
|
|
||||||
|
def success(other_elements={})
|
||||||
nonprofit.stripe_account_id = Stripe::Account.create()['id']
|
nonprofit.stripe_account_id = Stripe::Account.create()['id']
|
||||||
nonprofit.save!
|
nonprofit.save!
|
||||||
card.stripe_customer_id = 'some other id'
|
card.stripe_customer_id = 'some other id'
|
||||||
|
@ -410,7 +418,7 @@ describe InsertTickets do
|
||||||
a}
|
a}
|
||||||
result = InsertTickets.create(include_valid_token.merge(event_discount_id:event_discount.id))
|
result = InsertTickets.create(include_valid_token.merge(event_discount_id:event_discount.id))
|
||||||
expected = generate_expected_tickets(
|
expected = generate_expected_tickets(
|
||||||
gross_amount: 1600,
|
{gross_amount: 1600,
|
||||||
payment_fee_total: 66,
|
payment_fee_total: 66,
|
||||||
payment_id: result['payment'].id,
|
payment_id: result['payment'].id,
|
||||||
nonprofit: nonprofit,
|
nonprofit: nonprofit,
|
||||||
|
@ -428,14 +436,12 @@ describe InsertTickets do
|
||||||
id: result['tickets'][0]['id'],
|
id: result['tickets'][0]['id'],
|
||||||
quantity: 2,
|
quantity: 2,
|
||||||
ticket_level_id: ticket_level2.id
|
ticket_level_id: ticket_level2.id
|
||||||
}])
|
}]}.merge(other_elements))
|
||||||
|
|
||||||
expect(result['payment'].attributes).to eq expected[:payment]
|
expect(result['payment'].attributes).to eq expected[:payment]
|
||||||
expect(result['charge'].attributes).to eq expected[:charge]
|
expect(result['charge'].attributes).to eq expected[:charge]
|
||||||
expect(result['tickets'].map{|i| i.attributes}[0]).to eq expected[:tickets][0]
|
expect(result['tickets'].map{|i| i.attributes}[0]).to eq expected[:tickets][0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'errors where kind == free and positive gross_amount' do
|
it 'errors where kind == free and positive gross_amount' do
|
||||||
|
|
Loading…
Reference in a new issue