Merge pull request #2011 from internetee/2009-mark-internal-invoice-as-paid

Mark internal invoices as paid prior to sending
This commit is contained in:
Timo Võhmar 2021-06-01 13:08:13 +03:00 committed by GitHub
commit e8c19d16e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 60 additions and 16 deletions

View file

@ -1,6 +1,6 @@
require 'test_helper'
class ProcessPaymentsTaskTest < ActiveSupport::TestCase
class ProcessPaymentsTaskTest < ActiveJob::TestCase
setup do
@payment_amount = payment_amount = 0.1
@payment_currency = payment_currency = 'EUR'
@ -162,6 +162,28 @@ class ProcessPaymentsTaskTest < ActiveSupport::TestCase
assert_equal 0.1, registrar.invoices.last.total
end
def test_topup_creates_invoice_and_send_it_as_paid
registrar = registrars(:bestnames)
@invoice.payment_orders.destroy_all
@invoice.destroy
perform_enqueued_jobs do
run_task
end
invoice = Invoice.last
assert invoice.paid?
assert_not invoice.e_invoice_sent_at.blank?
pdf_source = Invoice::PdfGenerator.new(invoice)
pdf_source.send(:invoice_html).include?('Receipt date')
email= ActionMailer::Base.deliveries.last
assert email.subject.include?('already paid')
assert_equal 0.1, registrar.invoices.last.total
end
def test_output
assert_output "Transactions processed: 1\n" do
run_task