mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-17 00:07:24 +00:00
Do not allow deselecting distributor after product added to cart at controller level
This commit is contained in:
@@ -24,8 +24,11 @@ module Spree
|
||||
|
||||
def deselect
|
||||
order = current_order(true)
|
||||
order.distributor = nil
|
||||
order.save!
|
||||
|
||||
if order.line_items.empty?
|
||||
order.distributor = nil
|
||||
order.save!
|
||||
end
|
||||
|
||||
redirect_back_or_default(root_path)
|
||||
end
|
||||
|
||||
@@ -52,6 +52,21 @@ describe Spree::DistributorsController do
|
||||
o.distributor.should == d1
|
||||
end
|
||||
|
||||
it "does not allow deselecting distributors"
|
||||
it "does not allow deselecting distributors" do
|
||||
# Given a distributor and an order with a product
|
||||
d = create(:distributor)
|
||||
p = create(:product, :distributors => [d])
|
||||
o = current_order(true)
|
||||
o.add_variant(p.master, 1)
|
||||
o.distributor = d
|
||||
o.save!
|
||||
|
||||
# When I attempt to deselect the distributor
|
||||
spree_get :deselect
|
||||
|
||||
# Then my distributor should remain unchanged
|
||||
o.reload
|
||||
o.distributor.should == d
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user