Remove the now-unused Product#shipping_method_for_distributor

This commit is contained in:
Rohan Mitchell
2013-08-13 08:42:16 +10:00
parent 94e49d4190
commit 7677f79f17
2 changed files with 0 additions and 35 deletions

View File

@@ -80,23 +80,6 @@ Spree::Product.class_eval do
self.product_distributions.find_by_distributor_id(distributor)
end
# This method is called on products that are distributed via order cycles, but at the time of
# writing (27-5-2013), order cycle fees were not implemented, so there's no defined result
# that this method should return. As a stopgap, we notify Bugsnag of the situation and return
# an undefined, but valid shipping method. When order cycle fees are implemented, this method
# should return the order cycle shipping method, or raise an exepction with the message,
# "This product is not available through that distributor".
def shipping_method_for_distributor(distributor)
distribution = product_distribution_for distributor
unless distribution
Bugsnag.notify(Exception.new "No product distribution for product #{id} at distributor #{distributor.andand.id}. Perhaps this product is distributed via an order cycle? This is a warning that OrderCycle fees and shipping methods are not yet implemented, and the shipping fee charged is undefined until then.")
end
distribution.andand.shipping_method || Spree::ShippingMethod.where("name != 'Delivery'").last
end
# Build a product distribution for each distributor
def build_product_distributions_for_user user
Enterprise.is_distributor.managed_by(user).each do |distributor|

View File

@@ -191,24 +191,6 @@ module Spree
product_distribution = create(:product_distribution, product: product, distributor: distributor)
product.product_distribution_for(distributor).should == product_distribution
end
it "finds the shipping method for a particular distributor" do
shipping_method = create(:shipping_method)
distributor = create(:distributor_enterprise)
product = create(:product)
product_distribution = create(:product_distribution, product: product, distributor: distributor, shipping_method: shipping_method)
product.shipping_method_for_distributor(distributor).should == shipping_method
end
it "logs an error and returns an undefined shipping method if distributor is not found" do
distributor = create(:distributor_enterprise)
product = create(:product)
Bugsnag.should_receive(:notify)
product.shipping_method_for_distributor(distributor).should ==
Spree::ShippingMethod.where("name != 'Delivery'").last
end
end
describe "membership" do