Skip to content

armgit / spree

Public Imported from GitHub
0

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.

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.rb
similarity index 95%
rename from core/app/presenters/spree/filters/options.rb
rename to core/app/presenters/spree/filters/options_presenter.rb
index 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 Spree
module Filters
- class Options
+ class OptionsPresenter
FilterableOptionType = Struct.new(:option_type, :option_values, keyword_init: true) do
delegate_missing_to :option_type
end
diff --git a/core/app/presenters/spree/filters/price.rb b/core/app/presenters/spree/filters/price_presenter.rb
similarity index 93%
rename from core/app/presenters/spree/filters/price.rb
rename to core/app/presenters/spree/filters/price_presenter.rb
index 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 Spree
module Filters
- class Price
+ class PricePresenter
def initialize(amount:, currency:)
@amount = amount.to_i
@currency = currency
diff --git a/core/app/presenters/spree/filters/price_range.rb b/core/app/presenters/spree/filters/price_range_presenter.rb
similarity index 70%
rename from core/app/presenters/spree/filters/price_range.rb
rename to core/app/presenters/spree/filters/price_range_presenter.rb
index 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 Spree
module Filters
- class PriceRange
+ class PriceRangePresenter
def 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)
)
end
diff --git a/core/app/presenters/spree/filters/properties.rb b/core/app/presenters/spree/filters/properties_presenter.rb
similarity index 77%
rename from core/app/presenters/spree/filters/properties.rb
rename to core/app/presenters/spree/filters/properties_presenter.rb
index 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 Spree
module Filters
- class Properties
+ class PropertiesPresenter
def initialize(product_properties_scope:)
@product_properties = product_properties_scope.includes(:property)
end
def to_a
grouped_options.map do |property, product_properties|
- Property.new(property: property, product_properties: product_properties)
+ PropertyPresenter.new(property: property, product_properties: product_properties)
end
end
diff --git a/core/app/presenters/spree/filters/property.rb b/core/app/presenters/spree/filters/property_presenter.rb
similarity index 93%
rename from core/app/presenters/spree/filters/property.rb
rename to core/app/presenters/spree/filters/property_presenter.rb
index 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 Spree
module Filters
- class Property
+ class PropertyPresenter
def initialize(property:, product_properties:)
@property = property
@product_properties = product_properties
diff --git a/core/app/presenters/spree/filters/quantified_price_range.rb b/core/app/presenters/spree/filters/quantified_price_range_presenter.rb
similarity index 95%
rename from core/app/presenters/spree/filters/quantified_price_range.rb
rename to core/app/presenters/spree/filters/quantified_price_range_presenter.rb
index 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 Spree
module Filters
- class QuantifiedPriceRange
+ class QuantifiedPriceRangePresenter
ALLOWED_QUANTIFIERS = [
:less_than,
:more_than
diff --git a/core/spec/presenters/spree/filters/options_spec.rb b/core/spec/presenters/spree/filters/options_presenter_spec.rb
similarity index 96%
rename from core/spec/presenters/spree/filters/options_spec.rb
rename to core/spec/presenters/spree/filters/options_presenter_spec.rb
index 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 do
let(: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.rb
similarity index 86%
rename from core/spec/presenters/spree/filters/price_spec.rb
rename to core/spec/presenters/spree/filters/price_presenter_spec.rb
index 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 do
let(:price) { described_class.new(amount: 50, currency: 'USD') }
describe '#to_i' do
diff --git a/core/spec/presenters/spree/filters/price_range_spec.rb b/core/spec/presenters/spree/filters/price_range_presenter_spec.rb
similarity index 79%
rename from core/spec/presenters/spree/filters/price_range_spec.rb
rename to core/spec/presenters/spree/filters/price_range_presenter_spec.rb
index 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 Spree
module Filters
- RSpec.describe PriceRange do
+ RSpec.describe PriceRangePresenter do
let(: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' do
subject(: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.rb
similarity index 96%
rename from core/spec/presenters/spree/filters/properties_spec.rb
rename to core/spec/presenters/spree/filters/properties_presenter_spec.rb
index 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 do
let(: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.rb
similarity index 94%
rename from core/spec/presenters/spree/filters/property_spec.rb
rename to core/spec/presenters/spree/filters/property_presenter_spec.rb
index 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 do
let(: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.rb
similarity index 89%
rename from core/spec/presenters/spree/filters/quantified_price_range_spec.rb
rename to core/spec/presenters/spree/filters/quantified_price_range_presenter_spec.rb
index 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 Spree
module Filters
- RSpec.describe QuantifiedPriceRange do
+ RSpec.describe QuantifiedPriceRangePresenter do
let(: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' do
let(:quantifier) { :less_than }
diff --git a/frontend/app/helpers/spree/frontend_helper.rb b/frontend/app/helpers/spree/frontend_helper.rb
index 8288e6661a..1830fa63da 100644
--- a/frontend/app/helpers/spree/frontend_helper.rb
+++ b/frontend/app/helpers/spree/frontend_helper.rb
@@ -315,7 +315,7 @@ module Spree
def available_option_types
@available_option_types ||= Rails.cache.fetch("available-option-types/#{available_option_types_cache_key}") do
option_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_a
end
end
@@ -329,7 +329,7 @@ module Spree
def available_properties
@available_properties ||= Rails.cache.fetch("available-properties/#{available_properties_cache_key}") do
product_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_a
end
end
diff --git a/frontend/app/helpers/spree/products_filters_helper.rb b/frontend/app/helpers/spree/products_filters_helper.rb
index 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 Spree
end
def 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)
end
def 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)
)
end
def 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)
end
def 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)
end
def filters_price(amount)
- Filters::Price.new(amount: amount, currency: current_currency)
+ Filters::PricePresenter.new(amount: amount, currency: current_currency)
end
end
end