Fix invoice tests

This commit is contained in:
Martin Lensment 2015-04-20 10:29:40 +03:00
parent 10891d1638
commit e987e201ad
6 changed files with 33 additions and 2 deletions

View file

@ -2,7 +2,7 @@ class Admin::InvoicesController < AdminController
load_and_authorize_resource
def index
@q = Invoice.search(params[:q])
@q = Invoice.includes(:account_activity).search(params[:q])
@q.sorts = 'id desc' if @q.sorts.empty?
@invoices = @q.result.page(params[:page])
end

View file

@ -2,5 +2,5 @@ Fabricator(:account) do
account_type { Account::CASH }
balance 0.0
currency 'EUR'
account_activities(count: 2)
# account_activities(count: 2)
end

View file

@ -9,4 +9,5 @@ Fabricator(:invoice) do
seller_street { 'Paldiski mnt. 123' }
invoice_items(count: 2)
vat_prc 0.2
buyer { Fabricate(:registrar) }
end

View file

@ -0,0 +1,28 @@
require 'rails_helper'
feature 'Invoice', type: :feature do
background { create_settings }
before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087')
Fabricate(:invoice)
end
it 'should show index of invoices' do
sign_in @user
visit admin_invoices_url
i = Invoice.first
page.should have_link("Invoice no. #{i.id}")
end
it 'should show invoice' do
sign_in @user
visit admin_invoices_url
i = Invoice.first
click_link("Invoice no. #{i.id}")
page.should have_content("Seller")
page.should have_content("Details")
page.should have_content("Paldiski mnt. 123")
end
end

View file

@ -3,6 +3,7 @@ require 'rails_helper'
feature 'Account activity', type: :feature do
before :all do
@user = Fabricate(:api_user)
Fabricate(:account_activity, account: @user.registrar.cash_account)
end
context 'as unknown user' do

View file

@ -4,6 +4,7 @@ feature 'Invoices', type: :feature do
before :all do
create_settings
@user = Fabricate(:api_user)
Fabricate(:invoice)
end
context 'as unknown user' do