solidus_core 2.11.1 → 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 (198) 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/adjustment_source.rb +0 -15
  6. data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
  7. data/app/models/concerns/spree/soft_deletable.rb +2 -4
  8. data/app/models/concerns/spree/user_address_book.rb +0 -37
  9. data/app/models/concerns/spree/user_methods.rb +2 -11
  10. data/app/models/spree/ability.rb +0 -37
  11. data/app/models/spree/address.rb +7 -162
  12. data/app/models/spree/address/name.rb +2 -20
  13. data/app/models/spree/adjustment.rb +0 -28
  14. data/app/models/spree/base.rb +1 -12
  15. data/app/models/spree/calculator.rb +4 -11
  16. data/app/models/spree/calculator/flexi_rate.rb +0 -5
  17. data/app/models/spree/country.rb +1 -6
  18. data/app/models/spree/credit_card.rb +0 -27
  19. data/app/models/spree/customer_return.rb +1 -4
  20. data/app/models/spree/image.rb +0 -7
  21. data/app/models/spree/inventory_unit.rb +0 -21
  22. data/app/models/spree/line_item.rb +2 -45
  23. data/app/models/spree/order.rb +3 -136
  24. data/app/models/spree/order/payments.rb +2 -2
  25. data/app/models/spree/order_cancellations.rb +4 -24
  26. data/app/models/spree/order_merger.rb +1 -1
  27. data/app/models/spree/order_updater.rb +2 -11
  28. data/app/models/spree/payment.rb +10 -6
  29. data/app/models/spree/payment/cancellation.rb +3 -22
  30. data/app/models/spree/payment_create.rb +1 -13
  31. data/app/models/spree/payment_method.rb +2 -103
  32. data/app/models/spree/payment_method/credit_card.rb +1 -3
  33. data/app/models/spree/payment_source.rb +2 -2
  34. data/app/models/spree/product.rb +8 -41
  35. data/app/models/spree/product/scopes.rb +0 -28
  36. data/app/models/spree/promotion.rb +2 -6
  37. data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
  38. data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
  39. data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
  40. data/app/models/spree/promotion/rules/taxon.rb +2 -15
  41. data/app/models/spree/promotion_action.rb +2 -9
  42. data/app/models/spree/promotion_code/batch_builder.rb +0 -14
  43. data/app/models/spree/refund.rb +3 -47
  44. data/app/models/spree/reimbursement.rb +3 -41
  45. data/app/models/spree/reimbursement_performer.rb +2 -8
  46. data/app/models/spree/reimbursement_type/credit.rb +1 -4
  47. data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
  48. data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
  49. data/app/models/spree/return_authorization.rb +1 -4
  50. data/app/models/spree/return_item.rb +1 -19
  51. data/app/models/spree/shipment.rb +1 -54
  52. data/app/models/spree/shipping_method.rb +1 -26
  53. data/app/models/spree/shipping_rate.rb +0 -2
  54. data/app/models/spree/state.rb +0 -4
  55. data/app/models/spree/stock/availability_validator.rb +2 -2
  56. data/app/models/spree/stock/inventory_validator.rb +2 -2
  57. data/app/models/spree/stock/simple_coordinator.rb +0 -14
  58. data/app/models/spree/stock/splitter/base.rb +2 -7
  59. data/app/models/spree/stock_item.rb +1 -7
  60. data/app/models/spree/store.rb +0 -12
  61. data/app/models/spree/store_credit_category.rb +0 -32
  62. data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
  63. data/app/models/spree/tax_rate.rb +0 -27
  64. data/app/models/spree/taxon.rb +0 -11
  65. data/app/models/spree/taxon/active_storage_attachment.rb +0 -6
  66. data/app/models/spree/taxon/paperclip_attachment.rb +0 -4
  67. data/app/models/spree/user_address.rb +0 -5
  68. data/app/models/spree/variant.rb +1 -45
  69. data/config/locales/en.yml +0 -8
  70. data/db/migrate/20210122110141_add_name_to_spree_addresses.rb +13 -0
  71. data/lib/generators/solidus/install/install_generator.rb +12 -1
  72. data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
  73. data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
  74. data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
  75. data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
  76. data/lib/generators/spree/dummy/templates/rails/test.rb +6 -1
  77. data/lib/spree/app_configuration.rb +7 -66
  78. data/lib/spree/core.rb +10 -12
  79. data/lib/spree/core/class_constantizer.rb +2 -0
  80. data/lib/spree/core/controller_helpers/auth.rb +1 -14
  81. data/lib/spree/core/controller_helpers/order.rb +2 -22
  82. data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
  83. data/lib/spree/core/controller_helpers/pricing.rb +0 -8
  84. data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
  85. data/lib/spree/core/engine.rb +6 -42
  86. data/lib/spree/core/environment_extension.rb +0 -9
  87. data/lib/spree/core/product_filters.rb +0 -40
  88. data/lib/spree/core/role_configuration.rb +0 -14
  89. data/lib/spree/core/search/base.rb +0 -26
  90. data/lib/spree/core/state_machines.rb +2 -11
  91. data/lib/spree/core/version.rb +1 -1
  92. data/lib/spree/event.rb +0 -31
  93. data/lib/spree/event/configuration.rb +0 -5
  94. data/lib/spree/event/subscriber.rb +0 -18
  95. data/lib/spree/event/subscriber_registry.rb +3 -1
  96. data/lib/spree/i18n.rb +0 -22
  97. data/lib/spree/money.rb +3 -18
  98. data/lib/spree/permitted_attributes.rb +2 -53
  99. data/lib/spree/testing_support.rb +31 -0
  100. data/lib/spree/testing_support/capybara_ext.rb +0 -30
  101. data/lib/spree/testing_support/controller_requests.rb +0 -82
  102. data/lib/spree/testing_support/dummy_app.rb +10 -16
  103. data/lib/spree/testing_support/dummy_app/mailer_previews/test_mailer_preview.rb +4 -0
  104. data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
  105. data/lib/spree/testing_support/factories.rb +8 -4
  106. data/lib/spree/testing_support/factories/address_factory.rb +6 -2
  107. data/lib/spree/testing_support/factories/adjustment_factory.rb +10 -5
  108. data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +5 -0
  109. data/lib/spree/testing_support/factories/calculator_factory.rb +5 -0
  110. data/lib/spree/testing_support/factories/carton_factory.rb +7 -2
  111. data/lib/spree/testing_support/factories/country_factory.rb +5 -0
  112. data/lib/spree/testing_support/factories/credit_card_factory.rb +5 -0
  113. data/lib/spree/testing_support/factories/customer_return_factory.rb +8 -3
  114. data/lib/spree/testing_support/factories/image_factory.rb +5 -0
  115. data/lib/spree/testing_support/factories/inventory_unit_factory.rb +9 -4
  116. data/lib/spree/testing_support/factories/line_item_factory.rb +7 -2
  117. data/lib/spree/testing_support/factories/option_type_factory.rb +8 -0
  118. data/lib/spree/testing_support/factories/option_value_factory.rb +5 -0
  119. data/lib/spree/testing_support/factories/order_factory.rb +11 -7
  120. data/lib/spree/testing_support/factories/order_promotion_factory.rb +7 -2
  121. data/lib/spree/testing_support/factories/payment_factory.rb +9 -4
  122. data/lib/spree/testing_support/factories/payment_method_factory.rb +5 -0
  123. data/lib/spree/testing_support/factories/price_factory.rb +6 -1
  124. data/lib/spree/testing_support/factories/product_factory.rb +10 -5
  125. data/lib/spree/testing_support/factories/product_option_type_factory.rb +7 -2
  126. data/lib/spree/testing_support/factories/product_property_factory.rb +7 -2
  127. data/lib/spree/testing_support/factories/promotion_category_factory.rb +5 -0
  128. data/lib/spree/testing_support/factories/promotion_code_factory.rb +7 -2
  129. data/lib/spree/testing_support/factories/promotion_factory.rb +7 -2
  130. data/lib/spree/testing_support/factories/property_factory.rb +5 -0
  131. data/lib/spree/testing_support/factories/refund_factory.rb +7 -3
  132. data/lib/spree/testing_support/factories/refund_reason_factory.rb +5 -0
  133. data/lib/spree/testing_support/factories/reimbursement_factory.rb +6 -1
  134. data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +5 -0
  135. data/lib/spree/testing_support/factories/return_authorization_factory.rb +8 -3
  136. data/lib/spree/testing_support/factories/return_item_factory.rb +8 -3
  137. data/lib/spree/testing_support/factories/return_reason_factory.rb +5 -0
  138. data/lib/spree/testing_support/factories/role_factory.rb +5 -0
  139. data/lib/spree/testing_support/factories/shipment_factory.rb +9 -3
  140. data/lib/spree/testing_support/factories/shipping_category_factory.rb +5 -0
  141. data/lib/spree/testing_support/factories/shipping_method_factory.rb +8 -3
  142. data/lib/spree/testing_support/factories/shipping_rate_factory.rb +7 -2
  143. data/lib/spree/testing_support/factories/state_factory.rb +7 -1
  144. data/lib/spree/testing_support/factories/stock_item_factory.rb +7 -2
  145. data/lib/spree/testing_support/factories/stock_location_factory.rb +8 -3
  146. data/lib/spree/testing_support/factories/stock_movement_factory.rb +6 -1
  147. data/lib/spree/testing_support/factories/stock_package_factory.rb +7 -2
  148. data/lib/spree/testing_support/factories/store_credit_category_factory.rb +5 -0
  149. data/lib/spree/testing_support/factories/store_credit_event_factory.rb +7 -2
  150. data/lib/spree/testing_support/factories/store_credit_factory.rb +8 -3
  151. data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +5 -0
  152. data/lib/spree/testing_support/factories/store_credit_type_factory.rb +5 -0
  153. data/lib/spree/testing_support/factories/store_factory.rb +6 -1
  154. data/lib/spree/testing_support/factories/tax_category_factory.rb +7 -1
  155. data/lib/spree/testing_support/factories/tax_rate_factory.rb +8 -3
  156. data/lib/spree/testing_support/factories/taxon_factory.rb +6 -1
  157. data/lib/spree/testing_support/factories/taxonomy_factory.rb +5 -0
  158. data/lib/spree/testing_support/factories/user_factory.rb +8 -3
  159. data/lib/spree/testing_support/factories/variant_factory.rb +9 -4
  160. data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +7 -2
  161. data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +8 -3
  162. data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +7 -2
  163. data/lib/spree/testing_support/factories/zone_factory.rb +7 -2
  164. data/lib/spree/testing_support/factory_bot.rb +68 -0
  165. data/lib/spree/testing_support/order_walkthrough.rb +10 -13
  166. data/lib/spree/testing_support/preferences.rb +0 -25
  167. data/lib/spree/testing_support/sequences.rb +4 -1
  168. data/{app/models → lib}/spree/user_class_handle.rb +0 -0
  169. data/lib/tasks/migrations/migrate_address_names.rake +158 -0
  170. data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +38 -0
  171. data/lib/tasks/upgrade.rake +13 -0
  172. data/solidus_core.gemspec +3 -4
  173. metadata +32 -63
  174. data/app/mailers/spree/test_mailer.rb +0 -13
  175. data/app/models/concerns/spree/user_payment_source.rb +0 -26
  176. data/app/models/spree/calculator/free_shipping.rb +0 -21
  177. data/app/models/spree/calculator/percent_per_item.rb +0 -49
  178. data/app/models/spree/calculator/price_sack.rb +0 -27
  179. data/app/models/spree/gateway.rb +0 -14
  180. data/app/models/spree/gateway/bogus.rb +0 -13
  181. data/app/models/spree/gateway/bogus_simple.rb +0 -13
  182. data/app/models/spree/order/checkout.rb +0 -244
  183. data/app/models/spree/order_capturing.rb +0 -50
  184. data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
  185. data/lib/generators/spree/install/install_generator.rb +0 -15
  186. data/lib/solidus/migrations/rename_gateways.rb +0 -41
  187. data/lib/spree/awesome_nested_set_override.rb +0 -44
  188. data/lib/spree/core/current_store.rb +0 -24
  189. data/lib/spree/paranoia_deprecations.rb +0 -41
  190. data/lib/spree/promo/environment.rb +0 -12
  191. data/lib/spree/testing_support/bar_ability.rb +0 -19
  192. data/lib/tasks/core.rake +0 -104
  193. data/lib/tasks/email.rake +0 -11
  194. data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
  195. data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
  196. data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
  197. data/lib/tasks/migrations/rename_gateways.rake +0 -23
  198. data/lib/tasks/order_capturing.rake +0 -27
