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
Removed unused classes with no callers (#14794)
Damian Legawieccbabb5fd7c00
diff --git a/docs/plans/6.0-analytics-semantic-layer.md b/docs/plans/6.0-analytics-semantic-layer.mdindex f5080e2864..a7317aa82c 100644--- a/docs/plans/6.0-analytics-semantic-layer.md+++ b/docs/plans/6.0-analytics-semantic-layer.md@@ -26,7 +26,7 @@ The 5.6 dashboard work (branch `claude/react-dashboard-home-reporting-71weaz`) i### 1. Developers extend vocabulary, not reports-The extension point is a registry of metrics and dimensions, mirroring `Spree.order_routing.rules` / `Spree::Dependencies`. **Namespace: `Spree.reporting` / `Spree::Reporting`** — `Spree.analytics` / `Spree::Analytics` is already taken by the storefront event-tracking config (`spree/core/lib/spree/analytics.rb`, `AnalyticsConfig`: tracked events + handlers) and stays untouched; "reporting" also matches the merchant-facing Reports nav this plan powers.+The extension point is a registry of metrics and dimensions, mirroring `Spree.order_routing.rules` / `Spree::Dependencies`. **Namespace: `Spree.reporting` / `Spree::Reporting`** — `Spree.analytics` / `Spree::Analytics` was the storefront event-tracking config (tracked events + handlers), removed in 6.0 as unused; "reporting" also matches the merchant-facing Reports nav this plan powers.```rubySpree.reporting.metric :net_sales,diff --git a/spree/core/app/models/concerns/spree/has_image_alt_text.rb b/spree/core/app/models/concerns/spree/has_image_alt_text.rbdeleted file mode 100644index aea16ff020..0000000000--- a/spree/core/app/models/concerns/spree/has_image_alt_text.rb+++ /dev/null@@ -1,18 +0,0 @@-module Spree- module HasImageAltText- extend ActiveSupport::Concern-- # @return [String] Alt text resolved from preference, asset filename, or i18n fallback.- def image_alt- return preferred_image_alt if respond_to?(:preferred_image_alt) && preferred_image_alt.present?-- if respond_to?(:asset) && asset&.filename.present?- filename = asset.filename.to_s- base = File.basename(filename, File.extname(filename))- return base.tr('-_.', ' ').squeeze(' ').strip- end-- Spree.t(:image, default: 'Image')- end- end-end\ No newline at end of filediff --git a/spree/core/app/models/spree/base_analytics_event_handler.rb b/spree/core/app/models/spree/base_analytics_event_handler.rbdeleted file mode 100644index 91e998c8f9..0000000000--- a/spree/core/app/models/spree/base_analytics_event_handler.rb+++ /dev/null@@ -1,54 +0,0 @@-module Spree- class BaseAnalyticsEventHandler- # Initializes the event handler- # @param client [Object] The client object- # @param opts [Hash] The options- # @option opts [User] :user- # @option opts [String] :session_id- # @option opts [Spree::Store] :store- def initialize(opts = {})- @user = opts[:user]- @session = opts[:session]- @request = opts[:request]- @store = opts[:store]- @visitor_id = opts[:visitor_id]- end-- attr_reader :user, :session, :request, :store, :visitor_id-- # Returns the client- # @return [Object] The client object- def client- raise NotImplementedError, 'Subclasses must implement the client method'- end-- # Handles the event- # @param event_name [String] eg. 'order_completed'- # @param properties [Hash] eg. { product: Spree::Product, taxon: Spree::Category, query: String }- # rubocop:disable Lint/UnusedMethodArgument- def handle_event(event_name, properties = {})- raise NotImplementedError, 'Subclasses must implement the handle method'- end- # rubocop:enable Lint/UnusedMethodArgument-- # Returns the human name for the event- # @param event_name [String] eg. 'order_completed'- # @return [String] eg. 'Order Completed'- def event_human_name(event_name)- Analytics.events[event_name.to_sym]- end-- protected-- # Returns the identity hash for the event- # @return [Hash] eg. { user_id: 1, session_id: '123' }- def identity_hash- {- user_id: user&.id,- # session.id is a custom class (not a string), which has overridden the `to_json` method, we have to convert it to a string first so it does not send garbage to the analytics service- session_id: session&.id&.to_s,- visitor_id: visitor_id- }- end- end-enddiff --git a/spree/core/app/models/spree/invitations/store.rb b/spree/core/app/models/spree/invitations/store.rbdeleted file mode 100644index cc6d75720e..0000000000--- a/spree/core/app/models/spree/invitations/store.rb+++ /dev/null@@ -1,6 +0,0 @@-module Spree- module Invitations- class Store < Base- end- end-enddiff --git a/spree/core/app/models/spree/promotion_handler/promotion_duplicator.rb b/spree/core/app/models/spree/promotion_handler/promotion_duplicator.rbdeleted file mode 100644index 0d92b9253f..0000000000--- a/spree/core/app/models/spree/promotion_handler/promotion_duplicator.rb+++ /dev/null@@ -1,60 +0,0 @@-module Spree- module PromotionHandler- class PromotionDuplicator- def initialize(promotion, random_string: nil)- @promotion = promotion.reload- @random_string = random_string || generate_random_string(4)- end-- def duplicate- @new_promotion = @promotion.dup- @new_promotion.path = "#{@promotion.path}_#{@random_string}"- @new_promotion.name = "New #{@promotion.name}"- @new_promotion.code = "#{@promotion.code}_#{@random_string}"- @new_promotion.store = @promotion.store-- ActiveRecord::Base.transaction do- @new_promotion.save- copy_rules- copy_actions- end-- @new_promotion.reload- end-- private-- def copy_rules- @promotion.promotion_rules.each do |rule|- new_rule = rule.dup- new_rule.promotion = @new_promotion- new_rule.save!-- new_rule.users = rule.users if rule.try(:users)- new_rule.categories = rule.categories if rule.try(:categories)- new_rule.products = rule.products if rule.try(:products)- end- end-- def generate_random_string(number)- charset = Array('A'..'Z') + Array('a'..'z')- Array.new(number) { charset.sample }.join- end-- def copy_actions- @promotion.promotion_actions.each do |action|- new_action = action.dup- new_action.promotion = @new_promotion- new_action.calculator = action.calculator.dup if action.try(:calculator)- new_action.save!-- next unless action.try(:promotion_action_line_items)-- action.promotion_action_line_items.each do |item|- new_action.promotion_action_line_items << item.dup- end- end- end- end- end-enddiff --git a/spree/core/app/models/spree/stock/differentiator.rb b/spree/core/app/models/spree/stock/differentiator.rbdeleted file mode 100644index a1d2a37632..0000000000--- a/spree/core/app/models/spree/stock/differentiator.rb+++ /dev/null@@ -1,45 +0,0 @@-module Spree- module Stock- class Differentiator- attr_reader :missing, :packed, :required, :packages, :order-- def initialize(order, packages)- @order = order- @packages = packages- build_packed- build_required- build_missing- end-- def missing?- missing.values.any? { |v| v > 0 }- end-- private-- def build_missing- @missing = Hash.new(0)- required.keys.each do |variant|- missing = required[variant] - packed[variant]- @missing[variant] = missing if missing > 0- end- end-- def build_packed- @packed = Hash.new(0)- packages.each do |package|- package.contents.each do |content_item|- @packed[content_item.variant] += content_item.quantity- end- end- end-- def build_required- @required = Hash.new(0)- order.line_items.each do |line_item|- @required[line_item.variant] = line_item.quantity- end- end- end- end-enddiff --git a/spree/core/app/presenters/spree/filters/options_presenter.rb b/spree/core/app/presenters/spree/filters/options_presenter.rbdeleted file mode 100644index 0283a61803..0000000000--- a/spree/core/app/presenters/spree/filters/options_presenter.rb+++ /dev/null@@ -1,47 +0,0 @@-module Spree- module Filters- class OptionsPresenter- FilterableOptionType = Struct.new(:option_type, :option_values, keyword_init: true) do- delegate_missing_to :option_type-- def to_h- {- id: option_type.id,- name: option_type.name,- presentation: option_type.label,- option_values: option_values.map { |e| option_value_hash(e) }- }- end-- private-- def option_value_hash(option_value)- {- id: option_value.id,- name: option_value.name,- presentation: option_value.label,- position: option_value.position- }- end- end-- def initialize(option_values_scope:)- @option_values = option_values_scope.includes(:option_type)- end-- def to_a- grouped_options.map do |option_type, option_values|- FilterableOptionType.new(option_type: option_type, option_values: option_values)- end- end-- private-- attr_reader :option_values-- def grouped_options- option_values.group_by(&:option_type)- end- end- end-enddiff --git a/spree/core/app/services/spree/country_to_timezone.rb b/spree/core/app/services/spree/country_to_timezone.rbdeleted file mode 100644index 285e70755b..0000000000--- a/spree/core/app/services/spree/country_to_timezone.rb+++ /dev/null@@ -1,273 +0,0 @@-module Spree- class CountryToTimezone- prepend Spree::ServiceModule::Base-- CAPITAL_CITIES = {- "AD"=>"Andorra la Vella",- "AE"=>"Abu Dhabi",- "AF"=>"Kabul",- "AG"=>"Saint John's",- "AI"=>"The Valley",- "AL"=>"Tirana",- "AM"=>"Yerevan",- "AN"=>"Willemstad",- "AO"=>"Luanda",- "AQ"=>nil,- "AR"=>"Buenos Aires",- "AS"=>"Pago Pago",- "AT"=>"Vienna",- "AU"=>"Canberra",- "AW"=>"Oranjestad",- "AZ"=>"Baku",- "BA"=>"Sarajevo",- "BB"=>"Bridgetown",- "BD"=>"Dhaka",- "BE"=>"Brussels",- "BF"=>"Ouagadougou",- "BG"=>"Sofia",- "BH"=>"Manama",- "BI"=>"Bujumbura",- "BJ"=>"Porto-Novo",- "BL"=>"Gustavia",- "BM"=>"Hamilton",- "BN"=>"Bandar Seri Begawan",- "BO"=>"La Paz",- "BR"=>"Brasilia",- "BS"=>"Nassau",- "BT"=>"Thimphu",- "BV"=>nil,- "BW"=>"Gaborone",- "BY"=>"Minsk",- "BZ"=>"Belmopan",- "CA"=>"Ottawa",- "CC"=>"West Island",- "CD"=>"Kinshasa",- "CF"=>"Bangui",- "CG"=>"Brazzaville",- "CH"=>"Bern",- "CI"=>"Yamoussoukro",- "CK"=>"Avarua",- "CL"=>"Santiago",- "CM"=>"Yaounde",- "CN"=>"Beijing",- "CO"=>"Bogota",- "CR"=>"San Jose",- "CU"=>"Havana",- "CV"=>"Praia",- "CX"=>"The Settlement",- "CY"=>"Nicosia",- "CZ"=>"Prague",- "DE"=>"Berlin",- "DJ"=>"Djibouti",- "DK"=>"Copenhagen",- "DM"=>"Roseau",- "DO"=>"Santo Domingo",- "DZ"=>"Algiers",- "EC"=>"Quito",- "EE"=>"Tallinn",- "EG"=>"Cairo",- "EH"=>nil,- "ER"=>"Asmara",- "ES"=>"Madrid",- "ET"=>"Addis Ababa",- "FI"=>"Helsinki",- "FJ"=>"Suva",- "FK"=>"Stanley",- "FM"=>"Palikir",- "FO"=>"Torshavn",- "FR"=>"Paris",- "GA"=>"Libreville",- "GB"=>"London",- "GD"=>"Saint George's",- "GE"=>"T'bilisi",- "GG"=>"Saint Peter Port",- "GH"=>"Accra",- "GI"=>"Gibraltar",- "GL"=>"Nuuk",- "GM"=>"Banjul",- "GN"=>"Conakry",- "GQ"=>"Malabo",- "GR"=>"Athens",- "GT"=>"Guatemala City",- "GU"=>"Hagatna",- "GW"=>"Bissau",- "GY"=>"Georgetown",- "HK"=>"Hong Kong",- "HM"=>nil,- "HN"=>"Tegucigalpa",- "HR"=>"Zagreb",- "HT"=>"Port-au-Prince",- "HU"=>"Budapest",- "ID"=>"Jakarta",- "IE"=>"Dublin",- "IL"=>"Jerusalem",- "IM"=>"Douglas",- "IN"=>"New Delhi",- "IO"=>nil,- "IQ"=>"Baghdad",- "IR"=>"Tehran",- "IS"=>"Reykjavik",- "IT"=>"Rome",- "JE"=>"Saint Helier",- "JM"=>"Kingston",- "JO"=>"Amman",- "JP"=>"Tokyo",- "KE"=>"Nairobi",- "KG"=>"Bishkek",- "KH"=>"Phnom Penh",- "KI"=>"Tarawa",- "KM"=>"Moroni",- "KN"=>"Basseterre",- "KP"=>"Pyongyang",- "KR"=>"Seoul",- "KW"=>"Kuwait City",- "KY"=>"George Town",- "KZ"=>"Astana",- "LA"=>"Vientiane",- "LB"=>"Beirut",- "LC"=>"Castries",- "LI"=>"Vaduz",- "LK"=>"Colombo",- "LR"=>"Monrovia",- "LS"=>"Maseru",- "LT"=>"Vilnius",- "LU"=>"Luxembourg",- "LV"=>"Riga",- "LY"=>"Tripoli",- "MA"=>"Rabat",- "MC"=>"Monaco",- "MD"=>"Chisinau",- "ME"=>"Podgorica",- "MF"=>"Marigot",- "MG"=>"Antananarivo",- "MH"=>"Majuro",- "MK"=>"Skopje",- "ML"=>"Bamako",- "MM"=>"Rangoon",- "MN"=>"Ulaanbaatar",- "MO"=>nil,- "MP"=>"Saipan",- "MR"=>"Nouakchott",- "MS"=>"Plymouth",- "MT"=>"Valletta",- "MU"=>"Port Louis",- "MV"=>"Male",- "MW"=>"Lilongwe",- "MX"=>"Mexico City",- "MY"=>"Kuala Lumpur",- "MZ"=>"Maputo",- "NA"=>"Windhoek",- "NC"=>"Noumea",- "NE"=>"Niamey",- "NF"=>"Kingston",- "NG"=>"Abuja",- "NI"=>"Managua",- "NL"=>"Amsterdam",- "NO"=>"Oslo",- "NP"=>"Kathmandu",- "NR"=>nil,- "NU"=>"Alofi",- "NZ"=>"Wellington",- "OM"=>"Muscat",- "PA"=>"Panama City",- "PE"=>"Lima",- "PF"=>"Papeete",- "PG"=>"Port Moresby",- "PH"=>"Manila",- "PK"=>"Islamabad",- "PL"=>"Warsaw",- "PM"=>"Saint-Pierre",- "PN"=>"Adamstown",- "PR"=>"San Juan",- "PS"=>nil,- "PT"=>"Lisbon",- "PW"=>"Melekeok",- "PY"=>"Asuncion",- "QA"=>"Doha",- "RO"=>"Bucharest",- "RS"=>"Belgrade",- "RU"=>"Moscow",- "RW"=>"Kigali",- "SA"=>"Riyadh",- "SB"=>"Honiara",- "SC"=>"Victoria",- "SD"=>"Khartoum",- "SE"=>"Stockholm",- "SG"=>"Singapore",- "SH"=>"Jamestown",- "SI"=>"Ljubljana",- "SJ"=>"Longyearbyen",- "SK"=>"Bratislava",- "SL"=>"Freetown",- "SM"=>"San Marino",- "SN"=>"Dakar",- "SO"=>"Mogadishu",- "SR"=>"Paramaribo",- "ST"=>"Sao Tome",- "SV"=>"San Salvador",- "SY"=>"Damascus",- "SZ"=>"Mbabane",- "TC"=>"Grand Turk",- "TD"=>"N'Djamena",- "TF"=>nil,- "TG"=>"Lome",- "TH"=>"Bangkok",- "TJ"=>"Dushanbe",- "TK"=>nil,- "TL"=>"Dili",- "TM"=>"Ashgabat",- "TN"=>"Tunis",- "TO"=>"Nuku'alofa",- "TR"=>"Ankara",- "TT"=>"Port-of-Spain",- "TV"=>"Funafuti",- "TW"=>"Taipei",- "TZ"=>"Dar es Salaam",- "UA"=>"Kyiv",- "UG"=>"Kampala",- "US"=>"Washington, DC",- "UY"=>"Montevideo",- "UZ"=>"Tashkent",- "VA"=>"Vatican City",- "VC"=>"Kingstown",- "VE"=>"Caracas",- "VG"=>"Road Town",- "VI"=>"Charlotte Amalie",- "VN"=>"Hanoi",- "VU"=>"Port-Vila",- "WF"=>"Mata-Utu",- "WS"=>"Apia",- "YE"=>"Sanaa",- "YT"=>"Mamoudzou",- "ZA"=>"Pretoria",- "ZM"=>"Lusaka",- "ZW"=>"Harare"}.freeze-- def call(code:)- case code- when 'US', 'CA'- success('Central Time (US & Canada)')- else- success(from_timezone_helper(code))- end- end-- private-- def from_timezone_helper(code)- timezones = ActiveSupport::TimeZone.country_zones(code)- return 'Central Time (US & Canada)' if timezones.empty?-- timezones.first.name if timezones.size == 1-- # If there is more than one timezone for the country, then we'll use the capital city- # to determine the timezone- # eg GB has London and Edinburgh- capital_city = CAPITAL_CITIES[code]- capital_city_time_zone = timezones.find{ |tz| tz.name.match(capital_city) }- return capital_city_time_zone.name if capital_city_time_zone.present?-- timezones.first.name- end- end-enddiff --git a/spree/core/app/validators/spree/url_validator.rb b/spree/core/app/validators/spree/url_validator.rbdeleted file mode 100644index 63bc79bc28..0000000000--- a/spree/core/app/validators/spree/url_validator.rb+++ /dev/null@@ -1,23 +0,0 @@-module Spree- class UrlValidator < ActiveModel::EachValidator- def validate_each(record, attribute, value)- unless url_valid?(value)- record.errors.add(attribute, (options[:message] || ERROR_MESSAGE))- end- end-- private-- ERROR_MESSAGE = 'must be a valid URL'- private_constant :ERROR_MESSAGE-- def url_valid?(url)- uri = begin- URI.parse(url)- rescue URI::InvalidURIError- return false- end- uri.host.present? && uri.is_a?(URI::HTTP)- end- end-enddiff --git a/spree/core/lib/spree/analytics.rb b/spree/core/lib/spree/analytics.rbdeleted file mode 100644index 59853b3b23..0000000000--- a/spree/core/lib/spree/analytics.rb+++ /dev/null@@ -1,11 +0,0 @@-module Spree- module Analytics- def self.events- @@supported_events ||= Spree.analytics.events- end-- def self.event_handlers- @@event_handlers ||= Spree.analytics.handlers- end- end-enddiff --git a/spree/core/lib/spree/core.rb b/spree/core/lib/spree/core.rbindex 044a5f1aba..dba71947ee 100644--- a/spree/core/lib/spree/core.rb+++ b/spree/core/lib/spree/core.rb@@ -766,7 +766,6 @@ module Spreeend# Semantic reporting registry — the queryable metric/dimension vocabulary.- # Not to be confused with +Spree.analytics+ (storefront event tracking).## @return [Spree::Reporting::Registry]def self.reporting@@ -777,29 +776,6 @@ module SpreeRails.application.config.spree.reporting = valueend- def self.analytics- @analytics ||= AnalyticsConfig.new- end-- # Group analytics configuration options together, but still make it backwards compatible.- class AnalyticsConfig- def events- Rails.application.config.spree.analytics_events- end-- def events=(value)- Rails.application.config.spree.analytics_events = value- end-- def handlers- Rails.application.config.spree.analytics_event_handlers- end-- def handlers=(value)- Rails.application.config.spree.analytics_event_handlers = value- end- end-# The permission catalog — the grant vocabulary shared by staff roles and# secret API key scopes. Roles themselves are data (Spree::Role#permissions);# code only registers the vocabulary.@@ -910,7 +886,6 @@ require 'spree/core/version'require 'spree/core/number_generator'require 'spree/number_generators/registry'require 'spree/migrations'-require 'spree/translation_migrations'require 'spree/validators'require 'spree/core/engine'@@ -922,7 +897,6 @@ require 'spree/translations'require 'spree/money'require 'spree/service_module'require 'spree/workflow'-require 'spree/analytics'require 'spree/reporting'require 'spree/events'require 'spree/store_scope_guard'diff --git a/spree/core/lib/spree/core/engine.rb b/spree/core/lib/spree/core/engine.rbindex 59aa5f5379..2d020ae3e1 100644--- a/spree/core/lib/spree/core/engine.rb+++ b/spree/core/lib/spree/core/engine.rb@@ -48,8 +48,6 @@ module Spree:actor_classes,:custom_fields,:reporting,- :analytics_events,- :analytics_event_handlers,:integrations,:number_generators,:subscribers,@@ -603,33 +601,6 @@ module SpreeSpree.customer_class]- Rails.application.config.spree.analytics_events = {- product_viewed: 'Product Viewed',- product_list_viewed: 'Product List Viewed',- product_searched: 'Product Searched',- product_added: 'Product Added',- product_removed: 'Product Removed',-- product_added_to_wishlist: 'Product Added to Wishlist',- product_removed_from_wishlist: 'Product Removed from Wishlist',-- subscribed_to_newsletter: 'Subscribed to Newsletter',- unsubscribed_from_newsletter: 'Unsubscribed from Newsletter',-- payment_info_entered: 'Payment Info Entered',- coupon_entered: 'Coupon Entered',- coupon_removed: 'Coupon Removed',- coupon_applied: 'Coupon Applied',- coupon_denied: 'Coupon Denied',-- checkout_started: 'Checkout Started',- checkout_email_entered: 'Checkout Email Entered',- checkout_step_viewed: 'Checkout Step Viewed',- checkout_step_completed: 'Checkout Step Completed',- order_completed: 'Order Completed',- }- Rails.application.config.spree.analytics_event_handlers = []-Rails.application.config.spree.integrations = []Rails.application.config.spree.validators.addresses = [diff --git a/spree/core/lib/spree/translation_migrations.rb b/spree/core/lib/spree/translation_migrations.rbdeleted file mode 100644index b18c15b110..0000000000--- a/spree/core/lib/spree/translation_migrations.rb+++ /dev/null@@ -1,52 +0,0 @@-module Spree- class TranslationMigrations- def initialize(resource_class, default_locale)- @resource_class = resource_class- @translations_table = resource_class::Translation.table_name- @translatable_fields = resource_class.translatable_fields.join(', ')- @foreign_key = "#{resource_class.table_name.singularize}_id"- @default_locale = default_locale- end-- def transfer_translation_data- nullify_translatable_fields = @resource_class.translatable_fields.map { |f| "#{f}=null" }.join(', ')-- unless @resource_class::Translation.exists?- # Copy data from main table to translations table- @resource_class.find_each do |resource|- translation_attrs = @resource_class.translatable_fields.each_with_object({}) do |field, attrs|- attrs[field] = resource[field]- end-- @resource_class::Translation.create!(- translation_attrs.merge(- @foreign_key => resource.id,- locale: @default_locale,- created_at: resource.created_at,- updated_at: resource.updated_at- )- )- end-- # Nullify translatable fields in main table- @resource_class.update_all(nullify_translatable_fields)- end- end-- def revert_translation_data_transfer- translation_table_fields = @resource_class.translatable_fields.map { |f| "#{@translations_table}.#{f}" }.join(', ')- row_expression = @resource_class.translatable_fields.count == 1 ? 'ROW' : ''-- # Update main table with translations- @resource_class::Translation.find_each do |translation|- resource = @resource_class.find(translation[@foreign_key])- @resource_class.translatable_fields.each do |field|- resource.update_column(field, translation[field])- end- end-- # Clear translations table- @resource_class::Translation.delete_all- end- end-enddiff --git a/spree/core/spec/lib/spree/core_environment_spec.rb b/spree/core/spec/lib/spree/core_environment_spec.rbindex b01c71d189..1862dfe417 100644--- a/spree/core/spec/lib/spree/core_environment_spec.rb+++ b/spree/core/spec/lib/spree/core_environment_spec.rb@@ -73,16 +73,6 @@ RSpec.describe 'Spree environment accessors' doexpect(Spree.custom_fields.enabled_resources).to be_an(Array)end- it 'provides access to analytics.events' do- expect(Spree.analytics.events).to eq(Rails.application.config.spree.analytics_events)- expect(Spree.analytics.events).to be_a(Hash)- end-- it 'provides access to analytics.handlers' do- expect(Spree.analytics.handlers).to eq(Rails.application.config.spree.analytics_event_handlers)- expect(Spree.analytics.handlers).to be_an(Array)- end-it 'provides access to integrations' doexpect(Spree.integrations).to eq(Rails.application.config.spree.integrations)expect(Spree.integrations).to be_an(Array)diff --git a/spree/core/spec/models/concerns/spree/has_image_alt_text_spec.rb b/spree/core/spec/models/concerns/spree/has_image_alt_text_spec.rbdeleted file mode 100644index ed67ba4dfb..0000000000--- a/spree/core/spec/models/concerns/spree/has_image_alt_text_spec.rb+++ /dev/null@@ -1,87 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::HasImageAltText, type: :concern do- # Create a dummy class to test the concern- let(:dummy_class) do- Class.new do- include Spree::HasImageAltText-- attr_accessor :preferred_image_alt, :asset-- def initialize- @preferred_image_alt = nil- @asset = nil- end- end- end-- let(:instance) { dummy_class.new }-- describe 'included behavior' do- it 'creates the image_alt method' do- expect(instance).to respond_to(:image_alt)- end-- it 'returns preference value when present' do- instance.preferred_image_alt = 'Custom alt text'- expect(instance.image_alt).to eq('Custom alt text')- end-- it 'falls back when preference is whitespace-only' do- instance.preferred_image_alt = ' '- expect(instance.image_alt).to eq('Image')- end-- it 'returns filename-based alt when preference is blank but asset has filename' do- instance.preferred_image_alt = ''-- # Mock asset with filename- asset_double = double('asset')- allow(asset_double).to receive(:filename).and_return('test-image_file.jpg')- instance.asset = asset_double-- expect(instance.image_alt).to eq('test image file')- end-- it 'returns "Image" as fallback when no preference and no asset' do- instance.preferred_image_alt = nil- instance.asset = nil-- expect(instance.image_alt).to eq('Image')- end-- context 'when asset has no filename' do- it 'returns "Image" fallback' do- instance.preferred_image_alt = nil-- # Mock asset without filename- asset_double = double('asset')- allow(asset_double).to receive(:filename).and_return(nil)- instance.asset = asset_double-- expect(instance.image_alt).to eq('Image')- end- end-- context 'filename processing' do- it 'correctly converts various filename formats' do- instance.preferred_image_alt = nil-- test_cases = [- ['hero-banner_image.jpg', 'hero banner image'],- ['product_photo-main.png', 'product photo main'],- ['logo.svg', 'logo'],- ['My-File_Name.webp', 'My File Name']- ]-- test_cases.each do |filename, expected_alt|- asset_double = double('asset')- allow(asset_double).to receive(:filename).and_return(filename)- instance.asset = asset_double-- expect(instance.image_alt).to eq(expected_alt)- end- end- end- end-enddiff --git a/spree/core/spec/models/spree/base_analytics_event_handler_spec.rb b/spree/core/spec/models/spree/base_analytics_event_handler_spec.rbdeleted file mode 100644index 31beaf9036..0000000000--- a/spree/core/spec/models/spree/base_analytics_event_handler_spec.rb+++ /dev/null@@ -1,66 +0,0 @@-require 'spec_helper'--RSpec.describe Spree::BaseAnalyticsEventHandler do- let(:client) { double('client') }- let(:user) { create(:user) }- let(:session) { double('session', id: 'test-session-123') }- let(:request) { double('request', remote_ip: '127.0.0.1') }- let(:visitor_id) { 'test-visitor-123' }- let(:handler) { described_class.new(user: user, session: session, request: request, visitor_id: visitor_id) }-- describe '#client' do- it 'raises NotImplementedError' do- expect { handler.client }.to raise_error(NotImplementedError)- end- end-- describe '#initialize' do- it 'sets user, session and request ' do- expect(handler.user).to eq(user)- expect(handler.session).to eq(session)- expect(handler.request).to eq(request)- end- end-- describe '#handle_event' do- it 'raises NotImplementedError' do- expect { handler.handle_event('test_event') }.to raise_error(NotImplementedError)- end- end-- describe '#event_human_name' do- it 'returns the label for supported events' do- expect(handler.event_human_name('product_viewed')).to eq('Product Viewed')- expect(handler.event_human_name('order_completed')).to eq('Order Completed')- expect(handler.event_human_name('checkout_started')).to eq('Checkout Started')- end-- it 'returns nil for unsupported events' do- expect(handler.event_human_name('unsupported_event')).to be_nil- end- end-- describe '#identity_hash' do- context 'when user is present' do- it 'returns hash with user_id, visitor_id and session_id' do- expect(handler.send(:identity_hash)).to eq({- user_id: user.id,- session_id: session.id,- visitor_id: visitor_id- })- end- end-- context 'when user is not present' do- let(:handler) { described_class.new(session: session, visitor_id: visitor_id) }-- it 'returns hash with nil user_id, visitor_id and session_id' do- expect(handler.send(:identity_hash)).to eq({- user_id: nil,- visitor_id: visitor_id,- session_id: session.id- })- end- end- end-enddiff --git a/spree/core/spec/models/spree/promotion_handler/promotion_duplicator_spec.rb b/spree/core/spec/models/spree/promotion_handler/promotion_duplicator_spec.rbdeleted file mode 100644index 8e75e967e4..0000000000--- a/spree/core/spec/models/spree/promotion_handler/promotion_duplicator_spec.rb+++ /dev/null@@ -1,113 +0,0 @@-require 'spec_helper'--describe Spree::PromotionHandler::PromotionDuplicator do- subject { described_class.new(promotion) }-- let!(:promo_category) { create(:promotion_category) }- let!(:calculator) { create(:calculator) }-- let(:store) { @default_store }- let!(:promotion) do- create(:promotion_with_item_total_rule,- description: 'Test description',- expires_at: Date.current + 30,- starts_at: Date.current,- usage_limit: 100,- match_policy: 'all',- code: 'test1',- advertise: true,- path: 'test1',- promotion_category: promo_category,- store: store)- end-- before do- Spree::Promotion::Actions::CreateItemAdjustments.create!(calculator: calculator, promotion: promotion)- end-- describe '#duplicate' do- let!(:new_promotion) { subject.duplicate }-- context 'model fields' do- let(:excluded_fields) { ['code', 'name', 'path', 'id', 'created_at', 'updated_at', 'deleted_at'] }-- it 'returns a duplicate of a promotion with the path, name and code fields changed' do- expect("New #{promotion.name}").to eq new_promotion.name- expect(new_promotion.path).to match /#{promotion.path}_[a-zA-Z]{4}/- expect(new_promotion.code).to match /#{promotion.code}_[a-zA-Z]{4}/- end-- it 'returns a duplicate of a promotion with all the fields (except the path, name and code fields) the same' do- promotion.attributes.each_key do |key|- expect(promotion.send(key)).to eq new_promotion.send(key) unless excluded_fields.include?(key)- end- end- end-- context 'model associations - rules' do- let(:excluded_fields) { ['promotion_id', 'id', 'created_at', 'updated_at', 'deleted_at'] }-- it 'copies all promotion rules' do- expect(promotion.promotion_rules.size).to eq new_promotion.promotion_rules.size- end-- it "promotion rule's fields (except promotion_id) are the same" do- old_rule = promotion.promotion_rules.first- new_rule = new_promotion.reload.promotion_rules.first-- old_rule.attributes.each_key do |key|- expect(old_rule.send(key)).to eq new_rule.send(key) unless excluded_fields.include?(key)- end- end-- it 'assigns a new promotion rule to new promotion' do- expect(promotion.promotion_rules.first.promotion_id).not_to eq new_promotion.promotion_rules.first.promotion_id- end- end-- context 'model associations - actions' do- let(:excluded_fields) { ['promotion_id', 'id', 'created_at', 'updated_at', 'deleted_at'] }-- it 'copies all promotion actions' do- expect(promotion.promotion_actions.size).to eq new_promotion.promotion_actions.size- end-- it 'copies promotion store' do- expect(promotion.store_id).to eq new_promotion.store_id- end-- it "promotion action's fields (except promotion_id) are the same" do- old_action = promotion.promotion_actions.first- new_action = new_promotion.promotion_actions.first-- old_action.attributes.each_key do |key|- expect(old_action.send(key)).to eq new_action.send(key) unless excluded_fields.include?(key)- end- end-- it 'assigns a new promotion action to new promotion' do- expect(promotion.promotion_actions.first.promotion_id).not_to eq new_promotion.promotion_actions.first.promotion_id- end- end-- context "model associations - action's calculator" do- let(:excluded_fields) { ['calculable_id', 'id', 'created_at', 'updated_at', 'deleted_at'] }-- it "copies promotion action's calculator" do- new_calc = new_promotion.promotion_actions.first.calculator- old_calc = promotion.promotion_actions.first.calculator-- new_calc.attributes.each_key do |key|- expect(old_calc.send(key)).to eq new_calc.send(key) unless excluded_fields.include?(key)- end- end-- it 'assigns a new calculator to promotion action' do- new_calc = new_promotion.promotion_actions.first.calculator- old_calc = promotion.promotion_actions.first.calculator-- expect(old_calc.calculable_id).not_to eq new_calc.calculable_id- end- end- end-enddiff --git a/spree/core/spec/models/spree/stock/differentiator_spec.rb b/spree/core/spec/models/spree/stock/differentiator_spec.rbdeleted file mode 100644index 2acab212c1..0000000000--- a/spree/core/spec/models/spree/stock/differentiator_spec.rb+++ /dev/null@@ -1,39 +0,0 @@-require 'spec_helper'--module Spree- module Stock- describe Differentiator, type: :model do- subject { Differentiator.new(order, packages) }-- let(:variant1) { create(:variant) }- let(:variant2) { create(:variant) }-- let(:line_item1) { create(:line_item, variant: variant1, quantity: 2) }- let(:line_item2) { create(:line_item, variant: variant2, quantity: 2) }-- let(:stock_location) { create(:stock_location) }-- let(:inventory_unit1) { create(:fulfillment_item, variant: variant1, line_item: line_item1) }- let(:inventory_unit2) { create(:fulfillment_item, variant: variant2, line_item: line_item2) }-- let(:order) { create(:order, line_items: [line_item1, line_item2]) }-- let(:package1) do- Package.new(stock_location).tap { |p| p.add(inventory_unit1) }- end-- let(:package2) do- Package.new(stock_location).tap { |p| p.add(inventory_unit2) }- end-- let(:packages) { [package1, package2] }-- it { is_expected.to be_missing }-- it 'calculates the missing items' do- expect(subject.missing[variant1]).to eq 1- expect(subject.missing[variant2]).to eq 1- end- end- end-enddiff --git a/spree/core/spec/presenters/spree/filters/options_presenter_spec.rb b/spree/core/spec/presenters/spree/filters/options_presenter_spec.rbdeleted file mode 100644index 08d8bc8418..0000000000--- a/spree/core/spec/presenters/spree/filters/options_presenter_spec.rb+++ /dev/null@@ -1,37 +0,0 @@-require 'spec_helper'--module Spree- RSpec.describe Filters::OptionsPresenter do- let(:options) { described_class.new(option_values_scope: OptionValue.where(id: option_values)) }-- let(:size) { Spree::OptionType.find_by(name: 'size') || create(:option_type, :size) }- let(:s_size) { size.option_values.find_by(name: 's') || create(:option_value, option_type: size, name: 's') }- let(:m_size) { size.option_values.find_by(name: 'm') || create(:option_value, option_type: size, name: 'm') }-- let(:color) { Spree::OptionType.find_by(name: 'color') || create(:option_type, :color) }- let(:red_color) { color.option_values.find_by(name: 'red') || create(:option_value, option_type: color, name: 'red') }- let(:green_color) { color.option_values.find_by(name: 'green') || create(:option_value, option_type: color, name: 'green') }- let(:blue_color) { color.option_values.find_by(name: 'blue') || create(:option_value, option_type: color, name: 'blue') }-- let(:option_values) do- [- s_size, m_size,- red_color, green_color, blue_color- ]- end-- describe '#to_a' do- subject(:filterable_options) { options.to_a }-- it 'returns filterable Option Types and Values' do- aggregate_failures 'filterable options' do- size_option = filterable_options.find { |option| option.option_type == size }- expect(size_option.option_values).to contain_exactly(s_size, m_size)-- color_option = filterable_options.find { |option| option.option_type == color }- expect(color_option.option_values).to contain_exactly(red_color, green_color, blue_color)- end- end- end- end-enddiff --git a/spree/core/spec/validators/spree/url_validator_spec.rb b/spree/core/spec/validators/spree/url_validator_spec.rbdeleted file mode 100644index 499d7678ce..0000000000--- a/spree/core/spec/validators/spree/url_validator_spec.rb+++ /dev/null@@ -1,60 +0,0 @@-require 'spec_helper'--module Spree- module Test- Product = Struct.new(:url, keyword_init: true) do- include ActiveModel::Validations-- validates :url, 'spree/url': true- end- end-end--describe Spree::UrlValidator do- describe 'validating the given URL' do- context 'is invalid' do- it { expect(Spree::Test::Product.new(url: nil).valid?).to eq(false) }- it { expect(Spree::Test::Product.new(url: '').valid?).to eq(false) }- it { expect(Spree::Test::Product.new(url: 'google.com').valid?).to eq(false) }- it { expect(Spree::Test::Product.new(url: 'http:/google').valid?).to eq(false) }- it { expect(Spree::Test::Product.new(url: 'www.google.com').valid?).to eq(false) }- end-- context 'is valid' do- it { expect(Spree::Test::Product.new(url: 'http://google.com').valid?).to eq(true) }- it { expect(Spree::Test::Product.new(url: 'https://google.com').valid?).to eq(true) }- it { expect(Spree::Test::Product.new(url: 'http://www.google.com').valid?).to eq(true) }- it { expect(Spree::Test::Product.new(url: 'https://www.google.com').valid?).to eq(true) }- # Due to simplicity, this is valid even without tld- it { expect(Spree::Test::Product.new(url: 'http://google').valid?).to eq(true) }- end- end-- describe 'using a given message or a defined one' do- let(:test_product) { Spree::Test::Product.new(url: nil) }-- context 'using the message option' do- let(:message) { 'is needed' }-- it 'adds the given message to the record url errors array' do- # Remove the validation set at the beginning- Spree::Test::Product.clear_validators!- Spree::Test::Product.validates(:url, 'spree/url': { message: message })-- test_product.valid?- expect(test_product.errors.messages).to eq(url: [message])-- # Add back the validation removed previously- Spree::Test::Product.clear_validators!- Spree::Test::Product.validates(:url, 'spree/url': true)- end- end-- context 'without using the message option' do- it 'adds a pre-defined message to the record url error array' do- test_product.valid?- expect(test_product.errors.messages).to eq(url: ['must be a valid URL'])- end- end- end-end