spree_core 6.0.4 → 6.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/app/jobs/spree/imports/create_rows_job.rb +4 -2
  3. data/app/jobs/spree/imports/process_rows_job.rb +4 -2
  4. data/app/jobs/spree/products/auto_match_taxons_job.rb +5 -2
  5. data/app/jobs/spree/search_provider/index_job.rb +8 -0
  6. data/app/jobs/spree/search_provider/remove_job.rb +3 -0
  7. data/app/jobs/spree/stock_locations/stock_items/create_job.rb +5 -2
  8. data/app/mailers/spree/base_mailer.rb +1 -1
  9. data/app/models/concerns/spree/acted_by.rb +2 -2
  10. data/app/models/concerns/spree/customer_methods.rb +6 -4
  11. data/app/models/concerns/spree/deprecated_customer_alias.rb +11 -3
  12. data/app/models/concerns/spree/derived_number.rb +1 -1
  13. data/app/models/concerns/spree/has_custom_fields.rb +12 -10
  14. data/app/models/concerns/spree/integrations_concern.rb +5 -3
  15. data/app/models/concerns/spree/label_translatable.rb +4 -4
  16. data/app/models/concerns/spree/metadata.rb +3 -3
  17. data/app/models/concerns/spree/presentation_translatable.rb +1 -1
  18. data/app/models/concerns/spree/purchase/addresses.rb +8 -5
  19. data/app/models/concerns/spree/purchase/deprecated_aliases.rb +2 -2
  20. data/app/models/concerns/spree/stores/markets.rb +4 -2
  21. data/app/models/concerns/spree/user_address.rb +5 -2
  22. data/app/models/concerns/spree/user_methods.rb +2 -2
  23. data/app/models/spree/address.rb +29 -14
  24. data/app/models/spree/asset.rb +3 -3
  25. data/app/models/spree/base.rb +1 -1
  26. data/app/models/spree/calculator/shipping/flat_rate.rb +6 -4
  27. data/app/models/spree/cart.rb +2 -2
  28. data/app/models/spree/category.rb +8 -6
  29. data/app/models/spree/classification.rb +2 -2
  30. data/app/models/spree/current.rb +19 -0
  31. data/app/models/spree/custom_field.rb +6 -6
  32. data/app/models/spree/custom_field_definition.rb +10 -7
  33. data/app/models/spree/delivery_method.rb +21 -15
  34. data/app/models/spree/delivery_rate.rb +1 -1
  35. data/app/models/spree/digital.rb +1 -1
  36. data/app/models/spree/digital_asset.rb +2 -2
  37. data/app/models/spree/digital_link.rb +4 -4
  38. data/app/models/spree/export.rb +29 -2
  39. data/app/models/spree/fulfillment/custom_events.rb +18 -10
  40. data/app/models/spree/fulfillment.rb +30 -23
  41. data/app/models/spree/fulfillment_item.rb +3 -3
  42. data/app/models/spree/fulfilment_changer.rb +1 -1
  43. data/app/models/spree/gift_card.rb +12 -12
  44. data/app/models/spree/import.rb +23 -15
  45. data/app/models/spree/import_row.rb +6 -6
  46. data/app/models/spree/inventory_unit.rb +1 -1
  47. data/app/models/spree/invitation.rb +8 -4
  48. data/app/models/spree/line_item.rb +10 -8
  49. data/app/models/spree/media.rb +2 -2
  50. data/app/models/spree/metafield.rb +1 -1
  51. data/app/models/spree/metafield_definition.rb +1 -1
  52. data/app/models/spree/metafields.rb +2 -2
  53. data/app/models/spree/option_type.rb +26 -0
  54. data/app/models/spree/option_value.rb +3 -3
  55. data/app/models/spree/order.rb +87 -45
  56. data/app/models/spree/order_inventory.rb +2 -2
  57. data/app/models/spree/order_merger.rb +2 -2
  58. data/app/models/spree/order_updater.rb +34 -20
  59. data/app/models/spree/payment.rb +8 -8
  60. data/app/models/spree/payment_method.rb +11 -9
  61. data/app/models/spree/price.rb +19 -8
  62. data/app/models/spree/price_list.rb +12 -6
  63. data/app/models/spree/price_rules/zone_rule.rb +1 -1
  64. data/app/models/spree/product.rb +26 -24
  65. data/app/models/spree/product_category.rb +3 -3
  66. data/app/models/spree/promotion/rules/category.rb +27 -10
  67. data/app/models/spree/promotion/rules/country.rb +1 -1
  68. data/app/models/spree/promotion/rules/taxon.rb +4 -2
  69. data/app/models/spree/promotion/rules/user.rb +1 -1
  70. data/app/models/spree/promotion_action.rb +1 -1
  71. data/app/models/spree/promotion_rule_category.rb +5 -5
  72. data/app/models/spree/promotion_rule_taxon.rb +2 -2
  73. data/app/models/spree/prototype.rb +4 -1
  74. data/app/models/spree/return_authorization_reason.rb +3 -3
  75. data/app/models/spree/return_reason.rb +1 -1
  76. data/app/models/spree/search_provider/base.rb +2 -2
  77. data/app/models/spree/search_provider.rb +7 -5
  78. data/app/models/spree/shipment.rb +4 -1
  79. data/app/models/spree/shipping_method.rb +4 -1
  80. data/app/models/spree/shipping_rate.rb +1 -1
  81. data/app/models/spree/stock/coordinator.rb +2 -2
  82. data/app/models/spree/stock/estimator.rb +7 -5
  83. data/app/models/spree/stock/package.rb +10 -8
  84. data/app/models/spree/stock_item.rb +1 -1
  85. data/app/models/spree/stock_level/custom_events.rb +1 -1
  86. data/app/models/spree/stock_level.rb +1 -1
  87. data/app/models/spree/stock_location.rb +12 -8
  88. data/app/models/spree/stock_movement.rb +6 -6
  89. data/app/models/spree/stock_reservation.rb +5 -5
  90. data/app/models/spree/store.rb +42 -16
  91. data/app/models/spree/store_credit.rb +2 -2
  92. data/app/models/spree/store_credit_category.rb +5 -5
  93. data/app/models/spree/store_credit_type.rb +2 -2
  94. data/app/models/spree/subscriber.rb +7 -7
  95. data/app/models/spree/tax_rate.rb +5 -5
  96. data/app/models/spree/taxon.rb +3 -3
  97. data/app/models/spree/taxon_rule.rb +2 -2
  98. data/app/models/spree/taxonomy.rb +1 -1
  99. data/app/models/spree/variant.rb +12 -10
  100. data/app/models/spree/variant_media.rb +1 -1
  101. data/app/models/spree/wished_item.rb +1 -1
  102. data/app/models/spree/wishlist.rb +2 -2
  103. data/app/models/spree/wishlist_item/custom_events.rb +2 -2
  104. data/app/models/spree/zone.rb +1 -1
  105. data/app/models/spree/zone_member.rb +1 -1
  106. data/app/services/spree/carts/associate.rb +6 -2
  107. data/app/services/spree/carts/create.rb +1 -1
  108. data/app/services/spree/carts/destroy.rb +1 -1
  109. data/app/services/spree/carts/remove_item.rb +1 -1
  110. data/app/services/spree/carts/remove_line_item.rb +2 -2
  111. data/app/services/spree/carts/remove_out_of_stock_items.rb +3 -1
  112. data/app/services/spree/carts/set_quantity.rb +2 -2
  113. data/app/services/spree/carts/update.rb +17 -0
  114. data/app/services/spree/checkout/add_store_credit.rb +3 -3
  115. data/app/services/spree/checkout/remove_store_credit.rb +2 -2
  116. data/app/services/spree/imports/row_processors/product_variant.rb +19 -0
  117. data/app/services/spree/orders/approve.rb +3 -3
  118. data/app/services/spree/orders/create_user_account.rb +2 -2
  119. data/app/services/spree/products/auto_match_taxons.rb +5 -2
  120. data/app/services/spree/shipments/update.rb +2 -2
  121. data/app/services/spree/stock_locations/stock_items/create.rb +5 -2
  122. data/app/services/spree/stock_reservations/extend.rb +3 -1
  123. data/app/services/spree/stock_reservations/reserve.rb +3 -1
  124. data/app/services/spree/taxons/add_products.rb +4 -2
  125. data/app/services/spree/taxons/regenerate_products.rb +5 -2
  126. data/app/services/spree/taxons/remove_products.rb +4 -2
  127. data/app/workflows/spree/carts/add_item.rb +1 -1
  128. data/app/workflows/spree/carts/recalculate.rb +1 -1
  129. data/app/workflows/spree/fulfillments/update.rb +1 -1
  130. data/app/workflows/spree/orders/cancel.rb +3 -1
  131. data/app/workflows/spree/payments/capture.rb +2 -2
  132. data/app/workflows/spree/seller_transfers/create.rb +1 -1
  133. data/config/locales/en.yml +4 -0
  134. data/db/migrate/20260710000001_rename_taxons_to_categories.rb +1 -1
  135. data/db/migrate/20260728000004_rename_shipping_to_fulfillment_and_delivery.rb +1 -1
  136. data/db/migrate/20260806000001_add_store_id_to_spree_tax_rates_and_categories.rb +1 -1
  137. data/db/migrate/20260807130001_add_country_state_codes_to_consumers.rb +1 -1
  138. data/db/migrate/20260809000001_rename_metafields_to_custom_fields.rb +1 -1
  139. data/db/migrate/20260809150001_promote_shipping_categories_to_delivery_profiles.rb +1 -1
  140. data/db/migrate/20260811000001_add_delivery_tracking_to_fulfillments.rb +1 -1
  141. data/db/migrate/20260824000001_add_store_to_spree_media.rb +1 -1
  142. data/db/migrate/20260828100001_unify_import_and_export_tenancy.rb +1 -1
  143. data/db/migrate/20261016000001_remove_default_from_spree_tax_rates_included_in_price.rb +1 -1
  144. data/lib/spree/agent_tools/default_catalog.rb +2 -2
  145. data/lib/spree/agent_tools/legacy_tools.rb +1 -1
  146. data/lib/spree/core/dependencies.rb +10 -10
  147. data/lib/spree/core/engine.rb +4 -0
  148. data/lib/spree/core/number_generator.rb +4 -3
  149. data/lib/spree/core/preferences/preferable.rb +1 -1
  150. data/lib/spree/core/preferences/preferable_class_methods.rb +5 -1
  151. data/lib/spree/core/pricing/resolver.rb +2 -2
  152. data/lib/spree/core/version.rb +1 -1
  153. data/lib/spree/core.rb +37 -10
  154. data/lib/spree/i18n.rb +6 -2
  155. data/lib/spree/localized_number.rb +1 -1
  156. data/lib/spree/removed_apis.rb +274 -0
  157. data/lib/spree/reporting/default_vocabulary.rb +1 -1
  158. data/lib/spree/testing_support/factories/digital_asset_factory.rb +1 -1
  159. data/lib/spree/testing_support/factories/stock_level_factory.rb +1 -1
  160. data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
  161. data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
  162. data/lib/spree/testing_support/factories/wishlist_item_factory.rb +1 -1
  163. data/lib/spree/testing_support/i18n.rb +7 -2
  164. data/lib/spree/testing_support/order_walkthrough.rb +5 -2
  165. data/lib/spree/upgrades/5_6_to_6_0/manifest.yml +14 -14
  166. data/lib/tasks/carts_migration.rake +1 -1
  167. data/lib/tasks/categories_and_collections.rake +1 -1
  168. data/lib/tasks/deliveries_migration.rake +1 -1
  169. data/lib/tasks/delivery_method_rules_migration.rake +1 -1
  170. data/lib/tasks/delivery_migration.rake +1 -1
  171. data/lib/tasks/delivery_profiles_migration.rake +2 -2
  172. data/lib/tasks/fold_store_credit_categories.rake +1 -1
  173. data/lib/tasks/migrate_country_state_codes.rake +1 -1
  174. data/lib/tasks/migrate_returns.rake +4 -4
  175. data/lib/tasks/migrate_rich_text_to_columns.rake +1 -1
  176. data/lib/tasks/store_settings.rake +1 -1
  177. data/lib/tasks/typed_stock_movements_migration.rake +1 -1
  178. metadata +7 -6
