allow to edit GroupOrderArticle result from orders screen
Conflicts: app/assets/javascripts/application.js
This commit is contained in:
parent
f9d2c20aaa
commit
60826ceedc
34 changed files with 393 additions and 220 deletions
|
|
@ -2,6 +2,7 @@ require_relative '../spec_helper'
|
|||
|
||||
describe 'settling an order', :type => :feature do
|
||||
let(:admin) { create :user, groups:[create(:workgroup, role_finance: true)] }
|
||||
let(:user) { create :user, groups:[create(:ordergroup)] }
|
||||
let(:supplier) { create :supplier }
|
||||
let(:article) { create :article, supplier: supplier, unit_quantity: 1 }
|
||||
let(:order) { create :order, supplier: supplier, article_ids: [article.id] } # need to ref article
|
||||
|
|
@ -43,10 +44,10 @@ describe 'settling an order', :type => :feature do
|
|||
expect(page).to have_content(go1.ordergroup.name)
|
||||
expect(page).to have_content(go2.ordergroup.name)
|
||||
# and that their order results match what we expect
|
||||
expect(page).to have_selector("#group_order_article_#{goa1.id}_quantity")
|
||||
expect(find("#group_order_article_#{goa1.id}_quantity").text.to_f).to eq(3)
|
||||
expect(page).to have_selector("#group_order_article_#{goa2.id}_quantity")
|
||||
expect(find("#group_order_article_#{goa2.id}_quantity").text.to_f).to eq(1)
|
||||
expect(page).to have_selector("#r_#{goa1.id}")
|
||||
expect(find("#r_#{goa1.id}").value.to_f).to eq(3)
|
||||
expect(page).to have_selector("#r_#{goa2.id}")
|
||||
expect(find("#r_#{goa2.id}").value.to_f).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -120,6 +121,48 @@ describe 'settling an order', :type => :feature do
|
|||
expect(oa.units_to_order).to eq(0)
|
||||
end
|
||||
|
||||
it 'can add an ordergroup to an order article' do
|
||||
user # need to reference user before "new article" dialog is loaded
|
||||
click_link article.name
|
||||
within("#group_order_articles_#{oa.id}") do
|
||||
click_link I18n.t('finance.balancing.group_order_articles.add_group')
|
||||
end
|
||||
expect(page).to have_selector('form#new_group_order_article')
|
||||
within('#new_group_order_article') do
|
||||
select user.ordergroup.name, :from => 'group_order_article_ordergroup_id'
|
||||
fill_in 'group_order_article_result', :with => 8
|
||||
find('input[type="submit"]').click
|
||||
end
|
||||
expect(page).to have_content(user.ordergroup.name)
|
||||
goa = GroupOrderArticle.last
|
||||
expect(goa).to_not be_nil
|
||||
expect(goa.result).to eq 8
|
||||
expect(page).to have_selector("#group_order_article_#{goa.id}")
|
||||
expect(find("#r_#{goa.id}").value.to_f).to eq 8
|
||||
end
|
||||
|
||||
it 'can modify an ordergroup result' do
|
||||
click_link article.name
|
||||
within("#group_order_articles_#{oa.id}") do
|
||||
fill_in "r_#{goa1.id}", :with => 5
|
||||
# leave input box and wait a bit so that update is sent using ajax
|
||||
find("#r_#{goa1.id}").native.send_keys :tab
|
||||
sleep 1
|
||||
end
|
||||
expect(goa1.reload.result).to eq 5
|
||||
expect(find("#group_order_articles_#{oa.id} tfoot td:nth-child(3)").text.to_f).to eq 6
|
||||
end
|
||||
|
||||
it 'can modify an ordergroup result using the + button' do
|
||||
click_link article.name
|
||||
within("#group_order_article_#{goa1.id}") do
|
||||
4.times { find('button[data-increment]').click }
|
||||
sleep 1
|
||||
end
|
||||
expect(goa1.reload.result).to eq 7
|
||||
expect(find("#group_order_articles_#{oa.id} tfoot td:nth-child(3)").text.to_f).to eq 8
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue