mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-26 20:54:21 +01:00
improved invoices test + added fixtures
This commit is contained in:
parent
5ab0333176
commit
d00dfad8d8
12
test/fixtures/invoice_items.yml
vendored
12
test/fixtures/invoice_items.yml
vendored
@ -33,7 +33,6 @@ invoice_item_3:
|
|||||||
subscription_id: 3
|
subscription_id: 3
|
||||||
invoice_item_id:
|
invoice_item_id:
|
||||||
|
|
||||||
|
|
||||||
invoice_item_4:
|
invoice_item_4:
|
||||||
id: 4
|
id: 4
|
||||||
invoice_id: 4
|
invoice_id: 4
|
||||||
@ -45,3 +44,14 @@ invoice_item_4:
|
|||||||
subscription_id:
|
subscription_id:
|
||||||
invoice_item_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:
|
||||||
|
|
||||||
|
17
test/fixtures/invoices.yml
vendored
17
test/fixtures/invoices.yml
vendored
@ -67,3 +67,20 @@ invoice_4:
|
|||||||
type:
|
type:
|
||||||
subscription_to_expire:
|
subscription_to_expire:
|
||||||
description:
|
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:
|
||||||
|
11
test/fixtures/reservations.yml
vendored
11
test/fixtures/reservations.yml
vendored
@ -9,3 +9,14 @@ reservation_1:
|
|||||||
reservable_type: Training
|
reservable_type: Training
|
||||||
stp_invoice_id:
|
stp_invoice_id:
|
||||||
nb_reserve_places:
|
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:
|
||||||
|
12
test/fixtures/slots.yml
vendored
12
test/fixtures/slots.yml
vendored
@ -10,3 +10,15 @@ slot_1:
|
|||||||
canceled_at:
|
canceled_at:
|
||||||
ex_end_at:
|
ex_end_at:
|
||||||
offered:
|
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:
|
||||||
|
4
test/fixtures/slots_reservations.yml
vendored
4
test/fixtures/slots_reservations.yml
vendored
@ -3,3 +3,7 @@
|
|||||||
one:
|
one:
|
||||||
slot_id: 1
|
slot_id: 1
|
||||||
reservation_id: 1
|
reservation_id: 1
|
||||||
|
|
||||||
|
two:
|
||||||
|
slot_id: 2
|
||||||
|
reservation_id: 2
|
||||||
|
@ -10,7 +10,6 @@ class InvoicesTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'admin list invoices' do
|
test 'admin list invoices' do
|
||||||
|
|
||||||
post '/api/invoices/list', { query: {
|
post '/api/invoices/list', { query: {
|
||||||
number: '',
|
number: '',
|
||||||
customer: '',
|
customer: '',
|
||||||
@ -33,4 +32,34 @@ class InvoicesTest < ActionDispatch::IntegrationTest
|
|||||||
assert_equal '1203001', invoices.last[:reference]
|
assert_equal '1203001', invoices.last[:reference]
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user