solidus_core 2.11.17 → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree.js.erb +0 -51
  3. data/app/helpers/spree/store_helper.rb +0 -11
  4. data/app/mailers/spree/carton_mailer.rb +1 -5
  5. data/app/models/concerns/spree/active_storage_adapter/attachment.rb +11 -13
  6. data/app/models/concerns/spree/active_storage_adapter.rb +0 -2
  7. data/app/models/concerns/spree/adjustment_source.rb +0 -15
  8. data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
  9. data/app/models/concerns/spree/soft_deletable.rb +2 -4
  10. data/app/models/concerns/spree/user_address_book.rb +0 -37
  11. data/app/models/concerns/spree/user_methods.rb +2 -11
  12. data/app/models/spree/ability.rb +0 -37
  13. data/app/models/spree/address/name.rb +2 -20
  14. data/app/models/spree/address.rb +8 -187
  15. data/app/models/spree/adjustment.rb +0 -28
  16. data/app/models/spree/base.rb +12 -48
  17. data/app/models/spree/calculator/flexi_rate.rb +0 -5
  18. data/app/models/spree/calculator.rb +0 -11
  19. data/app/models/spree/country.rb +1 -6
  20. data/app/models/spree/credit_card.rb +0 -27
  21. data/app/models/spree/customer_return.rb +1 -4
  22. data/app/models/spree/image/active_storage_attachment.rb +2 -10
  23. data/app/models/spree/image/paperclip_attachment.rb +1 -1
  24. data/app/models/spree/image.rb +0 -7
  25. data/app/models/spree/inventory_unit.rb +0 -21
  26. data/app/models/spree/line_item.rb +2 -45
  27. data/app/models/spree/log_entry.rb +1 -74
  28. data/app/models/spree/order.rb +4 -137
  29. data/app/models/spree/order_cancellations.rb +4 -24
  30. data/app/models/spree/order_shipping.rb +9 -6
  31. data/app/models/spree/order_updater.rb +2 -11
  32. data/app/models/spree/payment/cancellation.rb +3 -22
  33. data/app/models/spree/payment.rb +0 -3
  34. data/app/models/spree/payment_create.rb +1 -13
  35. data/app/models/spree/payment_method/bogus_credit_card.rb +9 -13
  36. data/app/models/spree/payment_method/credit_card.rb +1 -3
  37. data/app/models/spree/payment_method/simple_bogus_credit_card.rb +4 -4
  38. data/app/models/spree/payment_method.rb +2 -106
  39. data/app/models/spree/product/scopes.rb +0 -27
  40. data/app/models/spree/product.rb +0 -39
  41. data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
  42. data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
  43. data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
  44. data/app/models/spree/promotion/rules/taxon.rb +2 -15
  45. data/app/models/spree/promotion.rb +2 -6
  46. data/app/models/spree/promotion_action.rb +2 -12
  47. data/app/models/spree/promotion_code/batch_builder.rb +0 -14
  48. data/app/models/spree/promotion_code.rb +2 -2
  49. data/app/models/spree/promotion_rule.rb +0 -4
  50. data/app/models/spree/refund.rb +0 -60
  51. data/app/models/spree/reimbursement.rb +3 -41
  52. data/app/models/spree/reimbursement_performer.rb +2 -8
  53. data/app/models/spree/reimbursement_type/credit.rb +1 -4
  54. data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
  55. data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
  56. data/app/models/spree/return_authorization.rb +1 -4
  57. data/app/models/spree/return_item.rb +1 -19
  58. data/app/models/spree/shipment.rb +1 -54
  59. data/app/models/spree/shipping_method.rb +0 -25
  60. data/app/models/spree/shipping_rate.rb +0 -2
  61. data/app/models/spree/state.rb +0 -4
  62. data/app/models/spree/stock/simple_coordinator.rb +1 -20
  63. data/app/models/spree/stock/splitter/base.rb +2 -7
  64. data/app/models/spree/stock_item.rb +1 -7
  65. data/app/models/spree/store.rb +0 -12
  66. data/app/models/spree/store_credit.rb +0 -8
  67. data/app/models/spree/store_credit_category.rb +0 -32
  68. data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
  69. data/app/models/spree/tax_rate.rb +0 -27
  70. data/app/models/spree/taxon/active_storage_attachment.rb +0 -5
  71. data/app/models/spree/taxon/paperclip_attachment.rb +0 -5
  72. data/app/models/spree/taxon.rb +0 -11
  73. data/app/models/spree/user_address.rb +0 -5
  74. data/app/models/spree/variant.rb +2 -46
  75. data/config/locales/en.yml +0 -8
  76. data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
  77. data/lib/generators/solidus/install/install_generator.rb +13 -2
  78. data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
  79. data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
  80. data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
  81. data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
  82. data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
  83. data/lib/spree/app_configuration.rb +6 -89
  84. data/lib/spree/core/class_constantizer.rb +2 -0
  85. data/lib/spree/core/controller_helpers/auth.rb +1 -14
  86. data/lib/spree/core/controller_helpers/order.rb +2 -22
  87. data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
  88. data/lib/spree/core/controller_helpers/pricing.rb +0 -8
  89. data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
  90. data/lib/spree/core/engine.rb +0 -49
  91. data/lib/spree/core/environment_extension.rb +0 -9
  92. data/lib/spree/core/product_filters.rb +0 -40
  93. data/lib/spree/core/role_configuration.rb +0 -14
  94. data/lib/spree/core/search/base.rb +0 -26
  95. data/lib/spree/core/state_machines.rb +2 -11
  96. data/lib/spree/core/validators/email.rb +1 -1
  97. data/lib/spree/core/version.rb +1 -1
  98. data/lib/spree/core.rb +9 -8
  99. data/lib/spree/event/configuration.rb +0 -5
  100. data/lib/spree/event/subscriber.rb +0 -18
  101. data/lib/spree/event/subscriber_registry.rb +3 -1
  102. data/lib/spree/event.rb +0 -31
  103. data/lib/spree/i18n.rb +0 -22
  104. data/lib/spree/money.rb +3 -18
  105. data/lib/spree/permitted_attributes.rb +3 -60
  106. data/lib/spree/testing_support/blacklist_urls.rb +1 -1
  107. data/lib/spree/testing_support/capybara_ext.rb +0 -30
  108. data/lib/spree/testing_support/controller_requests.rb +0 -82
  109. data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
  110. data/lib/spree/testing_support/dummy_app.rb +6 -16
  111. data/lib/spree/testing_support/factories/order_factory.rb +0 -1
  112. data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
  113. data/lib/spree/testing_support/factories/user_factory.rb +0 -6
  114. data/lib/spree/testing_support/order_walkthrough.rb +0 -3
  115. data/lib/spree/testing_support/preferences.rb +0 -25
  116. data/lib/spree/testing_support.rb +1 -1
  117. data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +20 -15
  118. data/solidus_core.gemspec +1 -25
  119. metadata +9 -94
  120. data/app/mailers/spree/test_mailer.rb +0 -13
  121. data/app/models/concerns/spree/user_payment_source.rb +0 -26
  122. data/app/models/spree/calculator/free_shipping.rb +0 -22
  123. data/app/models/spree/calculator/percent_per_item.rb +0 -51
  124. data/app/models/spree/calculator/price_sack.rb +0 -28
  125. data/app/models/spree/gateway/bogus.rb +0 -13
  126. data/app/models/spree/gateway/bogus_simple.rb +0 -13
  127. data/app/models/spree/gateway.rb +0 -14
  128. data/app/models/spree/order/checkout.rb +0 -244
  129. data/app/models/spree/order_capturing.rb +0 -50
  130. data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
  131. data/lib/generators/spree/install/install_generator.rb +0 -15
  132. data/lib/solidus/migrations/rename_gateways.rb +0 -41
  133. data/lib/spree/core/current_store.rb +0 -24
  134. data/lib/spree/paranoia_deprecations.rb +0 -41
  135. data/lib/spree/preferences/persistable.rb +0 -23
  136. data/lib/spree/promo/environment.rb +0 -12
  137. data/lib/spree/testing_support/bar_ability.rb +0 -19
  138. data/lib/spree/testing_support/fixtures/file.txt +0 -1
  139. data/lib/tasks/core.rake +0 -104
  140. data/lib/tasks/email.rake +0 -12
  141. data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
  142. data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
  143. data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
  144. data/lib/tasks/migrations/rename_gateways.rake +0 -23
  145. data/lib/tasks/order_capturing.rake +0 -27
  146. data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/preferences/persistable'
