solidus_core 4.1.5 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -1
  3. data/app/assets/images/logo/solidus.svg +18 -1
  4. data/app/assets/images/logo/solidus_logo.png +0 -0
  5. data/app/models/spree/adjustment.rb +2 -0
  6. data/app/models/spree/option_value.rb +1 -0
  7. data/app/models/spree/order.rb +3 -3
  8. data/app/models/spree/order_inventory.rb +6 -4
  9. data/app/models/spree/order_updater.rb +1 -1
  10. data/app/models/spree/product.rb +19 -1
  11. data/app/models/spree/promotion_handler/coupon.rb +1 -1
  12. data/app/models/spree/stock/simple_coordinator.rb +36 -22
  13. data/app/models/spree/stock/splitter/shipping_category.rb +1 -1
  14. data/app/models/spree/store_selector/by_server_name.rb +1 -1
  15. data/app/models/spree/variant/scopes.rb +4 -0
  16. data/config/locales/en.yml +4 -0
  17. data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -1
  18. data/lib/generators/solidus/install/install_generator.rb +9 -0
  19. data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +6 -3
  20. data/lib/generators/spree/dummy/dummy_generator.rb +0 -1
  21. data/lib/generators/spree/dummy/templates/rails/database.yml +2 -2
  22. data/lib/generators/spree/dummy/templates/rails/test.rb +1 -1
  23. data/lib/spree/app_configuration.rb +0 -2
  24. data/lib/spree/core/engine.rb +6 -0
  25. data/lib/spree/core/state_machines/order.rb +1 -5
  26. data/lib/spree/core/version.rb +2 -2
  27. data/lib/spree/core.rb +8 -2
  28. data/lib/spree/deprecated_instance_variable_proxy.rb +57 -0
  29. data/lib/spree/deprecation.rb +3 -51
  30. data/lib/spree/money.rb +1 -1
  31. data/lib/spree/preferences/configuration.rb +1 -1
  32. data/lib/spree/preferences/preferable_class_methods.rb +0 -1
  33. data/lib/spree/testing_support/dummy_app/assets/stylesheets/solidus_admin/tailwind.css +1 -0
  34. data/lib/spree/testing_support/dummy_app.rb +1 -1
  35. data/lib/spree/testing_support/factory_bot.rb +1 -1
  36. data/lib/spree/testing_support/silence_deprecations.rb +1 -1
  37. data/solidus_core.gemspec +1 -1
  38. metadata +5 -24
  39. data/app/models/spree/promotion_rule_role.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8422983aea32a3cdf481647862a2ada3210d21c38936c0d0af370772bc04b4d
4
- data.tar.gz: 6fb241fe0339fce0747a496366f449f69671d90c0a69cd9483ccd1b0229ce7c0
3
+ metadata.gz: 87d19e38f8adcb38c0b6ef11dbec002b9e91a318f2d4e17fdeacc0c5dc5e8a23
4
+ data.tar.gz: d72606376f7c22b9a3f33f6fde535c7e79170150aedbfcac3ac3a62048aa657f
5
5
  SHA512:
6
- metadata.gz: 5ca4af53faa281166a5a0f345d60a628e96dadbfce58a30d4948a63a21dc7386009d4b2a7c88521dc9979a61d8ac1adc4741e70168cc689e70b7b6f0deeb5368
7
- data.tar.gz: 59ea38f49224546adf4bafc2720e6bd583b8823f3e4582c250c3fa949cc1a153479f2d969694f65a0b2e1d224e3c60595cfd0140e69c0e929db7d50a039b679d
6
+ metadata.gz: d383cdf58d3939f4d0e013a9b2598e77e54e6aa0b72b91d3f4be512cce53f049cb560d3843bc7129ef6bbe23c1b36f5a8020e436a4df7d3d2f1e2f8aa3a73c4d
7
+ data.tar.gz: 4cb2ee92d241c9110dd1c261511771ccac993dd21e7d29826859ebaba3218e318da1d9b9f90af5f535c1187f3d46b884768b80fc46ff842f56cadedb39cfd6fc
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ require 'rake'
5
5
  require 'rake/testtask'
6
6
  require 'rspec/core/rake_task'
7
7
  require 'spree/testing_support/dummy_app/rake_tasks'
8
- require 'bundler/gem_tasks'
9
8
 
10
9
  RSpec::Core::RakeTask.new
11
10
  task default: :spec
