Delete dead code from products helper

This commit is contained in:
Luis Ramos
2020-04-09 16:33:17 +01:00
parent dd717fe8ac
commit 2ff8356c63
4 changed files with 13 additions and 51 deletions

View File

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

View File

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

View File

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

View File

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