4
3
  require 'spree/preferences/statically_configurable'
5
4
 
6
5
  module Spree
@@ -12,8 +11,6 @@ module Spree
12
11
  # This class is not meant to be instantiated. Please create instances of concrete payment methods.
13
12
  #
14
13
  class PaymentMethod < Spree::Base
15
- include Spree::Preferences::Persistable
16
-
17
14
  preference :server, :string, default: 'test'
18
15
  preference :test_mode, :boolean, default: true
19
16
 
@@ -21,19 +18,6 @@ module Spree
21
18
 
22
19
  acts_as_list
23
20
 
24
- # @private
25
- def self.const_missing(name)
26
- if name == :DISPLAY
27
- Spree::Deprecation.warn(
28
- "#{self}::DISPLAY has been deprecated and will be removed in Solidus v3.",
29
- caller
30
- )
31
- const_set(:DISPLAY, [:both, :front_end, :back_end])
32
- else
33
- super
34
- end
35
- end
36
-
37
21
  validates :name, :type, presence: true
38
22
 
39
23
  has_many :payments, class_name: "Spree::Payment", inverse_of: :payment_method
@@ -70,51 +54,9 @@ module Spree
70
54
  end
71
55
 
72
56
  class << self
73
- # @deprecated Use Spree::Config.environment.payment_methods instead
74
- def providers
75
- Spree::Deprecation.warn 'Spree::PaymentMethod.providers is deprecated and will be deleted in Solidus 3.0. ' \
76
- 'Please use Rails.application.config.spree.payment_methods instead'
77
- Spree::Config.environment.payment_methods
78
- end
79
-
80
- # @deprecated Use {.active}, {.available_to_users}, and {.available_to_admin} scopes instead.
81
- def available(display_on = nil, store: nil)
82
- Spree::Deprecation.warn "Spree::PaymentMethod.available is deprecated."\
83
- "Please use .active, .available_to_users, and .available_to_admin scopes instead."\
84
- "For payment methods associated with a specific store, use Spree::PaymentMethod.available_to_store(your_store)"\
85
- " as the base applying any further filtering"
86
-
87
- display_on = display_on.to_s
88
-
89
- available_payment_methods =
90
- case display_on
91
- when 'front_end'
92
- active.available_to_users
93
- when 'back_end'
94
- active.available_to_admin
95
- else
96
- active.available_to_users.available_to_admin
97
- end
98
- available_payment_methods.select do |payment|
99
- store.nil? || store.payment_methods.empty? || store.payment_methods.include?(payment)
100
- end
101
- end
102
-
103
57
  def model_name
104
58
  ModelName.new(self, Spree)
105
59
  end
106
-
107
- # @deprecated Use .active.any? instead
108
- def active?
109
- Spree::Deprecation.warn "#{self}.active? is deprecated. Use #{self}.active.any? instead"
110
- where(type: to_s, active: true).count > 0
111
- end
112
-
113
- # @deprecated Use .with_discarded.find instead
114
- def find_with_destroyed(*args)
115
- Spree::Deprecation.warn "#{self}.find_with_destroyed is deprecated. Use #{self}.with_discarded.find instead"
116
- unscoped { find(*args) }
117
- end
118
60
  end
119
61
 
120
62
  # Represents the gateway of this payment method
@@ -141,8 +83,6 @@ module Spree
141
83
 
142
84
  @gateway ||= gateway_class.new(gateway_options)
143
85
  end
144
- alias_method :provider, :gateway
145
- deprecate provider: :gateway, deprecator: Spree::Deprecation
146
86
 
147
87
  # Represents all preferences as a Hash
148
88
  #
@@ -162,29 +102,6 @@ module Spree
162
102
  raise ::NotImplementedError, "You must implement payment_source_class method for #{self.class}."
163
103
  end
164
104
 
165
- # @deprecated Use {Spree::PaymentMethod#available_to_users=} and {Spree::PaymentMethod#available_to_admin=} instead
166
- def display_on=(value)
167
- Spree::Deprecation.warn "Spree::PaymentMethod#display_on= is deprecated."\
168
- "Please use #available_to_users= and #available_to_admin= instead."
169
- self.available_to_users = value.blank? || value == 'front_end'
170
- self.available_to_admin = value.blank? || value == 'back_end'
171
- end
172
-
173
- # @deprecated Use {Spree::PaymentMethod#available_to_users} and {Spree::PaymentMethod#available_to_admin} instead
174
- def display_on
175
- Spree::Deprecation.warn "Spree::PaymentMethod#display_on is deprecated."\
176
- "Please use #available_to_users and #available_to_admin instead."
177
- if available_to_users? && available_to_admin?
178
- ''
179
- elsif available_to_users?
180
- 'front_end'
181
- elsif available_to_admin?
182
- 'back_end'
183
- else
184
- 'none'
185
- end
186
- end
187
-
188
105
  # Used as partial name for your payment method
189
106
  #
190
107
  # Currently your payment method needs to provide these partials:
@@ -205,21 +122,7 @@ module Spree
205
122
  # The view that represents your payment method on orders through the api
206
123
  #
207
124
  def partial_name
208
- deprecated_method_type_override || type.demodulize.underscore
209
- end
210
-
211
- # :nodoc:
212
- # If method_type has been overridden, call it and return the value, otherwise return nil
213
- def deprecated_method_type_override
214
- if method(:method_type).owner != Spree::PaymentMethod
215
- Spree::Deprecation.warn "#{method(:method_type).owner} is overriding PaymentMethod#method_type. This is deprecated and will be removed from Solidus 3.0 (override partial_name instead).", caller[1..-1]
216
- method_type
217
- end
218
- end
219
-
220
- def method_type
221
- Spree::Deprecation.warn "method_type is deprecated and will be removed from Solidus 3.0 (use partial_name instead)", caller
222
- partial_name
125
+ type.demodulize.underscore
223
126
  end
224
127
 
225
128
  def payment_profiles_supported?
@@ -277,14 +180,7 @@ module Spree
277
180
  # Represents the gateway class of this payment method
278
181
  #
279
182
  def gateway_class
280
- if respond_to? :provider_class
281
- Spree::Deprecation.warn \
282
- "provider_class is deprecated and will be removed from Solidus 3.0 " \
283
- "(use gateway_class instead)"
284
- public_send :provider_class
285
- else
286
- raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
287
- end
183
+ raise ::NotImplementedError, "You must implement gateway_class method for #{self.class}."
288
184
  end
289
185
  end
290
186
  end
@@ -201,33 +201,6 @@ module Spree
201
201
  where(subquery.arel.exists)
202
202
  end
203
203
 
204
- def self.distinct_by_product_ids(sort_order = nil)
205
- Spree::Deprecation.warn "Product.distinct_by_product_ids is deprecated and should not be used"
206
-
207
- sort_column = sort_order.split(" ").first
208
-
209
- # Postgres will complain when using ordering by expressions not present in
210
- # SELECT DISTINCT. e.g.
211
- #
212
- # PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY
213
- # expressions must appear in select list. e.g.
214
- #
215
- # SELECT DISTINCT "spree_products".* FROM "spree_products" LEFT OUTER JOIN
216
- # "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."is_master" = 't'
217
- # AND "spree_variants"."deleted_at" IS NULL LEFT OUTER JOIN "spree_prices" ON
218
- # "spree_prices"."variant_id" = "spree_variants"."id" AND "spree_prices"."currency" = 'USD'
219
- # AND "spree_prices"."deleted_at" IS NULL WHERE "spree_products"."deleted_at" IS NULL AND ('t'='t')
220
- # ORDER BY "spree_prices"."amount" ASC LIMIT 10 OFFSET 0
221
- #
222
- # Don't allow sort_column, a variable coming from params,
223
- # to be anything but a column in the database
224
- if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' && !column_names.include?(sort_column)
225
- all
226
- else
227
- distinct
228
- end
229
- end
230
-
231
204
  class << self
232
205
  private
233
206
 
@@ -5,10 +5,6 @@ module Spree
5
5
  # variations, called variants. Product properties include description,
6
6
  # permalink, availability, shipping category, etc. that do not change by
7
7
  # variant.
8
- #
9
- # @note this model uses {https://github.com/radar/paranoia paranoia}.
10
- # +#destroy+ will only soft-destroy records and the default scope hides
11
- # soft-destroyed records using +WHERE deleted_at IS NULL+.
12
8
  class Product < Spree::Base
13
9
  extend FriendlyId
14
10
  friendly_id :slug_candidates, use: :history
@@ -89,7 +85,6 @@ module Spree
89
85
  :has_default_price?,
90
86
  :images,
91
87
  :price_for,
92
- :price_in,
93
88
  :rebuild_vat_prices=,
94
89
  to: :find_or_build_master
95
90
 
@@ -186,19 +181,6 @@ module Spree
186
181
  !!discontinue_on&.past?
187
182
  end
188
183
 
189
- # Groups variants by the specified option type.
190
- #
191
- # @deprecated This method is not called in the Solidus codebase
192
- # @param opt_type [String] the name of the option type to group by
193
- # @param pricing_options [Spree::Config.pricing_options_class] the pricing options to search
194
- # for, default: the default pricing options
195
- # @return [Hash] option_type as keys, array of variants as values.
196
- def categorise_variants_from_option(opt_type, pricing_options = Spree::Config.default_pricing_options)
197
- return {} unless option_types.include?(opt_type)
198
- variants.with_prices(pricing_options).group_by { |variant| variant.option_values.detect { |option| option.option_type == opt_type } }
199
- end
200
- deprecate :categorise_variants_from_option, deprecator: Spree::Deprecation
201
-
202
184
  # Poor man's full text search.
203
185
  #
204
186
  # Filters products to those which have any of the strings in +values+ in
@@ -214,17 +196,6 @@ module Spree
214
196
  where conditions.inject(:or)
215
197
  end
216
198
 
