1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

fix test Events::AsUserTest

the event price calculalation was using a variable not reinitialized
This commit is contained in:
Sylvain 2021-04-26 16:38:00 +02:00
parent 53e9a1c4f2
commit da372cf8ad
2 changed files with 108 additions and 105 deletions

View File

@ -21,16 +21,17 @@ class CartItem::EventReservation < CartItem::Reservation
end
elements = { slots: [] }
total = 0
@slots.each do |slot|
amount += get_slot_price(amount,
total += get_slot_price(amount,
slot,
is_privileged,
elements: elements,
is_division: false)
end
{ elements: elements, amount: amount }
{ elements: elements, amount: total }
end
def name

View File

@ -1,7 +1,10 @@
# frozen_string_literal: true
module Events
class AsUserTest < ActionDispatch::IntegrationTest
require 'test_helper'
module Events; end
class Events::AsUserTest < ActionDispatch::IntegrationTest
test 'reserve event with many prices and payment means and VAT' do
vlonchamp = User.find_by(username: 'vlonchamp')
login_as(vlonchamp, scope: :user)
@ -29,8 +32,8 @@ module Events
post '/api/stripe/confirm_payment',
params: {
payment_method_id: stripe_payment_method,
customer_id: User.find_by(username: 'vlonchamp').id,
cart_items: {
customer_id: User.find_by(username: 'vlonchamp').id,
reservation: {
reservable_id: radio.id,
reservable_type: 'Event',
@ -95,7 +98,7 @@ module Events
VCR.use_cassette('reserve_event_with_many_prices_and_payment_means_retrieve_invoice_from_stripe') do
stp_intent = invoice.payment_gateway_object.gateway_object.retrieve
assert_equal stp_intent.amount, (invoice.total - invoice.wallet_amount) # total minus coupon minus wallet = amount really payed by the user
assert_equal stp_intent.amount, (invoice.total - invoice.wallet_amount) # total minus coupon minus wallet = amount really paid by the user
end
# wallet assertions
@ -111,4 +114,3 @@ module Events
assert_not_empty Notification.where(attached_object: invoice)
end
end
end