@@ -1 +1,18 @@
1
- <svg width="153" height="38" viewBox="0 0 153 38" xmlns="http://www.w3.org/2000/svg"><g fill="#242830" fill-rule="nonzero"><path d="M45.0815035 17.9295775l-4.2797203-.808169c-1.6476923-.2729578-2.5838811-.899155-2.5838811-2.0819719 0-1.6056338 1.8135315-2.4994366 3.6431119-2.4994366 1.3962587 0 3.2472377.4335211 5.3496503 2.2050704l2.4340909-2.9971831c-2.706923-1.93746476-5.1196153-2.75098589-7.863986-2.75098589-4.9537762 0-7.7890909 3.12563379-7.7890909 6.47605629 0 2.8312677 1.5620979 4.6242254 7.1417832 5.6678874l2.4126923.4549295c1.5620979.2943662 2.5838812.9794367 2.5838812 2.2907043 0 1.1025352-1.4818532 2.4994366-3.9373427 2.4994366-2.2040559 0-4.7023426-1.2684507-6.2216433-2.9169014l-2.9637063 2.9597183c2.706923 2.2907042 5.5796853 3.4788732 8.9285664 3.4788732 6.0183566 0 8.3882517-3.7464788 8.3882517-6.6847887s-1.727937-4.6456338-5.2426573-5.2932394zM62.960035 8.99690141c-6.9545455 0-10.9293357 5.20760559-10.9293357 10.43661969 0 5.2290141 4.0175874 10.4312676 10.9293357 10.4312676 6.9117482 0 10.9293356-5.2076056 10.9293356-10.4312676 0-5.2236619-4.0175874-10.43661969-10.9293356-10.43661969zm0 16.89126759c-3.5454364 0-6.4195805-2.8754669-6.4195805-6.4225352 0-3.5470682 2.8741441-6.4225352 6.4195805-6.4225352 3.5454363 0 6.4195804 2.875467 6.4195804 6.4225352.0277543 1.7117236-.6396762 3.3615035-1.8496498 4.572034-1.2099737 1.2105306-2.8589946 1.8782684-4.5699306 1.8505012zM88.5634615 3.58591549c-1.1818121 0-2.1398601.95848899-2.1398601 2.14084507 0 1.18235609.958048 2.14084507 2.1398601 2.14084507 1.1818122 0 2.1398602-.95848898 2.1398602-2.14084507 0-1.18235608-.958048-2.14084507-2.1398602-2.14084507zm-2.1238112 8.53661971h4.2476224v17.763662h-4.2476224v-17.763662zm23.8915387-1.0597183c-1.951059-1.37951017-4.293144-2.09615393-6.681713-2.04450704-6.9063991 0-10.9239865 5.20760564-10.9239865 10.43126764 0 5.2236619 4.0175874 10.4366197 10.9239865 10.4366197 2.388342.0384309 4.727465-.6810542 6.681713-2.0552113v2.0445071h4.247622V3.58591549h-4.247622v7.47690141zm-6.681713 14.8253521c-3.545437 0-6.4195809-2.8754669-6.4195809-6.4225352 0-3.5470682 2.8741439-6.4225352 6.4195809-6.4225352 3.545436 0 6.41958 2.875467 6.41958 6.4225352.027754 1.7117236-.639676 3.3615035-1.84965 4.572034-1.209974 1.2105306-2.858994 1.8782684-4.56993 1.8505012zm26.881993-5.2504225c0 2.9169014-2.139861 4.9988732-4.787938 4.9988732-2.648076 0-4.787937-2.0819718-4.787937-4.9988732V9.03971831h-4.27972V21.0123944c0 5.5822535 4.349266 8.8952112 9.051609 8.8952112 4.702342 0 9.083706-3.3343662 9.083706-8.8952112V9.03971831h-4.27972V20.6377465zm17.118881-2.6439437l-4.279721-.8135211c-1.647692-.2676056-2.583881-.8938028-2.583881-2.0819718 0-1.6056338 1.813532-2.4994367 3.643112-2.4994367 1.396259 0 3.247238.4388733 5.34965 2.2104226l2.434091-2.9971831c-2.701573-1.93746481-5.119615-2.75098594-7.863986-2.75098594-4.953776 0-7.783741 3.12563384-7.783741 6.47605634 0 2.8098592 1.556748 4.6242254 7.115035 5.6411268l2.418042.4602816c1.556748.2890141 2.578532.9794367 2.578532 2.2907043 0 1.1025352-1.476504 2.4994366-3.931993 2.4994366-2.209406 0-4.707693-1.2684507-6.226993-2.9169014l-2.91021 2.9811267c2.680175 2.2907043 5.547587 3.4788733 8.901818 3.4788733 6.013007 0 8.388252-3.7464789 8.388252-6.6847887 0-2.9383099-1.727937-4.6456338-5.248007-5.2932395zm-67.3734969 3.7678873V7.98c0-4.14788732-2.0382167-5.64647887-6.4195804-7.74985916L71.9848951 3.5859155l2.2896504 1.31126761c1.1822727.68507042 1.6637412 1.45577465 1.727937 3.45746479V22.1577465c0 4.1478873 2.0382168 5.6464789 6.4195804 7.7498591l1.8723777-3.3557746-2.2896504-1.3326761c-1.1876224-.6850704-1.6637412-1.4557746-1.7279371-3.4574648zM.20863636 37.8876056H23.6829021V.15521127H.20863636V37.8876056zM3.56821678 3.51633803H20.2698252V34.4729577H3.56821678V3.51633803z"/><path d="M13.5934615 24.2450704V13.6104225c0-3.2112676-1.5727972-4.35126757-4.95912584-5.97295771L7.18993007 10.2225352l1.76538462 1.0169014c.91479021.5352113 1.28391611 1.1239437 1.33206291 2.6760564v10.6507042c0 3.2112676 1.5727972 4.3512676 4.9591259 5.9729577l1.4497552-2.5850704-1.7707342-1.043662c-.9147902-.5298591-1.2839161-1.1239436-1.332063-2.6653521z"/></g></svg>
1
+ <svg width="800" height="154" viewBox="0 0 800 154" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_1325_2710)">
3
+ <path d="M47.8141 51.0973V102.195L0 54.3805C9.53862 22.9134 38.7766 0 73.3714 0C107.966 0 135.13 21.3237 145.654 51.0973H47.8141Z" fill="#EF3023"/>
4
+ <path d="M146.725 98.9286C137.187 130.413 107.949 153.309 73.3541 153.309C38.7593 153.309 11.595 131.968 1.07137 102.212H98.9114V51.0973L146.725 98.9114V98.9286Z" fill="#EF3023"/>
5
+ <path d="M282.53 99.9481C282.53 79.765 265.734 73.9934 251.028 69.9499C236.478 65.9063 225.972 64.3165 225.972 53.6547C225.972 45.8614 233.109 40.0898 243.615 40.0898C254.121 40.0898 261.811 46.4316 263.072 56.0912H281.13C278.469 36.0463 263.919 23.6392 243.615 23.6392C223.311 23.6392 207.776 36.772 207.776 53.9312C207.776 74.4081 224.434 80.1797 239.278 84.2232C253.828 88.1113 264.61 89.8565 264.61 100.518C264.61 108.156 256.627 113.928 245.568 113.928C232.556 113.928 224.849 107.724 223.173 96.4748H204.7C206.515 117.246 222.62 130.361 245.568 130.361C267.271 130.361 282.513 118.11 282.513 99.9309L282.53 99.9481Z" fill="#222222"/>
6
+ <path d="M345.637 130.378C375.739 130.378 396.44 106.878 396.44 77.0175C396.44 47.1574 375.721 23.6565 345.637 23.6565C315.552 23.6565 294.833 47.1574 294.833 77.0175C294.833 106.878 315.552 130.378 345.637 130.378ZM345.637 112.787C326.888 112.787 313.029 97.3562 313.029 77.0175C313.029 56.6788 326.888 41.2477 345.637 41.2477C364.385 41.2477 378.244 56.9725 378.244 77.0175C378.244 97.0624 362.848 112.787 345.637 112.787Z" fill="#222222"/>
7
+ <path d="M474.961 111.629H428.063V25.0906H410.42V128.927H474.944V111.612L474.961 111.629Z" fill="#222222"/>
8
+ <path d="M493.399 25.0906V128.927H511.042V25.0906H493.399Z" fill="#222222"/>
9
+ <path d="M566.753 25.0908H531.208V128.927H566.753C594.609 128.927 615.189 108.156 615.189 77.0002C615.189 45.8442 594.609 25.0735 566.753 25.0735V25.0908ZM566.338 111.63H548.834V42.4054H566.338C584.811 42.4054 596.993 56.2468 596.993 77.0175C596.993 97.7882 584.811 111.63 566.338 111.63Z" fill="#222222"/>
10
+ <path d="M708.156 25.0906H690.513V89.7009C690.513 103.11 683.238 112.77 668.671 112.77C655.797 112.77 646.829 104.977 646.829 89.7009V25.0906H629.186V90.1329C629.186 114.221 645.274 130.378 668.654 130.378C692.034 130.378 708.122 114.221 708.122 90.1329V25.0906H708.156Z" fill="#222222"/>
11
+ <path d="M800 99.9481C800 79.765 783.204 73.9934 768.498 69.9499C753.949 65.9063 743.442 64.3165 743.442 53.6547C743.442 45.8614 750.579 40.0898 761.085 40.0898C771.592 40.0898 779.281 46.4316 780.543 56.0912H798.6C795.939 36.0463 781.389 23.6392 761.085 23.6392C740.781 23.6392 725.246 36.772 725.246 53.9312C725.246 74.4081 741.904 80.1797 756.748 84.2232C771.298 88.1113 782.081 89.8565 782.081 100.518C782.081 108.156 774.097 113.928 763.038 113.928C750.026 113.928 742.319 107.724 740.643 96.4748H722.17C723.985 117.246 740.09 130.361 763.038 130.361C784.724 130.361 799.983 118.11 799.983 99.9309L800 99.9481Z" fill="#222222"/>
12
+ </g>
13
+ <defs>
14
+ <clipPath id="clip0_1325_2710">
15
+ <rect width="800" height="153.309" fill="white"/>
16
+ </clipPath>
17
+ </defs>
18
+ </svg>
@@ -48,6 +48,8 @@ module Spree
48
48
  scope :is_included, -> { where(included: true) }
