From c265edfb9507f7d0804d06d667d0d17aff1b071b Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 14 Jul 2015 13:52:00 +0300 Subject: [PATCH] Update admin invoices tests #2566 --- spec/features/admin/invoice_spec.rb | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/spec/features/admin/invoice_spec.rb b/spec/features/admin/invoice_spec.rb index 4e3747373..91e29afab 100644 --- a/spec/features/admin/invoice_spec.rb +++ b/spec/features/admin/invoice_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' feature 'Invoice', type: :feature do before :all do @user = Fabricate(:admin_user) - Fabricate(:invoice) + @invoice = Fabricate(:invoice) end before do @@ -12,15 +12,13 @@ feature 'Invoice', type: :feature do it 'should show index of invoices' do visit admin_invoices_url - i = Invoice.first - page.should have_link("Invoice no. #{i.id}") + page.should have_link("Invoice no. #{@invoice.id}") end it 'should show invoice' do visit admin_invoices_url - i = Invoice.first - click_link("Invoice no. #{i.id}") + click_link("Invoice no. #{@invoice.id}") page.should have_content("Seller") page.should have_content("Details") page.should have_content("Paldiski mnt. 123") @@ -42,4 +40,23 @@ feature 'Invoice', type: :feature do page.should have_content('120.0') page.should have_content(r.name) end + + it 'should forward invoice' do + visit '/admin/invoices' + click_link @invoice.to_s + click_link 'Forward' + click_button 'Forward' + page.should have_text('Failed to forward invoice') + fill_in 'Billing email', with: 'test@test.ee' + click_button 'Forward' + page.should have_text('Invoice forwarded') + end + + it 'should download invoice' do + visit '/admin/invoices' + click_link @invoice.to_s + click_link 'Download' + response_headers['Content-Type'].should == 'application/pdf' + response_headers['Content-Disposition'].should == "attachment; filename=\"#{@invoice.pdf_name}\"" + end end