Merge pull request #173 from foodcoop-adam/keep-member-order-on-orderarticle-deletion
Keep member order on orderarticle deletion
This commit is contained in:
commit
857eb64a45
3 changed files with 69 additions and 2 deletions
|
|
@ -50,6 +50,59 @@ describe 'settling an order', :type => :feature do
|
|||
end
|
||||
end
|
||||
|
||||
it 'keeps ordered quantities when article is deleted from resulting order' do
|
||||
within("#order_article_#{oa.id}") do
|
||||
click_link I18n.t('ui.delete')
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
end
|
||||
expect(page).to_not have_selector("#order_article_#{oa.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_true
|
||||
oa.reload
|
||||
expect(oa.quantity).to eq(4)
|
||||
expect(oa.tolerance).to eq(0)
|
||||
expect(oa.units_to_order).to eq(0)
|
||||
expect(goa1.reload.result).to eq(0)
|
||||
expect(goa2.reload.result).to eq(0)
|
||||
end
|
||||
|
||||
it 'deletes an OrderArticle with no GroupOrderArticles' do
|
||||
goa1.destroy
|
||||
goa2.destroy
|
||||
within("#order_article_#{oa.id}") do
|
||||
click_link I18n.t('ui.delete')
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
end
|
||||
expect(page).to_not have_selector("#order_article_#{oa.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_false
|
||||
end
|
||||
|
||||
it 'keeps ordered quantities when GroupOrderArticle is deleted from resulting order' do
|
||||
click_link article.name
|
||||
expect(page).to have_selector("#group_order_article_#{goa1.id}")
|
||||
within("#group_order_article_#{goa1.id}") do
|
||||
click_link I18n.t('ui.delete')
|
||||
end
|
||||
expect(page).to_not have_selector("#group_order_article_#{goa1.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_true
|
||||
expect(GroupOrderArticle.exists?(goa1.id)).to be_true
|
||||
goa1.reload
|
||||
expect(goa1.result).to eq(0)
|
||||
expect(goa1.quantity).to eq(3)
|
||||
expect(goa1.tolerance).to eq(0)
|
||||
end
|
||||
|
||||
it 'deletes a GroupOrderArticle with no ordered amounts' do
|
||||
goa1.update_attributes({:quantity => 0, :tolerance => 0})
|
||||
click_link article.name
|
||||
expect(page).to have_selector("#group_order_article_#{goa1.id}")
|
||||
within("#group_order_article_#{goa1.id}") do
|
||||
click_link I18n.t('ui.delete')
|
||||
end
|
||||
expect(page).to_not have_selector("#group_order_article_#{goa1.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_true
|
||||
expect(GroupOrderArticle.exists?(goa1.id)).to be_false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue