solidus_core 2.9.5 → 2.10.2

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 (221) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/spree/base_helper.rb +4 -4
  3. data/app/helpers/spree/products_helper.rb +2 -1
  4. data/app/jobs/spree/promotion_code_batch_job.rb +2 -2
  5. data/app/models/concerns/spree/user_address_book.rb +2 -2
  6. data/app/models/concerns/spree/user_methods.rb +2 -2
  7. data/app/models/spree/address.rb +13 -17
  8. data/app/models/spree/adjustment.rb +20 -9
  9. data/app/models/spree/asset.rb +1 -1
  10. data/app/models/spree/base.rb +0 -2
  11. data/app/models/spree/calculator.rb +1 -1
  12. data/app/models/spree/calculator/price_sack.rb +1 -1
  13. data/app/models/spree/calculator/shipping/flexi_rate.rb +2 -2
  14. data/app/models/spree/calculator/tiered_flat_rate.rb +5 -5
  15. data/app/models/spree/calculator/tiered_percent.rb +6 -6
  16. data/app/models/spree/carton.rb +3 -3
  17. data/app/models/spree/classification.rb +2 -2
  18. data/app/models/spree/credit_card.rb +4 -4
  19. data/app/models/spree/customer_return.rb +1 -1
  20. data/app/models/spree/image/paperclip_attachment.rb +1 -1
  21. data/app/models/spree/inventory_unit.rb +5 -23
  22. data/app/models/spree/line_item.rb +4 -4
  23. data/app/models/spree/line_item_action.rb +2 -2
  24. data/app/models/spree/log_entry.rb +1 -1
  25. data/app/models/spree/option_value.rb +1 -1
  26. data/app/models/spree/option_values_variant.rb +2 -2
  27. data/app/models/spree/order.rb +11 -27
  28. data/app/models/spree/order/checkout.rb +1 -1
  29. data/app/models/spree/order/payments.rb +2 -2
  30. data/app/models/spree/order_cancellations.rb +1 -1
  31. data/app/models/spree/order_capturing.rb +2 -2
  32. data/app/models/spree/order_contents.rb +2 -2
  33. data/app/models/spree/order_mutex.rb +1 -1
  34. data/app/models/spree/order_promotion.rb +3 -3
  35. data/app/models/spree/order_shipping.rb +1 -1
  36. data/app/models/spree/order_taxation.rb +3 -3
  37. data/app/models/spree/payment.rb +8 -45
  38. data/app/models/spree/payment/processing.rb +3 -3
  39. data/app/models/spree/payment_capture_event.rb +1 -1
  40. data/app/models/spree/payment_method.rb +5 -2
  41. data/app/models/spree/payment_method/bogus_credit_card.rb +1 -1
  42. data/app/models/spree/payment_source.rb +1 -1
  43. data/app/models/spree/price.rb +2 -2
  44. data/app/models/spree/product.rb +5 -5
  45. data/app/models/spree/product/scopes.rb +218 -210
  46. data/app/models/spree/product_option_type.rb +2 -2
  47. data/app/models/spree/product_promotion_rule.rb +2 -2
  48. data/app/models/spree/product_property.rb +2 -2
  49. data/app/models/spree/promotion.rb +28 -13
  50. data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +1 -1
  51. data/app/models/spree/promotion/actions/free_shipping.rb +1 -1
  52. data/app/models/spree/promotion/rules/option_value.rb +2 -2
  53. data/app/models/spree/promotion/rules/product.rb +3 -3
  54. data/app/models/spree/promotion_action.rb +2 -2
  55. data/app/models/spree/promotion_chooser.rb +2 -2
  56. data/app/models/spree/promotion_code.rb +11 -10
  57. data/app/models/spree/promotion_code/batch_builder.rb +3 -3
  58. data/app/models/spree/promotion_code_batch.rb +1 -1
  59. data/app/models/spree/promotion_rule.rb +2 -2
  60. data/app/models/spree/promotion_rule_role.rb +2 -2
  61. data/app/models/spree/promotion_rule_store.rb +2 -2
  62. data/app/models/spree/promotion_rule_taxon.rb +2 -2
  63. data/app/models/spree/promotion_rule_user.rb +2 -2
  64. data/app/models/spree/refund.rb +5 -5
  65. data/app/models/spree/reimbursement.rb +5 -13
  66. data/app/models/spree/reimbursement/credit.rb +2 -2
  67. data/app/models/spree/reimbursement/reimbursement_type_engine.rb +1 -1
  68. data/app/models/spree/reimbursement_tax_calculator.rb +1 -1
  69. data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +2 -2
  70. data/app/models/spree/return_authorization.rb +4 -10
  71. data/app/models/spree/return_item.rb +13 -52
  72. data/app/models/spree/return_item/eligibility_validator/default.rb +1 -1
  73. data/app/models/spree/role_user.rb +2 -2
  74. data/app/models/spree/shipment.rb +7 -41
  75. data/app/models/spree/shipping_calculator.rb +0 -4
  76. data/app/models/spree/shipping_manifest.rb +3 -3
  77. data/app/models/spree/shipping_method.rb +2 -2
  78. data/app/models/spree/shipping_method_category.rb +2 -2
  79. data/app/models/spree/shipping_method_stock_location.rb +2 -2
  80. data/app/models/spree/shipping_method_zone.rb +2 -2
  81. data/app/models/spree/shipping_rate.rb +2 -2
  82. data/app/models/spree/shipping_rate_tax.rb +2 -2
  83. data/app/models/spree/state.rb +2 -2
  84. data/app/models/spree/state_change.rb +2 -2
  85. data/app/models/spree/stock/differentiator.rb +1 -1
  86. data/app/models/spree/stock/package.rb +1 -1
  87. data/app/models/spree/stock_item.rb +3 -3
  88. data/app/models/spree/stock_location.rb +2 -2
  89. data/app/models/spree/stock_movement.rb +2 -2
  90. data/app/models/spree/stock_quantities.rb +13 -12
  91. data/app/models/spree/store_credit.rb +8 -8
  92. data/app/models/spree/store_credit_event.rb +3 -3
  93. data/app/models/spree/store_payment_method.rb +2 -2
  94. data/app/models/spree/store_shipping_method.rb +2 -2
  95. data/app/models/spree/tax_calculator/default.rb +0 -4
  96. data/app/models/spree/tax_calculator/shipping_rate.rb +0 -3
  97. data/app/models/spree/tax_rate.rb +5 -1
  98. data/app/models/spree/tax_rate_tax_category.rb +2 -2
  99. data/app/models/spree/taxon/paperclip_attachment.rb +13 -0
  100. data/app/models/spree/unit_cancel.rb +5 -2
  101. data/app/models/spree/user_address.rb +2 -2
  102. data/app/models/spree/user_last_url_storer.rb +46 -0
  103. data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +36 -0
  104. data/app/models/spree/user_stock_location.rb +2 -2
  105. data/app/models/spree/variant.rb +10 -10
  106. data/app/models/spree/variant/scopes.rb +37 -29
  107. data/app/models/spree/variant_property_rule.rb +1 -1
  108. data/app/models/spree/variant_property_rule_condition.rb +2 -2
  109. data/app/models/spree/variant_property_rule_value.rb +2 -2
  110. data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +1 -1
  111. data/app/models/spree/wallet_payment_source.rb +2 -2
  112. data/app/models/spree/zone.rb +1 -1
  113. data/app/models/spree/zone_member.rb +2 -2
  114. data/config/initializers/inflections.rb +5 -0
  115. data/config/initializers/money.rb +2 -0
  116. data/config/locales/en.yml +34 -3
  117. data/lib/generators/spree/dummy/dummy_generator.rb +2 -0
  118. data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +8 -0
  119. data/lib/spree/app_configuration.rb +18 -3
  120. data/lib/spree/core.rb +12 -0
  121. data/lib/spree/core/controller_helpers/auth.rb +1 -13
  122. data/lib/spree/core/controller_helpers/strong_parameters.rb +21 -7
  123. data/lib/spree/core/engine.rb +2 -2
  124. data/lib/spree/core/importer/order.rb +29 -28
  125. data/lib/spree/core/importer/product.rb +2 -2
  126. data/lib/spree/core/product_filters.rb +15 -15
  127. data/lib/spree/core/role_configuration.rb +2 -2
  128. data/lib/spree/core/search/variant.rb +1 -1
  129. data/lib/spree/core/state_machines.rb +78 -0
  130. data/lib/spree/core/state_machines/inventory_unit.rb +42 -0
  131. data/lib/spree/core/state_machines/payment.rb +61 -0
  132. data/lib/spree/core/state_machines/reimbursement.rb +33 -0
  133. data/lib/spree/core/state_machines/return_authorization.rb +32 -0
  134. data/lib/spree/core/state_machines/return_item/acceptance_status.rb +51 -0
  135. data/lib/spree/core/state_machines/return_item/reception_status.rb +42 -0
  136. data/lib/spree/core/state_machines/shipment.rb +58 -0
  137. data/lib/spree/core/stock_configuration.rb +1 -0
  138. data/lib/spree/core/validators/email.rb +1 -8
  139. data/lib/spree/core/version.rb +1 -1
  140. data/lib/spree/money.rb +2 -2
  141. data/lib/spree/permission_sets/default_customer.rb +1 -1
  142. data/lib/spree/permission_sets/user_management.rb +3 -0
  143. data/lib/spree/permitted_attributes.rb +78 -9
  144. data/lib/spree/preferences/static_model_preferences.rb +2 -2
  145. data/lib/spree/testing_support/dummy_app.rb +4 -1
  146. data/lib/spree/testing_support/dummy_app/rake_tasks.rb +6 -2
  147. data/lib/spree/testing_support/factories/inventory_unit_factory.rb +8 -1
  148. data/lib/spree/testing_support/factories/promotion_factory.rb +7 -0
  149. data/lib/spree/testing_support/factories/stock_package_factory.rb +1 -1
  150. data/lib/spree/testing_support/factories/user_factory.rb +4 -1
  151. data/solidus_core.gemspec +6 -6
  152. data/spec/lib/search/base_spec.rb +5 -1
  153. data/spec/lib/search/variant_spec.rb +1 -1
  154. data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +8 -1
  155. data/spec/lib/spree/core/stock_configuration_spec.rb +36 -0
  156. data/spec/lib/spree/core/validators/email_spec.rb +18 -18
  157. data/spec/lib/spree/event_spec.rb +15 -3
  158. data/spec/lib/spree/permitted_attributes_spec.rb +41 -0
  159. data/spec/models/spree/ability_spec.rb +1 -1
  160. data/spec/models/spree/address_spec.rb +23 -0
  161. data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +1 -1
  162. data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +1 -1
  163. data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +1 -1
  164. data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +2 -2
  165. data/spec/models/spree/calculator/shipping/per_item_spec.rb +1 -1
  166. data/spec/models/spree/calculator/shipping/price_sack_spec.rb +24 -15
  167. data/spec/models/spree/carton_spec.rb +10 -2
  168. data/spec/models/spree/classification_spec.rb +21 -9
  169. data/spec/models/spree/concerns/user_address_book_spec.rb +4 -4
  170. data/spec/models/spree/concerns/user_methods_spec.rb +5 -4
  171. data/spec/models/spree/credit_card_spec.rb +2 -2
  172. data/spec/models/spree/customer_return_spec.rb +1 -1
  173. data/spec/models/spree/order/checkout_spec.rb +1 -1
  174. data/spec/models/spree/order/outstanding_balance_integration_spec.rb +5 -5
  175. data/spec/models/spree/order/payment_spec.rb +1 -1
  176. data/spec/models/spree/order_contents_spec.rb +1 -1
  177. data/spec/models/spree/order_inventory_spec.rb +3 -3
  178. data/spec/models/spree/order_merger_spec.rb +3 -3
  179. data/spec/models/spree/order_shipping_spec.rb +1 -1
  180. data/spec/models/spree/order_spec.rb +14 -21
  181. data/spec/models/spree/order_updater_spec.rb +4 -3
  182. data/spec/models/spree/payment_create_spec.rb +6 -16
  183. data/spec/models/spree/payment_spec.rb +12 -12
  184. data/spec/models/spree/permission_sets/user_management_spec.rb +2 -0
  185. data/spec/models/spree/preference_spec.rb +4 -4
  186. data/spec/models/spree/preferences/preferable_spec.rb +3 -3
  187. data/spec/models/spree/preferences/statically_configurable_spec.rb +2 -2
  188. data/spec/models/spree/promotion/rules/first_repeat_purchase_since_spec.rb +2 -2
  189. data/spec/models/spree/promotion/rules/nth_order_spec.rb +2 -2
  190. data/spec/models/spree/promotion/rules/taxon_spec.rb +1 -0
  191. data/spec/models/spree/promotion_rule_spec.rb +6 -6
  192. data/spec/models/spree/promotion_spec.rb +71 -54
  193. data/spec/models/spree/reimbursement_type/original_payment_spec.rb +3 -3
  194. data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +1 -1
  195. data/spec/models/spree/return_item_spec.rb +11 -11
  196. data/spec/models/spree/returns_calculator_spec.rb +2 -2
  197. data/spec/models/spree/shipment_spec.rb +6 -6
  198. data/spec/models/spree/shipping_calculator_spec.rb +1 -13
  199. data/spec/models/spree/shipping_method_spec.rb +32 -0
  200. data/spec/models/spree/stock/availability_validator_spec.rb +2 -2
  201. data/spec/models/spree/stock/differentiator_spec.rb +2 -2
  202. data/spec/models/spree/stock/estimator_spec.rb +3 -3
  203. data/spec/models/spree/stock/inventory_units_finalizer_spec.rb +4 -4
  204. data/spec/models/spree/stock/package_spec.rb +28 -28
  205. data/spec/models/spree/stock/quantifier_spec.rb +2 -2
  206. data/spec/models/spree/stock/simple_coordinator_spec.rb +11 -11
  207. data/spec/models/spree/stock/splitter/base_spec.rb +4 -4
  208. data/spec/models/spree/stock/splitter/shipping_category_spec.rb +7 -7
  209. data/spec/models/spree/stock_quantities_spec.rb +1 -1
  210. data/spec/models/spree/store_credit_spec.rb +8 -8
  211. data/spec/models/spree/tax_category_spec.rb +1 -1
  212. data/spec/models/spree/tax_rate_spec.rb +1 -0
  213. data/spec/models/spree/taxon_spec.rb +2 -2
  214. data/spec/models/spree/taxons/paperclip_attachment_spec.rb +29 -0
  215. data/spec/models/spree/unit_cancel_spec.rb +5 -0
  216. data/spec/models/spree/user_last_url_storer/rules/authentication_rule_spec.rb +31 -0
  217. data/spec/models/spree/user_last_url_storer_spec.rb +60 -0
  218. data/spec/models/spree/user_spec.rb +3 -3
  219. metadata +46 -39
  220. data/spec/migrate/20190106184413_remove_code_from_spree_promotions_spec.rb +0 -148
  221. data/spec/models/spree/order/updating_spec.rb +0 -18
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spree
4
+ module Core
5
+ class StateMachines
6
+ # Shipments' state machine
7
+ #
8
+ # for each event the following instance methods are dynamically implemented:
9
+ # #<event_name>
10
+ # #<event_name>!
11
+ # #can_<event_name>?
12
+ #
13
+ # for each state the following instance methods are implemented:
14
+ # #<state_name>?
15
+ #
16
+ module Shipment
17
+ extend ActiveSupport::Concern
18
+
19
+ included do
20
+ state_machine initial: :pending, use_transactions: false do
21
+ event :ready do
22
+ transition from: :pending, to: :shipped, if: :can_transition_from_pending_to_shipped?
23
+ transition from: :pending, to: :ready, if: :can_transition_from_pending_to_ready?
24
+ end
25
+
26
+ event :pend do
27
+ transition from: :ready, to: :pending
28
+ end
29
+
30
+ event :ship do
31
+ transition from: [:ready, :canceled], to: :shipped
32
+ end
33
+ after_transition to: :shipped, do: :after_ship
34
+
35
+ event :cancel do
36
+ transition to: :canceled, from: [:pending, :ready]
37
+ end
38
+ after_transition to: :canceled, do: :after_cancel
39
+
40
+ event :resume do
41
+ transition from: :canceled, to: :ready, if: :can_transition_from_canceled_to_ready?
42
+ transition from: :canceled, to: :pending
43
+ end
44
+ after_transition from: :canceled, to: [:pending, :ready, :shipped], do: :after_resume
45
+
46
+ after_transition do |shipment, transition|
47
+ shipment.state_changes.create!(
48
+ previous_state: transition.from,
49
+ next_state: transition.to,
50
+ name: 'shipment'
51
+ )
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -5,6 +5,7 @@ module Spree
5
5
  class StockConfiguration
