Refactor email sending, tests

This commit is contained in:
Martin Lensment 2015-04-23 10:59:45 +03:00
parent d3c17ce4e3
commit 12e32af524
3 changed files with 24 additions and 7 deletions

View file

@ -4,7 +4,7 @@ feature 'Invoices', type: :feature do
before :all do
create_settings
@user = Fabricate(:api_user)
Fabricate(:invoice)
@invoice = Fabricate(:invoice, buyer: @user.registrar)
end
context 'as unknown user' do
@ -32,5 +32,24 @@ feature 'Invoices', type: :feature do
visit '/registrar/invoices'
page.should have_text('Invoices')
end
it 'should forward invoice' do
visit '/registrar/invoices'
click_link @invoice.to_s
click_link 'Forward invoice'
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 '/registrar/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
end