@@ -99,6 +99,7 @@ module Spree
99
99
  # wins over the environment — is never rejected for a stale env var.
100
100
  config.after_initialize do
101
101
  Spree::Core::Configuration.validate_env!(Spree::Config)
102
+ Rails.error.subscribe(Spree::RemovedApis::ErrorSubscriber.new)
102
103
  end
103
104
 
104
105
  # I18n's config lives in fiber/thread-local storage that survives across
@@ -596,7 +597,10 @@ module Spree
596
597
  app/models/spree/classification.rb
597
598
  app/models/spree/promotion/rules/taxon.rb
598
599
  app/models/spree/promotion_rule_taxon.rb
600
+ app/models/spree/prototype.rb
599
601
  app/models/spree/return_authorization_reason.rb
602
+ app/models/spree/shipment.rb
603
+ app/models/spree/shipping_method.rb
600
604
  app/models/spree/taxon.rb
601
605
  app/services/spree/checkout/add_store_credit.rb
602
606
  app/services/spree/checkout/remove_store_credit.rb
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  module Core
3
- # @deprecated Use {Spree::HasNumber} instead. Removed in Spree 6.1.
3
+ # @deprecated Use {Spree::HasNumber} instead. Removed in Spree 6.3.
4
4
  #
5
5
  # # before