@@ -59,14 +59,6 @@ module Spree
59
59
  # end
60
60
  # end
61
61
  def event_action(method_name, event_name: nil)
62
- mattr_writer "#{method_name}_handler"
63
-
64
- define_method "#{method_name}_handler" do
65
- Spree::Deprecation.warn("#{name}.#{method_name}_handler and #{name}.#{method_name}_handler= from the old events mapping interface are deprecated. Please use the new mapping stored in Spree::Event.subscribers.", caller)
66
-
67
- class_variable_get("@@#{method_name}_handler")
68
- end
69
-
70
62
  event_actions[method_name] = (event_name || method_name).to_s
71
63
  end
72
64
 
@@ -89,16 +81,6 @@ module Spree
89
81
  def deactivate(event_action_name = nil)
90
82
  Spree::Event.subscriber_registry.deactivate_subscriber(self, event_action_name)
91
83
  end
92
-
93
- def subscribe!
94
- Spree::Deprecation.warn("#{self}.subscribe! is deprecated. Please use `#{self}.activate`.", caller)
95
- activate
96
- end
97
-
98
- def unsubscribe!
99
- Spree::Deprecation.warn("#{self}.unsubscribe! is deprecated. Please use `#{self}.deactivate`.", caller)
100
- deactivate
101
- end
102
84
  end
