Remove DistributionChangeValidator#can_change_distributor? method

This commit is contained in:
Rohan Mitchell
2013-06-17 14:00:39 +10:00
parent da02cb5a93
commit 17103a8b0c
3 changed files with 1 additions and 26 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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) }