6
6
  # include Spree::Core::NumberGenerator.new(prefix: 'R')
@@ -9,7 +9,7 @@ module Spree
9
9
  # has_spree_number prefix: 'R'
10
10
  #
11
11
  # Kept as a shell so existing models and extension decorators keep
12
- # working for one release. Including it wires up {Spree::HasNumber} with
12
+ # working until 6.3. Including it wires up {Spree::HasNumber} with
13
13
  # the given prefix, which means numbers now follow the store's format
14
14
  # preference (sequential by default) rather than always being random.
15
15
  # Hosts that need the old random numbers should switch the store's
@@ -25,13 +25,14 @@ module Spree
25
25
  attr_accessor :prefix, :length
26
26
 
27
27
  def initialize(options)
28
+ super()
28
29
  @prefix = options.fetch(:prefix)
29
30
  @length = options.fetch(:length, DEFAULT_LENGTH)
30
31
  @letters = options[:letters]
31
32
 
32
33
  Spree::Deprecation.warn(
33
34
  'Spree::Core::NumberGenerator is deprecated and will be removed in ' \
34
- "Spree 6.1. Replace `include Spree::Core::NumberGenerator.new(prefix: '#{@prefix}')` " \
35
+ "Spree 6.3. Replace `include Spree::Core::NumberGenerator.new(prefix: '#{@prefix}')` " \
35
36
  "with `has_spree_number prefix: '#{@prefix}'`. " \
36
37
  'See docs/plans/6.0-document-numbers.md.'
37
38
  )
@@ -283,7 +283,7 @@ module Spree::Preferences::Preferable
283
283
  # `(value, owner = nil)` shapes.
284
284
  value = parse_on_set.arity.abs > 1 ? parse_on_set.call(value, self) : parse_on_set.call(value)
285
285
  end
286
- # Spree 6.0 bridge, removed with incomplete declarations in 6.1: an id list
286
+ # Spree 6.0 bridge, removed with incomplete declarations in 6.3: an id list
287
287
  # an extension declared without `of: :id` still has its prefixed ids
288
288
  # decoded, as the API did for every `*_ids` key before.
289
289
  if definition[:type] == :array && definition[:of].nil? && name.to_s.end_with?('_ids') && value.is_a?(Array)
@@ -192,6 +192,10 @@ module Spree::Preferences
192
192
  raise ArgumentError, "`currency:` applies to a :money preference, not `#{name}` (#{type})" if options[:currency] && type != :money
193
193
  raise ArgumentError, "`of: :object` needs `properties:` on preference `#{name}`" if options[:of] == :object && options[:properties].blank?
194
194
 
195
+ warn_incomplete_preference_declaration(name, type, options)
196
+ end
197
+
198
+ def warn_incomplete_preference_declaration(name, type, options)
195
199
  missing = case type
196
200
  when :any then 'a type other than :any'
197
201
  when :array then '`of:`' unless options[:of]
@@ -201,7 +205,7 @@ module Spree::Preferences
201
205
 
202
206
  Spree::Deprecation.warn(
203
207
  "#{self.name} preference `#{name}` (#{type}) needs #{missing}; until it has one, its schema accepts any value. " \
204
- 'Spree 6.1 will raise for an incomplete declaration.'
208
+ 'Spree 6.3 will raise for an incomplete declaration.'
205
209
  )
206
210
  end
207
211
 
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  module Pricing
3
- # @deprecated Use {Spree::Pricing::PriceResolution}; removed in 6.1.
3
+ # @deprecated Use {Spree::Pricing::PriceResolution}; removed in 6.3.
4
4
  #
5
5
  # Answering a price used to mean walking the store's price lists and
6
6
  # falling back to the variant's base price. That is now one engine among
@@ -22,7 +22,7 @@ module Spree
22
22
  # @return [Spree::Price, nil]
23
23
  def resolve
24
24
  Spree::Deprecation.warn(
25
- 'Spree::Pricing::Resolver is deprecated and will be removed in Spree 6.1. ' \
25
+ 'Spree::Pricing::Resolver is deprecated and will be removed in Spree 6.3. ' \
26
26
  'Use Spree::Pricing::PriceResolution.call(context) instead.'
27
27
  )