6
6
  attr_writer :coordinator_class
7
7
  attr_writer :estimator_class
8
+ attr_writer :location_filter_class
8
9
  attr_writer :location_sorter_class
9
10
  attr_writer :allocator_class
10
11
 
@@ -15,16 +15,9 @@ module Spree
15
15
  EMAIL_REGEXP = /\A([^@\.]|[^@\.]([^@\s]*)[^@\.])@([^@\s]+\.)+[^@\s]+\z/
16
16
 
17
17
  def validate_each(record, attribute, value)
18
- unless value =~ EMAIL_REGEXP
18
+ unless EMAIL_REGEXP.match? value
19
19
  record.errors.add(attribute, :invalid, { value: value }.merge!(options))
20
20
  end
21
21
  end
22
22
  end
23
23
  end
24
-
25
- # @private
26
- EmailValidator = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(
27
- 'EmailValidator',
28
- 'Spree::EmailValidator',
29
- message: "EmailValidator is deprecated! Use Spree::EmailValidator instead.\nChange `validates :email, email: true` to `validates :email, 'spree/email' => true`\n"
30
- )
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "2.9.5"
4
+ VERSION = "2.10.2"
5
5
 
6
6
  def self.solidus_version
7
7
  VERSION
@@ -82,9 +82,9 @@ module Spree
82
82
  # Maintain compatibility by checking html option renamed to html_wrap.
83
83
  if options[:html] || options[:html] == false
84
84
  Spree::Deprecation.warn <<-WARN.squish, caller
85
- Spree::Money#to_html called with Spree::Money#to_html(html: #{options[:html]}),
85
+ Spree::Money#to_html called with Spree::Money#to_html(html: #{options[:html].inspect}),
86
86
  which will not be supported in the future.
87
- Instead use :html_wrap e.g. Spree::Money#to_html(html_wrap: #{options[:html]})
87
+ Instead use :html_wrap e.g. Spree::Money#to_html(html_wrap: #{options[:html].inspect})
88
88
  WARN
89
89
  end
90
90
  if options[:html_wrap] || options[:html]
@@ -8,7 +8,7 @@ module Spree
8
8
  can :display, OptionType
9
9
  can :display, OptionValue
10
10
  can :create, Order
11
- can [:read, :update], Order do |order, token|
11
+ can [:read, :update], Order, Order.where(user: user) do |order, token|
12
12
  order.user == user || (order.guest_token.present? && token == order.guest_token)
13
13
  end
14
14
  cannot :update, Order do |order|
@@ -11,6 +11,9 @@ module Spree
11
11
  can :update_email, Spree.user_class do |user|
12
12
  user.spree_roles.none?
13
13
  end
14
+ can :update_password, Spree.user_class do |user|
15
+ user.spree_roles.none?
16
+ end
14
17
 
15
18
  cannot [:delete, :destroy], Spree.user_class
16
19
  can :manage, Spree::StoreCredit
@@ -8,7 +8,10 @@ module Spree
8
8
  ATTRIBUTES = [
9
9
  :address_attributes,
10
10
  :address_book_attributes,
11
- :checkout_attributes,
11
+ :checkout_address_attributes,
12
+ :checkout_delivery_attributes,
13
+ :checkout_payment_attributes,
14
+ :checkout_confirm_attributes,
12
15
  :credit_card_update_attributes,
13
16
  :customer_return_attributes,
14
17
  :image_attributes,
@@ -45,10 +48,6 @@ module Spree
45
48
 
46
49
  @@address_book_attributes = address_attributes + [:default]
47
50
 
48
- @@checkout_attributes = [
49
- :coupon_code, :email, :special_instructions, :use_billing
50
- ]
51
-
52
51
  @@credit_card_update_attributes = [
53
52
  :month, :year, :expiry, :first_name, :last_name, :name
54
53
  ]
@@ -91,7 +90,7 @@ module Spree
91
90
  :number, :month, :year, :expiry, :verification_value,
92
91
  :first_name, :last_name, :cc_type, :gateway_customer_profile_id,
93
92
  :gateway_payment_profile_id, :last_digits, :name, :encrypted_data,
94
- :existing_card_id, :wallet_payment_source_id
93
+ :existing_card_id, :wallet_payment_source_id, address_attributes: address_attributes
95
94
  ]