217
- # @param current_currency [String] currency to filter variants by; defaults to Spree's default
218
- # @deprecated This method can only handle prices for currencies
219
- # @return [Array<Spree::Variant>] all variants with at least one option value
220
- def variants_and_option_values(current_currency = nil)
221
- variants.includes(:option_values).active(current_currency).select do |variant|
222
- variant.option_values.any?
223
- end
224
- end
225
- deprecate variants_and_option_values: :variants_and_option_values_for,
226
- deprecator: Spree::Deprecation
227
-
228
199
  # @param pricing_options [Spree::Variant::PricingOptions] the pricing options to search
229
200
  # for, default: the default pricing options
230
201
  # @return [Array<Spree::Variant>] all variants with at least one option value
@@ -296,16 +267,6 @@ module Spree
296
267
  end
297
268
  end
298
269
 
299
- # Image that can be used for the product.
300
- #
301
- # Will first search for images on the product, then those belonging to the
302
- # variants. If all else fails, will return a new image object.
303
- # @return [Spree::Image] the image to display
304
- def display_image
305
- Spree::Deprecation.warn('Spree::Product#display_image is DEPRECATED. Choose an image from Spree::Product#gallery instead.')
306
- images.first || variant_images.first || Spree::Image.new
307
- end
308
-
309
270
  # Finds the variant property rule that matches the provided option value ids.
310
271
  #
311
272
  # @param option_value_ids [Array<Integer>] list of option value ids
@@ -39,9 +39,6 @@ module Spree
39
39
  # item_total and ship_total
40
40
  def compute_amount(calculable)
41
41
  amount = calculator.compute(calculable)
42
- if !amount.is_a?(BigDecimal)
43
- Spree::Deprecation.warn "#{calculator.class.name}#compute returned #{amount.inspect}, it should return a BigDecimal"
44
- end
45
42
  amount ||= BigDecimal(0)
46
43
  amount = amount.abs
47
44
  [(calculable.item_total + calculable.ship_total), amount].min * -1
@@ -33,9 +33,6 @@ module Spree
33
33
  order = adjustable.is_a?(Order) ? adjustable : adjustable.order
34
34
  return 0 unless promotion.line_item_actionable?(order, adjustable)
35
35
  promotion_amount = calculator.compute(adjustable)
36
- if !promotion_amount.is_a?(BigDecimal)
37
- Spree::Deprecation.warn "#{calculator.class.name}#compute returned #{promotion_amount.inspect}, it should return a BigDecimal"
38
- end
39
36
  promotion_amount ||= BigDecimal(0)
40
37
  promotion_amount = promotion_amount.abs
41
38
  [adjustable.amount, promotion_amount].min * -1
@@ -57,9 +57,6 @@ module Spree
57
57
  #
58
58
  def compute_amount(line_item)
59
59
  adjustment_amount = calculator.compute(PartialLineItem.new(line_item))
60
- if !adjustment_amount.is_a?(BigDecimal)
61
- Spree::Deprecation.warn "#{calculator.class.name}#compute returned #{adjustment_amount.inspect}, it should return a BigDecimal"
62
- end
63
60
  adjustment_amount ||= BigDecimal(0)
64
61
  adjustment_amount = adjustment_amount.abs
65
62
 
@@ -38,11 +38,7 @@ module Spree
38
38
  eligibility_errors.add(:base, eligibility_error_message(:has_excluded_taxon), error_code: :has_excluded_taxon)
39
39
  end
40
40
  else
41
- # Change this to an exception in a future version of Solidus
42
- warn_invalid_match_policy(assume: 'any')
43
- unless order_taxons.where(id: rule_taxon_ids_with_children).exists?
44
- eligibility_errors.add(:base, eligibility_error_message(:no_matching_taxons), error_code: :no_matching_taxons)
45
- end
41
+ raise "unexpected match policy: #{preferred_match_policy.inspect}"
46
42
  end
47
43
 
48
44
  eligibility_errors.empty?
@@ -60,9 +56,7 @@ module Spree
60
56
  when 'none'
61
57
  !found
62
58
  else
63
- # Change this to an exception in a future version of Solidus
64
- warn_invalid_match_policy(assume: 'any')
65
- found
59
+ raise "unexpected match policy: #{preferred_match_policy.inspect}"
66
60
  end
67
61
  end
68
62
 
@@ -77,13 +71,6 @@ module Spree
77
71
 
78
72
  private
79
73
 
80
- def warn_invalid_match_policy(assume:)
81
- Spree::Deprecation.warn(
82
- "#{self.class.name} id=#{id} has unexpected match policy #{preferred_match_policy.inspect}. "\
83
- "Interpreting it as '#{assume}'."
84
- )
85
- end
86
-
87
74
  # All taxons in an order