28
28
 
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- VERSION = '6.0.4'.freeze
2
+ VERSION = '6.0.5'.freeze
3
3
 
4
4
  def self.version
5
5
  VERSION
data/lib/spree/core.rb CHANGED
@@ -86,15 +86,23 @@ module Spree
86
86
  resolve_class_setting(:customer_class, @@customer_class, constantize)
87
87
  end
88
88
 
89
- # @deprecated Spree.user_class was renamed to Spree.customer_class in 6.0; removed in 6.1.
89
+ # @deprecated Spree.user_class was renamed to Spree.customer_class in 6.0; removed in 6.3.
90
90
  def self.user_class(constantize: true)
91
- Spree::Deprecation.warn('Spree.user_class is deprecated and will be removed in Spree 6.1. Use Spree.customer_class instead.') if defined?(Spree::Deprecation)
91
+ if defined?(Spree::Deprecation)
92
+ Spree::Deprecation.warn(
93
+ 'Spree.user_class is deprecated and will be removed in Spree 6.3. Use Spree.customer_class instead.'
94
+ )
95
+ end
92
96
  customer_class(constantize: constantize)
93
97
  end
94
98
 
95
- # @deprecated Spree.user_class= was renamed to Spree.customer_class= in 6.0; removed in 6.1.
99
+ # @deprecated Spree.user_class= was renamed to Spree.customer_class= in 6.0; removed in 6.3.
96
100
  def self.user_class=(value)
97
- Spree::Deprecation.warn('Spree.user_class= is deprecated and will be removed in Spree 6.1. Use Spree.customer_class= instead.') if defined?(Spree::Deprecation)
101
+ if defined?(Spree::Deprecation)
102
+ Spree::Deprecation.warn(
103
+ 'Spree.user_class= is deprecated and will be removed in Spree 6.3. Use Spree.customer_class= instead.'
104
+ )
105
+ end
98
106
  self.customer_class = value
99
107
  end
100
108
 
@@ -135,24 +143,38 @@ module Spree
135
143
  payouts: :default,
136
144
  maintenance_tasks: :default
137
145
  ).tap do |queues|
138
- # @deprecated The taxons queue was renamed to categories in 6.0; removed in 6.1.
146
+ # @deprecated The taxons queue was renamed to categories in 6.0; removed in 6.3.
139
147
  queues.define_singleton_method(:taxons) do
140
- Spree::Deprecation.warn('Spree.queues.taxons is deprecated and will be removed in Spree 6.1. Use Spree.queues.categories instead.') if defined?(Spree::Deprecation)
148
+ if defined?(Spree::Deprecation)
149
+ Spree::Deprecation.warn(
150
+ 'Spree.queues.taxons is deprecated and will be removed in Spree 6.3. Use Spree.queues.categories instead.'
151
+ )
152
+ end
141
153
  categories
142
154
  end
143
155
 
144
- # @deprecated Renamed with the stock level rename in 6.0; removed in 6.1.
156
+ # @deprecated Renamed with the stock level rename in 6.0; removed in 6.3.
145
157
  #
146
158
  # The writer matters as much as the reader here: these are ordered options, so
147
159
  # an existing initializer assigning the old name would quietly define a
148
160
  # field nobody reads and its jobs would fall back to the default queue.
149
161
  queues.define_singleton_method(:stock_location_stock_items) do
150
- Spree::Deprecation.warn('Spree.queues.stock_location_stock_items is deprecated and will be removed in Spree 6.1. Use Spree.queues.stock_location_stock_levels instead.') if defined?(Spree::Deprecation)
162
+ if defined?(Spree::Deprecation)
163
+ Spree::Deprecation.warn(
164
+ 'Spree.queues.stock_location_stock_items is deprecated and will be removed in Spree 6.3. ' \
165
+ 'Use Spree.queues.stock_location_stock_levels instead.'
166
+ )
167
+ end
151
168
  stock_location_stock_levels
152
169
  end
153
170
 
154
171
  queues.define_singleton_method(:stock_location_stock_items=) do |value|
155
- Spree::Deprecation.warn('Spree.queues.stock_location_stock_items= is deprecated and will be removed in Spree 6.1. Use Spree.queues.stock_location_stock_levels= instead.') if defined?(Spree::Deprecation)
172
+ if defined?(Spree::Deprecation)
173
+ Spree::Deprecation.warn(
174
+ 'Spree.queues.stock_location_stock_items= is deprecated and will be removed in Spree 6.3. ' \
175
+ 'Use Spree.queues.stock_location_stock_levels= instead.'
176
+ )
177
+ end
156
178
  self.stock_location_stock_levels = value
157
179
  end
158
180
  end
@@ -477,7 +499,11 @@ module Spree
477
499
  end
478
500
 
479
501
  def self.metafields
480
- Spree::Deprecation.warn('Spree.metafields is deprecated and will be removed in Spree 6.1. Use Spree.custom_fields instead.') if defined?(Spree::Deprecation)
502
+ if defined?(Spree::Deprecation)
503
+ Spree::Deprecation.warn(
504
+ 'Spree.metafields is deprecated and will be removed in Spree 6.3. Use Spree.custom_fields instead.'
505
+ )
506
+ end
481
507
  custom_fields
482
508
  end
483
509
 
@@ -701,6 +727,7 @@ require 'spree/agent_tool'
701
727
  require 'spree/agent_tools'
702
728
  require 'spree/events'
703
729
  require 'spree/store_scope_guard'
730
+ require 'spree/removed_apis'
704
731
  require 'spree/uploads'
705
732
 
706
733
  # Not autoloaded from app/: the registry keeps registered steps in
data/lib/spree/i18n.rb CHANGED
@@ -5,9 +5,13 @@ module Spree
5
5
 
6
6
  class << self
7
7
  # @deprecated Use +I18n.t+ with the full key, e.g. +I18n.t('spree.free')+.
8
- # Will be removed in Spree 6.1.
8
+ # Will be removed in Spree 6.3.
9
9
  def translate(key, options = {})
10
- Spree::Deprecation.warn('Spree.t is deprecated and will be removed in Spree 6.1. Use I18n.t with the full key, e.g. I18n.t("spree.free").') if defined?(Spree::Deprecation)
10
+ if defined?(Spree::Deprecation)
11
+ Spree::Deprecation.warn(
12
+ 'Spree.t is deprecated and will be removed in Spree 6.3. Use I18n.t with the full key, e.g. I18n.t("spree.free").'
13
+ )
14
+ end
11
15
 
12
16
  I18n.t(key, **options.symbolize_keys, scope: [:spree, *Array(options[:scope]).map(&:to_sym)].uniq)
13
17
  end
@@ -5,7 +5,7 @@ module Spree
5
5
  # Strips all non-price-like characters from the number, taking into account locale settings.
6
6
  def self.parse(number)
7
7
  Spree::Deprecation.warn(
8
- 'Spree::LocalizedNumber is deprecated and will be removed in Spree 6.1. ' \
8
+ 'Spree::LocalizedNumber is deprecated and will be removed in Spree 6.3. ' \
9
9
  'Parse a canonical decimal string with BigDecimal, or Spree::Money::Rounding.parse_canonical for API input.'
10
10
  )
11
11
  return number unless number.is_a?(String)
