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
@@ -19,7 +19,7 @@ class Spree::Wallet::AddPaymentSourcesToWallet
19
19
  sources = payments.map(&:source).
20
20
  uniq.
21
21
  compact.
22
- select { |p| p.try(:reusable?) }
22
+ select { |payment| payment.try(:reusable?) }
23
23
 
24
24
  # add valid sources to wallet and optionally set a default
25
25
  if sources.any?
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Spree
4
4
  class WalletPaymentSource < Spree::Base
5
- belongs_to :user, class_name: Spree::UserClassHandle.new, foreign_key: 'user_id', inverse_of: :wallet_payment_sources
6
- belongs_to :payment_source, polymorphic: true, inverse_of: :wallet_payment_sources
5
+ belongs_to :user, class_name: Spree::UserClassHandle.new, foreign_key: 'user_id', inverse_of: :wallet_payment_sources, optional: true
6
+ belongs_to :payment_source, polymorphic: true, inverse_of: :wallet_payment_sources, optional: true
7
7
 
8
8
  validates_presence_of :user
9
9
  validates_presence_of :payment_source
@@ -40,7 +40,7 @@ module Spree
40
40
  end
41
41
 
42
42
  alias :members :zone_members
43
- accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |a| a['zoneable_id'].blank? }
43
+ accepts_nested_attributes_for :zone_members, allow_destroy: true, reject_if: proc { |member| member['zoneable_id'].blank? }
44
44
 
45
45
  self.whitelisted_ransackable_attributes = %w[name description]
46
46
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Spree
4
4
  class ZoneMember < Spree::Base
5
- belongs_to :zone, class_name: 'Spree::Zone', counter_cache: true, inverse_of: :zone_members
6
- belongs_to :zoneable, polymorphic: true
5
+ belongs_to :zone, class_name: 'Spree::Zone', counter_cache: true, inverse_of: :zone_members, optional: true
6
+ belongs_to :zoneable, polymorphic: true, optional: true
7
7
 
8
8
  delegate :name, to: :zoneable, allow_nil: true
9
9
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActiveSupport::Inflector.inflections(:en) do |inflect|
4
+ inflect.acronym 'RMA'
5
+ end
@@ -3,3 +3,5 @@
3
3
  require 'money'
4
4
 
5
5
  Money.locale_backend = :i18n
6
+ Money.rounding_mode = BigDecimal::ROUND_HALF_EVEN
7
+ Money.default_currency = Money::Currency.new(Spree::Config.currency)
@@ -163,8 +163,11 @@ en:
163
163
  type: Type
164
164
  spree/price:
165
165
  amount: Price
166
+ country: Country
166
167
  currency: Currency
167
168
  is_default: Currently Valid
169
+ price: Price
170
+ variant: Variant
168
171
  spree/product:
169
172
  available_on: Available On
170
173
  cost_currency: Cost Currency
@@ -200,6 +203,7 @@ en:
200
203
  starts_at: Start
201
204
  status: Status
202
205
  usage_limit: Usage Limit
206
+ uses: Uses
203
207
  spree/promotion/actions/create_adjustment:
204
208
  description: Creates a promotion credit adjustment on the order
205
209
  spree/promotion/actions/create_item_adjustments:
@@ -238,7 +242,17 @@ en:
238
242
  spree/promotion/rules/user_role:
239
243
  description: Order includes User with specified Role(s)
240
244
  spree/promotion_category:
245
+ code: Code
241
246
  name: Name
247
+ spree/promotion_code:
248
+ value: Value
249
+ spree/promotion_code_batch:
250
+ base_code: Base code
251
+ email: Email
252
+ join_characters: Join characters
253
+ number_of_codes: Number of codes
254
+ status: Status
255
+ total_codes: Total codes
242
256
  spree/property:
243
257
  name: Name
244
258
  presentation: Presentation
@@ -250,6 +264,7 @@ en:
250
264
  active: Active
251
265
  code: Code
252
266
  name: Name
267
+ state: State
253
268
  spree/reimbursement:
254
269
  created_at: Date/Time
255
270
  number: Number
@@ -294,6 +309,7 @@ en:
294
309
  name: Name
295
310
  spree/shipping_method:
296
311
  admin_name: Internal Name
312
+ available_to_users: Available to users
297
313
  carrier: Carrier
298
314
  code: Code
299
315
  display_on: Display
@@ -326,6 +342,7 @@ en:
326
342
  phone: Phone
327
343
  propagate_all_variants: Propagate All Variants
328
344
  restock_inventory: Restock Inventory
345
+ state: State
329
346
  state_id: State
330
347
  zipcode: Zip
331
348
  spree/stock_movement:
@@ -358,6 +375,9 @@ en:
358
375
  action: Action
359
376
  amount_remaining: Total Unused
360
377
  user_total_amount: Total Amount
378
+ spree/store_credit_reason:
379
+ name: Name
380
+ state: State
361
381
  spree/store_credit_update_reason:
362
382
  name: Name
363
383
  spree/tax_category:
@@ -372,6 +392,7 @@ en:
372
392
  name: Name
373
393
  show_rate_in_label: Show Rate in Label
374
394
  starts_at: Start Date
395
+ tax_categories: Tax Categories
375
396
  spree/taxon:
376
397
  description: Description
377
398
  icon: Icon
@@ -1065,6 +1086,7 @@ en:
1065
1086
  cannot_create_payment_without_payment_methods_html: You cannot create a payment
1066
1087
  for an order without any payment methods defined. %{link}
1067
1088
  cannot_create_returns: Cannot create returns as this order has no shipped units.
1089
+ cannot_edit_orders: You may only edit your current shopping cart.
1068
1090
  cannot_perform_operation: Cannot perform requested operation
1069
1091
  cannot_rebuild_shipments_order_completed: Cannot rebuild shipments for a completed
1070
1092
  order.
@@ -1350,6 +1372,14 @@ en:
1350
1372
  hidden: hidden
1351
1373
  hide_out_of_stock: Hide out of stock
1352
1374
  hints:
1375
+ spree/calculator:
1376
+ tax_rates: This is used to calculate both sales tax (United States-style taxes)
1377
+ and value-added tax (VAT). Typically this calculator should be the only tax
1378
+ calculator required by your store.
1379
+ shipping_methods: This is used to calculate the shipping rates on a per order or
1380
+ per package rate.
1381
+ promotions: This is used to determine the promotional discount to be applied to an
1382
+ order, an item, or shipping charges.
1353
1383
  spree/price:
1354
1384
  country: 'This determines in what country the price is valid.<br/>Default:
1355
1385
  Any Country'
@@ -1498,6 +1528,7 @@ en:
1498
1528
  log_entries: Log Entries
1499
1529
  logged_in_as: Logged in as
1500
1530
  logged_in_succesfully: Logged in successfully
1531
+ logged_in_successfully: Logged in successfully
1501
1532
  logged_out: You have been logged out.
1502
1533
  login: Login
1503
1534
  login_as_existing: Login as Existing Customer
@@ -1527,6 +1558,7 @@ en:
1527
1558
  meta_title: Meta Title
1528
1559
  metadata: Metadata
1529
1560
  minimal_amount: Minimal Amount
1561
+ minimize_menu: Minimize Menu
1530
1562
  modify_stock_count: Modify (+/-)
1531
1563
  month: Month
1532
1564
  more: More
@@ -1923,7 +1955,6 @@ en:
1923
1955
  select: Select
1924
1956
  select_a_reason: Select a reason
1925
1957
  select_a_stock_location: Select a stock location
1926
- select_stock: Select stock
1927
1958
  selected_quantity_not_available: selected of %{item} is not available.
1928
1959
  send_copy_of_all_mails_to: Send Copy of All Mails To
1929
1960
  send_mailer: Send Mailer
@@ -2083,6 +2114,7 @@ en:
2083
2114
  (i.e. if the tax rate is 5% then enter 0.05)
