diff --git a/test/invoice_cancel_test.rb b/test/invoice_cancel_test.rb index 4b469b1..913664f 100644 --- a/test/invoice_cancel_test.rb +++ b/test/invoice_cancel_test.rb @@ -44,6 +44,22 @@ class InvoiceCancelTest < Minitest::Test assert_equal 'pending', @inv.status end + # Every state of the admin invoice page renders (pending, paid, + # cancelled, hidden), for a superuser and for a read-only user. + def test_admin_invoice_page_renders_in_every_state + admin_login! + get "/admin/invoices/#{@inv.uuid}" + assert last_response.ok?, last_response.body[0, 300] + assert_includes last_response.body, 'Cancel invoice' + @inv.update(paid_at: Time.now.utc) + get "/admin/invoices/#{@inv.uuid}" + assert last_response.ok?, last_response.body[0, 300] + @inv.update(cancelled_at: Time.now.utc, cancel_reason: 'dup', hidden: true) + get "/admin/invoices/#{@inv.uuid}" + assert last_response.ok?, last_response.body[0, 300] + assert_includes last_response.body, 'Reinstate' + end + def test_cancelled_pdf_renders @inv.cancelled_at = Time.now.utc @inv.cancel_reason = 'wrong client' diff --git a/test/templates_test.rb b/test/templates_test.rb new file mode 100644 index 0000000..0169a50 --- /dev/null +++ b/test/templates_test.rb @@ -0,0 +1,13 @@ +require_relative 'test_helper' + +# A template with unbalanced <% end %> only fails when that page is +# rendered; compile every view up front so CI catches it regardless. +class TemplatesTest < Minitest::Test + Dir[File.join(__dir__, '..', 'views', '**', '*.erb')].each do |path| + name = path.sub(%r{.*/views/}, '').tr('/.', '__') + define_method("test_compiles_#{name}") do + tmpl = Tilt::ErubiTemplate.new(path, escape_html: true) + tmpl.send(:compiled_method, [], Object) # raises SyntaxError if broken + end + end +end diff --git a/views/admin/invoices/show.erb b/views/admin/invoices/show.erb index 70fdbbb..04ce45b 100644 --- a/views/admin/invoices/show.erb +++ b/views/admin/invoices/show.erb @@ -68,9 +68,6 @@ <% end %> - <% end %> - - <% end %>

<% if can?('invoices', 'write') %>Use as template for a new invoice →<% end %>