mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(test) free reservation no invoice
This commit is contained in:
parent
e139067954
commit
b357f11d1e
51
test/integration/reservations/free_no_invoice_test.rb
Normal file
51
test/integration/reservations/free_no_invoice_test.rb
Normal file
@ -0,0 +1,51 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
module Reservations; end
|
||||
|
||||
class Reservations::FreeNoInvoiceTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = User.members.first
|
||||
@machine = Machine.find(6)
|
||||
@availability = @machine.availabilities.first
|
||||
@admin = User.with_role(:admin).first
|
||||
login_as(@admin, scope: :user)
|
||||
end
|
||||
|
||||
test 'free reservation does not generate an invoice' do
|
||||
Setting.set('prevent_invoices_zero', 'true')
|
||||
|
||||
reservations_count = Reservation.count
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
users_credit_count = UsersCredit.count
|
||||
subscriptions_count = Subscription.count
|
||||
|
||||
post '/api/local_payment/confirm_payment', params: {
|
||||
customer_id: @user.id,
|
||||
items: [
|
||||
{
|
||||
reservation: {
|
||||
reservable_id: @machine.id,
|
||||
reservable_type: @machine.class.name,
|
||||
slots_reservations_attributes: [
|
||||
{
|
||||
slot_id: @availability.slots.first.id,
|
||||
offered: true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
# general assertions
|
||||
assert_equal 201, response.status
|
||||
assert_equal reservations_count + 1, Reservation.count
|
||||
assert_equal invoice_count, Invoice.count
|
||||
assert_equal invoice_items_count, InvoiceItem.count
|
||||
assert_equal users_credit_count, UsersCredit.count
|
||||
assert_equal subscriptions_count, Subscription.count
|
||||
end
|
||||
end
|
@ -8,7 +8,7 @@ class Reservations::LastMinuteTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = User.members.first
|
||||
@space = Space.first
|
||||
@availbility = Availability.find(21)
|
||||
@availability = Availability.find(21)
|
||||
@admin = User.with_role(:admin).first
|
||||
end
|
||||
|
||||
@ -28,7 +28,7 @@ class Reservations::LastMinuteTest < ActionDispatch::IntegrationTest
|
||||
reservable_type: @space.class.name,
|
||||
slots_reservations_attributes: [
|
||||
{
|
||||
slot_id: @availbility.slots.first.id
|
||||
slot_id: @availability.slots.first.id
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -65,7 +65,7 @@ class Reservations::LastMinuteTest < ActionDispatch::IntegrationTest
|
||||
reservable_type: @space.class.name,
|
||||
slots_reservations_attributes: [
|
||||
{
|
||||
slot_id: @availbility.slots.first.id
|
||||
slot_id: @availability.slots.first.id
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -104,7 +104,7 @@ class Reservations::LastMinuteTest < ActionDispatch::IntegrationTest
|
||||
reservable_type: @space.class.name,
|
||||
slots_reservations_attributes: [
|
||||
{
|
||||
slot_id: @availbility.slots.first.id
|
||||
slot_id: @availability.slots.first.id
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user