96
95
 
97
96
  @@stock_item_attributes = [:variant, :stock_location, :backorderable, :variant_id]
@@ -117,10 +116,10 @@ module Spree
117
116
  :meta_description, :meta_keywords, :meta_title, :child_index
118
117
  ]
119
118
 
120
- # intentionally leaving off email here to prevent privilege escalation
119
+ # Intentionally leaving off email here to prevent privilege escalation
121
120
  # by changing a user with higher priveleges' email to one a lower-priveleged
122
- # admin owns. creating a user with an email is handled separate at the
123
- # controller level
121
+ # admin owns. Creating a user with an email is handled separate at the
122
+ # controller level.
124
123
  @@user_attributes = [:password, :password_confirmation]
125
124
 
126
125
  @@variant_attributes = [
@@ -129,5 +128,75 @@ module Spree
129
128
  :product_id, :product, :option_values_attributes, :price,
130
129
  :weight, :height, :width, :depth, :sku, :cost_currency, option_value_ids: [], options: [:name, :value]
131
130
  ]
131
+
132
+ @@checkout_address_attributes = [
133
+ :use_billing,
134
+ :email,
135
+ bill_address_attributes: address_attributes,
136
+ ship_address_attributes: address_attributes
137
+ ]
138
+
139
+ @@checkout_delivery_attributes = [
140
+ :special_instructions,
141
+ shipments_attributes: shipment_attributes
142
+ ]
143
+
144
+ @@checkout_payment_attributes = [
145
+ :coupon_code,
146
+ payments_attributes: payment_attributes + [
147
+ source_attributes: source_attributes
148
+ ]
149
+ ]
150
+
151
+ @@checkout_confirm_attributes = []
152
+
153
+ def self.checkout_attributes
154
+ Spree::Deprecation.warn <<-WARN.squish, caller
155
+ checkout_attributes is deprecated, please use the permitted
156
+ attributes set for the specific step that needs to be updated.
157
+
158
+ E.g. permitted_checkout_address_attributes
159
+ WARN
160
+
161
+ CheckoutAdditionalAttributes.new(
162
+ checkout_address_attributes +
163
+ checkout_delivery_attributes +
164
+ checkout_payment_attributes +
165
+ checkout_confirm_attributes
166
+ )
167
+ end
168
+ end
169
+
170
+ class CheckoutAdditionalAttributes < Array
171
+ def <<(*attributes)
172
+ super
173
+
174
+ inject_attributes_to_all_steps(attributes, :<<)
175
+ end
176
+
177
+ def push(*attributes)
178
+ super
179
+
180
+ inject_attributes_to_all_steps(attributes, :push)
181
+ end
182
+ alias append push
183
+
184
+ def prepend(*attributes)
185
+ super
186
+
187
+ inject_attributes_to_all_steps(attributes, :prepend)
188
+ end
189
+ alias unshift prepend
190
+
191
+ private
192
+
193
+ def inject_attributes_to_all_steps(attributes, method)
194
+ attributes.each do |attribute|
195
+ PermittedAttributes.checkout_address_attributes.send(method, attribute)
196
+ PermittedAttributes.checkout_delivery_attributes.send(method, attribute)
197
+ PermittedAttributes.checkout_payment_attributes.send(method, attribute)
198
+ PermittedAttributes.checkout_confirm_attributes.send(method, attribute)
199
+ end
200
+ end
132
201
  end