@@ -0,0 +1,274 @@
1
+ module Spree
2
+ # Names the replacement when code calls a Ruby API that Spree removed.
3
+ #
4
+ # Spree is old enough that coding agents, older tutorials and extensions
5
+ # still reach for 4.x and 5.x APIs: the checkout state machine,
6
+ # adjustments, single-currency prices, return authorizations. Without help,
7
+ # those calls fail with a bare NoMethodError or NameError, and the reader
8
+ # has to work out what replaced them. This module adds one paragraph to
9
+ # those errors naming what to use instead.
10
+ #
11
+ # The hint is added to Exception#detailed_message, the text Ruby, IRB and
12
+ # RSpec print for an error. The Rails log prints #message instead, so
13
+ # ErrorSubscriber logs the hint for errors Rails reports (unhandled request
14
+ # and job errors). The error keeps its class, its #message and its
15
+ # #respond_to? answers, so rescues and duck typing behave exactly as they
16
+ # did. Removed names are never defined, so nothing that still exists can be
17
+ # shadowed.
18
+ #
19
+ # docs/developer/upgrades/removed-apis.mdx lists every entry; regenerate it
20
+ # with UPDATE_DOCS=1 pnpm test:rspec core spec/lib/spree/removed_apis_spec.rb.
21
+ #
22
+ # Keys: 'Spree::Order#next' is an instance method, 'Spree::Order.checkout_flow'
23
+ # a class method (also matched when called on a relation), 'Spree::Adjustment'
24
+ # a constant. A key matches subclasses too.
25
+ #
26
+ # When you remove a public Ruby API, add it under the release that removed
27
+ # it (see spree/AGENTS.md).
28
+ module RemovedApis
29
+ UPGRADE_GUIDES = {
30
+ '6.0' => 'https://spreecommerce.org/docs/developer/upgrades/5.6-to-6.0'
31
+ }.freeze
32
+
33
+ # @return [Hash{String => String}] each name in +entries+, prefixed with each owner
34
+ def self.expand(owners, separator, entries)
35
+ owners.product(entries.to_a).to_h { |owner, (name, hint)| ["#{owner}#{separator}#{name}", hint] }
36
+ end
37
+
38
+ CHECKOUT = 'Checkout has no state machine. Write cart fields in any order (Spree::Carts::Update, ' \
39
+ 'or the Store API cart endpoints), read cart.current_checkout_step and the cart ' \
40
+ 'requirements to see what is missing, and place the order with ' \
41
+ 'Spree::Dependencies.carts_complete_workflow.constantize.call(cart: cart).'.freeze
42
+ CHECKOUT_CUSTOMIZATION = 'Checkout has no state machine. Add a checkout requirement with ' \
43
+ 'Spree::Checkout::Registry.add_requirement, or a step with Spree::Checkout::Registry.register_step, ' \
44
+ 'and run side effects of placing an order in an order.placed subscriber (Spree::Subscriber).'.freeze
45
+ ADJUSTMENTS = 'Adjustments are typed rows: tax_lines, discounts and fees.'.freeze
46
+ RETURNS = 'Returns, exchanges and claims are their own records on the order: returns, exchanges, claims.'.freeze
47
+ STATE_CHANGES = 'Status history is no longer stored. Subscribe to events instead (Spree::Subscriber).'.freeze
48
+ PRIMARY_MEDIA = 'Use primary_media.'.freeze
49
+ CUSTOMER_PRICE = 'Use price_in(currency).display_amount for the base price, or, on a variant (product.default_variant), ' \
50
+ 'price_for(context).display_amount for the price a customer pays including price lists.'.freeze
51
+ SEARCH = 'Use search, or q[search] in the Admin API.'.freeze
52
+
53
+ ORDER_AND_CART = {
54
+ 'next' => CHECKOUT,
55
+ 'next!' => CHECKOUT,
56
+ 'state' => 'Orders have status (draft, placed, canceled). Carts have no status: completed_at marks completion, ' \
57
+ 'and current_checkout_step says where checkout stands.',
58
+ 'state=' => 'Status changes through workflows, for example Spree::Orders::Cancel. Carts have no status.',
59
+ 'can_go_to_state?' => CHECKOUT,
60
+ 'restart_checkout_flow' => CHECKOUT,
61
+ 'contents' => 'Change cart items with Spree.cart_add_item_workflow or Spree::Dependencies.cart_upsert_items_workflow.',
62
+ 'adjustments' => ADJUSTMENTS,
63
+ 'all_adjustments' => ADJUSTMENTS,
64
+ 'state_changes' => STATE_CHANGES
65
+ }.freeze
66
+
67
+ ORDER_AND_CART_CLASS = {
68
+ 'checkout_flow' => CHECKOUT_CUSTOMIZATION,
69
+ 'checkout_steps' => CHECKOUT_CUSTOMIZATION,
70
+ 'insert_checkout_step' => CHECKOUT_CUSTOMIZATION,
71
+ 'remove_checkout_step' => CHECKOUT_CUSTOMIZATION,
72
+ 'remove_transition' => CHECKOUT_CUSTOMIZATION,
73
+ 'go_to_state' => CHECKOUT_CUSTOMIZATION,
74
+ 'state_machine' => 'Spree 6 has no state machines. Records move between statuses through workflows.',
75
+ 'multi_search' => SEARCH
76
+ }.freeze
77
+
78
+ VARIANT_AND_PRODUCT = {
79
+ 'price' => 'Prices are per currency: price_in(currency).amount or amount_in(currency).',
80
+ 'default_price' => 'Use price_in(currency).',
81
+ 'currency' => 'Pass the currency you mean to price_in(currency).',
82
+ 'display_price' => CUSTOMER_PRICE,
83
+ 'display_amount' => CUSTOMER_PRICE,
84
+ 'display_compare_at_price' => 'Use price_in(currency).display_compare_at_amount.',
85
+ 'price_including_vat_for' => 'Use price_in(currency).amount: prices are charged as entered.',
86
+ 'has_default_price?' => 'Use prices.base_prices.exists?(currency: currency).',
87
+ 'default_image' => PRIMARY_MEDIA,
88
+ 'primary_image' => PRIMARY_MEDIA
89
+ }.freeze
90
+
91
+ REPORTS = 'Use reporting queries for aggregates, or a Spree::Export subclass for CSV rows.'.freeze
92
+
93
+ # Removed APIs by the release that removed them.
94
+ REMOVED = {
95
+ '6.0' => {
96
+ # Checkout, orders and carts
97
+ **expand(%w[Spree::Order Spree::Cart], '#', ORDER_AND_CART),
98
+ **expand(%w[Spree::Order Spree::Cart], '.', ORDER_AND_CART_CLASS),
99
+ 'Spree::Order#line_item_adjustments' => 'Use line_item_tax_lines and line_item_discounts.',
100
+ 'Spree::Order#shipment_adjustments' => 'Use fulfillment_tax_lines and fulfillment_discounts.',
101
+ **expand(%w[Spree::Order], '#', %w[return_authorizations customer_returns reimbursements].index_with(RETURNS)),
102
+ 'Spree::Order::Checkout' => CHECKOUT_CUSTOMIZATION,
103
+ 'Spree::OrderContents' => 'Change cart items with Spree.cart_add_item_workflow or Spree::Dependencies.cart_upsert_items_workflow.',
104
+ 'Spree::Adjustment' => 'Adjustments are typed rows: Spree::TaxLine, Spree::Discount and Spree::Fee.',
105
+ 'Spree::LineItem#adjustments' => ADJUSTMENTS,
106
+ 'Spree::Fulfillment#adjustments' => ADJUSTMENTS,
107
+ 'Spree::StateChange' => STATE_CHANGES,
108
+ 'Spree::LogEntry' => STATE_CHANGES,
109
+ 'Spree::Payment#state_changes' => STATE_CHANGES,
110
+ 'Spree::Payment#log_entries' => STATE_CHANGES,
111
+ 'Spree::Fulfillment#state_changes' => STATE_CHANGES,
112
+
113
+ # Returns
114
+ 'Spree::ReturnAuthorization' => 'Use Spree::Return, or Spree::Exchange when different items go out.',
115
+ 'Spree::CustomerReturn' => 'Use Spree::Return: receiving is a status on the same record.',
116
+ 'Spree::Reimbursement' => 'Refund a return with the Spree::Returns::Refund workflow.',
117
+ 'Spree::ReimbursementType' => 'Refund a return with the Spree::Returns::Refund workflow.',
118
+ 'Spree::ReturnItem' => 'Use Spree::ReturnLineItem, Spree::ExchangeLineItem or Spree::ClaimLineItem.',
119
+
120
+ # Catalog and prices
121
+ **expand(%w[Spree::Variant Spree::Product], '#', VARIANT_AND_PRODUCT),
122
+ 'Spree::Variant#price=' => 'Use set_price(currency, amount).',
123
+ 'Spree::Variant#compare_at_price=' => 'Use set_price(currency, amount, compare_at_amount).',
124
+ 'Spree::Product#price=' => 'Set prices on a variant: default_variant.set_price(currency, amount).',
125
+ 'Spree::Product#compare_at_price=' => 'Set prices on a variant: default_variant.set_price(currency, amount, compare_at_amount).',
126
+ 'Spree::Product#featured_image' => PRIMARY_MEDIA,
127
+ 'Spree::DefaultPrice' => 'Use variant.price_in(currency) and variant.set_price(currency, amount).',
128
+ 'Spree::VatPriceCalculation' => 'Use price_in(currency).amount: prices include tax per market.',
129
+ 'Spree::Product.with_option' => 'Use with_option_value(option, value).',
130
+ **expand(%w[Spree::Product], '.', %w[in_name in_name_or_keywords in_name_or_description].index_with(SEARCH)),
131
+ 'Spree::Product.with_ids' => 'Use where(id: ids).',
132
+ 'Spree::Product.add_search_scope' => 'Declare a plain Active Record scope. To filter by it through the Admin API (q[...]), ' \
133
+ 'also register it with Spree.ransack.add_scope(Spree::Product, :scope_name).',
134
+ **expand(%w[Spree::Product Spree::Variant], '.', { 'multi_search' => SEARCH }),
135
+ 'Spree::OptionType#color?' => 'Use color_swatch?.',
136
+ 'Spree::Category#set_store' => 'Nothing to call: a new category gets its store from its parent or the current store when it is saved.',
137
+ 'Spree::Category.for_taxonomy' => 'Use for_store(taxonomy.store). It returns every category in that store, not one taxonomy.',
138
+
139
+ # Stores, addresses, users and permissions
140
+ 'Spree::Store#admin_users' => 'Use users.',
141
+ 'Spree::Store#supported_shipping_zones' => 'Use countries_with_shipping_coverage.',
142
+ 'Spree::Address#user_default_billing?' => 'Use is_default_billing?.',
143
+ 'Spree::Address#user_default_shipping?' => 'Use is_default_shipping?.',
144
+ 'Spree.searcher_class' => 'Use Spree.search_provider.',
145
+ 'Spree::PermittedAttributes' => 'Add writable API attributes with Spree::Product.additional_permitted_attributes += [...] ' \
146
+ 'inside Rails.application.config.to_prepare (any model; always +=).',
147
+ 'Spree::Preference' => 'Preferences live on each model in a JSON preferences column.',
148
+ 'Spree::User' => 'Use Spree.customer_class for customers and Spree.admin_user_class for staff.',
149
+
150
+ # Services and screens that are gone
151
+ 'Spree::PromotionHandler::Page' => 'Apply the promotion with a coupon code, or make it automatic.',
152
+ 'Spree::Carts::Empty' => 'Remove items through the Store API cart items endpoints, or delete the cart with Spree.cart_destroy_service.',
153
+ 'Spree::Payments::Create' => 'Use the Store API payments endpoint, Spree::StoreCredits::Apply or Spree.gift_card_apply_workflow.',
154
+ 'Spree::Report' => REPORTS,
155
+ 'Spree::ReportLineItem' => REPORTS,
156
+ 'Spree::ImageMethods' => 'Use Active Storage variants with cdn_image_url.',
157
+ 'Spree::Frontend' => 'The Rails storefront is gone. Build the storefront on the Store API (/api/v3/store), ' \
158
+ 'for example with the Next.js storefront and @spree/sdk.',
159
+ 'Spree::Backend' => 'The Rails admin is gone. The back office is the React Admin Dashboard on the Admin API (/api/v3/admin); ' \
160
+ 'extend it with dashboard plugins.',
161
+ 'Spree::Api::V2' => 'API v2 is gone. Use the Store API (/api/v3/store) or the Admin API (/api/v3/admin).'
162
+ }.freeze
163
+ }.freeze
164
+
165
+ module_function
166
+
167
+ # @param error [NameError]
168
+ # @return [String, nil] the hint for a removed Spree API, or nil
169
+ def hint_for(error)
170
+ key = lookup(error)
171
+ return unless key
172
+
173
+ version, entries = REMOVED.find { |_release, removed| removed.key?(key) }
174
+ "Spree #{version} removed #{key}. #{entries[key]}\nUpgrade guide: #{UPGRADE_GUIDES.fetch(version)}"
175
+ rescue StandardError
176
+ nil
177
+ end
178
+
179
+ def known?(key)
180
+ REMOVED.each_value.any? { |entries| entries.key?(key) }
181
+ end
182
+
183
+ # A receiverless call (`state` inside an Order decorator) raises a plain
184
+ # NameError, so only a capitalized name is treated as a constant.
185
+ def lookup(error)
186
+ name = error.name.to_s
187
+ receiver = error.receiver
188
+
189
+ if error.is_a?(NoMethodError) || !name.match?(/\A[A-Z]/)
190
+ method_lookup(receiver, name)
191
+ elsif receiver.is_a?(Module)
192
+ constant_lookup(receiver, name)
193
+ end
194
+ end
195
+
196
+ def method_lookup(receiver, name)
197
+ if receiver.is_a?(Module)
198
+ ancestor_lookup(receiver, ".#{name}")
199
+ elsif defined?(ActiveRecord::Relation) && receiver.is_a?(ActiveRecord::Relation)
200
+ ancestor_lookup(receiver.klass, ".#{name}")
201
+ else
202
+ ancestor_lookup(receiver.class, "##{name}")
203
+ end
204
+ end
205
+
206
+ def ancestor_lookup(klass, suffix)
207
+ klass.ancestors.each do |ancestor|
208
+ key = "#{ancestor.name}#{suffix}"
209
+ return key if known?(key)
210
+ end
211
+ nil
212
+ end
213
+
214
+ # Code written directly inside the Spree namespace (`module Spree; module
215
+ # OrderDecorator`) reports its own module as the receiver of a missing
216
+ # constant, so 'Spree::OrderDecorator::Adjustment' also tries 'Spree::Adjustment'.
217
+ # Deeper namespaces don't, so a missing Spree::Reporting::Report is not
218
+ # mistaken for the removed Spree::Report.
219
+ def constant_lookup(receiver, name)
220
+ candidates = receiver == Object ? [name] : ["#{receiver.name}::#{name}"]
221
+ candidates << "Spree::#{name}" if receiver.name.to_s.match?(/\ASpree::\w+\z/)
222
+ candidates.find { |candidate| known?(candidate) }
223
+ end
224
+
225
+ # @return [String] the documentation page listing every removed API
226
+ def to_mdx
227
+ sections = REMOVED.map do |version, entries|
228
+ rows = entries.map { |key, replacement| "| `#{key}` | #{replacement} |" }
229
+ <<~MARKDOWN
230
+ ## Removed in Spree #{version}
231
+
232
+ See the [upgrade guide](#{UPGRADE_GUIDES.fetch(version)}) for the reasons behind each change.
233
+
234
+ | Removed | Use instead |
235
+ | --- | --- |
236
+ #{rows.join("\n")}
237
+ MARKDOWN
238
+ end
239
+
240
+ <<~MARKDOWN
241
+ ---
242
+ title: Removed Ruby APIs
243
+ description: Ruby classes and methods removed from Spree, and what replaced each one.
244
+ ---
245
+
246
+ Code written for an older Spree release, or by a coding agent working from old examples, may call one of these APIs. It fails with a `NoMethodError` or `NameError`, and Ruby, the Rails console, RSpec and the Rails log add the replacement below to that error.
247
+
248
+ APIs that still work but print a deprecation warning are not listed here. They are in the upgrade guide for the release that deprecated them.
249
+
250
+ #{sections.join("\n")}
251
+ MARKDOWN
252
+ end
253
+
254
+ # Logs the hint for an error Rails reports, such as an unhandled error in
255
+ # a request or a job, so it appears in the Rails log next to the error.
256
+ class ErrorSubscriber
257
+ def report(error, **)
258
+ hint = Spree::RemovedApis.hint_for(error) if error.is_a?(NameError)
259
+ Rails.logger&.warn(hint) if hint
260
+ end
261
+ end
262
+
263
+ # Prepended to NameError (and so NoMethodError).
264
+ module ErrorHint
265
+ def detailed_message(**)
266
+ message = super
267
+ hint = Spree::RemovedApis.hint_for(self)
268
+ hint ? "#{message}\n\n#{hint}" : message
269
+ end
270
+ end
271
+ end
272
+ end
273
+
274
+ NameError.prepend(Spree::RemovedApis::ErrorHint)
@@ -443,7 +443,7 @@ module Spree
443
443
  dimension :payment_status, base: :orders, column: :payment_status,
444
444
  values: -> { Spree::Order::PAYMENT_STATUSES }
445
445
  # The rollup values Orders::UpdateStatuses writes today; the model
446
- # constant still carries the legacy machine states until 6.1.
446
+ # constant still carries the legacy machine states until 6.3.
447
447
  dimension :fulfillment_status, base: :orders, column: :fulfillment_status,
448
448
  values: -> { %w[backorder canceled partial unfulfilled fulfilled delivered] }
449
449
 
@@ -8,6 +8,6 @@ FactoryBot.define do
8
8
  variant
9
9
  end
10
10
 
11
- # @deprecated Use :digital_asset; removed in 6.1.
11
+ # @deprecated Use :digital_asset; removed in 6.3.
12
12
  factory :digital, parent: :digital_asset
13
13
  end
@@ -1,5 +1,5 @@
1
1
  FactoryBot.define do
2
- # :stock_item is the pre-6.0 name, kept for one release so host-app factories
2
+ # :stock_item is the pre-6.0 name, kept until 6.3 so host-app factories
3
3
  # and specs written against it keep working.
4
4
  factory :stock_level, class: Spree::StockLevel, aliases: [:stock_item] do
5
5
  backorderable { true }
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  # @deprecated Use :category. Kept so existing extension and application suites
3
- # keep passing through the 6.0 rename; removed in 6.1 with Spree::Taxon.
3
+ # keep passing through the 6.0 rename; removed in 6.3 with Spree::Taxon.
4
4
  #
5
5
  # A category is store-owned via store_id, so this creates no taxonomy. Callers
6
6
  # that need a legacy taxonomy-backed row pass `taxonomy:` explicitly.
@@ -1,5 +1,5 @@
1
1
  FactoryBot.define do
2
- # @deprecated Taxonomy is data-only in 6.0 and dropped in 6.1. Retained for the
2
+ # @deprecated Taxonomy is data-only in 6.0 and dropped in 6.3. Retained for the
3
3
  # upgrade-path specs. The root category is created here because the model no
4
4
  # longer manages one.
5
5
  factory :taxonomy, class: Spree::Taxonomy do
@@ -4,7 +4,7 @@ FactoryBot.define do
4
4
  wishlist
5
5
  end
6
6
 
7
- # Renamed in 6.0; the old name is kept for one release so extension suites
7
+ # Renamed in 6.0; the old name is kept until 6.3 so extension suites
8
8
  # keep building.
9
9
  factory :wished_item, parent: :wishlist_item
10
10
  end
@@ -1,3 +1,8 @@
1
1
  # Deprecated: Spree's specs now catch missing keys through Rails'
2
- # config.i18n.raise_on_missing_translations. Removed in Spree 6.1.
3
- Spree::Deprecation.warn("spree/testing_support/i18n is deprecated and does nothing; set config.i18n.raise_on_missing_translations = true in your test environment instead. It will be removed in Spree 6.1.") if defined?(Spree::Deprecation)
2
+ # config.i18n.raise_on_missing_translations. Removed in Spree 6.3.
3
+ if defined?(Spree::Deprecation)
4
+ Spree::Deprecation.warn(
5
+ 'spree/testing_support/i18n is deprecated and does nothing; set config.i18n.raise_on_missing_translations = true in your test environment ' \
6
+ 'instead. It will be removed in Spree 6.3.'
7
+ )
8
+ end
@@ -2,13 +2,16 @@
2
2
  # every step BEFORE the given one satisfied (matching the legacy contract
3
3
  # where `up_to(:delivery)` had completed the address step). `up_to(:complete)`
4
4
  # runs the real completion pipeline and returns the resulting Spree::Order.
5
- # @deprecated Removed in Spree 6.1 — build checkout state with the factories
5
+ # @deprecated Removed in Spree 6.3 — build checkout state with the factories
6
6
  # instead: create(:cart_ready_for_delivery) (address + delivery proposals),
7
7
  # create(:cart_ready_to_complete) (payment-covered), or
8
8
  # create(:completed_order_with_totals) for a placed order.
9
9
  class OrderWalkthrough
10
10
  def self.up_to(state, store = nil)
11
- Spree::Deprecation.warn('OrderWalkthrough is deprecated and will be removed in Spree 6.1. Use the cart factories instead: :cart_ready_for_delivery, :cart_ready_to_complete, or :completed_order_with_totals.')
11
+ Spree::Deprecation.warn(
12
+ 'OrderWalkthrough is deprecated and will be removed in Spree 6.3. ' \
13
+ 'Use the cart factories instead: :cart_ready_for_delivery, :cart_ready_to_complete, or :completed_order_with_totals.'
14
+ )
12
15
  store ||= Spree::Store.default
13
16
 
14
17
  # A payment method must exist for checkout to proceed