From 46474ea4ccfd40eeb7239d5b1f28d41d4cd00278 Mon Sep 17 00:00:00 2001 From: Andrew Spinks Date: Thu, 1 Aug 2013 15:01:47 +1000 Subject: [PATCH] Prevent order cycle validations on orders when feature toggled off. --- app/models/spree/order_decorator.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/spree/order_decorator.rb b/app/models/spree/order_decorator.rb index c22f5f938a..b1dba6cec3 100644 --- a/app/models/spree/order_decorator.rb +++ b/app/models/spree/order_decorator.rb @@ -15,7 +15,11 @@ Spree::Order.class_eval do def products_available_from_new_distribution # Check that the line_items in the current order are available from a newly selected distribution - errors.add(:base, "Distributor or order cycle cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distribution?(distributor, order_cycle) + if OpenFoodWeb::FeatureToggle.enabled? :order_cycles + errors.add(:base, "Distributor or order cycle cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distribution?(distributor, order_cycle) + else + errors.add(:distributor_id, "cannot supply the products in your cart") unless DistributionChangeValidator.new(self).can_change_to_distributor?(distributor) + end end def set_order_cycle!(order_cycle)