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
Add Presenter suffix for Filters Presenters
Damian Legawiec1bf152720527
diff --git a/core/app/presenters/spree/filters/options.rb b/core/app/presenters/spree/filters/options_presenter.rbsimilarity index 95%rename from core/app/presenters/spree/filters/options.rbrename to core/app/presenters/spree/filters/options_presenter.rbindex 9f3bd376a2..682cac5059 100644--- a/core/app/presenters/spree/filters/options.rb+++ b/core/app/presenters/spree/filters/options_presenter.rb@@ -1,6 +1,6 @@module Spreemodule Filters- class Options+ class OptionsPresenterFilterableOptionType = Struct.new(:option_type, :option_values, keyword_init: true) dodelegate_missing_to :option_typeenddiff --git a/core/app/presenters/spree/filters/price.rb b/core/app/presenters/spree/filters/price_presenter.rbsimilarity index 93%rename from core/app/presenters/spree/filters/price.rbrename to core/app/presenters/spree/filters/price_presenter.rbindex b3fd636258..7f32463f0b 100644--- a/core/app/presenters/spree/filters/price.rb+++ b/core/app/presenters/spree/filters/price_presenter.rb@@ -1,6 +1,6 @@module Spreemodule Filters- class Price+ class PricePresenterdef initialize(amount:, currency:)@amount = amount.to_i@currency = currencydiff --git a/core/app/presenters/spree/filters/price_range.rb b/core/app/presenters/spree/filters/price_range_presenter.rbsimilarity index 70%rename from core/app/presenters/spree/filters/price_range.rbrename to core/app/presenters/spree/filters/price_range_presenter.rbindex 64a2f2270d..65f7300085 100644--- a/core/app/presenters/spree/filters/price_range.rb+++ b/core/app/presenters/spree/filters/price_range_presenter.rb@@ -1,12 +1,12 @@module Spreemodule Filters- class PriceRange+ class PriceRangePresenterdef self.from_param(param, currency:)prices = param.split('-')new(- min_price: Price.new(amount: prices.first, currency: currency),- max_price: Price.new(amount: prices.last, currency: currency)+ min_price: PricePresenter.new(amount: prices.first, currency: currency),+ max_price: PricePresenter.new(amount: prices.last, currency: currency))enddiff --git a/core/app/presenters/spree/filters/properties.rb b/core/app/presenters/spree/filters/properties_presenter.rbsimilarity index 77%rename from core/app/presenters/spree/filters/properties.rbrename to core/app/presenters/spree/filters/properties_presenter.rbindex f2157677b2..ee4c951cd1 100644--- a/core/app/presenters/spree/filters/properties.rb+++ b/core/app/presenters/spree/filters/properties_presenter.rb@@ -1,13 +1,13 @@module Spreemodule Filters- class Properties+ class PropertiesPresenterdef initialize(product_properties_scope:)@product_properties = product_properties_scope.includes(:property)enddef to_agrouped_options.map do |property, product_properties|- Property.new(property: property, product_properties: product_properties)+ PropertyPresenter.new(property: property, product_properties: product_properties)endenddiff --git a/core/app/presenters/spree/filters/property.rb b/core/app/presenters/spree/filters/property_presenter.rbsimilarity index 93%rename from core/app/presenters/spree/filters/property.rbrename to core/app/presenters/spree/filters/property_presenter.rbindex 2565a4524b..47bd13937a 100644--- a/core/app/presenters/spree/filters/property.rb+++ b/core/app/presenters/spree/filters/property_presenter.rb@@ -1,6 +1,6 @@module Spreemodule Filters- class Property+ class PropertyPresenterdef initialize(property:, product_properties:)@property = property@product_properties = product_propertiesdiff --git a/core/app/presenters/spree/filters/quantified_price_range.rb b/core/app/presenters/spree/filters/quantified_price_range_presenter.rbsimilarity index 95%rename from core/app/presenters/spree/filters/quantified_price_range.rbrename to core/app/presenters/spree/filters/quantified_price_range_presenter.rbindex ac425a9be1..6ae090828d 100644--- a/core/app/presenters/spree/filters/quantified_price_range.rb+++ b/core/app/presenters/spree/filters/quantified_price_range_presenter.rb@@ -1,6 +1,6 @@module Spreemodule Filters- class QuantifiedPriceRange+ class QuantifiedPriceRangePresenterALLOWED_QUANTIFIERS = [:less_than,:more_thandiff --git a/core/spec/presenters/spree/filters/options_spec.rb b/core/spec/presenters/spree/filters/options_presenter_spec.rbsimilarity index 96%rename from core/spec/presenters/spree/filters/options_spec.rbrename to core/spec/presenters/spree/filters/options_presenter_spec.rbindex ac14828f66..c94f84b0da 100644--- a/core/spec/presenters/spree/filters/options_spec.rb+++ b/core/spec/presenters/spree/filters/options_presenter_spec.rb@@ -1,7 +1,7 @@require 'spec_helper'module Spree- RSpec.describe Filters::Options do+ RSpec.describe Filters::OptionsPresenter dolet(:options) { described_class.new(option_values_scope: OptionValue.where(id: option_values)) }let(:size) { create(:option_type, :size) }diff --git a/core/spec/presenters/spree/filters/price_spec.rb b/core/spec/presenters/spree/filters/price_presenter_spec.rbsimilarity index 86%rename from core/spec/presenters/spree/filters/price_spec.rbrename to core/spec/presenters/spree/filters/price_presenter_spec.rbindex a604a16d10..f545be8b74 100644--- a/core/spec/presenters/spree/filters/price_spec.rb+++ b/core/spec/presenters/spree/filters/price_presenter_spec.rb@@ -1,6 +1,6 @@require 'spec_helper'-RSpec.describe Spree::Filters::Price do+RSpec.describe Spree::Filters::PricePresenter dolet(:price) { described_class.new(amount: 50, currency: 'USD') }describe '#to_i' dodiff --git a/core/spec/presenters/spree/filters/price_range_spec.rb b/core/spec/presenters/spree/filters/price_range_presenter_spec.rbsimilarity index 79%rename from core/spec/presenters/spree/filters/price_range_spec.rbrename to core/spec/presenters/spree/filters/price_range_presenter_spec.rbindex 506ca28a21..66765ce6a6 100644--- a/core/spec/presenters/spree/filters/price_range_spec.rb+++ b/core/spec/presenters/spree/filters/price_range_presenter_spec.rb@@ -2,11 +2,11 @@ require 'spec_helper'module Spreemodule Filters- RSpec.describe PriceRange do+ RSpec.describe PriceRangePresenter dolet(:price_range) { described_class.new(min_price: min_price, max_price: max_price) }- let(:min_price) { Price.new(amount: 50, currency: 'USD') }- let(:max_price) { Price.new(amount: 100, currency: 'USD') }+ let(:min_price) { PricePresenter.new(amount: 50, currency: 'USD') }+ let(:max_price) { PricePresenter.new(amount: 100, currency: 'USD') }describe '.from_param' dosubject(:price_range) { described_class.from_param('50-100', currency: 'USD') }diff --git a/core/spec/presenters/spree/filters/properties_spec.rb b/core/spec/presenters/spree/filters/properties_presenter_spec.rbsimilarity index 96%rename from core/spec/presenters/spree/filters/properties_spec.rbrename to core/spec/presenters/spree/filters/properties_presenter_spec.rbindex d3c07a3cdd..c95230ae0c 100644--- a/core/spec/presenters/spree/filters/properties_spec.rb+++ b/core/spec/presenters/spree/filters/properties_presenter_spec.rb@@ -1,7 +1,7 @@require 'spec_helper'module Spree- RSpec.describe Filters::Properties do+ RSpec.describe Filters::PropertiesPresenter dolet(:properties) { described_class.new(product_properties_scope: ProductProperty.where(id: product_properties)) }let(:product_properties) { [alpha_brand, beta_brand, wilson_manufacturer] }diff --git a/core/spec/presenters/spree/filters/property_spec.rb b/core/spec/presenters/spree/filters/property_presenter_spec.rbsimilarity index 94%rename from core/spec/presenters/spree/filters/property_spec.rbrename to core/spec/presenters/spree/filters/property_presenter_spec.rbindex 6c5746196f..837ff9a371 100644--- a/core/spec/presenters/spree/filters/property_spec.rb+++ b/core/spec/presenters/spree/filters/property_presenter_spec.rb@@ -1,7 +1,7 @@require 'spec_helper'module Spree- RSpec.describe Filters::Property do+ RSpec.describe Filters::PropertyPresenter dolet(:property) { described_class.new(property: brand, product_properties: product_properties) }let(:product_properties) { [alpha_brand, beta_brand] }diff --git a/core/spec/presenters/spree/filters/quantified_price_range_spec.rb b/core/spec/presenters/spree/filters/quantified_price_range_presenter_spec.rbsimilarity index 89%rename from core/spec/presenters/spree/filters/quantified_price_range_spec.rbrename to core/spec/presenters/spree/filters/quantified_price_range_presenter_spec.rbindex ade24cb23e..2e8bc0fbac 100644--- a/core/spec/presenters/spree/filters/quantified_price_range_spec.rb+++ b/core/spec/presenters/spree/filters/quantified_price_range_presenter_spec.rb@@ -2,9 +2,9 @@ require 'spec_helper'module Spreemodule Filters- RSpec.describe QuantifiedPriceRange do+ RSpec.describe QuantifiedPriceRangePresenter dolet(:price_range) { described_class.new(price: price, quantifier: quantifier) }- let(:price) { Price.new(amount: 50, currency: 'USD') }+ let(:price) { PricePresenter.new(amount: 50, currency: 'USD') }context 'when the quantifier is less_than' dolet(:quantifier) { :less_than }diff --git a/frontend/app/helpers/spree/frontend_helper.rb b/frontend/app/helpers/spree/frontend_helper.rbindex 8288e6661a..1830fa63da 100644--- a/frontend/app/helpers/spree/frontend_helper.rb+++ b/frontend/app/helpers/spree/frontend_helper.rb@@ -315,7 +315,7 @@ module Spreedef available_option_types@available_option_types ||= Rails.cache.fetch("available-option-types/#{available_option_types_cache_key}") dooption_values = OptionValues::FindAvailable.new(products_scope: products_for_filters).execute- Filters::Options.new(option_values_scope: option_values).to_a+ Filters::OptionsPresenter.new(option_values_scope: option_values).to_aendend@@ -329,7 +329,7 @@ module Spreedef available_properties@available_properties ||= Rails.cache.fetch("available-properties/#{available_properties_cache_key}") doproduct_properties = ProductProperties::FindAvailable.new(products_scope: products_for_filters).execute- Filters::Properties.new(product_properties_scope: product_properties).to_a+ Filters::PropertiesPresenter.new(product_properties_scope: product_properties).to_aendenddiff --git a/frontend/app/helpers/spree/products_filters_helper.rb b/frontend/app/helpers/spree/products_filters_helper.rbindex 1ef51f181e..f789e98505 100644--- a/frontend/app/helpers/spree/products_filters_helper.rb+++ b/frontend/app/helpers/spree/products_filters_helper.rb@@ -143,26 +143,26 @@ module Spreeenddef filters_price_range_from_param- Filters::PriceRange.from_param(params[:price].to_s, currency: current_currency)+ Filters::PriceRangePresenter.from_param(params[:price].to_s, currency: current_currency)enddef filters_price_range(min_amount, max_amount)- Filters::PriceRange.new(+ Filters::PriceRangePresenter.new(min_price: filters_price(min_amount),max_price: filters_price(max_amount))enddef filters_less_than_price_range(amount)- Filters::QuantifiedPriceRange.new(price: filters_price(amount), quantifier: :less_than)+ Filters::QuantifiedPriceRangePresenter.new(price: filters_price(amount), quantifier: :less_than)enddef filters_more_than_price_range(amount)- Filters::QuantifiedPriceRange.new(price: filters_price(amount), quantifier: :more_than)+ Filters::QuantifiedPriceRangePresenter.new(price: filters_price(amount), quantifier: :more_than)enddef filters_price(amount)- Filters::Price.new(amount: amount, currency: current_currency)+ Filters::PricePresenter.new(amount: amount, currency: current_currency)endendend