mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Leave a distributor
This commit is contained in:
@@ -18,5 +18,13 @@ module Spree
|
||||
|
||||
redirect_back_or_default(root_path)
|
||||
end
|
||||
|
||||
def deselect
|
||||
order = current_order(true)
|
||||
order.distributor = nil
|
||||
order.save!
|
||||
|
||||
redirect_back_or_default(root_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,3 +8,5 @@
|
||||
%ul.filter_choices
|
||||
- @distributors.each do |distributor|
|
||||
%li.nowrap= link_to distributor.name, select_distributor_path(distributor)
|
||||
- if current_distributor
|
||||
%li.nowrap= link_to 'Leave distributor', deselect_distributors_path
|
||||
|
||||
@@ -8,6 +8,7 @@ Spree::Core::Engine.routes.prepend do
|
||||
resources :suppliers
|
||||
resources :distributors do
|
||||
get :select, :on => :member
|
||||
get :deselect, :on => :collection
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
|
||||
@@ -39,7 +39,18 @@ feature %q{
|
||||
|
||||
it "splits the product listing by local/remote distributor"
|
||||
|
||||
it "allows the user to leave the distributor"
|
||||
it "allows the user to leave the distributor" do
|
||||
# Given a distributor
|
||||
d = create(:distributor, :name => 'Melb Uni Co-op')
|
||||
|
||||
# When I select the distributor and then leave it
|
||||
visit spree.root_path
|
||||
click_link d.name
|
||||
click_link 'Leave distributor'
|
||||
|
||||
# Then I should have left the distributor
|
||||
page.should_not have_selector '#current-distributor', :text => 'You are shopping at Melb Uni Co-op'
|
||||
end
|
||||
|
||||
context "viewing a product" do
|
||||
it "provides a choice of distributor when adding to cart" # Test product at remote distributor
|
||||
|
||||
Reference in New Issue
Block a user