88
75
  def taxons_in_order(order)
89
76
  Spree::Taxon.joins(products: { variants_including_master: :line_items })
@@ -38,11 +38,7 @@ module Spree
38
38
 
39
39
  scope :coupons, -> { joins(:codes).distinct }
40
40
  scope :advertised, -> { where(advertise: true) }
41
- scope :active, -> do
42
- return started_and_unexpired if Spree::Config.consider_actionless_promotion_active == true
43
-
44
- has_actions.started_and_unexpired
45
- end
41
+ scope :active, -> { has_actions.started_and_unexpired }
46
42
  scope :started_and_unexpired, -> do
47
43
  table = arel_table
48
44
  time = Time.current
@@ -93,7 +89,7 @@ module Spree
93
89
  end
94
90
 
95
91
  def active?
96
- started? && not_expired? && (Spree::Config.consider_actionless_promotion_active || actions.present?)
92
+ started? && not_expired? && actions.present?
97
93
  end
98
94
 
99
95
  def inactive?
@@ -1,14 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/preferences/persistable'
4
-
5
3
  module Spree
6
4
  # Base class for all types of promotion action.
7
5
  #
8
6
  # PromotionActions perform the necessary tasks when a promotion is activated
9
7
  # by an event and determined to be eligible.
10
8
  class PromotionAction < Spree::Base
11
- include Spree::Preferences::Persistable
12
9
  include Spree::SoftDeletable
13
10
 
14
11
  belongs_to :promotion, class_name: 'Spree::Promotion', inverse_of: :promotion_actions, optional: true
@@ -32,15 +29,8 @@ module Spree
32
29
  #
33
30
  # @param order [Spree::Order] the order to remove the action from
34
31
  # @return [void]
35
- def remove_from(order)
36
- Spree::Deprecation.warn("#{self.class.name.inspect} does not define #remove_from. The default behavior may be incorrect and will be removed in a future version of Solidus.", caller)
37
- [order, *order.line_items, *order.shipments].each do |item|
38
- item.adjustments.each do |adjustment|
39
- if adjustment.source == self
40
- item.adjustments.destroy(adjustment)
41
- end
42
- end
43
- end
32
+ def remove_from(_order)
33
+ raise 'remove_from should be implemented in a sub-class of PromotionAction'
44
34
  end
45
35
 
46
36
  def to_partial_path
@@ -10,20 +10,6 @@ class ::Spree::PromotionCode::BatchBuilder
10
10
  sample_characters: ('a'..'z').to_a + (2..9).to_a.map(&:to_s)
11
11
  }
12
12
 
13
- [:random_code_length, :batch_size, :sample_characters].each do |attr|
14
- define_singleton_method(attr) do
15
- Spree::Deprecation.warn "#{name}.#{attr} is deprecated. Use #{name}::DEFAULT_OPTIONS[:#{attr}] instead"
16
- DEFAULT_OPTIONS[attr]
17
- end
18
-
19
- define_singleton_method(:"#{attr}=") do |val|
20
- Spree::Deprecation.warn "#{name}.#{attr}= is deprecated. Use #{name}::DEFAULT_OPTIONS[:#{attr}]= instead"
21
- DEFAULT_OPTIONS[attr] = val
22
- end
23
-
24
- delegate attr, to: self
25
- end
26
-
27
13
  def initialize(promotion_code_batch, options = {})
28
14
  @promotion_code_batch = promotion_code_batch
29
15
  options.assert_valid_keys(*DEFAULT_OPTIONS.keys)
@@ -5,12 +5,12 @@ class Spree::PromotionCode < Spree::Base
5
5
  belongs_to :promotion_code_batch, class_name: "Spree::PromotionCodeBatch", optional: true
6
6
  has_many :adjustments
7
7
 
8
- before_validation :normalize_code
9
-
10
8
  validates :value, presence: true, uniqueness: { allow_blank: true, case_sensitive: true }
11
9
  validates :promotion, presence: true
12
10
  validate :promotion_not_apply_automatically, on: :create
13
11
 
12
+ before_save :normalize_code
13
+
14
14
  self.whitelisted_ransackable_attributes = ['value']
15
15
 
16
16
  # Whether the promotion code has exceeded its usage restrictions
@@ -1,12 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/preferences/persistable'
4
-
5
3
  module Spree
6
4
  # Base class for all promotion rules
7
5
  class PromotionRule < Spree::Base
8
- include Spree::Preferences::Persistable
9
-
10
6
  belongs_to :promotion, class_name: 'Spree::Promotion', inverse_of: :promotion_rules, optional: true
11
7
 
12
8
  scope :of_type, ->(type) { where(type: type) }
