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.
- checksums.yaml +4 -4
- data/Rakefile +0 -1
- data/app/assets/images/logo/solidus.svg +18 -1
- data/app/assets/images/logo/solidus_logo.png +0 -0
- data/app/models/spree/adjustment.rb +2 -0
- data/app/models/spree/option_value.rb +1 -0
- data/app/models/spree/order.rb +3 -3
- data/app/models/spree/order_inventory.rb +6 -4
- data/app/models/spree/order_updater.rb +1 -1
- data/app/models/spree/product.rb +19 -1
- data/app/models/spree/promotion_handler/coupon.rb +1 -1
- data/app/models/spree/stock/simple_coordinator.rb +36 -22
- data/app/models/spree/stock/splitter/shipping_category.rb +1 -1
- data/app/models/spree/store_selector/by_server_name.rb +1 -1
- data/app/models/spree/variant/scopes.rb +4 -0
- data/config/locales/en.yml +4 -0
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -1
- data/lib/generators/solidus/install/install_generator.rb +9 -0
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +6 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +0 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +2 -2
- data/lib/generators/spree/dummy/templates/rails/test.rb +1 -1
- data/lib/spree/app_configuration.rb +0 -2
- data/lib/spree/core/engine.rb +6 -0
- data/lib/spree/core/state_machines/order.rb +1 -5
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +8 -2
- data/lib/spree/deprecated_instance_variable_proxy.rb +57 -0
- data/lib/spree/deprecation.rb +3 -51
- data/lib/spree/money.rb +1 -1
- data/lib/spree/preferences/configuration.rb +1 -1
- data/lib/spree/preferences/preferable_class_methods.rb +0 -1
- data/lib/spree/testing_support/dummy_app/assets/stylesheets/solidus_admin/tailwind.css +1 -0
- data/lib/spree/testing_support/dummy_app.rb +1 -1
- data/lib/spree/testing_support/factory_bot.rb +1 -1
- data/lib/spree/testing_support/silence_deprecations.rb +1 -1
- data/solidus_core.gemspec +1 -1
- metadata +5 -24
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87d19e38f8adcb38c0b6ef11dbec002b9e91a318f2d4e17fdeacc0c5dc5e8a23
|
4
|
+
data.tar.gz: d72606376f7c22b9a3f33f6fde535c7e79170150aedbfcac3ac3a62048aa657f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d383cdf58d3939f4d0e013a9b2598e77e54e6aa0b72b91d3f4be512cce53f049cb560d3843bc7129ef6bbe23c1b36f5a8020e436a4df7d3d2f1e2f8aa3a73c4d
|
7
|
+
data.tar.gz: 4cb2ee92d241c9110dd1c261511771ccac993dd21e7d29826859ebaba3218e318da1d9b9f90af5f535c1187f3d46b884768b80fc46ff842f56cadedb39cfd6fc
|
data/Rakefile
CHANGED
@@ -1 +1,18 @@
|
|
1
|
-
<svg width="
|
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>
|
Binary file
|
@@ -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.
|
data/app/models/spree/order.rb
CHANGED
@@ -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
|
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
|
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 ||
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
34
|
+
deprecate update: :recalculate, deprecator: Spree.deprecator
|
35
35
|
|
36
36
|
# Updates the +shipment_state+ attribute according to the following logic:
|
37
37
|
#
|
data/app/models/spree/product.rb
CHANGED
@@ -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(
|
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(
|
41
|
+
@desired = Spree::StockQuantities.new(inventory_units_by_variant.transform_values(&:count))
|
37
42
|
@availability = Spree::Stock::Availability.new(
|
38
|
-
variants:
|
39
|
-
stock_locations:
|
43
|
+
variants: desired.variants,
|
44
|
+
stock_locations: stock_locations
|
40
45
|
)
|
41
46
|
|
42
|
-
@allocator = Spree::Config.stock.allocator_class.new(
|
47
|
+
@allocator = Spree::Config.stock.allocator_class.new(availability)
|
43
48
|
end
|
44
49
|
|
45
50
|
def shipments
|
46
|
-
@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 =
|
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 =
|
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
|
-
|
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
|
-
|
113
|
+
inventory_units_by_variant[variant].shift(quantity)
|
100
114
|
end
|
101
115
|
end
|
102
116
|
end
|
@@ -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
|
#
|
data/config/locales/en.yml
CHANGED
@@ -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
|
+
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
|
-
#
|
61
|
-
# '
|
62
|
-
# url:
|
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
|
@@ -3,7 +3,7 @@
|
|
3
3
|
'mysql'
|
4
4
|
when 'postgres', 'postgresql'
|
5
5
|
'postgres'
|
6
|
-
when
|
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
|
22
|
+
<% case ENV['DB']
|
23
23
|
when 'mysql' %>
|
24
24
|
development:
|
25
25
|
adapter: mysql2
|
@@ -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)
|
data/lib/spree/core/engine.rb
CHANGED
@@ -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
|
-
|
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,
|
data/lib/spree/core/version.rb
CHANGED
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
|
data/lib/spree/deprecation.rb
CHANGED
@@ -1,57 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'spree/core'
|
4
4
|
|
5
5
|
module Spree
|
6
|
-
Deprecation =
|
6
|
+
Deprecation = Spree.deprecator
|
7
7
|
|
8
|
-
|
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
@@ -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
|
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:
|
@@ -0,0 +1 @@
|
|
1
|
+
/* Placeholder for compiled tailwind.css file */
|
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
|
-
|
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.
|
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:
|
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.
|
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.
|