mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
reproductible tests for invoice generation
This commit is contained in:
parent
5c7d52a6f3
commit
31ee151809
@ -95,8 +95,7 @@ module Reservations
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.find_by(invoiced: reservation)
|
||||
assert invoice
|
||||
assert File.exist?(invoice.file)
|
||||
assert_invoice_pdf invoice
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: reservation)
|
||||
@ -148,8 +147,7 @@ module Reservations
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.find_by(invoiced: reservation)
|
||||
assert invoice
|
||||
assert File.exist?(invoice.file)
|
||||
assert_invoice_pdf invoice
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: reservation)
|
||||
@ -217,8 +215,7 @@ module Reservations
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.find_by(invoiced: reservation)
|
||||
assert invoice
|
||||
assert File.exist?(invoice.file)
|
||||
assert_invoice_pdf invoice
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: reservation)
|
||||
|
@ -59,8 +59,7 @@ module Reservations
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.find_by(invoiced: reservation)
|
||||
assert invoice
|
||||
assert File.exist?(invoice.file)
|
||||
assert_invoice_pdf invoice
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: reservation)
|
||||
@ -152,8 +151,7 @@ module Reservations
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.find_by(invoiced: reservation)
|
||||
assert invoice
|
||||
assert File.exist?(invoice.file)
|
||||
assert_invoice_pdf invoice
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: reservation)
|
||||
@ -226,8 +224,7 @@ module Reservations
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.find_by(invoiced: reservation)
|
||||
assert invoice
|
||||
assert File.exist?(invoice.file)
|
||||
assert_invoice_pdf invoice
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: reservation)
|
||||
@ -287,8 +284,7 @@ module Reservations
|
||||
|
||||
# invoice assertions
|
||||
invoice = Invoice.find_by(invoiced: reservation)
|
||||
assert invoice
|
||||
assert File.exist?(invoice.file)
|
||||
assert_invoice_pdf invoice
|
||||
|
||||
# notification
|
||||
assert_not_empty Notification.where(attached_object: reservation)
|
||||
|
@ -50,8 +50,7 @@ module Subscriptions
|
||||
|
||||
# Check generated invoice
|
||||
invoice = Invoice.find_by(invoiced_type: 'Subscription', invoiced_id: subscription[:id])
|
||||
assert_not_nil invoice, 'Invoice was not created'
|
||||
assert File.exist?(invoice.file), 'Invoice PDF was not generated'
|
||||
assert_invoice_pdf invoice
|
||||
assert_equal plan.amount, invoice.total, 'Invoice total price does not match the bought subscription'
|
||||
end
|
||||
|
||||
|
@ -51,8 +51,7 @@ class Subscriptions::CreateAsUserTest < ActionDispatch::IntegrationTest
|
||||
|
||||
# Check generated invoice
|
||||
invoice = Invoice.find_by(invoiced_type: 'Subscription', invoiced_id: subscription[:id])
|
||||
assert_not_nil invoice, 'Invoice was not created'
|
||||
assert File.exist?(invoice.file), 'Invoice PDF was not generated'
|
||||
assert_invoice_pdf invoice
|
||||
assert_equal plan.amount, invoice.total, 'Invoice total price does not match the bought subscription'
|
||||
end
|
||||
|
||||
|
@ -46,8 +46,7 @@ class Subscriptions::RenewAsUserTest < ActionDispatch::IntegrationTest
|
||||
|
||||
# Check generated invoice
|
||||
invoice = Invoice.find_by(invoiced_type: 'Subscription', invoiced_id: subscription[:id])
|
||||
assert_not_nil invoice, 'Invoice was not created'
|
||||
#FIXME assert File.exist?(invoice.file), 'Invoice PDF was not generated'
|
||||
assert_invoice_pdf invoice
|
||||
assert_equal plan.amount, invoice.total, 'Invoice total price does not match the bought subscription'
|
||||
end
|
||||
|
||||
|
@ -10,9 +10,7 @@ VCR.configure do |config|
|
||||
config.hook_into :webmock
|
||||
end
|
||||
|
||||
Sidekiq::Testing.inline!# do |pp|
|
||||
#puts pp
|
||||
#end
|
||||
Sidekiq::Testing.fake!
|
||||
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new({ color: true })]
|
||||
|
||||
|
||||
@ -58,6 +56,20 @@ class ActiveSupport::TestCase
|
||||
},
|
||||
).id
|
||||
end
|
||||
|
||||
# Force the invoice generation worker to run NOW and check the resulting file generated.
|
||||
# Delete the file afterwards.
|
||||
# @param invoice {Invoice}
|
||||
def assert_invoice_pdf(invoice)
|
||||
assert_not_nil invoice, 'Invoice was not created'
|
||||
|
||||
invoice_worker = InvoiceWorker.new
|
||||
invoice_worker.perform(invoice.id)
|
||||
|
||||
assert File.exist?(invoice.file), 'Invoice PDF was not generated'
|
||||
|
||||
File.delete(invoice.file)
|
||||
end
|
||||
end
|
||||
|
||||
class ActionDispatch::IntegrationTest
|
||||
|
Loading…
x
Reference in New Issue
Block a user