diff --git a/app/views/spree/products/_source_sidebar.html.haml b/app/views/spree/products/_source_sidebar.html.haml index fa9d6232d2..f3861ea748 100644 --- a/app/views/spree/products/_source_sidebar.html.haml +++ b/app/views/spree/products/_source_sidebar.html.haml @@ -18,5 +18,4 @@ = link_to distributor.name, [main_app, distributor] - else %abbr(title="One or more of the products in your cart is not available from this distributor")= distributor.name - - if current_distributor && validator.can_change_distributor? - = button_to 'Browse All Distributors', deselect_distributor_orders_path, :method => :get + = button_to 'Browse All Distributors', deselect_distributor_orders_path, :method => :get diff --git a/lib/open_food_web/distribution_change_validator.rb b/lib/open_food_web/distribution_change_validator.rb index 2362877d1c..0d1062aca4 100644 --- a/lib/open_food_web/distribution_change_validator.rb +++ b/lib/open_food_web/distribution_change_validator.rb @@ -4,11 +4,6 @@ class DistributionChangeValidator @order = order end - def can_change_distributor? - # Distributor may not be changed once an item has been added to the cart/order - @order.line_items.empty? || available_distributors(Enterprise.all).length > 1 - end - def can_change_to_distributor? distributor # Distributor may not be changed once an item has been added to the cart/order, unless all items are available from the specified distributor @order.line_items.empty? || all_available_distributors.include?(distributor) diff --git a/spec/lib/open_food_web/distribution_change_validator_spec.rb b/spec/lib/open_food_web/distribution_change_validator_spec.rb index 45517d2e89..1fa6745b75 100644 --- a/spec/lib/open_food_web/distribution_change_validator_spec.rb +++ b/spec/lib/open_food_web/distribution_change_validator_spec.rb @@ -5,25 +5,6 @@ describe DistributionChangeValidator do let(:subject) { DistributionChangeValidator.new(order) } let(:product) { double(:product) } - context "permissions for changing distributor" do - it "allows distributor to be changed if line_items is empty" do - order.stub(:line_items) { [] } - subject.can_change_distributor?.should be_true - end - - it "allows distributor to be changed if there are multiple available distributors" do - order.stub(:line_items) { [1, 2, 3] } - subject.stub(:available_distributors).and_return([1, 2]) - subject.can_change_distributor?.should be_true - end - - it "does not allow distributor to be changed if there are no other available distributors" do - order.stub(:line_items) { [1, 2, 3] } - subject.stub(:available_distributors).and_return([1]) - subject.can_change_distributor?.should be_false - end - end - context "finding distributors which have the same variants" do let(:variant1) { double(:variant) } let(:variant2) { double(:variant) }