adapt tests for manually generating group order invoices for order
This commit is contained in:
parent
5a817a9acb
commit
3149e00e11
2 changed files with 16 additions and 3 deletions
|
@ -2,9 +2,10 @@ require_relative '../spec_helper'
|
||||||
|
|
||||||
feature GroupOrderInvoice, js: true do
|
feature GroupOrderInvoice, js: true do
|
||||||
let(:admin) { create :user, groups: [create(:workgroup, role_finance: true)] }
|
let(:admin) { create :user, groups: [create(:workgroup, role_finance: true)] }
|
||||||
|
let(:user) { create :user, groups: [create(:ordergroup)] }
|
||||||
let(:article) { create :article, unit_quantity: 1 }
|
let(:article) { create :article, unit_quantity: 1 }
|
||||||
let(:order) { create :order, supplier: article.supplier, article_ids: [article.id], ends: Time.now } # need to ref article
|
let(:order) { create :order, supplier: article.supplier, article_ids: [article.id], ends: Time.now } # need to ref article
|
||||||
let(:go) { create :group_order, order: order}
|
let(:go) { create :group_order, order: order, ordergroup: user.ordergroup}
|
||||||
let(:oa) { order.order_articles.find_by_article_id(article.id) }
|
let(:oa) { order.order_articles.find_by_article_id(article.id) }
|
||||||
let(:ftt) { create :financial_transaction_type }
|
let(:ftt) { create :financial_transaction_type }
|
||||||
let(:goa) { create :group_order_article, group_order: go, order_article: oa }
|
let(:goa) { create :group_order_article, group_order: go, order_article: oa }
|
||||||
|
@ -42,10 +43,23 @@ feature GroupOrderInvoice, js: true do
|
||||||
order.update!(state: 'closed')
|
order.update!(state: 'closed')
|
||||||
order.reload
|
order.reload
|
||||||
visit finance_order_index_path
|
visit finance_order_index_path
|
||||||
|
expect(page).to have_selector(:link_or_button, I18n.t('activerecord.attributes.group_order_invoice.links.generate'))
|
||||||
click_link_or_button I18n.t('activerecord.attributes.group_order_invoice.links.generate')
|
click_link_or_button I18n.t('activerecord.attributes.group_order_invoice.links.generate')
|
||||||
expect(GroupOrderInvoice.all.count).to eq(1)
|
expect(GroupOrderInvoice.all.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'generates multiple Group Order Invoice for order when order is closed if tax_number is set' do
|
||||||
|
goa.update_quantities 2, 0
|
||||||
|
oa.update_results!
|
||||||
|
FoodsoftConfig[:contact][:tax_number] = 12_345_678
|
||||||
|
order.update!(state: 'closed')
|
||||||
|
order.reload
|
||||||
|
visit finance_order_index_path
|
||||||
|
expect(page).to have_selector(:link_or_button, I18n.t('activerecord.attributes.group_order_invoice.links.generate_with_date'))
|
||||||
|
click_link_or_button I18n.t('activerecord.attributes.group_order_invoice.links.generate_with_date')
|
||||||
|
expect(GroupOrderInvoice.all.count).to eq(1)
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not generate Group Order Invoice when order is closed if tax_number not set' do
|
it 'does not generate Group Order Invoice when order is closed if tax_number not set' do
|
||||||
goa.update_quantities 2, 0
|
goa.update_quantities 2, 0
|
||||||
oa.update_results!
|
oa.update_results!
|
||||||
|
|
|
@ -9,9 +9,8 @@ describe GroupOrderInvoice do
|
||||||
|
|
||||||
describe 'erroneous group order invoice' do
|
describe 'erroneous group order invoice' do
|
||||||
let(:goi) { create :group_order_invoice, group_order_id: group_order.id }
|
let(:goi) { create :group_order_invoice, group_order_id: group_order.id }
|
||||||
|
|
||||||
it 'does not create group order invoice if tax_number not set' do
|
it 'does not create group order invoice if tax_number not set' do
|
||||||
expect { goi }.to raise_error(ActiveRecord::RecordInvalid)
|
expect { goi }.to raise_error(ActiveRecord::RecordInvalid, /.*/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue