Refactor invoice PDF generation, download and delivery

- Remove `Que::Mailer` (#895)
- Extract controllers
- Extract translations
- Convert HAML to ERB
- Add mailer preview
- Improve UI
- Remove unused routes
- Add tests
This commit is contained in:
Artur Beljajev 2019-04-07 19:10:11 +03:00
parent 7e0fd30125
commit 27ea790b28
30 changed files with 288 additions and 138 deletions

View file

@ -1,9 +1,13 @@
require 'test_helper'
class AdminAreaInvoicesTest < ApplicationSystemTestCase
include ActionMailer::TestHelper
setup do
sign_in users(:admin)
@invoice = invoices(:one)
ActionMailer::Base.deliveries.clear
end
def test_cancels_an_invoice
@ -17,4 +21,23 @@ class AdminAreaInvoicesTest < ApplicationSystemTestCase
assert @invoice.cancelled?
assert_text 'Invoice has been cancelled'
end
def test_invoice_delivery_form_is_pre_populated_with_billing_email_of_a_registrar
assert_equal 'billing@bestnames.test', @invoice.buyer.billing_email
visit new_admin_invoice_delivery_url(@invoice)
assert_field 'Recipient', with: 'billing@bestnames.test'
end
def test_delivers_an_invoice
visit admin_invoice_url(@invoice)
click_on 'Send'
fill_in 'Recipient', with: 'billing@registrar.test'
click_on 'Send'
assert_emails 1
email = ActionMailer::Base.deliveries.first
assert_equal ['billing@registrar.test'], email.to
assert_current_path admin_invoice_path(@invoice)
assert_text 'Invoice has been sent'
end
end