133
202
  end
@@ -30,8 +30,8 @@ module Spree
30
30
  end
31
31
 
32
32
  def initialize
33
- @store = Hash.new do |h, klass|
34
- h[klass] = {}
33
+ @store = Hash.new do |data, klass|
34
+ data[klass] = {}
35
35
  end
36
36
  end
37
37
 
@@ -13,6 +13,7 @@ Rails.env = 'test'
13
13
  require 'solidus_core'
14
14
 
15
15
  RAILS_52_OR_ABOVE = Gem::Version.new(Rails.version) >= Gem::Version.new('5.2')
16
+ RAILS_6_OR_ABOVE = Gem::Version.new(Rails.version) >= Gem::Version.new('6.0')
16
17
 
17
18
  # @private
18
19
  class ApplicationController < ActionController::Base
@@ -64,7 +65,9 @@ module DummyApp
64
65
 
65
66
  if RAILS_52_OR_ABOVE
66
67
  config.action_controller.default_protect_from_forgery = true
67
- config.active_record.sqlite3.represent_boolean_as_integer = true
68
+ unless RAILS_6_OR_ABOVE
69
+ config.active_record.sqlite3.represent_boolean_as_integer = true
70
+ end
68
71
  end
69
72
 
70
73
  # Avoid issues if an old spec/dummy still exists
@@ -38,8 +38,12 @@ namespace :db do
38
38
  # railties:install:migrations and then db:migrate.