@@ -15,11 +15,6 @@ module Spree
15
15
  validate :amount_is_less_than_or_equal_to_allowed_amount, on: :create
16
16
 
17
17
  attr_reader :perform_response
18
- attr_accessor :perform_after_create
19
-
20
- after_create :set_perform_after_create_default
21
- after_create :perform!
22
- after_create :clear_perform_after_create
23
18
 
24
19
  scope :non_reimbursement, -> { where(reimbursement_id: nil) }
25
20
 
@@ -36,14 +31,6 @@ module Spree
36
31
  end
37
32
  end
38
33
 
39
- # Sets this price's amount to a new value, parsing it if the new value is
40
- # a string.
41
- #
42
- # @param price [String, #to_d] a new amount
43
- def amount=(price)
44
- self[:amount] = Spree::LocalizedNumber.parse(price)
45
- end
46
-
47
34
  def description
48
35
  payment.payment_method.name
49
36
  end
@@ -53,29 +40,14 @@ module Spree
53
40
  # Attempts to perform the refund,
54
41
  # raises an error if the refund fails.
55
42
  def perform!
56
- return true if perform_after_create == false
57
43
  return true if transaction_id.present?
58
44
 
59
- # This is needed otherwise set_perform_after_create_default callback
60
- # will print a deprecation warning when save! creates a record
61
- self.perform_after_create = false unless persisted?
62
-
63
45
  credit_cents = money.cents
64
46
 
65
47
  @perform_response = process!(credit_cents)
66
-
67
- @response = Spree::DeprecatedInstanceVariableProxy.new(
68
- self,
69
- :perform_response,
70
- :@response,
71
- Spree::Deprecation,
72
- "Please, do not use Spree::Refund @response anymore, use Spree::Refund#perform_response"
73
- )
74
-
75
48
  log_entries.build(details: perform_response.to_yaml)
76
49
 
77
50
  self.transaction_id = perform_response.authorization
78
-
79
51
  save!
80
52
 
81
53
  update_order
@@ -83,38 +55,6 @@ module Spree
83
55
 
84
56
  private
85
57
 
86
- # This callback takes care of setting the behavior that determines if it is needed
87
- # to execute the perform! callback after_create.
88
- # Existing code that creates refund without explicitely passing
89
- #
90
- # perform_after_create: false
91
- #
92
- # as attribute will still call perform! but a deprecation warning is emitted in order
93
- # to ask users to change their code with the new supported behavior.
94
- def set_perform_after_create_default
95
- return true if perform_after_create == false
96
-
97
- Spree::Deprecation.warn <<-WARN.strip_heredoc, caller
98
- From Solidus v3.0 onwards, #perform! will need to be explicitly called when creating new
99
- refunds. Please, change your code from:
100
-
101
- Spree::Refund.create(your: attributes)
102
-
103
- to:
104
-
105
- Spree::Refund.create(your: attributes, perform_after_create: false).perform!
106
- WARN
107
-
108
- self.perform_after_create = true
109
- end
110
-
111
- # This is needed to avoid that when you create a refund with perform_after_create = false,
112
- # it's not possibile to call perform! on that instance, since the value of this attribute
113
- # will remain false until a reload of the instance.
114
- def clear_perform_after_create
115
- @perform_after_create = nil
116
- end
117
-
118
58
  # return an activemerchant response object if successful or else raise an error
119
59
  def process!(credit_cents)
120
60
  response = if payment.payment_method.payment_profiles_supported?
@@ -51,14 +51,6 @@ module Spree
51
51
  class_attribute :reimbursement_performer
52
52
  self.reimbursement_performer = ReimbursementPerformer
53
53
 
54
- # These are called if the call to "reimburse!" succeeds.
55
- class_attribute :reimbursement_success_hooks
56
- self.reimbursement_success_hooks = []
57
-
58
- # These are called if the call to "reimburse!" fails.
59
- class_attribute :reimbursement_failure_hooks
60
- self.reimbursement_failure_hooks = []
61
-
62
54
  include ::Spree::Config.state_machines.reimbursement
63
55
 
64
56
  class << self
@@ -91,10 +83,7 @@ module Spree
91
83
  total - paid_amount
92
84
  end
93
85
 
94
- def perform!(created_by: nil)
95
- unless created_by
96
- Spree::Deprecation.warn("Calling #perform on #{self} without created_by is deprecated")
97
- end
86
+ def perform!(created_by:)
98
87
  reimbursement_tax_calculator.call(self)
99
88
  reload
100
89
  update!(total: calculated_total)
@@ -104,21 +93,9 @@ module Spree
104
93
  if unpaid_amount_within_tolerance?
105
94
  reimbursed!