103
85
  end
104
86
  end
@@ -35,7 +35,9 @@ module Spree
35
35
  subscription = Spree::Event.subscribe(event_name) { |event| subscriber.send(event_action, event) }
36
36
 
37
37
  # deprecated mappings, to be removed when Solidus 2.10 is not supported anymore:
38
- subscriber.send("#{event_action}_handler=", subscription)
38
+ if subscriber.respond_to?("#{event_action}_handler=")
39
+ subscriber.send("#{event_action}_handler=", subscription)
40
+ end
39
41
 
40
42
  registry[subscriber.name][event_action] = subscription
41
43
  end
data/lib/spree/i18n.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'i18n'
4
- require 'active_support/core_ext/array/extract_options'
5
- require 'action_view'
6
4
 
7
5
  module Spree
8
6
  def self.i18n_available_locales
@@ -11,29 +9,9 @@ module Spree
11
9
  end
12
10
  end
13
11
 
14
- class TranslationHelperWrapper # :nodoc:
15
- include ActionView::Helpers::TranslationHelper
16
- end
17
-
18
12
  # This value is used as a count for the pluralization helpers related to I18n
19
13
  # ex: Spree::Order.model_name.human(count: Spree::I18N_GENERIC_PLURAL)
20
14
  # Related to Solidus issue #1164, this is needed to avoid problems with
