diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index dab3eb6752..fdbe51634d 100644 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -14,10 +14,6 @@ class BaseController < ApplicationController helper 'spree/base' - # Spree::Core::ControllerHelpers declares helper_method get_taxonomies, so we need to - # include Spree::ProductsHelper so that method is available on the controller - include Spree::ProductsHelper - before_filter :set_locale before_filter :check_order_cycle_expiry diff --git a/app/helpers/spree/products_helper.rb b/app/helpers/spree/products_helper.rb new file mode 100644 index 0000000000..9e367fb010 --- /dev/null +++ b/app/helpers/spree/products_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Spree + module ProductsHelper + def product_has_variant_unit_option_type?(product) + product.option_types.any? { |option_type| variant_unit_option_type? option_type } + end + + def variant_unit_option_type?(option_type) + Spree::Product.all_variant_unit_option_types.include? option_type + end + end +end diff --git a/app/helpers/spree/products_helper_decorator.rb b/app/helpers/spree/products_helper_decorator.rb deleted file mode 100644 index ac31d260b9..0000000000 --- a/app/helpers/spree/products_helper_decorator.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Spree - ProductsHelper.class_eval do - # Return the price of the variant, overriding sprees price diff capability. - # This will allways return the variant price as if the show_variant_full_price is set. - def variant_price_diff(variant) - "(#{Spree::Money.new(variant.price)})" - end - - def product_has_variant_unit_option_type?(product) - product.option_types.any? { |option_type| variant_unit_option_type? option_type } - end - - def variant_unit_option_type?(option_type) - Spree::Product.all_variant_unit_option_types.include? option_type - end - - def product_variant_unit_options - [[I18n.t(:weight), 'weight'], - [I18n.t(:volume), 'volume'], - [I18n.t(:items), 'items']] - end - end -end diff --git a/spec/helpers/products_helper_spec.rb b/spec/helpers/products_helper_spec.rb deleted file mode 100644 index 876c263eed..0000000000 --- a/spec/helpers/products_helper_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -module Spree - describe ProductsHelper, type: :helper do - it "displays variant price differences as absolute, not relative values" do - variant = make_variant_stub(10.00, 10.00) - expect(helper.variant_price_diff(variant)).to eq("(#{with_currency(10.00)})") - - variant = make_variant_stub(10.00, 15.55) - expect(helper.variant_price_diff(variant)).to eq("(#{with_currency(15.55)})") - - variant = make_variant_stub(10.00, 5.55) - expect(helper.variant_price_diff(variant)).to eq("(#{with_currency(5.55)})") - end - - private - - def make_variant_stub(product_price, variant_price) - product = double(:product, price: product_price) - variant = double(:variant, product: product, price: variant_price) - variant - end - end -end