remember what member ordered when deleted in balancing screen
This commit is contained in:
parent
1bb257c41b
commit
f224735718
2 changed files with 34 additions and 1 deletions
|
@ -65,7 +65,13 @@ class Finance::GroupOrderArticlesController < ApplicationController
|
|||
|
||||
def destroy
|
||||
group_order_article = GroupOrderArticle.find(params[:id])
|
||||
group_order_article.destroy
|
||||
# only destroy if quantity and tolerance was zero already, so that we don't
|
||||
# lose what the user ordered, if any
|
||||
if group_order_article.quantity > 0 or group_order_article.tolerance >0
|
||||
group_order_article.update_attribute(:result, 0)
|
||||
else
|
||||
group_order_article.destroy
|
||||
end
|
||||
update_summaries(group_order_article)
|
||||
@order_article = group_order_article.order_article
|
||||
|
||||
|
|
|
@ -76,6 +76,33 @@ describe 'settling an order', :type => :feature do
|
|||
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…
Reference in a new issue