39
39
  # Migrations should be run one directory at a time
40
40
  ActiveRecord::Migrator.migrations_paths.each do |path|
41
- if defined?(ActiveRecord::MigrationContext)
42
- # Rails >= 5.2
41
+ if Rails.gem_version >= Gem::Version.new('6.0.0')
42
+ ActiveRecord::MigrationContext.new(
43
+ [path],
44
+ ActiveRecord::SchemaMigration
45
+ ).migrate
46
+ elsif Rails.gem_version >= Gem::Version.new('5.2.0')
43
47
  ActiveRecord::MigrationContext.new([path]).migrate
44
48
  else
45
49
  ActiveRecord::Migrator.migrate(path)
@@ -9,6 +9,7 @@ FactoryBot.define do
9
9
  factory :inventory_unit, class: 'Spree::InventoryUnit' do
10
10
  transient do
11
11
  order { nil }
12
+ stock_location { nil }
12
13
  end
13
14
 
14
15
  variant
@@ -20,7 +21,13 @@ FactoryBot.define do
20
21
  end
21
22
  end
22
23
  state { 'on_hand' }
23
- shipment { build(:shipment, state: 'pending', order: line_item.order) }
24
+ shipment do
25
+ if stock_location
26
+ build(:shipment, state: 'pending', order: line_item.order, stock_location: stock_location)
27
+ else
28
+ build(:shipment, state: 'pending', order: line_item.order)
29
+ end
30
+ end
24
31
  # return_authorization
25
32
  end
26
33
  end
@@ -27,8 +27,15 @@ FactoryBot.define do
27
27
  Spree::Promotion::Actions::CreateItemAdjustments.create!(calculator: calculator, promotion: promotion)
28
28
  end
29
29
  end
30
+
30
31
  factory :promotion_with_item_adjustment, traits: [:with_line_item_adjustment]
31
32
 
33
+ trait :with_free_shipping do
34
+ after(:create) do |promotion|
35
+ Spree::Promotion::Actions::FreeShipping.create!(promotion: promotion)
36
+ end
37
+ end
38
+
32
39
  trait :with_order_adjustment do
33
40
  transient do
34
41
  weighted_order_adjustment_amount { 10 }
@@ -17,7 +17,7 @@ FactoryBot.define do
17
17
 
18
18
  after(:build) do |package, evaluator|
19
19
  evaluator.variants_contents.each do |variant, count|
20
- package.add_multiple build_list(:inventory_unit, count, variant: variant)
20
+ package.add_multiple build_list(:inventory_unit, count, variant: variant, stock_location: evaluator.stock_location)
21
21
  end
22
22
  end
23
23
 
@@ -17,7 +17,10 @@ FactoryBot.define do
17
17
  end
18
18
 
19
19
  factory :admin_user do
