Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Remove unused helpers and helper methods
Damian Legawiecd2bb3a2f8c4b
diff --git a/spree/core/app/finders/spree/variants/option_types_finder.rb b/spree/core/app/finders/spree/variants/option_types_finder.rbdeleted file mode 100644index db313531d6..0000000000--- a/spree/core/app/finders/spree/variants/option_types_finder.rb+++ /dev/null@@ -1,21 +0,0 @@-module Spree- module Variants- class OptionTypesFinder- COLOR_TYPE = 'color'.freeze-- def initialize(variant_ids:)- @variant_ids = variant_ids- end-- def execute- Spree::OptionType.includes(option_values: :variants).where(spree_variants: { id: variant_ids }).- reorder('spree_option_types.position ASC, spree_option_values.position ASC').- partition { |option_type| option_type.name.downcase == COLOR_TYPE }.flatten- end-- private-- attr_reader :variant_ids- end- end-enddiff --git a/spree/core/app/helpers/spree/addresses_helper.rb b/spree/core/app/helpers/spree/addresses_helper.rbdeleted file mode 100644index cf3e285339..0000000000--- a/spree/core/app/helpers/spree/addresses_helper.rb+++ /dev/null@@ -1,97 +0,0 @@-# https://github.com/spree-contrib/spree_address_book/blob/master/app/helpers/spree/addresses_helper.rb-module Spree- module AddressesHelper- def address_form_countries_states_cache_key- @address_form_countries_states_cache_key ||= [- I18n.locale,- current_store.cache_key_with_version- ].compact- end-- def address_field(form, method, address_id = 'b', required = false, text_field_attributes: {}, &handler)- content_tag :div, id: [address_id, method].join, class: 'mb-4' do- if handler- yield- else- method_name = I18n.t("activerecord.attributes.spree/address.#{method}")- form.label(method, method_name, class: 'block text-xs text-neutral-600 mb-1') +- form.text_field(method,- class: ['text-input w-full'].compact,- placeholder: method_name,- required: required,- aria: { label: method_name },- **text_field_attributes)-- end- end- end-- def address_zipcode(form, country, address_id = 'b')- method_name = Spree.t(:zipcode)- form.label(:zipcode, method_name, id: address_id + '_zipcode_label', class: 'block text-xs text-neutral-600 mb-1') +- form.text_field(:zipcode,- class: 'text-input',- placeholder: method_name,- required: country&.zipcode_required?,- data: { 'address-form-target': 'zipcode', address_autocomplete_target: 'zipcode' },- aria: { label: Spree.t(:zipcode) })- end-- def address_state(form, country, address_id = 'b')- country ||= address_default_country- states_required = country.states_required?- have_states = states_required && country.states.any?- state_elements = [- form.label(Spree.t(:state).downcase,- Spree.t(:state),- class: [have_states ? 'state-select-label' : nil, ' block text-xs text-neutral-600 mb-1'].compact,- id: address_id + '_state_label',- data: { 'address-form-target': 'stateLabel' }) +- form.collection_select(:state_id, checkout_zone_applicable_states_for(country).sort_by(&:name),- :id, :name,- { prompt: Spree.t(:state) },- class: 'select-input min-w-full max-w-full',- data: { 'address-form-target': 'state', address_autocomplete_target: 'state' },- required: have_states && states_required,- aria: { label: Spree.t(:state) }) +- form.text_field(:state_name,- class: 'ml-3 text-input',- aria: { label: Spree.t(:state) },- required: !have_states && states_required,- data: { 'address-form-target': 'stateName' },- placeholder: Spree.t(:state))- ].join.tr('"', "'").delete("\n")-- content_tag :span, class: 'w-full state-select max-w-full' do- state_elements.html_safe- end- end-- def available_states- @available_states ||= Rails.cache.fetch(['available-states-v2', current_store.cache_key_with_version]) do- Spree::State.where(country_id: available_countries).pluck(:country_id, :id, :abbr, :name)- end- end-- def user_available_addresses- return [] unless try_spree_current_user-- @user_available_addresses ||= begin- try_spree_current_user.- addresses.- includes(:country, :state).- not_quick_checkout.- where(country_id: current_store.countries_available_for_checkout.pluck(:id)).- includes(:user)- end- end-- def checkout_zone_applicable_states_for(country)- current_store.states_available_for_checkout(country)- end-- def address_default_country- @address_default_country ||= current_store.default_country- end- end-enddiff --git a/spree/core/app/helpers/spree/base_helper.rb b/spree/core/app/helpers/spree/base_helper.rbindex 74bbda8f2d..c87357a99c 100644--- a/spree/core/app/helpers/spree/base_helper.rb+++ b/spree/core/app/helpers/spree/base_helper.rb@@ -1,31 +1,5 @@module Spreemodule BaseHelper- def spree_dom_id(record)- dom_id(record, 'spree')- end-- def available_countries- countries = current_store.countries_available_for_checkout-- countries.collect do |country|- country.name = localized_country_name(country)- country- end.sort_by { |c| c.name.parameterize }- end-- def all_countries- countries = Spree::Country.all-- countries.collect do |country|- country.name = localized_country_name(country)- country- end.sort_by { |c| c.name.parameterize }- end-- def object- instance_variable_get('@' + controller_name.singularize)- end-# returns the URL of an object on the storefront# @param resource [Spree::Product, Spree::Category, Spree::Page] the resource to get the URL for# @param options [Hash] the options for the URL@@ -73,60 +47,5 @@ module Spreebase_url + localizeendend-- # we should always try to render image of the default variant- # same as it's done on PDP- def default_image_for_product(product)- Spree::Deprecation.warn('BaseHelper#default_image_for_product is deprecated and will be removed in Spree 6.0. Please use product.primary_media instead')-- product.primary_media- end-- def default_image_for_product_or_variant(product_or_variant)- Spree::Deprecation.warn('BaseHelper#default_image_for_product_or_variant is deprecated and will be removed in Spree 6.0. Please use product_or_variant.primary_media instead')-- product_or_variant.primary_media- end-- def spree_base_cache_key- @spree_base_cache_key ||= [- I18n.locale,- (current_currency if defined?(current_currency)),- defined?(try_spree_current_user) && try_spree_current_user.present?,- defined?(try_spree_current_user) && try_spree_current_user.respond_to?(:role_users) && try_spree_current_user.role_users.cache_key_with_version- ].compact- end-- def spree_base_cache_scope- ->(record = nil) { [*spree_base_cache_key, record].compact_blank }- end-- def payment_method_icon_tag(payment_method, opts = {})- return '' unless defined?(inline_svg)-- opts[:width] ||= opts[:height] * 1.5 if opts[:height]- opts[:size] = "#{opts[:width]}x#{opts[:height]}" if opts[:width] && opts[:height]-- opts[:fallback] = 'payment_icons/storecredit.svg'-- inline_svg "payment_icons/#{payment_method}.svg", opts- end-- # @param country [Spree::Country]- # @return [String]- def localized_country_name(country)- Spree.t(- country.iso,- scope: 'country_names',- default: country.localized_name- )- end-- private-- I18N_PLURAL_MANY_COUNT = 2.1- def plural_resource_name(resource_class)- resource_class.model_name.human(count: I18N_PLURAL_MANY_COUNT)- endendenddiff --git a/spree/core/app/helpers/spree/currency_helper.rb b/spree/core/app/helpers/spree/currency_helper.rbdeleted file mode 100644index 22a7ff7e0e..0000000000--- a/spree/core/app/helpers/spree/currency_helper.rb+++ /dev/null@@ -1,46 +0,0 @@-module Spree- module CurrencyHelper- # Returns the list of all currencies as options for a select field.- # By default the value is the default currency of the default store.- # @param selected_value [String] the selected value- # @return [String] the options for a select field- def currency_options(selected_value = nil)- selected_value ||= Spree::Store.default.default_currency- currencies = ::Money::Currency.table.map do |_code, details|- currency_presentation(details[:iso_code])- end- options_from_collection_for_select(currencies, :last, :first, selected_value)- end-- # Returns the list of supported currencies for the current store as options for a select field.- # @return [String] the options for a select field- def supported_currency_options- return if current_store.nil?-- @supported_currency_options ||= current_store.supported_currencies_list.map(&:iso_code).map { |currency| currency_presentation(currency) }- end-- def should_render_currency_dropdown?- return false if current_store.nil?-- current_store.supported_currencies_list.size > 1- end-- # Returns the currency symbol for the given currency.- # @param currency [String] the currency ISO code- # @return [String] the currency symbol- def currency_symbol(currency)- ::Money::Currency.find(currency).symbol- end-- # @param currency [String] the currency ISO code- # @return [Array] the currency presentation and ISO code- def currency_presentation(currency)- [Spree::Currency.new(code: currency).label, currency]- end-- def currency_money(currency = current_currency)- ::Money::Currency.find(currency)- end- end-enddiff --git a/spree/core/app/helpers/spree/integrations_helper.rb b/spree/core/app/helpers/spree/integrations_helper.rbdeleted file mode 100644index 67c2612ab6..0000000000--- a/spree/core/app/helpers/spree/integrations_helper.rb+++ /dev/null@@ -1,15 +0,0 @@-module Spree- module IntegrationsHelper- def store_integrations- @store_integrations ||= current_store.integrations.active.to_a- end-- def store_integration(name)- store_integrations.find { |integration| integration.type.to_s.demodulize.underscore == name }- end-- def grouped_available_store_integrations- Spree.integrations.group_by(&:integration_group).sort_by { |group, _| group }- end- end-enddiff --git a/spree/core/app/helpers/spree/locale_helper.rb b/spree/core/app/helpers/spree/locale_helper.rbdeleted file mode 100644index 8547520791..0000000000--- a/spree/core/app/helpers/spree/locale_helper.rb+++ /dev/null@@ -1,44 +0,0 @@-module Spree- module LocaleHelper- def all_locales_options- supported_locales_for_all_stores.map { |locale| locale_presentation(locale) }- end-- # Locales the admin UI is translated into, as [name, code] pairs for a- # select. Self-contained (reads Spree.available_locales directly) so it- # works outside the storefront/admin controller stack — e.g. the pre-auth- # login screen, which has no current store.- def admin_locales_options- Spree.available_locales.map { |locale| locale_presentation(locale) }- end-- def available_locales_options- available_locales.map { |locale| locale_presentation(locale) }- end-- # Locales a merchant may translate **content** into, as [name, code] pairs- # for a select. Backed by `Spree::Locales::ALL` (the canonical translation- # locale set) rather than the installed UI-translation bundles, so a- # market/store can adopt any supported locale instead of only ones already- # in use.- def translation_locales_options- Spree::Locales::ALL.map { |locale| locale_presentation(locale) }- end-- def supported_locales_options- return if current_store.nil?-- current_store.supported_locales_list.map { |locale| locale_presentation(locale) }- end-- def locale_presentation(locale)- [Spree::Locale.new(code: locale).label, locale.to_s]- end-- def should_render_locale_dropdown?- return false if current_store.nil?-- current_store.supported_locales_list.size > 1- end- end-enddiff --git a/spree/core/app/helpers/spree/localized_names_helper.rb b/spree/core/app/helpers/spree/localized_names_helper.rbdeleted file mode 100644index 897dccec3b..0000000000--- a/spree/core/app/helpers/spree/localized_names_helper.rb+++ /dev/null@@ -1,25 +0,0 @@-module Spree- module LocalizedNamesHelper- # @param code [String, Symbol]- # @return [String]- def locale_display_label(code)- return if code.blank?-- content_tag(- :span,- Spree::Locale.new(code: code).label,- data: {- controller: 'display-name',- display_name_type_value: 'language',- display_name_code_value: code- }- )- end-- # @param countries [Enumerable<Spree::Country>]- # @return [Array<Array>]- def country_select_options(countries)- countries.map { |country| [country.option_label, country.id] }- end- end-enddiff --git a/spree/core/app/helpers/spree/products_helper.rb b/spree/core/app/helpers/spree/products_helper.rbdeleted file mode 100644index 8b7e22056c..0000000000--- a/spree/core/app/helpers/spree/products_helper.rb+++ /dev/null@@ -1,145 +0,0 @@-module Spree- module ProductsHelper- include BaseHelper-- # returns the formatted price for the specified variant as a full price or a difference depending on configuration- def variant_price(variant)- if Spree::Config[:show_variant_full_price]- variant_full_price(variant)- else- variant_price_diff(variant)- end- end-- # returns the formatted price for the specified variant as a difference from product price- def variant_price_diff(variant)- variant_amount = variant.amount_in(current_currency)- product_amount = variant.product.amount_in(current_currency)- return if variant_amount == product_amount || product_amount.nil?-- diff = variant.amount_in(current_currency) - product_amount- amount = Spree::Money.new(diff.abs, currency: current_currency).to_html- label = diff > 0 ? :add : :subtract- "(#{Spree.t(label)}: #{amount})".html_safe- end-- # returns the formatted full price for the variant, if at least one variant price differs from product price- def variant_full_price(variant)- product = variant.product- unless product.variants.active(current_currency).all? { |v| v.price == product.price }- Spree::Money.new(variant.price, currency: current_currency).to_html- end- end-- def default_variant(variants, product)- variants_option_types_presenter(variants, product).default_variant || product.default_variant- end-- def should_display_compare_at_price?(default_variant)- default_variant_price = default_variant.price_in(current_currency)- default_variant_price.compare_at_amount.present? && (default_variant_price.compare_at_amount > default_variant_price.amount)- end-- def used_variants_options(variants, product)- variants_option_types_presenter(variants, product).options- end-- def line_item_description_text(description_text)- if description_text.present?- truncate(strip_tags(description_text.gsub(' ', ' ').squish), length: 100)- else- Spree.t(:product_has_no_description)- end- end-- def cache_key_for_products(products = @products, additional_cache_key = nil)- max_updated_at = (products.except(:group, :order).maximum(:updated_at) || Date.today).to_formatted_s(:number)- products_cache_keys = "spree/products/#{products.map(&:id).join('-')}-#{params[:page]}-#{params[:sort_by]}-#{max_updated_at}-#{@taxon&.id}"- (common_product_cache_keys + [products_cache_keys] + [additional_cache_key]).compact.join('/')- end-- def cache_key_for_product(product = @product)- cache_key_elements = common_product_cache_keys- cache_key_elements += [- product.cache_key_with_version,- product.possible_promotions.map(&:cache_key)- ]-- cache_key_elements.compact.join('/')- end-- def limit_description(string)- return string if string.length <= 450-- string.slice(0..449) + '...'- end-- def product_images(product, variants)- if product.variants_and_option_values(current_currency).any?- variant_images = variants.map(&:images).flatten-- return variant_images if variant_images.any?- end-- variants.map(&:images).flatten- end-- def product_variants_matrix(is_product_available_in_currency)- Spree::VariantPresenter.new(- variants: @variants,- is_product_available_in_currency: is_product_available_in_currency,- current_currency: current_currency,- current_price_options: current_price_options,- current_store: current_store- ).call.to_json- end-- def product_relation_types- @product_relation_types ||= @product.respond_to?(:relation_types) ? @product.relation_types : []- end-- def product_relations_by_type(relation_type)- return [] if product_relation_types.none? || [email protected]_to?(:relations)-- product_ids = @product.relations.where(relation_type: relation_type).pluck(:related_to_id).uniq-- return [] if product_ids.empty?-- current_store.products.- available.not_discontinued.distinct.- where(id: product_ids).- includes(- :tax_category,- default_variant: [- :prices,- { images: { attachment_attachment: :blob } },- ]- ).- limit(Spree::Config[:products_per_page])- end-- def product_available_in_currency?- !(@product_price.nil? || @product_price.zero?)- end-- def common_product_cache_keys- spree_base_cache_key + price_options_cache_key- end-- private-- def price_options_cache_key- current_price_options.sort.map(&:last).map do |value|- value.try(:cache_key) || value- end- end-- def variants_option_types_presenter(variants, product)- @variants_option_types_presenter ||= begin- option_types = Spree::Variants::OptionTypesFinder.new(variant_ids: variants.map(&:id)).execute-- Spree::Variants::OptionTypesPresenter.new(option_types, variants, product)- end- end- end-enddiff --git a/spree/core/app/helpers/spree/shipment_helper.rb b/spree/core/app/helpers/spree/shipment_helper.rbdeleted file mode 100644index c5cdc9d2e9..0000000000--- a/spree/core/app/helpers/spree/shipment_helper.rb+++ /dev/null@@ -1,11 +0,0 @@-module Spree- # Deprecated: use Spree::FulfillmentHelper. Removed in Spree 6.1.- module ShipmentHelper- include Spree::FulfillmentHelper-- def shipment_tracking_link_to(shipment:, name: nil, html_options: {})- Spree::Deprecation.warn('shipment_tracking_link_to is deprecated and will be removed in Spree 6.1. Use fulfillment_tracking_link_to instead.')- fulfillment_tracking_link_to(fulfillment: shipment, name: name, html_options: html_options)- end- end-enddiff --git a/spree/core/app/presenters/spree/variant_presenter.rb b/spree/core/app/presenters/spree/variant_presenter.rbdeleted file mode 100644index 59e28e0ce5..0000000000--- a/spree/core/app/presenters/spree/variant_presenter.rb+++ /dev/null@@ -1,81 +0,0 @@-module Spree- class VariantPresenter- include Rails.application.routes.url_helpers- include Spree::BaseHelper- include Spree::ProductsHelper-- attr_reader :current_currency, :current_price_options, :current_store-- def initialize(opts = {})- @variants = opts[:variants]- @is_product_available_in_currency = opts[:is_product_available_in_currency]- @current_currency = opts[:current_currency]- @current_price_options = opts[:current_price_options]- @current_store = opts[:current_store]- end-- def call- @variants.map do |variant|- price = variant.price_in(current_currency)- {- display_price: price.display_price_including_vat_for(current_price_options).to_html,- price: price,- display_compare_at_price: price.display_compare_at_price_including_vat_for(current_price_options).to_html,- should_display_compare_at_price: should_display_compare_at_price?(variant),- is_product_available_in_currency: @is_product_available_in_currency,- backorderable: backorderable?(variant),- in_stock: in_stock?(variant),- images: images(variant),- option_values: option_values(variant),- }.merge(- variant_attributes(variant)- )- end- end-- def images(variant)- variant.images.map do |image|- {- alt: image.alt,- url_product: rails_representation_url(image.url(:product), only_path: true)- }- end- end-- def option_values(variant)- variant.option_values.map do |option_value|- {- id: option_value.id,- name: option_value.name,- presentation: option_value.presentation,- }- end- end-- private-- def backorderable?(variant)- backorderable_variant_ids.include?(variant.id)- end-- def backorderable_variant_ids- @backorderable_variant_ids ||= Spree::Variant.where(id: @variants.map(&:id)).backorderable.ids- end-- def in_stock?(variant)- in_stock_variant_ids.include?(variant.id)- end-- def in_stock_variant_ids- @in_stock_variant_ids ||= Spree::Variant.where(id: @variants.map(&:id)).in_stock.ids- end-- def variant_attributes(variant)- {- id: variant.id,- sku: variant.sku,- purchasable: variant.purchasable?- }- end- end-enddiff --git a/spree/core/app/presenters/spree/variants/option_types_presenter.rb b/spree/core/app/presenters/spree/variants/option_types_presenter.rbdeleted file mode 100644index 0a2047f7b4..0000000000--- a/spree/core/app/presenters/spree/variants/option_types_presenter.rb+++ /dev/null@@ -1,87 +0,0 @@-module Spree- module Variants- class OptionTypesPresenter- def initialize(option_types, variants, product)- @option_types = option_types- @variant_ids = variants.map(&:id)- @product = product- end-- def default_variant- default_variant_data[:variant]- end-- def options- option_types.map do |option_type|- {- id: option_type.id,- name: option_type.name,- presentation: option_type.presentation,- position: option_type.position,- option_values: option_values_options(option_type.option_values)- }- end- end-- private-- attr_reader :option_types-- def default_variant_data- return {} if option_types.empty?-- @default_variant_data ||= begin- try_default_variant || find_in_stock_variant_data || find_backorderable_variant_data || find_first_variant_data- end- end-- def find_in_stock_variant_data- find_variant_data(&:in_stock?)- end-- def find_backorderable_variant_data- find_variant_data(&:backorderable?)- end-- def find_variant_data(&block)- option_types.first.option_values.each do |option_value|- variant = option_value.variants.where(id: @variant_ids).order(:position).find(&block)-- return { variant: variant, option_value: option_value } if variant- end-- nil- end-- def try_default_variant- option_types.first.option_values.each do |option_value|- variant = option_value.variants.where(id: @product.default_variant_id).first-- return { variant: variant, option_value: option_value } if variant- end-- nil- end-- def find_first_variant_data- option_value = option_types.first.option_values.first- variant = option_value.variants.where(id: @variant_ids).order(:position).first-- { variant: variant, option_value: option_value }- end-- def option_values_options(option_values)- option_values.map do |option_value|- {- id: option_value.id,- position: option_value.position,- presentation: option_value.presentation,- name: option_value.name,- variant_id: option_value.variants.where(id: @variant_ids).order(:position).first.id,- is_default: option_value == default_variant_data[:option_value]- }- end- end- end- end-enddiff --git a/spree/core/app/views/spree/shared/_google_places_api_loader.html.erb b/spree/core/app/views/spree/shared/_google_places_api_loader.html.erbdeleted file mode 100644index 21e5358f26..0000000000--- a/spree/core/app/views/spree/shared/_google_places_api_loader.html.erb+++ /dev/null@@ -1,7 +0,0 @@-<% if Spree.google_places_api_key.present? %>- <script>- (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({- key: "<%= Spree.google_places_api_key %>",- });- </script>-<% end %>\ No newline at end of filediff --git a/spree/core/app/views/spree/shared/_mailer_line_item.html.erb b/spree/core/app/views/spree/shared/_mailer_line_item.html.erbdeleted file mode 100644index a31accf8a3..0000000000--- a/spree/core/app/views/spree/shared/_mailer_line_item.html.erb+++ /dev/null@@ -1,12 +0,0 @@-<tr>- <td class="six sub-columns">- <strong>- <%= link_to line_item.variant.product.name, spree_storefront_resource_url(line_item.variant.product) %>- </strong>- <%= line_item.variant.options_text -%>- (<%= line_item.variant.sku %>)- </td>- <td class="six sub-columns last right">- <%= line_item.quantity %> x <%= line_item.single_money %> = <%= line_item.display_amount %>- </td>-</tr>diff --git a/spree/core/app/views/spree/shared/_payment.html.erb b/spree/core/app/views/spree/shared/_payment.html.erbdeleted file mode 100644index bc425c0cb6..0000000000--- a/spree/core/app/views/spree/shared/_payment.html.erb+++ /dev/null@@ -1,52 +0,0 @@-<% source = payment.source %>-<div class="d-flex flex items-top align-items-top gap-3">- <% if source.is_a?(Spree::CreditCard) %>- <div class="flex-shrink-0">- <% # display wallet icon, eg. Apple Pay, Google Pay, etc. %>- <%= payment_method_icon_tag source.wallet_type, height: 30 if source.try(:wallet_type).present? %>- <% # display card type icon, eg. Visa, Mastercard, etc. %>- <%= payment_method_icon_tag source.cc_type, height: 30 %>- </div>- <div>- <p class="mb-1"> •••• <%=source.last_digits %></p>- <p class="mb-0"><%= Spree.t(:expiration) %> <%= source.month %>/<%= source.year %></p>- </div>- <% elsif source.is_a?(Spree::StoreCredit) %>- <% if source.originator_type == 'Spree::GiftCard' %>- <% if respond_to?(:heroicon) %>- <%= heroicon('gift', options: { style: 'margin-right: 0 !important;' }) %>- <% else %>- <%= icon('gift', height: 30) %>- <% end %>- <div>- <p class="mb-1"><%= Spree.t(:gift_card) %>: <strong><%= source.originator.code.upcase %></strong></p>- <%= @order.display_gift_card_total %>- </div>- <% elsif payment.payment_method.present? && payment_method_icon_tag(payment.payment_method.payment_icon_name).present? %>- <div class="d-flex flex align-items-center items-center">- <div><%= payment_method_icon_tag(payment.payment_method.payment_icon_name) %></div>- <div class="ml-3"><%= Spree.t(:store_credit_name) %></div>- </div>- <% end %>- <% elsif source.present? %>- <div class="flex-shrink-0">- <%= payment_method_icon_tag source.class.to_s.demodulize.downcase, height: 30 %>- </div>- <div>- <% if payment.payment_method.present? && payment.payment_method.respond_to?(:source_partial_name) %>- <%= render partial: "spree/payment_sources/#{payment.payment_method.source_partial_name}", locals: { payment: payment, source: source } %>- <% elsif source.respond_to?(:name) %>- <%= source.name %>- <% else %>- <%= source.class.to_s.demodulize.downcase %>- <% end %>- </div>- <% elsif payment.payment_method.present? %>- <div class="flex-shrink-0">- <%= payment_method_icon_tag payment.payment_method.payment_icon_name %>- </div>- <div>- <%= payment.payment_method.name %>- </div>- <% end %>-</div>diff --git a/spree/core/spec/finders/spree/variants/option_types_finder_spec.rb b/spree/core/spec/finders/spree/variants/option_types_finder_spec.rbdeleted file mode 100644index eba5d0744f..0000000000--- a/spree/core/spec/finders/spree/variants/option_types_finder_spec.rb+++ /dev/null@@ -1,42 +0,0 @@-require 'spec_helper'--describe Spree::Variants::OptionTypesFinder do- let(:store) { @default_store }-- describe '#execute' do- let(:option_type_1) { create :option_type, position: 2 }- let(:option_type_2) { create :option_type, position: 1 }-- let(:product) { create :product, option_types: [option_type_1, option_type_2], store: store }-- let!(:variant_1) { create :variant, product: product, option_values: [option_value_1_1, option_value_2_2] }- let!(:variant_2) { create :variant, product: product, option_values: [option_value_1_2, option_value_2_1] }-- let!(:option_value_1_1) { create :option_value, option_type: option_type_1, position: 2 }- let!(:option_value_1_2) { create :option_value, option_type: option_type_1, position: 1 }- let!(:option_value_2_1) { create :option_value, option_type: option_type_2, position: 2 }- let!(:option_value_2_2) { create :option_value, option_type: option_type_2, position: 1 }-- let!(:another_option_type) { create :option_type }- let!(:another_product) { create :product, option_types: [another_option_type] }- let!(:another_variant) { create :variant, product: product, option_values: [another_option_value] }- let!(:another_option_value) { create :option_value, option_type: another_option_type }-- subject(:option_types) { described_class.new(variant_ids: [variant_1.id, variant_2.id]).execute }-- it 'returns ordered Option Types and Option Values' do- expect(option_types).to eq([option_type_2, option_type_1])-- expect(option_types.first.option_values).to eq([option_value_2_2, option_value_2_1])- expect(option_types.second.option_values).to eq([option_value_1_2, option_value_1_1])- end-- context 'when Option Type is color' do- let(:option_type_1) { create :option_type, position: 2, name: 'color' }-- it 'returns color Option Type first' do- expect(option_types).to eq([option_type_1, option_type_2])- end- end- end-enddiff --git a/spree/core/spec/helpers/base_helper_spec.rb b/spree/core/spec/helpers/base_helper_spec.rbindex 06c8c082eb..3d32677fa1 100644--- a/spree/core/spec/helpers/base_helper_spec.rb+++ b/spree/core/spec/helpers/base_helper_spec.rb@@ -10,31 +10,6 @@ describe Spree::BaseHelper, type: :helper doallow(Rails.application.routes).to receive(:default_url_options).and_return(protocol: 'http', port: nil)end- context 'available_countries' do- before do- create_list(:country, 3)- end-- context 'with markets' do- let!(:country) { create(:country) }-- before do- create(:market, store: current_store, countries: [country], currency: 'USD', default: true)- end-- it 'returns the countries from all markets including the bootstrap market' do- us = Spree::Country.find_by(iso: 'US')- expect(available_countries).to contain_exactly(country, us)- end- end-- context 'without extra markets' do- it 'returns the bootstrap market country' do- expect(available_countries.map(&:iso)).to eq(['US'])- end- end- end-describe '#spree_storefront_resource_url' dolet!(:store) { @default_store }let!(:taxon) { create(:taxon) }@@ -100,50 +75,4 @@ describe Spree::BaseHelper, type: :helper doendend- context 'spree_base_cache_key' do- let(:current_currency) { 'USD' }-- context 'when try_spree_current_user defined' do- before do- allow(I18n).to receive(:locale).and_return(I18n.default_locale)- allow_any_instance_of(described_class).to receive(:try_spree_current_user).and_return(user)- end-- context 'when admin user' do- let!(:user) { create(:admin_user) }-- it 'returns base cache key' do- expect(spree_base_cache_key).to eq [:en, 'USD', true, user.role_users.cache_key_with_version]- end- end-- context 'when user without admin role' do- let!(:user) { create(:user) }-- it 'returns base cache key' do- expect(spree_base_cache_key).to eq [:en, 'USD', true, user.role_users.cache_key_with_version]- end- end-- context 'when spree_current_user is nil' do- let!(:user) { nil }-- it 'returns base cache key' do- expect(spree_base_cache_key).to eq [:en, 'USD', false, false]- end- end- end-- context 'when try_spree_current_user is undefined' do- let(:current_currency) { 'USD' }-- before do- allow(I18n).to receive(:locale).and_return(I18n.default_locale)- end-- it 'returns base cache key' do- expect(spree_base_cache_key).to eq [:en, 'USD']- end- end- endenddiff --git a/spree/core/spec/helpers/currency_helper_spec.rb b/spree/core/spec/helpers/currency_helper_spec.rbdeleted file mode 100644index 27126088fd..0000000000--- a/spree/core/spec/helpers/currency_helper_spec.rb+++ /dev/null@@ -1,46 +0,0 @@-require 'spec_helper'--describe Spree::CurrencyHelper, type: :helper do- let(:current_store) { create(:store, default_currency: 'EUR', supported_currencies: 'EUR,PLN,GBP') }-- before do- allow(helper).to receive(:current_store).and_return(current_store)- allow(helper).to receive(:current_currency).and_return('USD')- end-- describe '#supported_currency_options' do- it { expect(supported_currency_options).to contain_exactly(['PLN — Polish Złoty', 'PLN'], ['GBP — British Pound', 'GBP'], ['EUR — Euro', 'EUR']) }- end-- describe '#should_render_currency_dropdown?' do- context 'store with multiple currencies' do- it { expect(should_render_currency_dropdown?).to be_truthy }- end-- context 'store with single currency' do- let(:current_store) { create(:store, default_currency: 'EUR', supported_currencies: 'EUR') }-- it { expect(should_render_currency_dropdown?).to be_falsey }- end- end-- describe '#currency_symbol' do- it { expect(currency_symbol('EUR')).to eq('€') }- end-- describe '#currency_presentation' do- it { expect(currency_presentation('EUR')).to eq(['EUR — Euro', 'EUR']) }- end-- describe '#currency_money' do- it 'returns Money::Currency instance for given currency' do- expect(helper.currency_money('EUR')).to be_a(Money::Currency)- expect(helper.currency_money('EUR').iso_code).to eq('EUR')- end-- it 'uses current_currency when no argument is provided' do- expect(helper.currency_money.iso_code).to eq('USD')- end- end--enddiff --git a/spree/core/spec/helpers/locale_helper_spec.rb b/spree/core/spec/helpers/locale_helper_spec.rbdeleted file mode 100644index 2d0e69a02d..0000000000--- a/spree/core/spec/helpers/locale_helper_spec.rb+++ /dev/null@@ -1,89 +0,0 @@-require 'spec_helper'--describe Spree::LocaleHelper, type: :helper do- let(:germany) { create(:country, name: 'Germany', iso: 'GR') }- let(:eu_store) { create(:store, default_currency: 'EUR', default_locale: 'de', default_country: germany, supported_locales: 'fr,de') }- let(:available_locales) { Spree::Store.available_locales }- let(:supported_locales_for_all_stores) { [:en, :de, :fr] }-- before do- I18n.backend.store_translations(:de,- spree: {- i18n: {- this_file_language: 'Deutsch (DE)'- }- })- I18n.backend.store_translations(:fr,- spree: {- i18n: {- this_file_language: 'Français (FR)'- }- })- end-- describe '#all_locales_options' do- it { expect(all_locales_options).to contain_exactly(['EN — English', 'en'], ['DE — Deutsch', 'de'], ['FR — Français', 'fr']) }- end-- describe '#available_locales_options' do- before do- store = create(:store, default: true, supported_locales: 'en,de', default_locale: 'en')- Spree::Store.where.not(id: store.id).update_all(default: false)- Rails.cache.clear- end-- it { expect(available_locales_options).to contain_exactly(['EN — English', 'en'], ['DE — Deutsch', 'de']) }- end-- describe '#supported_locales_options' do- let(:current_store) { eu_store }-- it { expect(supported_locales_options).to contain_exactly(['DE — Deutsch', 'de'], ['FR — Français', 'fr']) }- end-- describe '#translation_locales_options' do- subject { translation_locales_options }-- let(:current_store) { eu_store }-- it 'returns the full canonical translation-locale set in order' do- expect(subject.map(&:last)).to eq(Spree::Locales::ALL)- end-- it 'returns [name, code] pairs suitable for a select' do- expect(subject).to all(be_an(Array).and(have_attributes(size: 2)))- expect(subject).to include(['DE — Deutsch', 'de'], ['FR — Français', 'fr'])- end-- it 'offers regional variants a store may not yet use' do- expect(subject.map(&:last)).to include('pt-BR', 'pt-PT', 'zh-CN', 'es-MX', 'en-GB')- end-- it 'is independent of the store\'s configured supported_locales' do- # eu_store only supports fr,de — the picker still offers everything.- expect(subject.map(&:last)).to include('en', 'ja', 'ar')- end- end-- describe '#locale_presentation' do- it { expect(locale_presentation(:fr)).to eq(['FR — Français', 'fr']) }-- it 'returns the locale when no translation exists' do- expect(locale_presentation(:klingon)).to eq(['KLINGON', 'klingon'])- end- end-- describe '#should_render_locale_dropdown?' do- context 'store with multiple locales' do- let(:current_store) { eu_store }-- it { expect(should_render_locale_dropdown?).to be_truthy }- end-- context 'store with single locale' do- let(:current_store) { create(:store, supported_locales: 'en', default_locale: 'en') }-- it { expect(should_render_locale_dropdown?).to be_falsey }- end- end-enddiff --git a/spree/core/spec/helpers/localized_names_helper_spec.rb b/spree/core/spec/helpers/localized_names_helper_spec.rbdeleted file mode 100644index 5df0596fa9..0000000000--- a/spree/core/spec/helpers/localized_names_helper_spec.rb+++ /dev/null@@ -1,30 +0,0 @@-require 'spec_helper'--describe Spree::LocalizedNamesHelper, type: :helper do- describe '#locale_display_label' do- it 'renders the localized label inside a display-name span' do- html = helper.locale_display_label('en')-- expect(html).to have_css('span[data-controller="display-name"]', text: 'EN — English')- expect(html).to have_css('span[data-display-name-type-value="language"]')- expect(html).to have_css('span[data-display-name-code-value="en"]')- end-- it 'returns nil for a blank code' do- expect(helper.locale_display_label(nil)).to be_nil- end- end-- describe '#country_select_options' do- let(:country) { build_stubbed(:country, iso: 'US', name: 'United States') }-- it 'returns [label, id] pairs with the localized country option label' do- options = helper.country_select_options([country])-- expect(options.size).to eq(1)- label, id = options.first- expect(label).to include('United States')- expect(id).to eq(country.id)- end- end-enddiff --git a/spree/core/spec/helpers/products_helper_spec.rb b/spree/core/spec/helpers/products_helper_spec.rbdeleted file mode 100644index fd579129e0..0000000000--- a/spree/core/spec/helpers/products_helper_spec.rb+++ /dev/null@@ -1,290 +0,0 @@-require 'spec_helper'--module Spree- describe ProductsHelper, type: :helper do- include ProductsHelper-- let(:store) { @default_store }-- let(:product) { create(:product) }- let(:currency) { 'USD' }-- before do- allow(helper).to receive(:current_currency) { currency }- end-- context '#variant_price_diff' do- subject { helper.variant_price(@variant) }-- let(:product_price) { 10 }- let(:variant_price) { 10 }-- before do- @variant = create(:variant, product: product)- product.price = 15- @variant.price = 10- allow(product).to receive(:amount_in) { product_price }- allow(@variant).to receive(:amount_in) { variant_price }- end-- context 'when variant is same as the default variant' do- it { is_expected.to be_nil }- end-- context 'when the default variant has no price' do- let(:product_price) { nil }-- it { is_expected.to be_nil }- end-- context 'when currency is default' do- context 'when variant is more than the default variant' do- let(:variant_price) { 15 }-- it { is_expected.to eq('(Add: $5.00)') }- # Regression test for #2737- it { is_expected.to be_html_safe }- end-- context 'when variant is less than the default variant' do- let(:product_price) { 15 }-- it { is_expected.to eq('(Subtract: $5.00)') }- end- end-- context 'when currency is JPY' do- let(:variant_price) { 100 }- let(:product_price) { 100 }- let(:currency) { 'JPY' }-- context 'when variant is more than the default variant' do- let(:variant_price) { 150 }-- it { is_expected.to eq("(Add: \u00A550)") }- end-- context 'when variant is less than the default variant' do- let(:product_price) { 150 }-- it { is_expected.to eq("(Subtract: \u00A550)") }- end- end- end-- context '#variant_price_full' do- before do- Spree::Config[:show_variant_full_price] = true- @variant1 = create(:variant, product: product)- @variant2 = create(:variant, product: product)- end-- context 'when currency is default' do- it 'returns the variant price if the price is different than the default variant' do- product.price = 10- @variant1.price = 15- @variant2.price = 20- expect(helper.variant_price(@variant1)).to eq('$15.00')- expect(helper.variant_price(@variant2)).to eq('$20.00')- end- end-- context 'when currency is JPY' do- let(:currency) { 'JPY' }-- before do- product.variants.active.each do |variant|- variant.prices.each do |price|- price.currency = currency- price.save!- end- end- end-- it 'returns the variant price if the price is different than the default variant' do- product.price = 100- @variant1.price = 150- expect(helper.variant_price(@variant1)).to eq("\u00A5150")- end- end-- it 'is nil when all variant prices are equal' do- product.price = 10- @variant1.default_price.update_column(:amount, 10)- @variant2.default_price.update_column(:amount, 10)- expect(helper.variant_price(@variant1)).to be_nil- expect(helper.variant_price(@variant2)).to be_nil- end- end-- shared_examples_for 'line item descriptions' do- context 'variant has a blank description' do- let(:description) { nil }-- it { is_expected.to eq(Spree.t(:product_has_no_description)) }- end-- context 'variant has a description' do- let(:description) { 'test_desc' }-- it { is_expected.to eq(description) }- end-- context 'description has nonbreaking spaces' do- let(:description) { 'test desc' }-- it { is_expected.to eq('test desc') }- end-- context 'description has line endings' do- let(:description) { "test\n\r\ndesc" }-- it { is_expected.to eq('test desc') }- end- end-- context '#line_item_description_text' do- subject { line_item_description_text description }-- it_behaves_like 'line item descriptions'- end-- context '#cache_key_for_products' do- subject { helper.cache_key_for_products(products) }-- let(:zone) { Spree::Zone.new }- let(:price_options) { { tax_zone: zone } }- let!(:products) { create_list(:product, 5) }- let(:product_ids) { products.map(&:id).join('-') }- let(:taxon) { create(:taxon) }-- before do- allow(helper).to receive(:params).and_return(page: 10)- allow(helper).to receive(:current_price_options) { price_options }-- allow(products).to receive(:except).with(:group, :order).and_return(products)- end-- context 'when there is a maximum updated date' do- let(:updated_at) { Date.new(2011, 12, 13) }-- before do- allow(products).to receive(:maximum).with(:updated_at) { updated_at }- end-- it { is_expected.to eq("en/USD/spree/zones/new/spree/products/#{product_ids}-10--20111213-") }- end-- context 'when there is no considered maximum updated date' do- let(:today) { Date.new(2013, 12, 11) }-- before do- allow(products).to receive(:maximum).with(:updated_at).and_return(nil)- allow(Date).to receive(:today) { today }- end-- it { is_expected.to eq("en/USD/spree/zones/new/spree/products/#{product_ids}-10--20131211-") }- end-- context 'with Taxon ID present' do- let(:updated_at) { Date.new(2011, 12, 13) }-- before do- @taxon = taxon- allow(products).to receive(:maximum).with(:updated_at) { updated_at }- end-- it { is_expected.to eq("en/USD/spree/zones/new/spree/products/#{product_ids}-10--20111213-#{taxon.id}") }- end-- context 'with `additional_cache_key` passed' do- subject { helper.cache_key_for_products(products, 'json-ld') }-- let(:updated_at) { Date.new(2011, 12, 13) }-- before do- @taxon = taxon- allow(products).to receive(:maximum).with(:updated_at) { updated_at }- end-- it { is_expected.to eq("en/USD/spree/zones/new/spree/products/#{product_ids}-10--20111213-#{taxon.id}/json-ld") }- end- end-- context '#cache_key_for_product' do- subject(:cache_key) { helper.cache_key_for_product(product) }-- let(:product) { store.products.new }- let(:price_options) { { tax_zone: zone } }-- before do- allow(helper).to receive(:current_price_options) { price_options }- end-- context 'when there is a current tax zone' do- let(:zone) { Spree::Zone.new }-- it 'includes the current_tax_zone' do- expect(subject).to eq('en/USD/spree/zones/new/spree/products/new/')- end- end-- context 'when there is no current tax zone' do- let(:zone) { nil }-- it { is_expected.to eq('en/USD/spree/products/new/') }- end-- context 'when current_price_options includes nil values' do- let(:price_options) do- {- a: nil,- b: Spree::Zone.new- }- end-- it 'does not include nil values' do- expect(cache_key).to eq('en/USD/spree/zones/new/spree/products/new/')- end- end-- context 'when current_price_options includes values that do not implement cache_key' do- let(:price_options) do- {- a: true,- b: Spree::Zone.new- }- end-- it 'includes string representations of these values' do- expect(cache_key).to eq('en/USD/true/spree/zones/new/spree/products/new/')- end- end-- context 'when keys in the options hash are inserted in non-alphabetical order' do- let(:price_options) do- {- b: Spree::Zone.new,- a: true- }- end-- it 'the values are nevertheless returned in alphabetical order of their keys' do- expect(cache_key).to eq('en/USD/true/spree/zones/new/spree/products/new/')- end- end-- context 'given possible promotions' do- let(:zone) { nil }- let(:promotion) { create :promotion }- let(:promotion_2) { create :promotion }-- before do- allow(product).to receive(:possible_promotions).and_return([promotion, promotion_2])- end-- it { is_expected.to eq("en/USD/spree/products/new/#{promotion.cache_key}/#{promotion_2.cache_key}") }- end- end- end-enddiff --git a/spree/core/spec/helpers/shipment_helper_spec.rb b/spree/core/spec/helpers/shipment_helper_spec.rbdeleted file mode 100644index bbc68a152e..0000000000--- a/spree/core/spec/helpers/shipment_helper_spec.rb+++ /dev/null@@ -1,75 +0,0 @@-require 'spec_helper'--module Spree- describe ShipmentHelper, type: :helper do- let(:shipment) { create(:shipment, tracking: tracking) }- let(:tracking) { 'tracking' }-- before do- allow(shipment).to receive(:tracking_url).and_return(tracking_url)- end-- describe '#shipment_tracking_link_to' do- subject(:shipment_tracking_link_to) { helper.shipment_tracking_link_to(**params) }-- let(:params) do- {- shipment: shipment,- }- end-- let(:tracking_url) { 'https://example.com?tracking=Abc' }-- context 'with tracking and tracking_url' do- it 'creates link with tracking as a name' do- expect(shipment_tracking_link_to).to eq('<a href="https://example.com?tracking=Abc">tracking</a>')- end- end-- context 'with name passed in params' do- let(:name) { 'overridden name' }-- let(:params) do- {- shipment: shipment,- name: name- }- end-- it 'creates link with passed value as a name' do- expect(shipment_tracking_link_to).to eq('<a href="https://example.com?tracking=Abc">overridden name</a>')- end- end-- context 'with tracking_url only' do- let(:tracking) { nil }- let(:tracking_url) { 'https://example.com' }-- it 'creates a link with tracking_url as a name' do- expect(shipment_tracking_link_to).to eq('<a href="https://example.com">https://example.com</a>')- end- end-- context 'with no tracking_url' do- let(:tracking_url) { '' }-- it 'returns empty string' do- expect(shipment_tracking_link_to).to eq('')- end- end-- context 'with options' do- let(:params) do- {- shipment: shipment,- html_options: { data: { foo: 'bar' } }- }- end-- it 'sets options for link' do- expect(shipment_tracking_link_to).to include(' data-foo="bar"')- end- end- end- end-enddiff --git a/spree/core/spec/presenters/spree/variant_presenter_spec.rb b/spree/core/spec/presenters/spree/variant_presenter_spec.rbdeleted file mode 100644index c9df4f1401..0000000000--- a/spree/core/spec/presenters/spree/variant_presenter_spec.rb+++ /dev/null@@ -1,37 +0,0 @@-require 'spec_helper'--describe Spree::VariantPresenter do- describe '#call' do- subject { described_class.new(options) }-- let(:options) do- {- variants: [- create(:variant),- create(:variant)- ],- is_product_available_in_currency: true,- current_currency: 'USD',- current_price_options: {- tax_zone: create(:zone, default_tax: true)- }- }- end-- it 'returns an array of variant with option_values and images' do- array = subject.call-- expect(array).to_not be_empty- array.each do |variant|- expect(variant[:option_values]).to_not be_empty- variant[:option_values].each do |option_value|- expect(option_value[:id]).to_not be_nil- end- end- end-- it 'generates request body without raising any errors' do- expect { subject.call }.not_to raise_error- end- end-enddiff --git a/spree/core/spec/presenters/spree/variants/option_types_presenter_spec.rb b/spree/core/spec/presenters/spree/variants/option_types_presenter_spec.rbdeleted file mode 100644index 2ef3c049d3..0000000000--- a/spree/core/spec/presenters/spree/variants/option_types_presenter_spec.rb+++ /dev/null@@ -1,179 +0,0 @@-require 'spec_helper'--describe Spree::Variants::OptionTypesPresenter do- let(:option_type_1) { create :option_type, position: 2 }- let(:option_type_2) { create :option_type, position: 1 }-- let(:product) { create :product, option_types: [option_type_1, option_type_2] }- let(:product_2) { create :product, option_types: [option_type_1, option_type_2] }-- let!(:variant_0) { create :variant, product: product, option_values: [option_value_1_0, option_value_2_0] }- let!(:variant_1) { create :variant, product: product, option_values: [option_value_1_1, option_value_2_2] }- let!(:variant_2) { create :variant, product: product, option_values: [option_value_1_2, option_value_2_1] }- let!(:variant_3) { create :variant, product: product_2, option_values: [option_value_1_2, option_value_2_1] }-- let(:variants) { product.reload.variants }-- let!(:option_value_1_0) { create :option_value, option_type: option_type_1, position: 0 }- let!(:option_value_1_1) { create :option_value, option_type: option_type_1, position: 2 }- let!(:option_value_1_2) { create :option_value, option_type: option_type_1, position: 1 }- let!(:option_value_2_0) { create :option_value, option_type: option_type_2, position: 0 }- let!(:option_value_2_1) { create :option_value, option_type: option_type_2, position: 2 }- let!(:option_value_2_2) { create :option_value, option_type: option_type_2, position: 1 }-- let(:option_types) do- Spree::OptionType.- eager_load(:option_values).- reorder('spree_option_types.position ASC, spree_option_values.position ASC')- end-- describe '#default_variant' do- subject(:default_variant) { described_class.new(option_types, variants, product).default_variant }-- before { variant_0.stock_items.first.update(backorderable: false, count_on_hand: 0) }-- context 'default variant of product' do- before do- product.variants.where.missing(:option_value_variants).destroy_all- product.update_column(:default_variant_id, variant_0.id)- end-- context 'backorderable' do- before { variant_0.stock_items.first.update(backorderable: true) }-- it 'returns the same Variant as Product#default_variant' do- expect(default_variant).to eq(variant_0)- expect(product.default_variant).to eq(variant_0)- end- end-- context 'in stock' do- before { variant_0.stock_items.first.adjust_count_on_hand(1) }-- it 'returns the same Variant as Product#default_variant' do- expect(default_variant).to eq(variant_0)- expect(product.default_variant).to eq(variant_0)- end- end- end-- it 'returns first Variant of first Option Value of first Option Type' do- expect(default_variant).to eq(variant_1)- end-- context 'with in-stock Variant' do- before do- variant_0.stock_items.first.update(backorderable: false, count_on_hand: 0)- variant_1.stock_items.first.update(backorderable: false, count_on_hand: 0)- variant_2.stock_items.first.adjust_count_on_hand(1)- end-- it 'returns first in-stock Variant' do- expect(default_variant).to eq(variant_2)- end- end-- context 'with backorderable Variant' do- before do- variant_1.stock_items.first.update!(backorderable: false)- variant_2.stock_items.first.update!(backorderable: true)- end-- it 'returns first backorderable Variant' do- expect(default_variant).to eq(variant_2)- end- end-- context 'without Option Types' do- let(:option_types) { [] }-- it { is_expected.to eq(nil) }- end- end-- describe '#options' do- subject(:options) { described_class.new(option_types, variants, product).options }-- before do- product.variants.where.missing(:option_value_variants).destroy_all- product.update_column(:default_variant_id, variant_0.id)- end-- it 'returns serialized options for Option Types and Option Values' do- expect(options).to eq(- [- {- id: option_type_2.reload.id,- name: option_type_2.name,- position: option_type_2.position,- presentation: option_type_2.presentation,- option_values: [- {- id: option_value_2_2.reload.id,- is_default: false,- position: option_value_2_2.position,- presentation: option_value_2_2.presentation,- name: option_value_2_2.name,- variant_id: variant_1.id- },- {- id: option_value_2_1.reload.id,- is_default: false,- position: option_value_2_1.position,- presentation: option_value_2_1.presentation,- name: option_value_2_1.name,- variant_id: variant_2.id- },- {- id: option_value_2_0.reload.id,- is_default: true,- position: option_value_2_0.position,- presentation: option_value_2_0.presentation,- name: option_value_2_0.name,- variant_id: variant_0.id- }- ]- },- {- id: option_type_1.reload.id,- name: option_type_1.name,- position: option_type_1.position,- presentation: option_type_1.presentation,- option_values: [- {- id: option_value_1_2.reload.id,- is_default: false,- position: option_value_1_2.position,- presentation: option_value_1_2.presentation,- name: option_value_1_2.name,- variant_id: variant_2.id- },- {- id: option_value_1_0.reload.id,- is_default: false,- position: option_value_1_0.position,- presentation: option_value_1_0.presentation,- name: option_value_1_0.name,- variant_id: variant_0.id- },- {- id: option_value_1_1.reload.id,- is_default: false,- position: option_value_1_1.position,- presentation: option_value_1_1.presentation,- name: option_value_1_1.name,- variant_id: variant_1.id- }- ]- }- ]- )- end-- context 'without Option Types' do- let(:option_types) { [] }-- it { is_expected.to eq([]) }- end- end-enddiff --git a/spree/emails/app/helpers/spree/mail_helper.rb b/spree/emails/app/helpers/spree/mail_helper.rbindex bff478544a..1a373c7213 100644--- a/spree/emails/app/helpers/spree/mail_helper.rb+++ b/spree/emails/app/helpers/spree/mail_helper.rb@@ -3,21 +3,8 @@ module Spreeinclude Spree::BaseHelperinclude Spree::ImagesHelper- def variant_image_url(variant)- Spree::Deprecation.warn(- 'Spree::MailHelper#variant_image_url is deprecated. Use spree_image_url instead. Will be removed in Spree 6.0.'- )-- image = variant.primary_media- image.present? && image.attached? ? spree_image_url(image, variant: :mini) : image_url('noimage/small.png')- end-def name_for(order)order.name || Spree.t('customer')end-- def store_logo- @store_logo ||= current_store&.mailer_logo || current_store&.logo- endendenddiff --git a/spree/emails/spec/helpers/spree/mail_helper_spec.rb b/spree/emails/spec/helpers/spree/mail_helper_spec.rbindex 115c7ade14..f7ccc98d9d 100644--- a/spree/emails/spec/helpers/spree/mail_helper_spec.rb+++ b/spree/emails/spec/helpers/spree/mail_helper_spec.rb@@ -8,30 +8,6 @@ module Spreeallow(helper).to receive(:current_store) { store }end- describe '#variant_image_url' do- subject { helper.variant_image_url(variant) }-- let(:product) { create(:product) }- let(:variant) { create(:variant, product: product, images: images) }-- context 'with no images' do- let(:images) { [] }-- specify 'returns placeholder path' do- expect(subject).to match Regexp.new('assets/noimage/small-[0-9a-z]*\.png')- end- end-- context 'with images' do- let(:images) { [image] }- let(:image) { create(:image) }-- specify 'returns proper image path' do- expect(subject).to eq spree_image_url(image, variant: :mini)- end- end- end-describe '#name_for' dosubject { helper.name_for(order) }