21
15
  # some pluralization calculators
22
16
  I18N_GENERIC_PLURAL = 2.1
23
-
24
- class << self
25
- # Add spree namespace and delegate to Rails TranslationHelper for some nice
26
- # extra functionality. e.g return reasonable strings for missing translations
27
-
28
- def translate(key, options = {})
29
- Spree::Deprecation.warn <<-WARN.squish
30
- Spree.t & Spree.translate have been deprecated.
31
- Instead use I18n.t('spree.your_translation_key')
32
- WARN
33
- options[:scope] = [:spree, *options[:scope]]
34
- TranslationHelperWrapper.new.translate(key, **options)
35
- end
36
-
37
- alias_method :t, :translate
38
- end
39
17
  end
data/lib/spree/money.rb CHANGED
@@ -6,7 +6,6 @@ module Spree
6
6
  class Money
7
7
  include Comparable
8
8
  DifferentCurrencyError = Class.new(StandardError)
9
- RUBY_NUMERIC_STRING = /\A-?\d+(\.\d+)?\z/
10
9
 
11
10
  class <<self
12
11
  attr_accessor :default_formatting_rules
@@ -37,15 +36,8 @@ module Spree
37
36
  @money = amount
38
37
  else
39
38
  currency = (options[:currency] || Spree::Config[:currency])
