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 deprecated helpers and presenters scheduled for 5.5 (#14008)
Damian Legawiec632e1d95570d
diff --git a/spree/admin/app/helpers/spree/admin/base_helper.rb b/spree/admin/app/helpers/spree/admin/base_helper.rbindex fd0c8df532..d8b6e5de7a 100644--- a/spree/admin/app/helpers/spree/admin/base_helper.rb+++ b/spree/admin/app/helpers/spree/admin/base_helper.rb@@ -36,14 +36,6 @@ module Spree@settings_area.present?end- def settings_active?- Spree::Deprecation.warn('settings_active? is deprecated and will be removed in Spree 5.5. Please use settings_area? instead')- @settings_active || %w[admin_users audits custom_domains exports invitations oauth_applications- payment_methods refund_reasons reimbursement_types return_authorization_reasons roles- shipping_categories shipping_methods stock_locations store_credit_categories- stores tax_categories tax_rates webhooks webhooks_subscribers zones policies metafield_definitions].include?(controller_name) || settings_area?- end-# @return [Array<String>] the available countries for checkoutdef available_countries_iso@available_countries_iso ||= current_store.countries_available_for_checkout.pluck(:iso)diff --git a/spree/admin/app/helpers/spree/admin/modal_helper.rb b/spree/admin/app/helpers/spree/admin/modal_helper.rbdeleted file mode 100644index a9da471098..0000000000--- a/spree/admin/app/helpers/spree/admin/modal_helper.rb+++ /dev/null@@ -1,31 +0,0 @@-module Spree- module Admin- module ModalHelper- # render a header for the modal- # @param title [String, Proc] the title of the modal- # @return [String]- def modal_header(title)- Spree::Deprecation.warn('Bootstrap modals are deprecated and will be removed in Spree 5.5. Please use native dialogs with `dialog_header` helper.')-- title = capture(&title) if block_given?- content_tag(:div, class: 'modal-header') do- content_tag(:h5, title, class: 'modal-title') + modal_close_button- end.html_safe- end-- # render a close button for the modal- # @return [String]- def modal_close_button- button_tag('', type: 'button', class: 'btn-close', data: { dismiss: 'modal', aria_label: Spree.t(:close) }).html_safe- end-- # render a discard button for the modal- # @return [String]- def modal_discard_button- button_tag(type: 'button', class: 'btn btn-light mr-auto', data: { dismiss: 'modal' }) do- Spree.t('actions.discard')- end.html_safe- end- end- end-enddiff --git a/spree/admin/app/helpers/spree/admin/orders_helper.rb b/spree/admin/app/helpers/spree/admin/orders_helper.rbindex a20241866b..e4d933e1a1 100644--- a/spree/admin/app/helpers/spree/admin/orders_helper.rb+++ b/spree/admin/app/helpers/spree/admin/orders_helper.rb@@ -1,24 +1,6 @@module Spreemodule Adminmodule OrdersHelper- TaxLine = Struct.new(:label, :display_amount, :item, :for_shipment, keyword_init: true) do- def name- Spree::Deprecation.warn("TaxLine is deprecated and will be removed in Spree 5.5")- item_name = item.name- item_name += " #{Spree.t(:shipment).downcase}" if for_shipment-- "#{label} (#{item_name})"- end- end-- def order_summary_tax_lines_additional(order)- Spree::Deprecation.warn("order_summary_tax_lines_additional is deprecated and will be removed in Spree 5.5")- line_item_taxes = order.line_item_adjustments.tax.map { |tax_adjustment| map_to_tax_line(tax_adjustment) }- shipment_taxes = order.shipment_adjustments.tax.map { |tax_adjustment| map_to_tax_line(tax_adjustment, for_shipment: true) }-- line_item_taxes + shipment_taxes- end-def order_payment_state(order, options = {})return if order.payment_state.blank?@@ -140,17 +122,6 @@ module Spree'' => 'Transaction failed because wrong CVV2 number was entered or no CVV2 number was entered'}end-- private-- def map_to_tax_line(tax_adjustment, for_shipment: false)- TaxLine.new(- label: tax_adjustment.label,- display_amount: tax_adjustment.display_amount,- item: tax_adjustment.adjustable,- for_shipment: for_shipment- )- endendendenddiff --git a/spree/admin/app/helpers/spree/admin/turbo_helper.rb b/spree/admin/app/helpers/spree/admin/turbo_helper.rbindex d1ee03faea..719977441d 100644--- a/spree/admin/app/helpers/spree/admin/turbo_helper.rb+++ b/spree/admin/app/helpers/spree/admin/turbo_helper.rb@@ -1,24 +1,6 @@module Spreemodule Adminmodule TurboHelper- def turbo_close_modal(modal_id = nil)- Spree::Deprecation.warn('turbo_close_modal is deprecated and will be removed in Spree 5.5. Use turbo_close_dialog instead.')-- modal_id ||= 'modal'-- turbo_stream.replace :modal_scripts do- turbo_frame_tag :modal_scripts do- javascript_tag do- raw <<~JS- if (document.querySelector('##{modal_id}')) {- window.$("##{modal_id}").modal('hide');- }- JS- end- end- end- end-def turbo_close_dialogturbo_stream.replace 'main-dialog' dorender 'spree/admin/shared/dialog'diff --git a/spree/admin/app/views/spree/admin/shared/_modal.html.erb b/spree/admin/app/views/spree/admin/shared/_modal.html.erbdeleted file mode 100644index b4757387ca..0000000000--- a/spree/admin/app/views/spree/admin/shared/_modal.html.erb+++ /dev/null@@ -1,27 +0,0 @@-<div class="modal fade" id="modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">- <div class="modal-dialog modal-dialog-centered">- <%= turbo_frame_tag :dialog_modal do %>- <div class="modal-content">- <%= modal_header(Spree.t(:loading)) %>- <div class="modal-body text-center min-h-[300px]">- <%= render 'spree/admin/shared/spinner' %>- </div>- </div>- <% end %>- </div>-</div>--<div class="modal fade" id="modal-lg" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">- <div class="modal-dialog modal-dialog-centered modal-lg">- <%= turbo_frame_tag :dialog_modal_lg do %>- <div class="modal-content">- <%= modal_header(Spree.t(:loading)) %>- <div class="modal-body text-center min-h-[300px]">- <%= render 'spree/admin/shared/spinner' %>- </div>- </div>- <% end %>- </div>-</div>--<%= turbo_frame_tag :modal_scripts %>diff --git a/spree/core/app/helpers/spree/base_helper.rb b/spree/core/app/helpers/spree/base_helper.rbindex f75b39dc20..00da331174 100644--- a/spree/core/app/helpers/spree/base_helper.rb+++ b/spree/core/app/helpers/spree/base_helper.rb@@ -22,82 +22,10 @@ module Spreeend.sort_by { |c| c.name.parameterize }end- def spree_resource_path(resource)- Spree::Deprecation.warn('BaseHelper#spree_resource_path is deprecated and will be removed in Spree 5.5')-- last_word = resource.class.name.split('::', 10).last-- spree_class_name_as_path(last_word)- end-- def spree_class_name_as_path(class_name)- Spree::Deprecation.warn('BaseHelper#spree_class_name_as_path is deprecated and will be removed in Spree 5.5')-- class_name.underscore.humanize.parameterize(separator: '_')- end-- def display_price(product_or_variant)- Spree::Deprecation.warn('display_price is deprecated and will be removed in Spree 5.5. Use variant.price_for(context).display_amount instead.')-- product_or_variant.- price_in(current_currency).- display_price_including_vat_for(current_price_options).- to_html- end-- def display_compare_at_price(product_or_variant)- Spree::Deprecation.warn('display_compare_at_price is deprecated and will be removed in Spree 5.5. Use variant.price_for(context).display_compare_at_amount instead.')-- product_or_variant.- price_in(current_currency).- display_compare_at_price_including_vat_for(current_price_options).- to_html- end-- def link_to_tracking(shipment, options = {})- Spree::Deprecation.warn('BaseHelper#link_to_tracking is deprecated and will be removed in Spree 5.5. Please use shipment.tracking_url instead.')-- return unless shipment.tracking && shipment.shipping_method-- options[:target] ||= :blank-- if shipment.tracking_url- link_to(shipment.tracking, shipment.tracking_url, options)- else- content_tag(:span, shipment.tracking)- end- end-def objectinstance_variable_get('@' + controller_name.singularize)end- def pretty_time(time)- return '' if time.blank?-- Spree::Deprecation.warn('BaseHelper#pretty_time is deprecated and will be removed in Spree 5.5. Please add `local_time` gem to your Gemfile and use `local_time(time)` instead')-- [I18n.l(time.to_date, format: :long), time.strftime('%l:%M %p %Z')].join(' ')- end-- def pretty_date(date)- return '' if date.blank?-- Spree::Deprecation.warn('BaseHelper#pretty_date is deprecated and will be removed in Spree 5.5. Please add `local_time` gem to your Gemfile and use `local_date(date)` instead')-- [I18n.l(date.to_date, format: :long)].join(' ')- end-- def seo_url(taxon, options = {})- Spree::Deprecation.warn('BaseHelper#seo_url is deprecated and will be removed in Spree 5.5. Please use spree_storefront_resource_url')- spree.nested_taxons_path(taxon.permalink, options.merge(locale: locale_param))- end-- def frontend_available?- Spree::Deprecation.warn('BaseHelper#frontend_available? is deprecated and will be removed in Spree 5.5')- Spree::Core::Engine.frontend_available?- end-# returns the URL of an object on the storefront# @param resource [Spree::Product, Spree::Taxon, Spree::Page] the resource to get the URL for# @param options [Hash] the options for the URL@@ -160,11 +88,6 @@ module Spreeproduct_or_variant.primary_mediaend- def base_cache_key- Spree::Deprecation.warn('`base_cache_key` is deprecated and will be removed in Spree 5.5. Please use `spree_base_cache_key` instead')- spree_base_cache_key- end-def spree_base_cache_key@spree_base_cache_key ||= [I18n.locale,@@ -178,11 +101,6 @@ module Spree->(record = nil) { [*spree_base_cache_key, record].compact_blank }end- def maximum_quantity- Spree::Deprecation.warn('BaseHelper#maximum_quantity is deprecated and will be removed in Spree 5.5')- Spree::DatabaseTypeUtilities::INTEGER_MAX- end-def payment_method_icon_tag(payment_method, opts = {})return '' unless defined?(inline_svg)diff --git a/spree/core/app/helpers/spree/currency_helper.rb b/spree/core/app/helpers/spree/currency_helper.rbindex e3bf1a4f30..dc820ea65e 100644--- a/spree/core/app/helpers/spree/currency_helper.rb+++ b/spree/core/app/helpers/spree/currency_helper.rb@@ -42,18 +42,6 @@ module Spree[label, currency]end- # Returns the list of supported currencies for the current store.- # @return [Array<Money::Currency>] the list of supported currencies- def preferred_currencies- Spree::Deprecation.warn('preferred_currencies is deprecated and will be removed in Spree 5.5. Use current_store.supported_currencies_list instead.')- @preferred_currencies ||= current_store.supported_currencies_list- end-- def preferred_currencies_select_options- Spree::Deprecation.warn('preferred_currencies_select_options is deprecated and will be removed in Spree 5.5. Use supported_currency_options instead.')- preferred_currencies.map { |currency| currency_presentation(currency) }- end-def currency_money(currency = current_currency)::Money::Currency.find(currency)enddiff --git a/spree/core/app/helpers/spree/products_helper.rb b/spree/core/app/helpers/spree/products_helper.rbindex 327cf8a840..cd9bd6b4a9 100644--- a/spree/core/app/helpers/spree/products_helper.rb+++ b/spree/core/app/helpers/spree/products_helper.rb@@ -120,14 +120,6 @@ module Spreelimit(Spree::Config[:products_per_page])end- def related_products- Spree::Deprecation.warn('ProductsHelper#related_products is deprecated and will be removed in Spree 5.5. Please use ProductsHelper#relations from now on.')-- return [] unless @product.respond_to?(:has_related_products?)-- @related_products ||= relations_by_type('related_products')- end-def product_available_in_currency?!(@product_price.nil? || @product_price.zero?)enddiff --git a/spree/core/app/presenters/spree/product_summary_presenter.rb b/spree/core/app/presenters/spree/product_summary_presenter.rbdeleted file mode 100644index a05d35e1d9..0000000000--- a/spree/core/app/presenters/spree/product_summary_presenter.rb+++ /dev/null@@ -1,27 +0,0 @@-module Spree- class ProductSummaryPresenter- include Rails.application.routes.url_helpers-- def initialize(product)- Spree::Deprecation.warn('Spree::ProductSummaryPresenter is deprecated and will be removed in Spree 5.5.')- @product = product- end-- def call- {- name: @product.name,- images: images- }- end-- private-- def images- @product.images.map do |image|- {- url_product: rails_representation_url(image.url(:product), only_path: true)- }- end- end- end-enddiff --git a/spree/core/app/presenters/spree/variant_presenter.rb b/spree/core/app/presenters/spree/variant_presenter.rbindex 7ccf9cf88f..59e28e0ce5 100644--- a/spree/core/app/presenters/spree/variant_presenter.rb+++ b/spree/core/app/presenters/spree/variant_presenter.rb@@ -16,10 +16,11 @@ module Spreedef call@variants.map do |variant|+ price = variant.price_in(current_currency){- display_price: display_price(variant),- price: variant.price_in(current_currency),- display_compare_at_price: display_compare_at_price(variant),+ 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),diff --git a/spree/core/spec/helpers/base_helper_spec.rb b/spree/core/spec/helpers/base_helper_spec.rbindex 84357bb4d2..404d7c6664 100644--- a/spree/core/spec/helpers/base_helper_spec.rb+++ b/spree/core/spec/helpers/base_helper_spec.rb@@ -40,7 +40,6 @@ describe Spree::BaseHelper, type: :helper dolet!(:product) { create(:product) }before do- allow(helper).to receive(:frontend_available?).and_return(false)allow(helper).to receive(:current_store).and_return(store)allow(helper).to receive(:locale_param)end@@ -100,35 +99,6 @@ describe Spree::BaseHelper, type: :helper doendend- context 'link_to_tracking' do- it 'returns tracking link if available' do- a = link_to_tracking_html(shipping_method: true, tracking: '123', tracking_url: 'http://g.c/?t=123').css('a')-- expect(a.text).to eq '123'- expect(a.attr('href').value).to eq 'http://g.c/?t=123'- end-- it 'returns tracking without link if link unavailable' do- html = link_to_tracking_html(shipping_method: true, tracking: '123', tracking_url: nil)- expect(html.css('span').text).to eq '123'- end-- it 'returns nothing when no shipping method' do- html = link_to_tracking_html(shipping_method: nil, tracking: '123')- expect(html.css('span').text).to eq ''- end-- it 'returns nothing when no tracking' do- html = link_to_tracking_html(tracking: nil)- expect(html.css('span').text).to eq ''- end-- def link_to_tracking_html(options = {})- node = link_to_tracking(double(:shipment, options))- Nokogiri::HTML(node.to_s)- end- end-context 'spree_base_cache_key' dolet(:current_currency) { 'USD' }@@ -175,90 +145,4 @@ describe Spree::BaseHelper, type: :helper doendendend-- # Regression test for #5384-- context 'pretty_time' do- it 'prints in a format' do- time = Time.new(2012, 5, 6, 13, 33)- expect(pretty_time(time)).to eq "May 06, 2012 1:33 PM #{time.zone}"- end-- it 'return empty string when nil is supplied' do- expect(pretty_time(nil)).to eq ''- end- end-- context 'pretty_date' do- it 'prints in a format' do- expect(pretty_date(Time.new(2012, 5, 6, 13, 33))).to eq 'May 06, 2012'- end-- it 'return empty string when nil is supplied' do- expect(pretty_date(nil)).to eq ''- end- end-- describe '#display_price' do- let!(:product) { create(:product, stores: [current_store]) }- let(:current_currency) { 'USD' }- let(:current_price_options) { { tax_zone: current_tax_zone } }-- context 'when there is no current order' do- let (:current_tax_zone) { nil }-- it 'returns the price including default vat' do- expect(display_price(product)).to eq('$19.99')- end-- context 'with a default VAT' do- let(:current_tax_zone) { create(:zone_with_country, default_tax: true) }- let!(:tax_rate) do- create :tax_rate,- included_in_price: true,- zone: current_tax_zone,- tax_category: product.tax_category,- amount: 0.2- end-- it 'returns the price adding the VAT' do- expect(display_price(product)).to eq('$19.99')- end- end- end-- context 'with an order that has a tax zone' do- let(:current_tax_zone) { create(:zone_with_country) }- let(:current_order) { Spree::Order.new }- let(:default_zone) { create(:zone_with_country, default_tax: true) }-- let!(:default_vat) do- create :tax_rate,- included_in_price: true,- zone: default_zone,- tax_category: product.tax_category,- amount: 0.2- end-- context 'that matches no VAT' do- it 'returns the price excluding VAT' do- expect(display_price(product)).to eq('$16.66')- end- end-- context 'that matches a VAT' do- let!(:other_vat) do- create :tax_rate,- included_in_price: true,- zone: current_tax_zone,- tax_category: product.tax_category,- amount: 0.4- end-- it 'returns the price adding the VAT' do- expect(display_price(product)).to eq('$23.32')- end- end- end- endenddiff --git a/spree/core/spec/helpers/currency_helper_spec.rb b/spree/core/spec/helpers/currency_helper_spec.rbindex 496af1f190..359e5f794e 100644--- a/spree/core/spec/helpers/currency_helper_spec.rb+++ b/spree/core/spec/helpers/currency_helper_spec.rb@@ -43,9 +43,4 @@ describe Spree::CurrencyHelper, type: :helper doendend- describe '#preferred_currencies' do- it 'returns array of supported currencies from current store as `Money::Currency`' do- expect(helper.preferred_currencies).to contain_exactly(Money::Currency.find('EUR'), Money::Currency.find('PLN'), Money::Currency.find('GBP'))- end- endenddiff --git a/spree/emails/app/helpers/spree/mail_helper.rb b/spree/emails/app/helpers/spree/mail_helper.rbindex 5839f21630..1ef4ac2646 100644--- a/spree/emails/app/helpers/spree/mail_helper.rb+++ b/spree/emails/app/helpers/spree/mail_helper.rb@@ -15,13 +15,5 @@ module Spreedef store_logo@store_logo ||= current_store&.mailer_logo || current_store&.logoend-- def logo_path- Spree::Deprecation.warn('logo_path is deprecated and will be removed in Spree 5.5. Please use Active Storage URL helpers instead.')-- return main_app.cdn_image_url(store_logo.variant(resize_to_limit: [244, 104])) if store_logo&.variable?-- return main_app.cdn_image_url(store_logo) if store_logo&.image?- endendend