20
- spree_roles { [Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')] }
20
+ after(:create) do |user, _|
21
+ admin_role = Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')
22
+ user.spree_roles << admin_role
23
+ end
21
24
  end
22
25
 
23
26
  factory :user_with_addresses do |_u|
@@ -17,27 +17,27 @@ Gem::Specification.new do |s|
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.require_path = 'lib'
19
19
 
20
- s.required_ruby_version = '>= 2.2.2'
20
+ s.required_ruby_version = '>= 2.4.0'
21
21
  s.required_rubygems_version = '>= 1.8.23'
22
22
 
23
23
  %w[
24
24
  actionmailer actionpack actionview activejob activemodel activerecord
25
25
  activesupport railties
26
26
  ].each do |rails_dep|
27
- s.add_dependency rails_dep, ['>= 5.1', '< 5.3.x']
27
+ s.add_dependency rails_dep, ['>= 5.1', '< 7.0.x']
28
28
  end
29
29
 
30
30
  s.add_dependency 'activemerchant', '~> 1.66'
31
31
  s.add_dependency 'acts_as_list', '~> 0.3'
32
- s.add_dependency 'awesome_nested_set', '~> 3.0', '>= 3.0.1'
33
- s.add_dependency 'cancancan', '~> 2.2'
32
+ s.add_dependency 'awesome_nested_set', '~> 3.2'
33
+ s.add_dependency 'cancancan', ['>= 2.2', '< 4.0']
34
34
  s.add_dependency 'carmen', '~> 1.1.0'
35
35
  s.add_dependency 'discard', '~> 1.0'
36
36
  s.add_dependency 'friendly_id', '~> 5.0'
37
37
  s.add_dependency 'kaminari-activerecord', '~> 1.1'
38
38
  s.add_dependency 'monetize', '~> 1.8'
39
- s.add_dependency 'paperclip', ['>= 4.2', '< 6']
39
+ s.add_dependency 'paperclip', '>= 4.2'
40
40
  s.add_dependency 'paranoia', '~> 2.4'
41
41
  s.add_dependency 'ransack', '~> 2.0'
42
- s.add_dependency 'state_machines-activerecord', '~> 0.4'
42
+ s.add_dependency 'state_machines-activerecord', '~> 0.6'
43
43
  end
@@ -60,7 +60,11 @@ RSpec.describe Spree::Core::Search::Base do
60
60
  search: { "price_range_any" => ["Under $10.00", "$10.00 - $15.00"] } }
61
61
  searcher = Spree::Core::Search::Base.new(params)
62
62
  expect(searcher.send(:get_base_scope).to_sql).to match /<= 10/
63
- expect(searcher.send(:get_base_scope).to_sql).to match /between 10 and 15/i
63
+ if Rails.gem_version >= Gem::Version.new('6.0.0')
64
+ expect(searcher.send(:get_base_scope).to_sql).to match /between 10\.0 and 15\.0/i
65
+ else
66
+ expect(searcher.send(:get_base_scope).to_sql).to match /between 10 and 15/i
67
+ end
64
68
  expect(searcher.retrieve_products.count).to eq(2)
65
69
  end
66
70
 
@@ -85,7 +85,7 @@ module Spree
85
85
  example.run
86
86
  described_class.search_terms = search_terms
87
87
  end
88
- before { variant.update_attributes!(weight: 5000) }
88
+ before { variant.update!(weight: 5000) }
89
89
 
90
90
  it { assert_found("5000", variant) }
91
91
  end
@@ -23,7 +23,14 @@ RSpec.describe Spree::Core::ControllerHelpers::StrongParameters, type: :controll
23
23
 
24
24
  describe '#permitted_checkout_attributes' do
25
25
  it 'returns Array class' do
26
- expect(controller.permitted_checkout_attributes.class).to eq Array
26
+ Spree::Deprecation.silence do
27
+ expect(controller.permitted_checkout_attributes.class).to eq Spree::CheckoutAdditionalAttributes
28
+ end
29
+ end
30
+
31
+ it 'is deprecated' do
32
+ expect(Spree::Deprecation).to receive(:warn)
33
+ controller.permitted_checkout_attributes
27
34
  end
28
35
  end
29
36
 
@@ -39,6 +39,24 @@ RSpec.describe Spree::Core::StockConfiguration do
39
39
  end
40
40
  end
41
41
 
42
+ describe '#location_filter_class' do
43
+ let(:stock_configuration) { described_class.new }
44
+ subject { stock_configuration.location_filter_class }
45
+
46
+ it "returns Spree::Stock::LocationFilter::Active" do
47
+ is_expected.to be ::Spree::Stock::LocationFilter::Active
48
+ end
49
+
50
+ context "with another constant name assiged" do
51
+ MyFilter = Class.new
52
+ before { stock_configuration.location_filter_class = MyFilter.to_s }
53
+
54
+ it "returns the constant" do
55
+ is_expected.to be MyFilter
56
+ end
57
+ end
58
+ end
59
+
42
60
  describe '#location_sorter_class' do
43
61
  let(:stock_configuration) { described_class.new }
44
62
  subject { stock_configuration.location_sorter_class }
@@ -56,4 +74,22 @@ RSpec.describe Spree::Core::StockConfiguration do
56
74
  end
57
75
  end
58
76
  end
77
+
78
+ describe '#allocator_class' do
79
+ let(:stock_configuration) { described_class.new }
80
+ subject { stock_configuration.allocator_class }
81
+
82
+ it "returns Spree::Stock::Allocator::OnHandFirst" do
83
+ is_expected.to be ::Spree::Stock::Allocator::OnHandFirst
84
+ end
85
+
86
+ context "with another constant name assiged" do
87
+ MyAllocator = Class.new
88
+ before { stock_configuration.allocator_class = MyAllocator.to_s }
89
+
90
+ it "returns the constant" do
91
+ is_expected.to be MyAllocator
92
+ end
93
+ end
94
+ end
59
95
  end