40
- if amount.to_s =~ RUBY_NUMERIC_STRING
41
- @money = Monetize.from_string(amount, currency)
42
- else
43
- @money = Spree::Money.parse_to_money(amount, currency)
44
- Spree::Deprecation.warn <<-WARN.squish, caller
45
- Spree::Money was initialized with #{amount.inspect}, which will not be supported in the future.
46
- Instead use Spree::Money.new(#{@money.to_s.inspect}, options) or Spree::Money.parse(#{amount.inspect})
47
- WARN
48
- end
39
+
40
+ @money = Monetize.from_string(amount, currency)
49
41
  end
50
42
  @options = Spree::Money.default_formatting_rules.merge(options)
51
43
  end
@@ -80,14 +72,7 @@ module Spree
80
72
  def to_html(options = { html_wrap: true })
81
73
  output = format(options)
82
74
  # Maintain compatibility by checking html option renamed to html_wrap.
83
- if options[:html] || options[:html] == false
84
- Spree::Deprecation.warn <<-WARN.squish, caller
85
- Spree::Money#to_html called with Spree::Money#to_html(html: #{options[:html].inspect}),
86
- which will not be supported in the future.
87
- Instead use :html_wrap e.g. Spree::Money#to_html(html_wrap: #{options[:html].inspect})
88
- WARN
89
- end
90
- if options[:html_wrap] || options[:html]
75
+ if options[:html_wrap]
91
76
  output = output.html_safe
92
77
  end
93
78
  output
@@ -39,8 +39,7 @@ module Spree
39
39
  mattr_reader(*ATTRIBUTES)
40
40
 
41
41
  @@address_attributes = [
42
- :id, :name, :firstname, :lastname, :first_name, :last_name,
43
- :address1, :address2, :city, :country_id, :state_id,
42
+ :id, :name, :address1, :address2, :city, :country_id, :state_id,
44
43
  :zipcode, :phone, :state_name, :country_iso, :alternative_phone, :company,
45
44
  country: [:iso, :name, :iso3, :iso_name],
46
45
  state: [:name, :abbr]
@@ -90,7 +89,7 @@ module Spree
90
89
  :number, :month, :year, :expiry, :verification_value,
91
90
  :first_name, :last_name, :cc_type, :gateway_customer_profile_id,
92
91
  :gateway_payment_profile_id, :last_digits, :name, :encrypted_data,
93
- :existing_card_id, :wallet_payment_source_id, address_attributes: address_attributes
92
+ :wallet_payment_source_id, address_attributes: address_attributes
94
93
  ]
95
94
 
96
95
  @@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id]
@@ -143,61 +142,11 @@ module Spree
143
142
  ]
144
143
 
145
144
  @@checkout_payment_attributes = [
146
- :coupon_code,
147
145
  payments_attributes: payment_attributes + [
148
146
  source_attributes: source_attributes
149
147
  ]
150
148
  ]
151
149
 
152
150
  @@checkout_confirm_attributes = []
