mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
adds integration test for reservations for user with invoicing disabled
This commit is contained in:
parent
9bfd5e0362
commit
74e2d170bf
@ -7,6 +7,45 @@ module Reservations
|
||||
login_as(@admin, scope: :user)
|
||||
end
|
||||
|
||||
test "user without subscription and with invoicing disabled reserves a machine with success" do
|
||||
@user_without_subscription.update!(invoicing_disabled: true)
|
||||
machine = Machine.find(6)
|
||||
availability = machine.availabilities.first
|
||||
|
||||
reservations_count = Reservation.count
|
||||
invoice_count = Invoice.count
|
||||
invoice_items_count = InvoiceItem.count
|
||||
users_credit_count = UsersCredit.count
|
||||
|
||||
post reservations_path, { reservation: {
|
||||
user_id: @user_without_subscription.id,
|
||||
reservable_id: machine.id,
|
||||
reservable_type: machine.class.name,
|
||||
slots_attributes: [
|
||||
{ start_at: availability.start_at.to_s(:iso8601),
|
||||
end_at: (availability.start_at + 1.hour).to_s(:iso8601),
|
||||
availability_id: availability.id
|
||||
}
|
||||
]
|
||||
}}.to_json, 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
|
||||
|
||||
# reservation assertions
|
||||
reservation = Reservation.last
|
||||
|
||||
refute reservation.invoice
|
||||
assert reservation.stp_invoice_id.blank?
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: reservation)
|
||||
end
|
||||
|
||||
test "user without subscription reserves a machine with success" do
|
||||
machine = Machine.find(6)
|
||||
availability = machine.availabilities.first
|
||||
|
Loading…
x
Reference in New Issue
Block a user