2084
2115
  tax_rates: Tax Rates
2085
2116
  taxon: Taxon
2117
+ taxon_attachment_removal_error: There was an error removing the attachment
2086
2118
  taxon_edit: Edit Taxon
2087
2119
  taxon_placeholder: Add a Taxon
2088
2120
  taxon_rule:
@@ -2202,8 +2234,7 @@ en:
2202
2234
  you_cannot_undo_action: You will not be able to undo this action
2203
2235
  you_have_no_orders_yet: You have no orders yet
2204
2236
  your_cart_is_empty: Your cart is empty
2205
- your_order_is_empty_add_product: Your order is empty, please search for and add
2206
- a product above
2237
+ your_order_is_empty_add_product: Your order is empty. Please add products first.
2207
2238
  zip: Zip
2208
2239
  zipcode: Zip Code
2209
2240
  zone: Zone
@@ -42,6 +42,8 @@ module Spree
42
42
  opts[:skip_spring] = true
43
43
  opts[:skip_test] = true
44
44
  opts[:skip_yarn] = true
45
+ opts[:skip_bootsnap] = true
46
+ opts[:skip_webpack_install] = true
45
47
 
46
48
  puts "Generating dummy Rails application..."
47
49
  invoke Rails::Generators::AppGenerator,
@@ -93,3 +93,11 @@ Spree.user_class = <%= (options[:user_class].blank? ? "Spree::LegacyUser" : opti
93
93
  # just uncomment the following code and change it as you need.
94
94
  #
95
95
  # Spree::Model.whitelisted_ransackable_attributes << 'field'
96
+
97
+ # Rules for avoiding to store the current path into session for redirects
98
+ # When at least one rule is matched, the request path will not be stored
99
+ # in session.
100
+ # You can add your custom rules by uncommenting this line and changing
101
+ # the class name:
102
+ #
103
+ # Spree::UserLastUrlStorer.rules << 'Spree::UserLastUrlStorer::Rules::AuthenticationRule'
@@ -292,6 +292,14 @@ module Spree
292
292
 
293
293
  class_name_attribute :variant_search_class, default: 'Spree::Core::Search::Variant'
294
294
 
295
+ # Allows implementing custom vat prices generation
296
+ # @!attribute [rw] variant_vat_prices_generator_class
297
+ # @see Spree::Variant::VatPriceGenerator
298
+ # @return [Class] an object that conforms to the API of
299
+ # the standard variant vat prices generator class
300
+ # Spree::Variant::VatPriceGenerator.
301
+ class_name_attribute :variant_vat_prices_generator_class, default: 'Spree::Variant::VatPriceGenerator'
302
+
295
303
  # promotion_chooser_class allows extensions to provide their own PromotionChooser
296
304
  class_name_attribute :promotion_chooser_class, default: 'Spree::PromotionChooser'
297
305
 
@@ -306,7 +314,6 @@ module Spree
306
314
  # @!attribute [rw] shipping_rate_tax_calculator_class
307
315
  # @return [Class] a class with the same public interfaces as
308
316
  # Spree::TaxCalculator::ShippingRate
309
- # @api experimental
310
317
  class_name_attribute :shipping_rate_tax_calculator_class, default: 'Spree::TaxCalculator::ShippingRate'
311
318
 
312
319
  # Allows providing your own Mailer for order mailer.
@@ -384,7 +391,6 @@ module Spree
384
391
  # @!attribute [rw] tax_adjuster_class
385
392
  # @return [Class] a class with the same public interfaces as
386
393
  # Spree::Tax::OrderAdjuster
387
- # @api experimental
388
394
  class_name_attribute :tax_adjuster_class, default: 'Spree::Tax::OrderAdjuster'
389
395
 
390
396
  # Allows providing your own class for calculating taxes on an order.
@@ -392,7 +398,6 @@ module Spree
392
398
  # @!attribute [rw] tax_calculator_class
393
399
  # @return [Class] a class with the same public interfaces as
394
400
  # Spree::TaxCalculator::Default
395
- # @api experimental
396
401
  class_name_attribute :tax_calculator_class, default: 'Spree::TaxCalculator::Default'
397
402
 
398
403
  # Allows providing your own class for choosing which store to use.
@@ -454,6 +459,10 @@ module Spree
454
459
  @order_number_generator ||= Spree::Order::NumberGenerator.new
455
460
  end
456
461
 
462
+ def state_machines
463
+ @state_machines ||= Spree::Core::StateMachines.new
464
+ end
465
+
457
466
  def static_model_preferences
458
467
  @static_model_preferences ||= Spree::Preferences::StaticModelPreferences.new
459
468
  end
@@ -473,6 +482,12 @@ module Spree
473
482
  @events_configuration ||= Spree::Event::Configuration.new
474
483
  end
475
484
 
485
+ def user_last_url_storer_rules
486
+ @user_last_url_storer_rules ||= ::Spree::Core::ClassConstantizer::Set.new.tap do |set|
487
+ set << 'Spree::UserLastUrlStorer::Rules::AuthenticationRule'
488
+ end
489
+ end
490
+
476
491
  def environment
477
492
  @environment ||= Spree::Core::Environment.new(self).tap do |env|
478
493
  env.calculators.promotion_actions_create_adjustments = %w[
@@ -53,6 +53,17 @@ module Spree
53
53
  end
54
54
  end
55
55
 
56
+ if Gem::Version.new(Rails.version) < Gem::Version.new('5.2')
57
+ warn <<~HEREDOC
58
+ Rails 5.1 (EOL) is deprecated and will not be supported anymore from the next Solidus version.
59
+ Please, upgrade to a more recent Rails version.
60
+
61
+ Read more on upgrading from Rails 5.1 to Rails 5.2 here:
62
+ https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-5-1-to-rails-5-2
63
+
64
+ HEREDOC
65
+ end
66
+
56
67
  require 'spree/core/version'
57
68
 
58
69
  require 'spree/core/active_merchant_dependencies'
@@ -85,6 +96,7 @@ require 'spree/core/controller_helpers/search'
85
96
  require 'spree/core/controller_helpers/store'
86
97
  require 'spree/core/controller_helpers/strong_parameters'
87
98
  require 'spree/core/role_configuration'
99
+ require 'spree/core/state_machines'
88
100
  require 'spree/core/stock_configuration'
89
101
  require 'spree/core/validators/email'
90
102
  require 'spree/permission_sets'
@@ -50,19 +50,7 @@ module Spree
50
50
  end
51
51
 
52
52
  def store_location
53
- # disallow return to login, logout, signup pages
54
- authentication_routes = [:spree_signup_path, :spree_login_path, :spree_logout_path]
55
- disallowed_urls = []
56
- authentication_routes.each do |route|
57
- if respond_to?(route)
58
- disallowed_urls << send(route)
59
- end
60
- end
61
-
62
- disallowed_urls.map!{ |url| url[/\/\w+$/] }
63
- unless disallowed_urls.include?(request.fullpath)
64
- session['spree_user_return_to'] = request.fullpath.gsub('//', '/')
65
- end
53
+ Spree::UserLastUrlStorer.new(self).store_location
66
54
  end
67
55
 
68
56
  # proxy method to *possible* spree_current_user method
@@ -31,16 +31,30 @@ module Spree
31
31
  end
32
32
 
33
33
  def permitted_checkout_attributes
34
- permitted_attributes.checkout_attributes + [
35
- bill_address_attributes: permitted_address_attributes,
36
- ship_address_attributes: permitted_address_attributes,
37
- payments_attributes: permitted_payment_attributes,
38
- shipments_attributes: permitted_shipment_attributes
39
- ]
34
+ permitted_attributes.checkout_attributes
35
+ end
36
+
37
+ def permitted_checkout_address_attributes
38
+ permitted_attributes.checkout_address_attributes
39
+ end
40
+
41
+ def permitted_checkout_delivery_attributes
42
+ permitted_attributes.checkout_delivery_attributes
43
+ end
44
+
45
+ def permitted_checkout_payment_attributes
46
+ permitted_attributes.checkout_payment_attributes
47
+ end
48
+
49
+ def permitted_checkout_confirm_attributes
50
+ permitted_attributes.checkout_confirm_attributes
40
51
  end
41
52
 
42
53
  def permitted_order_attributes
43
- permitted_checkout_attributes + [
54
+ permitted_checkout_address_attributes +
55
+ permitted_checkout_delivery_attributes +
56
+ permitted_checkout_payment_attributes +
57
+ permitted_checkout_confirm_attributes + [
44
58
  line_items_attributes: permitted_line_item_attributes
45
59
  ]
46
60
  end
@@ -11,8 +11,8 @@ module Spree
11
11
  isolate_namespace Spree
12
12
  engine_name 'spree'
13
13
 
14
- config.generators do |g|
15
- g.test_framework :rspec
14
+ config.generators do |generator|
15
+ generator.test_framework :rspec
16
16
  end
17
17
 
18
18
  initializer "spree.environment", before: :load_config_initializers do |app|
@@ -29,7 +29,7 @@ module Spree
29
29
 
30
30
  completed_at = params.delete(:completed_at)
31
31
 
32
- order.update_attributes!(params)
32
+ order.update!(params)
33
33
 
34
34
  order.create_proposed_shipments unless shipments_attrs.present?
35
35
 
@@ -53,17 +53,17 @@ module Spree
53
53
  def self.create_shipments_from_params(shipments_hash, order)
54
54
  return [] unless shipments_hash
55
55
 
56
- shipments_hash.each do |s|
56
+ shipments_hash.each do |target|
57
57
  shipment = Shipment.new
58
- shipment.tracking = s[:tracking]
59
- shipment.stock_location = Spree::StockLocation.find_by(admin_name: s[:stock_location]) || Spree::StockLocation.find_by!(name: s[:stock_location])
58
+ shipment.tracking = target[:tracking]
59
+ shipment.stock_location = Spree::StockLocation.find_by(admin_name: target[:stock_location]) || Spree::StockLocation.find_by!(name: target[:stock_location])
60
60
 
61
- inventory_units = s[:inventory_units] || []
62
- inventory_units.each do |iu|
63
- ensure_variant_id_from_params(iu)
61
+ inventory_units = target[:inventory_units] || []
62
+ inventory_units.each do |inventory_unit|
63
+ ensure_variant_id_from_params(inventory_unit)
64
64
 
65
- unless line_item = order.line_items.find_by(variant_id: iu[:variant_id])
66
- line_item = order.contents.add(Spree::Variant.find(iu[:variant_id]), 1)
65
+ unless line_item = order.line_items.find_by(variant_id: inventory_unit[:variant_id])
66
+ line_item = order.contents.add(Spree::Variant.find(inventory_unit[:variant_id]), 1)
67
67
  end
68
68
 
69
69
  # Spree expects a Inventory Unit to always reference a line
@@ -71,14 +71,14 @@ module Spree
71
71
  # trying to view these units. Note the Importer might not be
72
72
  # able to find the line item if line_item.variant_id |= iu.variant_id
73
73
  shipment.inventory_units.new(
74
- variant_id: iu[:variant_id],
74
+ variant_id: inventory_unit[:variant_id],
75
75
  line_item: line_item
76
76
  )
77
77
  end
78
78
 
79
79
  # Mark shipped if it should be.
80
- if s[:shipped_at].present?
81
- shipment.shipped_at = s[:shipped_at]
80
+ if target[:shipped_at].present?
81
+ shipment.shipped_at = target[:shipped_at]
82
82
  shipment.state = 'shipped'
83
83
  shipment.inventory_units.each do |unit|
84
84
  unit.state = 'shipped'
@@ -88,9 +88,9 @@ module Spree
88
88
  order.shipments << shipment
89
89
  shipment.save!
90
90
 
91
- shipping_method = Spree::ShippingMethod.find_by(name: s[:shipping_method]) || Spree::ShippingMethod.find_by!(admin_name: s[:shipping_method])
91
+ shipping_method = Spree::ShippingMethod.find_by(name: target[:shipping_method]) || Spree::ShippingMethod.find_by!(admin_name: target[:shipping_method])
92
92
  rate = shipment.shipping_rates.create!(shipping_method: shipping_method,
93
- cost: s[:cost])
93
+ cost: target[:cost])
94
94
  shipment.selected_shipping_rate_id = rate.id
95
95
  shipment.update_amounts
96
96
  end
@@ -98,13 +98,13 @@ module Spree
98
98
 
99
99
  def self.create_line_items_from_params(line_items_hash, order)
100
100
  return {} unless line_items_hash
101
- line_items_hash.each_key do |k|
102
- extra_params = line_items_hash[k].except(:variant_id, :quantity, :sku)
103
- line_item = ensure_variant_id_from_params(line_items_hash[k])
101
+ line_items_hash.each_key do |key|
102
+ extra_params = line_items_hash[key].except(:variant_id, :quantity, :sku)
103
+ line_item = ensure_variant_id_from_params(line_items_hash[key])
104
104
  line_item = order.contents.add(Spree::Variant.find(line_item[:variant_id]), line_item[:quantity])
105
105
  # Raise any errors with saving to prevent import succeeding with line items failing silently.
106
106
  if extra_params.present?
107
- line_item.update_attributes!(extra_params)
107
+ line_item.update!(extra_params)
108
108
  else
109
109
  line_item.save!
110
110
  end
@@ -113,11 +113,11 @@ module Spree
113
113
 
114
114
  def self.create_adjustments_from_params(adjustments, order)
115
115
  return [] unless adjustments
116
- adjustments.each do |a|
116
+ adjustments.each do |target|
117
117
  adjustment = order.adjustments.build(
118
118
  order: order,
119
- amount: a[:amount].to_d,
120
- label: a[:label]
119
+ amount: target[:amount].to_d,
120
+ label: target[:label]
121
121
  )
122
122
  adjustment.save!
123
123
  adjustment.finalize!
@@ -126,14 +126,15 @@ module Spree
126
126
 
127
127
  def self.create_payments_from_params(payments_hash, order)
128
128
  return [] unless payments_hash
129
- payments_hash.each do |p|
129
+ payments_hash.each do |target|
130
130
  payment = order.payments.build order: order
131
- payment.amount = p[:amount].to_f
131
+ payment.amount = target[:amount].to_f
132
132
  # Order API should be using state as that's the normal payment field.
133
133
  # spree_wombat serializes payment state as status so imported orders should fall back to status field.
134
- payment.state = p[:state] || p[:status] || 'completed'
135
- payment.payment_method = Spree::PaymentMethod.find_by!(name: p[:payment_method])
136
- payment.source = create_source_payment_from_params(p[:source], payment) if p[:source]
134
+ payment.state = target[:state] || target[:status] || 'completed'
135
+ payment.payment_method = Spree::PaymentMethod.find_by!(name: target[:payment_method])
136
+ source_attributes = target[:source] || target[:source_attributes]
137
+ payment.source = create_source_payment_from_params(source_attributes, payment) if source_attributes
137
138
  payment.save!
138
139
  end
139
140
  end
@@ -170,8 +171,8 @@ module Spree
170
171
  search[:iso_name] = iso_name.upcase
171
172
  elsif iso = address[:country]['iso']
172
173
  search[:iso] = iso.upcase
173
- elsif iso3 = address[:country]['iso3']
174
- search[:iso3] = iso3.upcase
174
+ elsif iso_three = address[:country]['iso3']
175
+ search[:iso3] = iso_three.upcase
175
176
  end
176
177
 
177
178
  address.delete(:country)