49
49
  scope :additional, -> { where(included: false) }
50
50
 
51
+ singleton_class.deprecate :return_authorization, deprecator: Spree.deprecator
52
+
51
53
  extend DisplayMoney
52
54
  money_methods :amount
53
55
 
@@ -17,6 +17,7 @@ module Spree
17
17
  delegate :name, :presentation, to: :option_type, prefix: :option_type
18
18
 
19
19
  self.allowed_ransackable_attributes = %w[name presentation]
20
+ self.allowed_ransackable_associations = %w[variants]
20
21
 
21
22
  # Updates the updated_at column on all the variants associated with this
22
23
  # option value.
@@ -264,7 +264,7 @@ module Spree
264
264
  @recalculator ||= Spree::Config.order_recalculator_class.new(self)
265
265
  end
266
266
  alias_method :updater, :recalculator
267
- deprecate updater: :recalculator, deprecator: Spree::Deprecation
267
+ deprecate updater: :recalculator, deprecator: Spree.deprecator
268
268
 
269
269
  def assign_billing_to_shipping_address
270
270
  self.ship_address = bill_address if bill_address
@@ -513,7 +513,7 @@ module Spree
513
513
  end
514
514
 
515
515
  alias_method :ensure_updated_shipments, :check_shipments_and_restart_checkout
