1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

improved invoices test + added fixtures

This commit is contained in:
Sylvain 2019-01-10 12:40:42 +01:00
parent 5ab0333176
commit d00dfad8d8
6 changed files with 89 additions and 6 deletions

View File

@ -33,7 +33,6 @@ invoice_item_3:
subscription_id: 3
invoice_item_id:
invoice_item_4:
id: 4
invoice_id: 4
@ -45,3 +44,14 @@ invoice_item_4:
subscription_id:
invoice_item_id:
invoice_item_5:
id: 5
invoice_id: 5
stp_invoice_item_id:
amount: 1500
created_at: 2015-06-10 11:20:01.341130000 Z
updated_at: 2015-06-10 11:20:01.341130000 Z
description: Imprimante 3D June 15, 2015 12:00 - 01:00 PM
subscription_id:
invoice_item_id:

View File

@ -67,3 +67,20 @@ invoice_4:
type:
subscription_to_expire:
description:
invoice_5:
id: 5
invoiced_id: 2
invoiced_type: Reservation
stp_invoice_id:
total: 1500
created_at: 2015-06-10 11:20:01.341130000 Z
updated_at: 2015-06-10 11:20:01.341130000 Z
user_id: 3
reference: '1506031'
avoir_mode:
avoir_date:
invoice_id:
type:
subscription_to_expire:
description:

View File

@ -9,3 +9,14 @@ reservation_1:
reservable_type: Training
stp_invoice_id:
nb_reserve_places:
reservation_2:
id: 2
user_id: 3
message:
created_at: 2015-06-10 11:20:01.341130000 Z
updated_at: 2015-06-10 11:20:01.341130000 Z
reservable_id: 4
reservable_type: Machine
stp_invoice_id:
nb_reserve_places:

View File

@ -10,3 +10,15 @@ slot_1:
canceled_at:
ex_end_at:
offered:
slot_2:
id: 2
start_at: 2015-06-15 12:00:28.000000000 Z
end_at: 2015-06-15 13:00:28.000000000 Z
created_at: 2015-06-10 11:20:01.341130000 Z
updated_at: 2015-06-10 11:20:01.341130000 Z
availability_id: 13
ex_start_at:
canceled_at:
ex_end_at:
offered:

View File

@ -3,3 +3,7 @@
one:
slot_id: 1
reservation_id: 1
two:
slot_id: 2
reservation_id: 2

View File

@ -10,7 +10,6 @@ class InvoicesTest < ActionDispatch::IntegrationTest
end
test 'admin list invoices' do
post '/api/invoices/list', { query: {
number: '',
customer: '',
@ -33,4 +32,34 @@ class InvoicesTest < ActionDispatch::IntegrationTest
assert_equal '1203001', invoices.last[:reference]
end
test 'admin generates a refund' do
date = DateTime.now.iso8601
post '/api/invoices', { avoir: {
avoir_date: date,
avoir_mode: 'cash',
description: 'Lorem ipsum',
invoice_id: 4,
invoice_items_ids: [4],
subscription_to_expire: false
} }.to_json, default_headers
# Check response format & status
assert_equal 201, response.status, response.body
assert_equal Mime::JSON, response.content_type
# Check that the refund match
refund = json_response(response.body)
avoir = Avoir.find(refund[:id])
assert_dates_equal date, refund[:avoir_date]
assert_dates_equal date, refund[:date]
assert_equal 'cash', refund[:avoir_mode]
assert_equal false, refund[:has_avoir]
assert_equal 4, refund[:invoice_id]
assert_equal 4, refund[:items][0][:invoice_item_id]
assert_match %r{^[0-9]+/A$}, refund[:reference]
assert_equal 'Lorem ipsum', avoir.description
end
end