106
95
  Spree::Event.fire 'reimbursement_reimbursed', reimbursement: self
107
- if reimbursement_success_hooks.any?
108
- Spree::Deprecation.warn \
109
- "reimbursement_success_hooks are deprecated. Please remove them " \
110
- "and subscribe to `reimbursement_reimbursed` event instead", caller(1)
111
- end
112
- reimbursement_success_hooks.each { |hook| hook.call self }
113
96
  else
114
97
  errored!
115
98
  Spree::Event.fire 'reimbursement_errored', reimbursement: self
116
- if reimbursement_failure_hooks.any?
117
- Spree::Deprecation.warn \
118
- "reimbursement_failure_hooks are deprecated. Please remove them " \
119
- "and subscribe to `reimbursement_errored` event instead", caller(1)
120
- end
121
- reimbursement_failure_hooks.each { |hook| hook.call self }
122
99
  end
123
100
 
124
101
  if errored?
@@ -126,10 +103,7 @@ module Spree
126
103
  end
127
104
  end
128
105
 
129
- def simulate(created_by: nil)
130
- unless created_by
131
- Spree::Deprecation.warn("Calling #simulate on #{self} without created_by is deprecated")
132
- end
106
+ def simulate(created_by:)
133
107
  reimbursement_simulator_tax_calculator.call(self)
134
108
  reload
135
109
  update!(total: calculated_total)
@@ -154,10 +128,7 @@ module Spree
154
128
  # @api public
155
129
  # @param [Spree.user_class] created_by the user that is performing this action
156
130
  # @return [void]
157
- def return_all(created_by: nil)
158
- unless created_by
159
- Spree::Deprecation.warn("Calling #return_all on #{self} without created_by is deprecated")
160
- end
131
+ def return_all(created_by:)
161
132
  return_items.each(&:accept!)
162
133
  save!
163
134
  perform!(created_by: created_by)
@@ -168,15 +139,6 @@ module Spree
168
139
  #
169
140
  # @return [Spree::StoreCreditCategory]
170
141
  def store_credit_category
171
- if Spree::Config.use_legacy_store_credit_reimbursement_category_name
172
- Spree::Deprecation.warn("Using the legacy reimbursement_category_name is deprecated. "\
173
- "Set Spree::Config.use_legacy_store_credit_reimbursement_category_name to false to use "\
174
- "the new version instead.", caller)
175
-
176
- name = Spree::StoreCreditCategory.reimbursement_category_name
177
- return Spree::StoreCreditCategory.find_by(name: name) || Spree::StoreCreditCategory.first
178
- end
179
-
180
142
  Spree::StoreCreditCategory.find_by(name: Spree::StoreCreditCategory::REIMBURSEMENT)
181
143
  end
182
144
 
@@ -11,18 +11,12 @@ module Spree
11
11
  # - #description
12
12
  # - #display_amount
13
13
  # so they can be displayed in the Admin UI appropriately.
14
- def simulate(reimbursement, created_by: nil)
15
- unless created_by
16
- Spree::Deprecation.warn("Calling #simulate on #{self} without created_by is deprecated")
17
- end
14
+ def simulate(reimbursement, created_by:)
18
15
  execute(reimbursement, true, created_by: created_by)
19
16
  end
20
17
 
21
18
  # Actually perform the reimbursement
22
- def perform(reimbursement, created_by: nil)
23
- unless created_by
24
- Spree::Deprecation.warn("Calling #perform on #{self} without created_by is deprecated")
25
- end
19
+ def perform(reimbursement, created_by:)
26
20
  execute(reimbursement, false, created_by: created_by)
27
21
  end
28
22
 
@@ -5,10 +5,7 @@ module Spree
5
5
  extend Spree::ReimbursementType::ReimbursementHelpers
6
6
 
7
7
  class << self
8
- def reimburse(reimbursement, return_items, simulate, created_by: nil)
9
- unless created_by
10
- Spree::Deprecation.warn("Calling #reimburse on #{self} without created_by is deprecated")
11
- end
8
+ def reimburse(reimbursement, return_items, simulate, created_by:)
12
9
  unpaid_amount = return_items.sum(&:total).round(2, :down)
13
10
  reimbursement_list, _unpaid_amount = create_credits(reimbursement, unpaid_amount, simulate, created_by: created_by)
14
11
  reimbursement_list
@@ -34,8 +34,7 @@ module Spree
34
34
  refund = reimbursement.refunds.build({
35
35
  payment: payment,
36
36
  amount: amount,
37
- reason: Spree::RefundReason.return_processing_reason,
38
- perform_after_create: false
37
+ reason: Spree::RefundReason.return_processing_reason
39
38
  })
40
39
 
41
40
  if simulate