516
- deprecate ensure_updated_shipments: :check_shipments_and_restart_checkout, deprecator: Spree::Deprecation
516
+ deprecate ensure_updated_shipments: :check_shipments_and_restart_checkout, deprecator: Spree.deprecator
517
517
 
518
518
  def restart_checkout_flow
519
519
  return if state == 'cart'
@@ -630,7 +630,7 @@ module Spree
630
630
  if can_complete? || complete?
631
631
  valid_store_credit_payments.to_a.sum(&:amount)
632
632
  else
633
- [total, user.try(:available_store_credit_total, currency: currency) || 0.0].min
633
+ [total, (user.try(:available_store_credit_total, currency: currency) || 0.0)].min
634
634
  end
635
635
  end
636
636
 
@@ -61,10 +61,12 @@ module Spree
61
61
 
62
62
  potential_shipments.detect do |shipment|
63
63
  shipment.include?(variant)
64
- end || potential_shipments.detect do |shipment|
65
- stock_item = variant.stock_items.detect { |stock_item| stock_item.stock_location == shipment.stock_location }
66
- if stock_item
67
- stock_item.backorderable? || stock_item.count_on_hand >= quantity
64
+ end || begin
65
+ stock_items = variant.stock_items.sort_by(&:id) # cache stock items to avoid N+1
66
+
67
+ potential_shipments.detect do |shipment|
68
+ stock_item = stock_items.detect { |stock_item| stock_item.stock_location == shipment.stock_location }
69
+ stock_item.backorderable? || stock_item.count_on_hand >= quantity if stock_item
68
70
  end
69
71
  end || potential_shipments.detect do |shipment|
70
72
  variant.stock_location_ids.include?(shipment.stock_location_id)
@@ -31,7 +31,7 @@ module Spree
31
31
  end
32
32
  end
33
33
  alias_method :update, :recalculate
34
- deprecate update: :recalculate, deprecator: Spree::Deprecation
34
+ deprecate update: :recalculate, deprecator: Spree.deprecator
35
35
 
36
36
  # Updates the +shipment_state+ attribute according to the following logic:
37
37
  #
@@ -131,8 +131,26 @@ module Spree
131
131
 
132
132
  alias :options :product_option_types
133
133
 
134
+ # The :variants_option_values ransacker filters Spree::Product based on
135
+ # variant option values ids.
136
+ #
137
+ # Usage:
138
+ # Spree::Product.ransack(
139
+ # variants_option_values_in: [option_value_id1, option_value_id2]
140
+ # ).result
141
+ ransacker :variants_option_values, formatter: proc { |v|
142
+ if OptionValue.exists?(v)
143
+ joins(variants_including_master: :option_values)
144
+ .where(spree_option_values: { id: v })
145
+ .distinct
146
+ .select(:id).arel
147
+ end
148
+ } do |parent|
149
+ parent.table[:id]
150
+ end
151
+
134
152
  self.allowed_ransackable_associations = %w[stores variants_including_master master variants]
135
- self.allowed_ransackable_attributes = %w[name slug]
153
+ self.allowed_ransackable_attributes = %w[name slug variants_option_values]
136
154
  self.allowed_ransackable_scopes = %i[available with_discarded with_all_variant_sku_cont with_kept_variant_sku_cont]
137
155
 
138
156
  # @return [Boolean] true if there are any variants
@@ -73,7 +73,7 @@ module Spree
73
73
 
74
74
  unless promotion.eligible?(order, promotion_code: promotion_code)
75
75
  set_promotion_eligibility_error_code(promotion)
76
- return error || ineligible_for_this_order
76
+ return (error || ineligible_for_this_order)
77
77
  end
78
78
 
79
79
  # If any of the actions for the promotion return `true`,
@@ -22,39 +22,65 @@ module Spree
22
22
  class SimpleCoordinator
23
23
  attr_reader :order
24
24
 
25
+ # @api private
26
+ attr_reader :inventory_units, :splitters, :stock_locations,
27
+ :filtered_stock_locations, :inventory_units_by_variant, :desired,
28
+ :availability, :allocator, :packages
29
+
25
30
  def initialize(order, inventory_units = nil)
26
31
  @order = order
27
32
  @inventory_units =
28
33
  inventory_units || Spree::Config.stock.inventory_unit_builder_class.new(order).units
29
34
  @splitters = Spree::Config.environment.stock_splitters
30
35
 
31
- filtered_stock_locations = Spree::Config.stock.location_filter_class.new(Spree::StockLocation.all, @order).filter
36
+ @filtered_stock_locations = Spree::Config.stock.location_filter_class.new(load_stock_locations, order).filter
32
37
  sorted_stock_locations = Spree::Config.stock.location_sorter_class.new(filtered_stock_locations).sort
33
38
  @stock_locations = sorted_stock_locations
34
39
 
35
40
  @inventory_units_by_variant = @inventory_units.group_by(&:variant)
36
- @desired = Spree::StockQuantities.new(@inventory_units_by_variant.transform_values(&:count))
41
+ @desired = Spree::StockQuantities.new(inventory_units_by_variant.transform_values(&:count))
37
42
  @availability = Spree::Stock::Availability.new(
38
- variants: @desired.variants,
39
- stock_locations: @stock_locations
43
+ variants: desired.variants,
44
+ stock_locations: stock_locations
40
45
  )
41
46
 
42
- @allocator = Spree::Config.stock.allocator_class.new(@availability)
47
+ @allocator = Spree::Config.stock.allocator_class.new(availability)
43
48
  end
44
49
 
45
50
  def shipments
46
- @shipments ||= build_shipments
51
+ @shipments ||= begin
52
+ @packages = build_packages
53
+ shipments = build_shipments
54
+
55
+ # Make sure we don't add the proposed shipments to the order
56
+ order.shipments = order.shipments - shipments
57
+
58
+ shipments
59
+ end
47
60
  end
48
61
 
49
62
  private
50
63
 
64
+ def load_stock_locations
65
+ Spree::StockLocation.all
66
+ end
67
+
51
68
  def build_shipments
69
+ # Turn the Stock::Packages into a Shipment with rates
70
+ packages.map do |package|
71
+ shipment = package.shipment = package.to_shipment
72
+ shipment.shipping_rates = Spree::Config.stock.estimator_class.new.shipping_rates(package)
73
+ shipment
74
+ end
75
+ end
76
+
77
+ def build_packages
52
78
  # Allocate any available on hand inventory and remaining desired inventory from backorders
53
- on_hand_packages, backordered_packages, leftover = @allocator.allocate_inventory(@desired)
79
+ on_hand_packages, backordered_packages, leftover = allocator.allocate_inventory(desired)
54
80
 
55
81
  raise Spree::Order::InsufficientStock.new(items: leftover.quantities) unless leftover.empty?
56
82
 
57
- packages = @stock_locations.map do |stock_location|
83
+ packages = stock_locations.map do |stock_location|
58
84
  # Combine on_hand and backorders into a single package per-location
59
85
  on_hand = on_hand_packages[stock_location.id] || Spree::StockQuantities.new
60
86
  backordered = backordered_packages[stock_location.id] || Spree::StockQuantities.new
@@ -71,19 +97,7 @@ module Spree
71
97
  end.compact
72
98
 
73
99
  # Split the packages
74
- packages = split_packages(packages)
75
-
76
- # Turn the Stock::Packages into a Shipment with rates
77
- shipments = packages.map do |package|
78
- shipment = package.shipment = package.to_shipment
79
- shipment.shipping_rates = Spree::Config.stock.estimator_class.new.shipping_rates(package)
80
- shipment
81
- end
82
-
83
- # Make sure we don't add the proposed shipments to the order
84
- order.shipments = order.shipments - shipments
85
-
86
- shipments
100
+ split_packages(packages)
87
101
  end
88
102
 
89
103
  def split_packages(initial_packages)
@@ -96,7 +110,7 @@ module Spree
96
110
  def get_units(quantities)
97
111
  # Change our raw quantities back into inventory units
98
112
  quantities.flat_map do |variant, quantity|
99
- @inventory_units_by_variant[variant].shift(quantity)
113
+ inventory_units_by_variant[variant].shift(quantity)
100
114
  end
101
115
  end
102
116
  end
@@ -24,7 +24,7 @@ module Spree
24
24
 
25
25
  def hash_to_packages(categories)
26
26
  packages = []
27
- categories.each_value do |contents|
27
+ categories.each do |_id, contents|
28
28
  packages << build_package(contents)
29
29
  end
30
30
  packages
@@ -25,7 +25,7 @@ module Spree
25
25
  store = Spree::Store.where(url: server_name).or(Store.where(default: true)).order(default: :asc).first
26
26
 
27
27
  # Provide a fallback, mostly for legacy/testing purposes
28
- store || Spree::Store.new
28
+ store || Spree::Store.new(url: server_name)
29
29
  end
30
30
  end
31
31
  end
@@ -10,6 +10,10 @@ module Spree
10
10
  order(Arel.sql("COALESCE((SELECT COUNT(*) FROM #{Spree::LineItem.quoted_table_name} GROUP BY #{Spree::LineItem.quoted_table_name}.variant_id HAVING #{Spree::LineItem.quoted_table_name}.variant_id = #{Spree::Variant.quoted_table_name}.id), 0) DESC"))
11
11
  }
12
12
 
13
+ scope :by_stock_location, ->(stock_location_id) {
14
+ joins(:stock_locations).where(spree_stock_locations: { id: stock_location_id })
15
+ }
16
+
13
17
  class << self
14
18
  # Returns variants that match a given option value
15
19
  #
@@ -179,6 +179,7 @@ en:
179
179
  price: Master Price
180
180
  promotionable: Promotable
181
181
  shipping_category: Shipping Category
182
+ sku: Master SKU
182
183
  slug: Slug
183
184
  tax_category: Tax Category
184
185
  weight: Weight
@@ -1789,6 +1790,9 @@ en:
1789
1790
  name_contains: Name Contains
1790
1791
  name_on_card: Name on card
1791
1792
  name_or_sku: Name or SKU (enter at least first 4 characters of product name)
1793
+ navigation:
1794
+ switch_to_legacy: Switch to legacy admin
1795
+ switch_to_solidus_admin: Switch to new admin
1792
1796
  negative_movement_absent_item: Cannot create negative movement for absent stock item.
1793
1797
  new: New
1794
1798
  new_adjustment: New Adjustment