153
-
154
- def self.checkout_attributes
155
- Spree::Deprecation.warn <<-WARN.squish, caller
156
- checkout_attributes is deprecated, please use the permitted
157
- attributes set for the specific step that needs to be updated.
158
-
159
- E.g. permitted_checkout_address_attributes
160
- WARN
161
-
162
- CheckoutAdditionalAttributes.new(
163
- checkout_address_attributes +
164
- checkout_delivery_attributes +
165
- checkout_payment_attributes +
166
- checkout_confirm_attributes
167
- )
168
- end
169
- end
170
-
171
- class CheckoutAdditionalAttributes < Array
172
- def <<(*attributes)
173
- super
174
-
175
- inject_attributes_to_all_steps(attributes, :<<)
176
- end
177
-
178
- def push(*attributes)
179
- super
180
-
181
- inject_attributes_to_all_steps(attributes, :push)
182
- end
183
- alias append push
184
-
185
- def prepend(*attributes)
186
- super
187
-
188
- inject_attributes_to_all_steps(attributes, :prepend)
189
- end
190
- alias unshift prepend
191
-
192
- private
193
-
194
- def inject_attributes_to_all_steps(attributes, method)
195
- attributes.each do |attribute|
196
- PermittedAttributes.checkout_address_attributes.send(method, attribute)
197
- PermittedAttributes.checkout_delivery_attributes.send(method, attribute)
198
- PermittedAttributes.checkout_payment_attributes.send(method, attribute)
199
- PermittedAttributes.checkout_confirm_attributes.send(method, attribute)
200
- end
201
- end
202
151
  end
203
152
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spree/testing_support/factory_bot'
4
+
5
+ module Spree
6
+ module TestingSupport
7
+ autoload :FactoryBot, "spree/testing_support/factory_bot"
8
+
9
+ autoload :SEQUENCES, "spree/testing_support/factory_bot"
10
+ autoload :FACTORIES, "spree/testing_support/factory_bot"
11
+
12
+ def factory_bot_paths
13
+ Spree::TestingSupport::FactoryBot.definition_file_paths
14
+ end
15
+
16
+ def check_factory_bot_version
17
+ Spree::TestingSupport::FactoryBot.check_version
18
+ end
19
+
20
+ def load_all_factories
21
+ Spree::TestingSupport::FactoryBot.add_paths_and_load!
22
+ end
23
+
24
+ deprecate(
25
+ factory_bot_paths: "Spree::TestingSupport::FactoryBot.definition_file_paths",
26
+ check_factory_bot_version: "Spree::TestingSupport::FactoryBot.check_version",
27
+ load_all_factories: "Spree::TestingSupport::FactoryBot.add_paths_and_load!",
28
+ deprecator: Spree::Deprecator
29
+ )
30
+ end
31
+ end
@@ -35,18 +35,6 @@ module Spree
35
35
  find("td:nth-of-type(#{num})").text
36
36
  end
37
37
 