@@ -1 +1 @@
1
- apply 'https://github.com/solidusio/solidus_starter_frontend/raw/v4.1/template.rb'
1
+ apply 'https://github.com/solidusio/solidus_starter_frontend/raw/v4.2/template.rb'
@@ -34,6 +34,7 @@ module Solidus
34
34
  class_option :seed, type: :boolean, default: true, banner: 'Load seed data (migrations must be run)'
35
35
  class_option :sample, type: :boolean, default: true, banner: 'Load sample data (migrations and seeds must be run)'
36
36
  class_option :active_storage, type: :boolean, default: true, banner: 'Install ActiveStorage as image attachments handler for products and taxons'
37
+ class_option :admin_preview, type: :boolean, default: false, desc: 'Install the admin preview'
37
38
  class_option :auto_accept, type: :boolean
38
39
  class_option :user_class, type: :string
39
40
  class_option :admin_email, type: :string
@@ -158,6 +159,14 @@ module Solidus
158
159
  end
159
160
  end
160
161
 
162
+ def install_solidus_admin
163
+ return unless options[:admin_preview]
164
+
165
+ say_status :installing, "SolidusAdmin", :blue
166
+ bundle_command 'add solidus_admin'
167
+ generate 'solidus_admin:install'
168
+ end
169
+
161
170
  def install_subcomponents
162
171
  apply_template_for :authentication, @selected_authentication
163
172
  apply_template_for :frontend, @selected_frontend
@@ -57,9 +57,12 @@ Spree::Backend::Config.configure do |config|
57
57
  # a new menu item:
58
58
  #
59
59
  # config.menu_items << config.class::MenuItem.new(
60
- # [:section],
61
- # 'icon-name',
62
- # url: 'https://solidus.io/'
60
+ # label: :my_reports,
61
+ # icon: 'file-text-o', # see https://fontawesome.com/v4/icons/
62
+ # url: :my_admin_reports_path,
63
+ # condition: -> { can?(:admin, MyReports) },
64
+ # partial: 'spree/admin/shared/my_reports_sub_menu',
65
+ # match_path: '/reports',
63
66
  # )
64
67
 
65
68
  # Custom frontend product path
@@ -44,7 +44,6 @@ module Spree
44
44
  opts[:skip_yarn] = true
45
45
  opts[:skip_bootsnap] = true
46
46
  opts[:skip_javascript] = true
47
- opts[:skip_action_cable] = true
48
47
 
49
48
  puts "Generating dummy Rails application..."
50
49
  invoke Rails::Generators::AppGenerator,
@@ -3,7 +3,7 @@
3
3
  'mysql'
4
4
  when 'postgres', 'postgresql'
5
5
  'postgres'
6
- when /sqlite3?/, '', nil
6
+ when 'sqlite', '', nil
7
7
  'sqlite'
8
8
  else
9
9
  raise "Invalid DB specified: #{ENV['DB']}"
@@ -19,7 +19,7 @@
19
19
  <% db_username = ENV['DB_USERNAME'] %>
20
20
  <% db_password = ENV['DB_PASSWORD'] %>
21
21
 
22
- <% case db
22
+ <% case ENV['DB']
23
23
  when 'mysql' %>
24
24
  development:
25
25
  adapter: mysql2
@@ -33,6 +33,6 @@ Dummy::Application.configure do
33
33
 
34
34
  # Raise on deprecation warnings
35
35
  if ENV['SOLIDUS_RAISE_DEPRECATIONS'].present?
36
- Spree::Deprecation.behavior = :raise
36
+ Spree.deprecator.behavior = :raise
37
37
  end
38
38
  end
@@ -22,8 +22,6 @@ require "spree/core/search/variant"
22
22
  require 'spree/preferences/configuration'
23
23
  require 'spree/core/environment'
24
24
 
25
- require 'uri'
26
-
27
25
  module Spree
28
26
  class AppConfiguration < Preferences::Configuration
29
27
  # Preferences (alphabetized to more easily lookup particular preferences)
@@ -75,6 +75,12 @@ module Spree
75
75
  ActionMailer::Base.preview_path = app.config.action_mailer.preview_path
76
76
  end
77
77
 
78
+ initializer "spree.deprecator" do |app|
79
+ if app.respond_to?(:deprecators)
80
+ app.deprecators[:spree] = Spree.deprecator
81
+ end
82
+ end
83
+
78
84
  config.after_initialize do
79
85
  Spree::Config.check_load_defaults_called('Spree::Config')
80
86
  Spree::Config.static_model_preferences.validate!
@@ -46,11 +46,7 @@ module Spree
46
46
 
47
47
  # Persist the state on the order
48
48
  after_transition do |order, transition|
49
- # Hard to say if this is really necessary, it was introduced in this commit:
50
- # https://github.com/mamhoff/solidus/commit/fa1d66c42e4c04ee7cd1c20d87e4cdb74a226d3d
51
- # But it seems to be harmless, so we'll keep it for now.
52
- order.state = order.state # rubocop:disable Lint/SelfAssignment
53
-
49
+ order.state = order.state
54
50
  order.state_changes.create(
55
51
  previous_state: transition.from,
56
52
  next_state: transition.to,
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "4.1.5"
4
+ VERSION = "4.2.0"
5
5
 
6
6
  def self.solidus_version
7
7
  VERSION
8
8
  end
9
9
 
10
10
  def self.previous_solidus_minor_version
11
- '4.0'
11
+ '4.1'
12
12
  end
13
13
 
14
14
  def self.solidus_gem_version
data/lib/spree/core.rb CHANGED
@@ -9,6 +9,8 @@ require "active_record/railtie"
9
9
  require "active_storage/engine"
10
10
  require "sprockets/railtie"
11
11
 
12
+ require 'active_support/deprecation'
13
+ require 'spree/deprecated_instance_variable_proxy'
12
14
  require 'acts_as_list'
13
15
  require 'awesome_nested_set'
14
16
  require 'cancan'
@@ -19,13 +21,17 @@ require 'paperclip'
19
21
  require 'ransack'
20
22
  require 'state_machines-activerecord'
21
23
 
22
- require 'spree/deprecation'
23
-
24
24
  # This is required because ActiveModel::Validations#invalid? conflicts with the
25
25
  # invalid state of a Payment. In the future this should be removed.
26
26
  StateMachines::Machine.ignore_method_conflicts = true
27
27
 
28
28
  module Spree
29
+ def self.deprecator
30
+ @deprecator ||= ActiveSupport::Deprecation.new('5.0', 'Solidus')
31
+ end
32
+
33
+ autoload :Deprecation, 'spree/deprecation'
34
+
29
35
  mattr_accessor :user_class, default: 'Spree::LegacyUser'
30
36
 
31
37
  def self.user_class
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/deprecation'
4
+
5
+ module Spree
6
+ # This DeprecatedInstanceVariableProxy transforms instance variable to
7
+ # deprecated instance variable.
8
+ #
9
+ # It differs from ActiveSupport::DeprecatedInstanceVariableProxy since
10
+ # it allows to define a custom message.
11
+ #
12
+ # class Example
13
+ # def initialize(deprecator)
14
+ # @request = Spree::DeprecatedInstanceVariableProxy.new(self, :request, :@request, deprecator, "Please, do not use this thing.")
15
+ # @_request = :a_request
16
+ # end
17
+ #
18
+ # def request
19
+ # @_request
20
+ # end
21
+ #
22
+ # def old_request
23
+ # @request
24
+ # end
25
+ # end
26
+ #
27
+ # When someone execute any method on @request variable this will trigger
28
+ # +warn+ method on +deprecator_instance+ and will fetch <tt>@_request</tt>
29
+ # variable via +request+ method and execute the same method on non-proxy
30
+ # instance variable.
31
+ #
32
+ # Default deprecator is <tt>Spree.deprecator</tt>.
33
+ class DeprecatedInstanceVariableProxy < ActiveSupport::Deprecation::DeprecationProxy
34
+ def initialize(instance, method_or_var, var = "@#{method}", deprecator = Spree.deprecator, message = nil)
35
+ @instance = instance
36
+ @method_or_var = method_or_var
37
+ @var = var
38
+ @deprecator = deprecator
39
+ @message = message
40
+ end
41
+
42
+ private
43
+
44
+ def target
45
+ return @instance.instance_variable_get(@method_or_var) if @instance.instance_variable_defined?(@method_or_var)
46
+
47
+ @instance.__send__(@method_or_var)
48
+ end
49
+
50
+ def warn(callstack, called, args)
51
+ message = @message || "#{@var} is deprecated! Call #{@method_or_var}.#{called} instead of #{@var}.#{called}."
52
+ message = [message, "Args: #{args.inspect}"].join(" ") unless args.empty?
53
+
54
+ @deprecator.warn(message, callstack)
55
+ end
56
+ end
57
+ end
@@ -1,57 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/deprecation'
3
+ require 'spree/core'
4
4
 
5
5
  module Spree
6
- Deprecation = ActiveSupport::Deprecation.new('5.0', 'Solidus')
6
+ Deprecation = Spree.deprecator
7
7
 
8
- # This DeprecatedInstanceVariableProxy transforms instance variable to
9
- # deprecated instance variable.
10
- #
11
- # It differs from ActiveSupport::DeprecatedInstanceVariableProxy since
12
- # it allows to define a custom message.
13
- #
14
- # class Example
15
- # def initialize(deprecator)
16
- # @request = Spree::DeprecatedInstanceVariableProxy.new(self, :request, :@request, deprecator, "Please, do not use this thing.")
17
- # @_request = :a_request
18
- # end
19
- #
20
- # def request
21
- # @_request
22
- # end
23
- #
24
- # def old_request
25
- # @request
26
- # end
27
- # end
28
- #
29
- # When someone execute any method on @request variable this will trigger
30
- # +warn+ method on +deprecator_instance+ and will fetch <tt>@_request</tt>
31
- # variable via +request+ method and execute the same method on non-proxy
32
- # instance variable.
33
- #
34
- # Default deprecator is <tt>Spree::Deprecation</tt>.
35
- class DeprecatedInstanceVariableProxy < ActiveSupport::Deprecation::DeprecationProxy
36
- def initialize(instance, method, var = "@#{method}", deprecator = Spree::Deprecation, message = nil)
37
- @instance = instance
38
- @method = method
39
- @var = var
40
- @deprecator = deprecator
41
- @message = message
42
- end
43
-
44
- private
45
-
46
- def target
47
- @instance.__send__(@method)
48
- end
49
-
50
- def warn(callstack, called, args)
51
- message = @message || "#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}."
52
- message = [message, "Args: #{args.inspect}"].join(" ")
53
-
54
- @deprecator.warn(message, callstack)
55
- end
56
- end
8
+ Spree.deprecator.warn "Spree::Deprecation is deprecated. Please use Spree.deprecator instead.", caller(2)
57
9
  end
data/lib/spree/money.rb CHANGED
@@ -35,7 +35,7 @@ module Spree
35
35
  if amount.is_a?(::Money)
36
36
  @money = amount
37
37
  else
38
- currency = options[:currency] || Spree::Config[:currency]
38
+ currency = (options[:currency] || Spree::Config[:currency])
39
39
 
40
40
  @money = Monetize.from_string(amount, currency)
41
41
  end
@@ -59,7 +59,7 @@ module Spree::Preferences
59
59
  return if load_defaults_called || !Spree::Core.has_install_generator_been_run?
60
60
 
61
61
  target_name = instance_constant_name || "#{self.class.name}.new"
62
- Spree::Deprecation.warn <<~MSG
62
+ Spree.deprecator.warn <<~MSG
63
63
  It's recommended that you explicitly load the default configuration for
64
64
  your current Solidus version. You can do it by adding the following call
65
65
  to your Solidus initializer within the #{target_name} block:
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/deprecation'
4
3
  require 'spree/encryptor'
5
4
 
6
5
  module Spree::Preferences
@@ -0,0 +1 @@
1
+ /* Placeholder for compiled tailwind.css file */
@@ -142,5 +142,5 @@ end
142
142
 
143
143
  # Raise on deprecation warnings
144
144
  if ENV['SOLIDUS_RAISE_DEPRECATIONS'].present?
145
- Spree::Deprecation.behavior = :raise
145
+ Spree.deprecator.behavior = :raise
146
146
  end
@@ -30,7 +30,7 @@ module Spree
30
30
  MSG
31
31
  end
32
32
  end
33
- deprecate :check_version, deprecator: Spree::Deprecation
33
+ deprecate :check_version, deprecator: Spree.deprecator
34
34
 
35
35
  def self.add_definitions!
36
36
  ::FactoryBot.definition_file_paths.unshift(*definition_file_paths).uniq!
@@ -2,7 +2,7 @@
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.around(:each, silence_deprecations: true) do |example|
5
- Spree::Deprecation.silence do
5
+ Spree.deprecator.silence do
6
6
  example.run
7
7
  end
8
8
  end
data/solidus_core.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
 
26
26
  %w[
27
27
  actionmailer actionpack actionview activejob activemodel activerecord
28
- activestorage activesupport railties
28
+ activesupport railties
29
29
  ].each do |rails_dep|
30
30
  s.add_dependency rails_dep, ['>= 7.0', '< 7.1']
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.5
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2023-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -130,26 +130,6 @@ dependencies:
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '7.1'
133
- - !ruby/object:Gem::Dependency
134
- name: activestorage
135
- requirement: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: '7.0'
140
- - - "<"
141
- - !ruby/object:Gem::Version
142
- version: '7.1'
143
- type: :runtime
144
- prerelease: false
145
- version_requirements: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- version: '7.0'
150
- - - "<"
151
- - !ruby/object:Gem::Version
152
- version: '7.1'
153
133
  - !ruby/object:Gem::Dependency
154
134
  name: activesupport
155
135
  requirement: !ruby/object:Gem::Requirement
@@ -597,7 +577,6 @@ files:
597
577
  - app/models/spree/promotion_handler/page.rb
598
578
  - app/models/spree/promotion_handler/shipping.rb
599
579
  - app/models/spree/promotion_rule.rb
600
- - app/models/spree/promotion_rule_role.rb
601
580
  - app/models/spree/promotion_rule_store.rb
602
581
  - app/models/spree/promotion_rule_taxon.rb
603
582
  - app/models/spree/promotion_rule_user.rb
@@ -866,6 +845,7 @@ files:
866
845
  - lib/spree/core/validators/email.rb
867
846
  - lib/spree/core/version.rb
868
847
  - lib/spree/core/versioned_value.rb
848
+ - lib/spree/deprecated_instance_variable_proxy.rb
869
849
  - lib/spree/deprecation.rb
870
850
  - lib/spree/encryptor.rb
871
851
  - lib/spree/i18n.rb
@@ -915,6 +895,7 @@ files:
915
895
  - lib/spree/testing_support/controller_requests.rb
916
896
  - lib/spree/testing_support/dummy_app.rb
917
897
  - lib/spree/testing_support/dummy_app/assets/javascripts/spree/backend/all.js
898
+ - lib/spree/testing_support/dummy_app/assets/stylesheets/solidus_admin/tailwind.css
918
899
  - lib/spree/testing_support/dummy_app/assets/stylesheets/spree/backend/all.css
919
900
  - lib/spree/testing_support/dummy_app/database.yml
920
901
  - lib/spree/testing_support/dummy_app/mailer_previews/test_mailer_preview.rb
@@ -1047,7 +1028,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1047
1028
  - !ruby/object:Gem::Version
1048
1029
  version: 1.8.23
1049
1030
  requirements: []
1050
- rubygems_version: 3.4.19
1031
+ rubygems_version: 3.3.23
1051
1032
  signing_key:
1052
1033
  specification_version: 4
1053
1034
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Spree
4
- class PromotionRuleRole < Spree::Base
5
- belongs_to :promotion_rule, class_name: 'Spree::PromotionRule', optional: true
6
- belongs_to :role, class_name: 'Spree::Role', optional: true
7
- end
8
- end