38
- def fill_in_quantity(table_column, selector, quantity)
39
- Spree::Deprecation.warn <<-WARN.strip_heredoc
40
- fill_in_quantity is deprecated. Instead use:
41
- within(#{table_column.inspect}) do
42
- fill_in #{selector.inspect}, with: #{quantity.inspect}
43
- end
44
- WARN
45
- within(table_column) do
46
- fill_in selector, with: quantity
47
- end
48
- end
49
-
50
38
  def select2_search(value, options)
51
39
  options = {
52
40
  search: value, # by default search for the value
@@ -122,21 +110,6 @@ module Spree
122
110
  # find the original.
123
111
  find('label:not(.select2-offscreen)', text: /#{Regexp.escape(text)}/i, match: :one)
124
112
  end
125
-
126
- def wait_for_ajax
127
- Spree::Deprecation.warn <<-WARN.squish, caller
128
- wait_for_ajax has been deprecated.
129
- Please refer to the capybara documentation on how to properly wait for asyncronous behavior:
130
- https://github.com/teamcapybara/capybara#asynchronous-javascript-ajax-and-friends
131
- WARN
132
-
133
- counter = 0
134
- while page.evaluate_script("typeof($) === 'undefined' || $.active > 0")
135
- counter += 1
136
- sleep(0.1)
137
- raise "AJAX request took longer than 5 seconds." if counter >= 50
138
- end
139
- end
140
113
  end
141
114
  end
142
115
  end
@@ -156,9 +129,6 @@ RSpec::Matchers.define :have_meta do |name, expected|
156
129
  end
157
130
  end
158
131
 
159
- # @private
160
- CapybaraExt = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('CapybaraExt', 'Spree::TestingSupport::CapybaraExt')
161
-
162
132
  RSpec.configure do |c|
163
133
  c.include Spree::TestingSupport::CapybaraExt
164
134
  end
@@ -2,23 +2,12 @@
2
2
 
3
3
  module Spree
4
4
  module TestingSupport
5
- # A module providing convenience methods to test Solidus controllers
6
- # in Rails controller/functional tests. Possibly from inside an
7
- # application with a mounted Solidus engine.
8
- #
9
5
  # *There is generaly no need* to use this module. Instead, in
10
6
  # a functional/controller test against a Spree controller, just
11
7
  # use standard Rails functionality by including:
12
8
  #
13
9
  # routes { Spree::Core::Engine.routes }
14
10
  #
15
- # And then use standard Rails test `get`, `post` etc methods.
16
- #
17
- # But some legacy code uses this ControllerRequests helper. It must
18
- # be included only in tests against Spree controllers, it will interfere
19
- # with tests against local app or other engine controllers, resulting
20
- # in ActionController::UrlGenerationError.
21
- #
22
11
  # To use this module, inside your spec_helper.rb, include this module inside
23
12
  # the RSpec.configure block by:
24
13
  #
@@ -26,83 +15,12 @@ module Spree
26
15
  # RSpec.configure do |c|
27
16
  # c.include Spree::TestingSupport::ControllerRequests, spree_controller: true
28
17
  # end
29
- #
30
- # Then, in your controller tests against spree controllers, you can access
31
- # tag to use this module, and access spree routes like this:
32
- #
33
- # require 'spec_helper'
34
- #
35
- # describe Spree::ProductsController, :spree_controller do
36
- # it "can see all the products" do
37
- # spree_get :index
38
- # end
39
- # end
40
- #
41
- # Use spree_get, spree_post, spree_put or spree_delete to make requests to
42
- # the Spree engine, and use regular get, post, put or delete to make
43
- # requests to your application.
44
18
  module ControllerRequests
45
19
  extend ActiveSupport::Concern
46
20
 
47
21
  included do
48
22
  routes { Spree::Core::Engine.routes }
49
23
  end
50
-
51
- def spree_get(action, parameters = nil, session = nil, flash = nil)
52
- process_spree_action(action, parameters, session, flash, "GET")
53
- end
54
- deprecate spree_get: :get, deprecator: Spree::Deprecation
55
-
56
- # Executes a request simulating POST HTTP method and set/volley the response
57
- def spree_post(action, parameters = nil, session = nil, flash = nil)
58
- process_spree_action(action, parameters, session, flash, "POST")
59
- end
60
- deprecate spree_post: :post, deprecator: Spree::Deprecation
61
-
62
- # Executes a request simulating PUT HTTP method and set/volley the response
63
- def spree_put(action, parameters = nil, session = nil, flash = nil)
64
- process_spree_action(action, parameters, session, flash, "PUT")
65
- end
66
- deprecate spree_put: :put, deprecator: Spree::Deprecation
67
-
68
- # Executes a request simulating DELETE HTTP method and set/volley the response
69
- def spree_delete(action, parameters = nil, session = nil, flash = nil)
70
- process_spree_action(action, parameters, session, flash, "DELETE")
71
- end
72
- deprecate spree_delete: :delete, deprecator: Spree::Deprecation
73
-
74
- def spree_xhr_get(action, parameters = nil, session = nil, flash = nil)
75
- process_spree_xhr_action(action, parameters, session, flash, :get)
76
- end
77
- deprecate spree_xhr_get: :get, deprecator: Spree::Deprecation
78
-
79
- def spree_xhr_post(action, parameters = nil, session = nil, flash = nil)
80
- process_spree_xhr_action(action, parameters, session, flash, :post)
81
- end
82
- deprecate spree_xhr_post: :post, deprecator: Spree::Deprecation
83
-
84
- def spree_xhr_put(action, parameters = nil, session = nil, flash = nil)
85
- process_spree_xhr_action(action, parameters, session, flash, :put)
86
- end
87
- deprecate spree_xhr_put: :put, deprecator: Spree::Deprecation
88
-
89
- def spree_xhr_delete(action, parameters = nil, session = nil, flash = nil)
90
- process_spree_xhr_action(action, parameters, session, flash, :delete)
91
- end
92
- deprecate spree_xhr_delete: :delete, deprecator: Spree::Deprecation
93
-
94
- private
95
-
96
- def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
97
- parameters ||= {}
98
- process(action, method, parameters, session, flash)
99
- end
100
-
101
- def process_spree_xhr_action(action, parameters = nil, session = nil, flash = nil, method = :get)
102
- parameters ||= {}
103
- parameters.reverse_merge!(format: :json)
104
- xml_http_request(method, action, parameters, session, flash)
105
- end
106
24
  end
107
25
  end
108
26
  end
@@ -7,6 +7,7 @@ require 'rails'
7
7
  require 'active_record/railtie'
8
8
  require 'action_controller/railtie'
9
9
  require 'action_mailer/railtie'
10
+ require 'active_storage/engine'
10
11
 
11
12
  Rails.env = 'test'
12
13
 
@@ -16,6 +17,7 @@ RAILS_6_OR_ABOVE = Rails.gem_version >= Gem::Version.new('6.0')
16
17
 
17
18
  # @private
18
19
  class ApplicationController < ActionController::Base
20
+ protect_from_forgery with: :exception
19
21
  end
20
22
 
21
23
  # @private
@@ -51,8 +53,8 @@ module DummyApp
51
53
  config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
52
54
  config.whiny_nils = true
53
55
  config.consider_all_requests_local = true
54
- config.action_controller.allow_forgery_protection = true
55
- config.action_controller.default_protect_from_forgery = true
56
+ config.action_controller.allow_forgery_protection = false
57
+ config.action_controller.default_protect_from_forgery = false
56
58
  config.action_controller.perform_caching = false
57
59
  config.action_dispatch.show_exceptions = false
58
60
  config.active_support.deprecation = :stderr
@@ -61,11 +63,12 @@ module DummyApp
61
63
  config.secret_key_base = 'SECRET_TOKEN'
62
64
 
63
65
  config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" if RAILS_6_OR_ABOVE
66
+ config.action_mailer.preview_path = File.expand_path('dummy_app/mailer_previews', __dir__)
64
67
  config.active_record.sqlite3.represent_boolean_as_integer = true unless RAILS_6_OR_ABOVE
65
68
 
66
69
  config.storage_path = Rails.root.join('tmp', 'storage')
67
70
 
68
- if ENV['ENABLE_ACTIVE_STORAGE']
71
+ unless ENV['DISABLE_ACTIVE_STORAGE']
69
72
  initializer 'solidus.active_storage' do
70
73
  config.active_storage.service_configurations = {
71
74
  test: {
@@ -114,20 +117,11 @@ end
114
117
 
115
118
  Spree.user_class = 'Spree::LegacyUser'
116
119
  Spree.config do |config|
117
- config.use_legacy_address_state_validator = false
118
120
  config.mails_from = "store@example.com"
119
- config.raise_with_invalid_currency = false
120
- config.redirect_back_on_unauthorized = true
121
- config.run_order_validations_on_order_updater = true
122
- config.use_combined_first_and_last_name_in_address = true
123
- config.use_legacy_order_state_machine = false
124
- config.use_custom_cancancan_actions = false
125
- config.consider_actionless_promotion_active = false
126
- config.use_legacy_store_credit_reimbursement_category_name = false
127
-
128
- if ENV['ENABLE_ACTIVE_STORAGE']
129
- config.image_attachment_module = 'Spree::Image::ActiveStorageAttachment'
130
- config.taxon_attachment_module = 'Spree::Taxon::ActiveStorageAttachment'
121
+
122
+ if ENV['DISABLE_ACTIVE_STORAGE']
123
+ config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
124
+ config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
131
125
  end
132
126
  end
133
127