solidus_core 3.4.6 → 4.0.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/helpers/spree/products_helper.rb +1 -1
- data/app/models/concerns/spree/active_storage_adapter.rb +0 -17
- data/app/models/concerns/spree/default_price.rb +0 -15
- data/app/models/concerns/spree/ransackable_attributes.rb +0 -21
- data/app/models/spree/adjustment.rb +0 -13
- data/app/models/spree/carton.rb +1 -1
- data/app/models/spree/fulfilment_changer.rb +2 -14
- data/app/models/spree/option_value.rb +2 -11
- data/app/models/spree/order.rb +9 -21
- data/app/models/spree/order_updater.rb +0 -29
- data/app/models/spree/payment.rb +5 -37
- data/app/models/spree/product/scopes.rb +0 -5
- data/app/models/spree/product.rb +3 -10
- data/app/models/spree/promotion/rules/item_total.rb +0 -11
- data/app/models/spree/promotion.rb +7 -30
- data/app/models/spree/promotion_rule.rb +0 -5
- data/app/models/spree/taxon.rb +2 -2
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/variant/price_selector.rb +1 -14
- data/app/models/spree/variant.rb +1 -17
- data/db/migrate/20210815004823_add_unique_index_to_option_values_variants.rb +16 -0
- data/db/migrate/20230321161854_change_column_null_option_values_option_type_id.rb +5 -0
- data/db/migrate/20230322085416_remove_match_policy_from_spree_promotion.rb +5 -0
- data/db/migrate/20230325132905_remove_unused_columns_from_promotion_rules.rb +6 -0
- data/db/migrate/20230325161633_drop_unused_promo_action_line_items.rb +13 -0
- data/db/migrate/20230425103509_remove_taxon_position.rb +5 -0
- data/db/migrate/20230427095534_drop_deprecated_address_id_from_shipments.rb +11 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +1 -2
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +1 -3
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +2 -14
- data/lib/generators/solidus/install/app_templates/payment_method/stripe.rb +5 -0
- data/lib/generators/solidus/install/install_generator.rb +59 -153
- data/lib/spree/app_configuration.rb +2 -82
- data/lib/spree/bus.rb +0 -11
- data/lib/spree/core/controller_helpers/auth.rb +0 -16
- data/lib/spree/core/engine.rb +11 -31
- data/lib/spree/core/validators/email.rb +0 -4
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +0 -2
- data/lib/spree/migration_helpers.rb +3 -3
- data/lib/spree/preferences/preferable_class_methods.rb +1 -25
- data/lib/spree/testing_support/common_rake.rb +5 -1
- data/lib/spree/testing_support/dummy_app/rake_tasks.rb +4 -8
- data/lib/spree/testing_support/dummy_app.rb +1 -6
- data/lib/spree/testing_support/factories/address_factory.rb +0 -7
- data/lib/spree/testing_support/factories/adjustment_factory.rb +0 -11
- data/lib/spree/testing_support/factories/adjustment_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/calculator_factory.rb +0 -5
- data/lib/spree/testing_support/factories/carton_factory.rb +0 -8
- data/lib/spree/testing_support/factories/country_factory.rb +0 -5
- data/lib/spree/testing_support/factories/credit_card_factory.rb +0 -5
- data/lib/spree/testing_support/factories/customer_return_factory.rb +0 -9
- data/lib/spree/testing_support/factories/image_factory.rb +0 -5
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +0 -10
- data/lib/spree/testing_support/factories/line_item_factory.rb +0 -8
- data/lib/spree/testing_support/factories/option_type_factory.rb +0 -8
- data/lib/spree/testing_support/factories/option_value_factory.rb +0 -5
- data/lib/spree/testing_support/factories/order_factory.rb +0 -12
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +0 -8
- data/lib/spree/testing_support/factories/payment_factory.rb +0 -10
- data/lib/spree/testing_support/factories/payment_method_factory.rb +0 -5
- data/lib/spree/testing_support/factories/price_factory.rb +0 -7
- data/lib/spree/testing_support/factories/product_factory.rb +0 -11
- data/lib/spree/testing_support/factories/product_option_type_factory.rb +0 -8
- data/lib/spree/testing_support/factories/product_property_factory.rb +0 -8
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/promotion_code_factory.rb +0 -8
- data/lib/spree/testing_support/factories/promotion_factory.rb +0 -8
- data/lib/spree/testing_support/factories/property_factory.rb +0 -5
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -8
- data/lib/spree/testing_support/factories/refund_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +0 -7
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +0 -5
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +0 -9
- data/lib/spree/testing_support/factories/return_item_factory.rb +0 -9
- data/lib/spree/testing_support/factories/return_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/role_factory.rb +0 -5
- data/lib/spree/testing_support/factories/shipment_factory.rb +0 -10
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +0 -9
- data/lib/spree/testing_support/factories/shipping_rate_factory.rb +0 -8
- data/lib/spree/testing_support/factories/state_factory.rb +0 -8
- data/lib/spree/testing_support/factories/stock_item_factory.rb +0 -8
- data/lib/spree/testing_support/factories/stock_location_factory.rb +0 -9
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +0 -7
- data/lib/spree/testing_support/factories/stock_package_factory.rb +0 -8
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_credit_event_factory.rb +0 -8
- data/lib/spree/testing_support/factories/store_credit_factory.rb +0 -9
- data/lib/spree/testing_support/factories/store_credit_reason_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +0 -5
- data/lib/spree/testing_support/factories/store_factory.rb +0 -5
- data/lib/spree/testing_support/factories/tax_category_factory.rb +0 -8
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +0 -9
- data/lib/spree/testing_support/factories/taxon_factory.rb +0 -7
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +0 -5
- data/lib/spree/testing_support/factories/user_factory.rb +0 -9
- data/lib/spree/testing_support/factories/variant_factory.rb +0 -10
- data/lib/spree/testing_support/factories/variant_property_rule_condition_factory.rb +0 -8
- data/lib/spree/testing_support/factories/variant_property_rule_factory.rb +0 -9
- data/lib/spree/testing_support/factories/variant_property_rule_value_factory.rb +0 -8
- data/lib/spree/testing_support/factories/zone_factory.rb +0 -8
- data/lib/spree/testing_support/factory_bot.rb +4 -28
- data/lib/spree/testing_support/sequences.rb +0 -5
- data/solidus_core.gemspec +4 -4
- metadata +48 -76
- data/app/subscribers/spree/mailer_subscriber.rb +0 -29
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +0 -54
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +0 -16
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +0 -13
- data/lib/spree/core/controller_helpers/current_host.rb +0 -19
- data/lib/spree/event/adapters/active_support_notifications.rb +0 -67
- data/lib/spree/event/configuration.rb +0 -25
- data/lib/spree/event/subscriber.rb +0 -86
- data/lib/spree/event/subscriber_registry.rb +0 -92
- data/lib/spree/event.rb +0 -119
- data/lib/spree/promotion/match_policies.rb +0 -2
- data/lib/spree/rails_compatibility.rb +0 -106
- data/lib/spree/testing_support/factories.rb +0 -11
- data/lib/spree/testing_support.rb +0 -36
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
- data/lib/tasks/solidus/split_promotions_with_any_match_policy.rake +0 -33
@@ -0,0 +1,13 @@
|
|
1
|
+
class DropUnusedPromoActionLineItems < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
drop_table :spree_promotion_action_line_items, force: :cascade do |t|
|
4
|
+
t.integer "promotion_action_id"
|
5
|
+
t.integer "variant_id"
|
6
|
+
t.integer "quantity", default: 1
|
7
|
+
t.datetime "created_at", precision: 6
|
8
|
+
t.datetime "updated_at", precision: 6
|
9
|
+
t.index ["promotion_action_id"], name: "index_spree_promotion_action_line_items_on_promotion_action_id"
|
10
|
+
t.index ["variant_id"], name: "index_spree_promotion_action_line_items_on_variant_id"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class DropDeprecatedAddressIdFromShipments < ActiveRecord::Migration[5.2]
|
2
|
+
def up
|
3
|
+
remove_index :spree_shipments, column: [:deprecated_address_id], name: :index_spree_shipments_on_deprecated_address_id
|
4
|
+
remove_column :spree_shipments, :deprecated_address_id
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
add_column :spree_shipments, :deprecated_address_id
|
9
|
+
add_index :spree_shipments, :deprecated_address_id, name: :index_spree_shipments_on_deprecated_address_id
|
10
|
+
end
|
11
|
+
end
|
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
run_bundle
|
1
|
+
# noop
|
@@ -1,17 +1,5 @@
|
|
1
|
-
unless Bundler.locked_gems.dependencies['solidus_frontend']
|
2
|
-
say_status :warning, "Support for frontends other than `solidus_frontend` by `solidus_paypal_commerce_platform` is still in progress.", :yellow
|
3
|
-
end
|
4
|
-
|
5
|
-
if @selected_frontend == 'classic'
|
6
|
-
version = '< 1'
|
7
|
-
migrations_flag = options[:migrate] ? '--auto-run-migrations' : '--skip-migrations'
|
8
|
-
else
|
9
|
-
version = '~> 1.0'
|
10
|
-
migrations_flag = "--migrate=#{options[:migrate]}"
|
11
|
-
end
|
12
|
-
|
13
1
|
unless Bundler.locked_gems.dependencies['solidus_paypal_commerce_platform']
|
14
|
-
bundle_command "add solidus_paypal_commerce_platform --version='
|
2
|
+
bundle_command "add solidus_paypal_commerce_platform --version='~> 1.0'"
|
15
3
|
end
|
16
4
|
|
17
|
-
generate "solidus_paypal_commerce_platform:install
|
5
|
+
generate "solidus_paypal_commerce_platform:install --migrate=#{options[:migrate]}"
|
@@ -11,70 +11,37 @@ module Solidus
|
|
11
11
|
|
12
12
|
CORE_MOUNT_ROUTE = "mount Spree::Core::Engine"
|
13
13
|
|
14
|
-
FRONTENDS =
|
15
|
-
|
16
|
-
|
17
|
-
starter
|
14
|
+
FRONTENDS = [
|
15
|
+
{ name: 'starter', description: 'Generate all necessary controllers and views directly in your Rails app', default: true },
|
16
|
+
{ name: 'none', description: 'Skip installing a frontend' }
|
18
17
|
]
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
AUTHENTICATIONS = %w[
|
26
|
-
devise
|
27
|
-
existing
|
28
|
-
custom
|
29
|
-
none
|
19
|
+
AUTHENTICATIONS = [
|
20
|
+
{ name: 'devise', description: 'Install and configure the standard `devise` integration', default: true },
|
21
|
+
{ name: 'existing', description: 'Integrate and configure an existing `devise` setup' },
|
22
|
+
{ name: 'custom', description: 'A starter configuration for rolling your own authentication system' },
|
23
|
+
{ name: 'none', description: 'Don\'t add any configuration for authentication' }
|
30
24
|
]
|
31
25
|
|
32
26
|
PAYMENT_METHODS = [
|
33
|
-
{
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
default: true,
|
38
|
-
},
|
39
|
-
{
|
40
|
-
name: 'bolt',
|
41
|
-
frontends: %w[classic],
|
42
|
-
description: 'Install `solidus_bolt`',
|
43
|
-
default: false,
|
44
|
-
},
|
45
|
-
{
|
46
|
-
name: 'braintree',
|
47
|
-
frontends: %w[none starter],
|
48
|
-
description: 'Install `solidus_braintree`',
|
49
|
-
default: false,
|
50
|
-
},
|
51
|
-
{
|
52
|
-
name: 'none',
|
53
|
-
frontends: %w[none classic starter],
|
54
|
-
description: 'Skip installing a payment method',
|
55
|
-
default: false,
|
56
|
-
},
|
27
|
+
{ name: 'paypal', description: 'Install `solidus_paypal_commerce_platform`', default: true },
|
28
|
+
{ name: 'stripe', description: 'Install `solidus_stripe`', default: false },
|
29
|
+
{ name: 'braintree', description: 'Install `solidus_braintree`', default: false },
|
30
|
+
{ name: 'none', description: 'Skip installing a payment method', default: false }
|
57
31
|
]
|
58
32
|
|
59
33
|
class_option :migrate, type: :boolean, default: true, banner: 'Run Solidus migrations'
|
60
34
|
class_option :seed, type: :boolean, default: true, banner: 'Load seed data (migrations must be run)'
|
61
35
|
class_option :sample, type: :boolean, default: true, banner: 'Load sample data (migrations and seeds must be run)'
|
62
|
-
class_option :active_storage, type: :boolean, default:
|
63
|
-
Rails.gem_version >= Gem::Version.new("6.1.0")
|
64
|
-
), banner: 'Install ActiveStorage as image attachments handler for products and taxons'
|
36
|
+
class_option :active_storage, type: :boolean, default: true, banner: 'Install ActiveStorage as image attachments handler for products and taxons'
|
65
37
|
class_option :auto_accept, type: :boolean
|
66
38
|
class_option :user_class, type: :string
|
67
39
|
class_option :admin_email, type: :string
|
68
40
|
class_option :admin_password, type: :string
|
69
41
|
|
70
|
-
class_option :frontend, type: :string, enum: FRONTENDS
|
71
|
-
class_option :authentication, type: :string, enum: AUTHENTICATIONS, default: nil, desc: "Indicates which authentication system to install."
|
72
|
-
class_option :payment_method, type: :string, enum: PAYMENT_METHODS.map {
|
73
|
-
|
74
|
-
# DEPRECATED
|
75
|
-
class_option :with_authentication, type: :boolean, hide: true, default: nil
|
76
|
-
class_option :enforce_available_locales, type: :boolean, hide: true, default: nil
|
77
|
-
class_option :lib_name, type: :string, hide: true, default: nil
|
42
|
+
class_option :frontend, type: :string, enum: FRONTENDS.map { _1[:name] }, default: nil, desc: "Indicates which frontend to install."
|
43
|
+
class_option :authentication, type: :string, enum: AUTHENTICATIONS.map { _1[:name] }, default: nil, desc: "Indicates which authentication system to install."
|
44
|
+
class_option :payment_method, type: :string, enum: PAYMENT_METHODS.map { _1[:name] }, default: nil, desc: "Indicates which payment method to install."
|
78
45
|
|
79
46
|
source_root "#{__dir__}/templates"
|
80
47
|
|
@@ -86,27 +53,37 @@ module Solidus
|
|
86
53
|
@run_migrations = options[:migrate]
|
87
54
|
@load_seed_data = options[:seed] && @run_migrations
|
88
55
|
@load_sample_data = options[:sample] && @run_migrations && @load_seed_data
|
89
|
-
|
90
|
-
@
|
91
|
-
|
56
|
+
|
57
|
+
@selected_frontend = selected_option_for(
|
58
|
+
'frontend',
|
59
|
+
selected: ENV['FRONTEND'] || options[:frontend],
|
60
|
+
available_options: FRONTENDS,
|
61
|
+
)
|
62
|
+
|
63
|
+
@selected_authentication = selected_option_for(
|
64
|
+
'authentication',
|
65
|
+
selected:
|
66
|
+
('devise' if @selected_frontend == 'starter') ||
|
67
|
+
('devise' if has_gem?('solidus_auth_devise')) ||
|
68
|
+
ENV['AUTHENTICATION'] || options[:authentication],
|
69
|
+
available_options: AUTHENTICATIONS,
|
70
|
+
)
|
71
|
+
|
72
|
+
@selected_payment_method = selected_option_for(
|
73
|
+
'payment method',
|
74
|
+
selected:
|
75
|
+
('paypal' if has_gem?('solidus_paypal_commerce_platform')) ||
|
76
|
+
('stripe' if has_gem?('solidus_stripe')) ||
|
77
|
+
('bolt' if has_gem?('solidus_bolt')) ||
|
78
|
+
ENV['PAYMENT_METHOD'] || options[:payment_method],
|
79
|
+
available_options: PAYMENT_METHODS,
|
80
|
+
)
|
92
81
|
|
93
82
|
# Silence verbose output (e.g. Rails migrations will rely on this environment variable)
|
94
83
|
ENV['VERBOSE'] = 'false'
|
95
84
|
|
96
85
|
# No reason to check for their presence if we're about to install them
|
97
86
|
ENV['SOLIDUS_SKIP_MIGRATIONS_CHECK'] = 'true'
|
98
|
-
|
99
|
-
if options[:enforce_available_locales] != nil
|
100
|
-
warn \
|
101
|
-
"DEPRECATION WARNING: using `solidus:install --enforce-available-locales` is now deprecated and has no effect. " \
|
102
|
-
"Since Rails 4.1 the default is `true` so we no longer need to explicitly set a value."
|
103
|
-
end
|
104
|
-
|
105
|
-
if options[:lib_name] != nil
|
106
|
-
warn \
|
107
|
-
"DEPRECATION WARNING: using `solidus:install --lib-name` is now deprecated and has no effect. " \
|
108
|
-
"The option is legacy and should be removed from scripts still using it."
|
109
|
-
end
|
110
87
|
end
|
111
88
|
|
112
89
|
def add_files
|
@@ -119,7 +96,7 @@ module Solidus
|
|
119
96
|
rake 'active_storage:install'
|
120
97
|
else
|
121
98
|
say_status :assets, "Paperclip", :green
|
122
|
-
gsub_file 'config/initializers/spree.rb', "
|
99
|
+
gsub_file 'config/initializers/spree.rb', "ActiveStorageAttachment", "PaperclipAttachment"
|
123
100
|
end
|
124
101
|
end
|
125
102
|
|
@@ -181,15 +158,9 @@ module Solidus
|
|
181
158
|
end
|
182
159
|
end
|
183
160
|
|
184
|
-
def
|
161
|
+
def install_subcomponents
|
185
162
|
apply_template_for :authentication, @selected_authentication
|
186
|
-
end
|
187
|
-
|
188
|
-
def install_frontend
|
189
163
|
apply_template_for :frontend, @selected_frontend
|
190
|
-
end
|
191
|
-
|
192
|
-
def install_payment_method
|
193
164
|
apply_template_for :payment_method, @selected_payment_method
|
194
165
|
end
|
195
166
|
|
@@ -271,93 +242,28 @@ module Solidus
|
|
271
242
|
end
|
272
243
|
end
|
273
244
|
|
274
|
-
def
|
275
|
-
|
276
|
-
selected_frontend = 'starter' if options[:frontend] == 'solidus_starter_frontend'
|
277
|
-
selected_frontend = 'classic' if options[:frontend] == 'solidus_frontend'
|
278
|
-
selected_frontend ||= options[:frontend]
|
279
|
-
|
280
|
-
ENV['FRONTEND'] ||
|
281
|
-
selected_frontend ||
|
282
|
-
(Bundler.locked_gems.dependencies['solidus_frontend'] && 'classic') ||
|
283
|
-
(options[:auto_accept] && 'starter') ||
|
284
|
-
ask_with_description(
|
285
|
-
default: 'starter',
|
286
|
-
limited_to: FRONTENDS,
|
287
|
-
desc: <<~TEXT
|
288
|
-
Which frontend would you like to use?
|
289
|
-
|
290
|
-
- [#{set_color 'starter', :bold}] Generate all necessary controllers and views directly in your Rails app (#{set_color :default, :bold}).
|
291
|
-
- [#{set_color 'classic', :bold}] Install `solidus_frontend`, was the default in previous solidus versions (#{set_color :deprecated, :bold}).
|
292
|
-
- [#{set_color 'none', :bold}] Skip installing a frontend.
|
293
|
-
|
294
|
-
Selecting `starter` is recommended, however, some extensions are still only compatible with `classic`.
|
295
|
-
TEXT
|
296
|
-
)
|
245
|
+
def has_gem?(name)
|
246
|
+
Bundler.locked_gems.dependencies[name]
|
297
247
|
end
|
298
248
|
|
299
|
-
def
|
300
|
-
return
|
301
|
-
|
302
|
-
if options[:with_authentication] != nil
|
303
|
-
say_status :warning, \
|
304
|
-
"Using `solidus:install --with-authentication` is now deprecated. " \
|
305
|
-
"Please use `--authentication` instead (see --help for the full list of options).",
|
306
|
-
:red
|
307
|
-
|
308
|
-
if options[:with_authentication] == 'false'
|
309
|
-
# Don't use the default authentication if the user explicitly
|
310
|
-
# requested no authentication system.
|
311
|
-
return 'none'
|
312
|
-
else
|
313
|
-
return 'devise'
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
ENV['AUTHENTICATION'] ||
|
318
|
-
options[:authentication] ||
|
319
|
-
(Bundler.locked_gems.dependencies['solidus_auth_devise'] && 'devise') ||
|
320
|
-
(options[:auto_accept] && 'devise') ||
|
321
|
-
ask_with_description(
|
322
|
-
default: 'devise',
|
323
|
-
limited_to: AUTHENTICATIONS,
|
324
|
-
desc: <<~TEXT
|
325
|
-
Which authentication would you like to use?
|
326
|
-
|
327
|
-
- [#{set_color 'devise', :bold}] Install and configure the standard `devise` integration. (#{set_color :default, :bold}).
|
328
|
-
- [#{set_color 'existing', :bold}] Integrate and configure an existing `devise` setup.
|
329
|
-
- [#{set_color 'custom', :bold}] A starter configuration for rolling your own authentication system.
|
330
|
-
- [#{set_color 'none', :bold}] Don't add any configuration for authentication.
|
331
|
-
|
332
|
-
Selecting `devise` is recommended.
|
333
|
-
TEXT
|
334
|
-
)
|
335
|
-
end
|
249
|
+
def selected_option_for(name, selected:, available_options:)
|
250
|
+
return selected if selected
|
336
251
|
|
337
|
-
|
338
|
-
|
339
|
-
return 'bolt' if Bundler.locked_gems.dependencies['solidus_bolt']
|
252
|
+
option_description = ->(name:, description:, default: false, **) do
|
253
|
+
default_label = " (#{set_color :default, :bold})" if default
|
340
254
|
|
341
|
-
|
342
|
-
payment_method[:frontends].include?(@selected_frontend)
|
255
|
+
"- [#{set_color name, :bold}] #{description}#{default_label}."
|
343
256
|
end
|
344
257
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
)
|
355
|
-
end
|
356
|
-
|
357
|
-
def formatted_payment_method_description(payment_method)
|
358
|
-
default_label = " (#{set_color :default, :bold})" if payment_method[:default]
|
359
|
-
|
360
|
-
"- [#{set_color payment_method[:name], :bold}] #{payment_method[:description]}#{default_label}."
|
258
|
+
default = available_options.find { _1[:default] }
|
259
|
+
(options[:auto_accept] && default[:name]) || ask_with_description(
|
260
|
+
default: default[:name],
|
261
|
+
limited_to: available_options.map { _1[:name] },
|
262
|
+
desc: <<~TEXT
|
263
|
+
Which #{name} would you like to use?
|
264
|
+
#{available_options.map { option_description[**_1] }.join("\n")}
|
265
|
+
TEXT
|
266
|
+
)
|
361
267
|
end
|
362
268
|
end
|
363
269
|
end
|
@@ -21,7 +21,6 @@ require "spree/core/search/base"
|
|
21
21
|
require "spree/core/search/variant"
|
22
22
|
require 'spree/preferences/configuration'
|
23
23
|
require 'spree/core/environment'
|
24
|
-
require 'spree/rails_compatibility'
|
25
24
|
|
26
25
|
module Spree
|
27
26
|
class AppConfiguration < Preferences::Configuration
|
@@ -61,27 +60,6 @@ module Spree
|
|
61
60
|
# @return [Boolean] When false, customers must create an account to complete an order (default: +true+)
|
62
61
|
preference :allow_guest_checkout, :boolean, default: true
|
63
62
|
|
64
|
-
# @!attribute [rw] allow_promotions_any_match_policy
|
65
|
-
# @return [Boolean] When false, admins cannot create promotions with an "any" match policy (default: +false+)
|
66
|
-
# Create individual, separate promotions for each of your rules instead.
|
67
|
-
preference :allow_promotions_any_match_policy, :boolean, default: false
|
68
|
-
def allow_promotions_any_match_policy=(value)
|
69
|
-
if value == true
|
70
|
-
Spree::Deprecation.warn <<~MSG
|
71
|
-
Solidus 4.0 will remove support for combining promotion rules with the "any" match policy.
|
72
|
-
|
73
|
-
Instead, it's suggested to create individual, separate promotions for each of your current
|
74
|
-
rules combined with the "any" policy. To automate this task, you can use the provided
|
75
|
-
task:
|
76
|
-
|
77
|
-
bin/rake solidus:split_promotions_with_any_match_policy
|
78
|
-
MSG
|
79
|
-
end
|
80
|
-
|
81
|
-
preferences[:allow_promotions_any_match_policy] = value
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
63
|
# @!attribute [rw] guest_token_cookie_options
|
86
64
|
# @return [Hash] Add additional guest_token cookie options here (ie. domain or path)
|
87
65
|
preference :guest_token_cookie_options, :hash, default: {}
|
@@ -171,38 +149,6 @@ module Spree
|
|
171
149
|
# @return [Regexp] Regex to be used in email validations, for example in Spree::EmailValidator
|
172
150
|
preference :default_email_regexp, :regexp, default: URI::MailTo::EMAIL_REGEXP
|
173
151
|
|
174
|
-
# @!attribute [rw] extra_taxon_validations
|
175
|
-
# Use extra validations on Taxons in 3.4.0, but default to false so stores can
|
176
|
-
# upgrade and then fix any now invalid Taxons before enabling.
|
177
|
-
# @return [Boolean]
|
178
|
-
versioned_preference :extra_taxon_validations, :boolean, initial_value: false, boundaries: { "3.4.0.dev" => true }
|
179
|
-
def extra_taxon_validations=(value)
|
180
|
-
Spree::Deprecation.warn <<~MSG
|
181
|
-
Solidus will remove `Spree::Config.extra_taxon_validations` preference
|
182
|
-
in the next major release and will always use the extra Taxon validations.
|
183
|
-
Before upgrading to the next major, please fix any now invalid Taxons
|
184
|
-
and then remove the preference definition in `config/initializers/spree.rb`.
|
185
|
-
MSG
|
186
|
-
|
187
|
-
preferences[:extra_taxon_validations] = value
|
188
|
-
end
|
189
|
-
|
190
|
-
# @!attribute [rw] extra_taxonomy_validations
|
191
|
-
# Use extra validations on Taxonomies in 3.4.0, but default to false so stores can
|
192
|
-
# upgrade and then fix any now invalid Taxonomies before enabling.
|
193
|
-
# @return [Boolean]
|
194
|
-
versioned_preference :extra_taxonomy_validations, :boolean, initial_value: false, boundaries: { "3.4.0.dev" => true }
|
195
|
-
def extra_taxonomy_validations=(value)
|
196
|
-
Spree::Deprecation.warn <<~MSG
|
197
|
-
Solidus will remove `Spree::Config.extra_taxonomy_validations` preference
|
198
|
-
in the next major release and will always use the extra Taxonomy validations.
|
199
|
-
Before upgrading to the next major, please fix any now invalid Taxons
|
200
|
-
and then remove the preference definition in `config/initializers/spree.rb`.
|
201
|
-
MSG
|
202
|
-
|
203
|
-
preferences[:extra_taxonomy_validations] = value
|
204
|
-
end
|
205
|
-
|
206
152
|
# @!attribute [rw] generate_api_key_for_all_roles
|
207
153
|
# @return [Boolean] Allow generating api key automatically for user
|
208
154
|
# at role_user creation for all roles. (default: +false+)
|
@@ -239,20 +185,6 @@ module Spree
|
|
239
185
|
# entity expansion attacks.
|
240
186
|
preference :log_entry_allow_aliases, :boolean, default: true
|
241
187
|
|
242
|
-
# @!attribute [rw] mails_from
|
243
|
-
# @return [String] Email address used as +From:+ field in transactional emails.
|
244
|
-
# @deprecated Spree::Store#mail_from_address is used instead
|
245
|
-
preference :mails_from, :string, default: 'solidus@example.com'
|
246
|
-
def mails_from=(value)
|
247
|
-
Spree::Deprecation.warn(<<~MSG) && preferences[:mail_from] = value
|
248
|
-
Solidus doesn't use `Spree::Config.mails_from` preference and it'll
|
249
|
-
removed on the next major release. Please, remove its definition in
|
250
|
-
`config/initializers/spree.rb`. Use the `Spree::Store#mail_from_address`
|
251
|
-
attribute for the default email address used as the 'From:' field in
|
252
|
-
transactional emails.
|
253
|
-
MSG
|
254
|
-
end
|
255
|
-
|
256
188
|
# @!attribute [rw] max_level_in_taxons_menu
|
257
189
|
# @return [Integer] maximum nesting level in taxons menu (default: +1+)
|
258
190
|
preference :max_level_in_taxons_menu, :integer, default: 1
|
@@ -347,14 +279,6 @@ module Spree
|
|
347
279
|
# @return [] Track on_hand values for variants / products. (default: true)
|
348
280
|
preference :track_inventory_levels, :boolean, default: true
|
349
281
|
|
350
|
-
# @!attribute [rw] use_legacy_events
|
351
|
-
# Before v3.2, Solidus used a custom pub/sub implementation based on
|
352
|
-
# ActiveSupport::Notifications. Now, we internally use and recommend
|
353
|
-
# [Omnes](https://github.com/nebulab/omnes). This preference allows falling
|
354
|
-
# back to the old system.
|
355
|
-
# @return [Boolean]
|
356
|
-
versioned_preference :use_legacy_events, :boolean, initial_value: true, boundaries: { "3.2.0.alpha" => false }
|
357
|
-
|
358
282
|
# Other configurations
|
359
283
|
|
360
284
|
# Allows restricting what currencies will be available.
|
@@ -566,7 +490,7 @@ module Spree
|
|
566
490
|
# @!attribute [rw] image_attachment_module
|
567
491
|
# @return [Module] a module that can be included into Spree::Image to allow attachments
|
568
492
|
# Enumerable of images adhering to the present_image_class interface
|
569
|
-
class_name_attribute :image_attachment_module, default: Spree::
|
493
|
+
class_name_attribute :image_attachment_module, default: "Spree::Image::ActiveStorageAttachment"
|
570
494
|
|
571
495
|
# @!attribute [rw] allowed_image_mime_types
|
572
496
|
#
|
@@ -633,7 +557,7 @@ module Spree
|
|
633
557
|
# @!attribute [rw] taxon_attachment_module
|
634
558
|
# @return [Module] a module that can be included into Spree::Taxon to allow attachments
|
635
559
|
# Enumerable of taxons adhering to the present_taxon_class interface
|
636
|
-
class_name_attribute :taxon_attachment_module, default: Spree::
|
560
|
+
class_name_attribute :taxon_attachment_module, default: "Spree::Taxon::ActiveStorageAttachment"
|
637
561
|
|
638
562
|
# Configures the absolute path that contains the Solidus engine
|
639
563
|
# migrations. This will be checked at app boot to confirm that all Solidus
|
@@ -676,10 +600,6 @@ module Spree
|
|
676
600
|
end
|
677
601
|
end
|
678
602
|
|
679
|
-
def events
|
680
|
-
@events_configuration ||= Spree::Event::Configuration.new
|
681
|
-
end
|
682
|
-
|
683
603
|
def user_last_url_storer_rules
|
684
604
|
@user_last_url_storer_rules ||= ::Spree::Core::ClassConstantizer::Set.new.tap do |set|
|
685
605
|
set << 'Spree::UserLastUrlStorer::Rules::AuthenticationRule'
|
data/lib/spree/bus.rb
CHANGED
@@ -5,16 +5,5 @@ module Spree
|
|
5
5
|
#
|
6
6
|
# This is used for internal events, while host applications are also able to
|
7
7
|
# use it.
|
8
|
-
#
|
9
|
-
# It has some modifications to support internal usage of the legacy event
|
10
|
-
# system {see Spree::AppConfiguration#use_legacy_events}.
|
11
8
|
Bus = Omnes::Bus.new
|
12
|
-
def Bus.publish(event, **kwargs)
|
13
|
-
if Spree::Config.use_legacy_events
|
14
|
-
Spree::Event.fire(event, **kwargs)
|
15
|
-
else
|
16
|
-
# Override caller_location to point to the actual event publisher
|
17
|
-
super(event, **kwargs, caller_location: caller_locations(1)[0])
|
18
|
-
end
|
19
|
-
end
|
20
9
|
end
|
@@ -17,7 +17,6 @@ module Spree
|
|
17
17
|
|
18
18
|
included do
|
19
19
|
before_action :set_guest_token
|
20
|
-
helper_method :try_spree_current_user
|
21
20
|
helper_method :spree_current_user
|
22
21
|
|
23
22
|
class_attribute :unauthorized_redirect
|
@@ -58,21 +57,6 @@ module Spree
|
|
58
57
|
def spree_current_user
|
59
58
|
defined?(super) ? super : nil
|
60
59
|
end
|
61
|
-
|
62
|
-
# proxy method to *possible* spree_current_user method
|
63
|
-
# Authentication extensions (such as spree_auth_devise) are meant to provide spree_current_user
|
64
|
-
def try_spree_current_user
|
65
|
-
# This one will be defined by apps looking to hook into Spree
|
66
|
-
# As per authentication_helpers.rb
|
67
|
-
if respond_to?(:spree_current_user, true)
|
68
|
-
spree_current_user
|
69
|
-
# This one will be defined by Devise
|
70
|
-
elsif respond_to?(:current_spree_user, true)
|
71
|
-
current_spree_user
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
deprecate try_spree_current_user: :spree_current_user, deprecator: Spree::Deprecation
|
76
60
|
end
|
77
61
|
end
|
78
62
|
end
|
data/lib/spree/core/engine.rb
CHANGED
@@ -52,27 +52,17 @@ module Spree
|
|
52
52
|
|
53
53
|
# Setup pub/sub
|
54
54
|
initializer 'spree.core.pub_sub' do |app|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
%i[
|
68
|
-
order_finalized
|
69
|
-
order_recalculated
|
70
|
-
reimbursement_reimbursed
|
71
|
-
reimbursement_errored
|
72
|
-
].each { |event_name| Spree::Bus.register(event_name) }
|
73
|
-
|
74
|
-
Spree::OrderMailerSubscriber.new.subscribe_to(Spree::Bus)
|
75
|
-
end
|
55
|
+
app.reloader.to_prepare do
|
56
|
+
Spree::Bus.clear
|
57
|
+
|
58
|
+
%i[
|
59
|
+
order_finalized
|
60
|
+
order_recalculated
|
61
|
+
reimbursement_reimbursed
|
62
|
+
reimbursement_errored
|
63
|
+
].each { |event_name| Spree::Bus.register(event_name) }
|
64
|
+
|
65
|
+
Spree::OrderMailerSubscriber.new.subscribe_to(Spree::Bus)
|
76
66
|
end
|
77
67
|
end
|
78
68
|
|
@@ -97,16 +87,6 @@ module Spree
|
|
97
87
|
Spree::UsersController.protect_from_forgery with: :exception
|
98
88
|
end
|
99
89
|
end
|
100
|
-
|
101
|
-
config.after_initialize do
|
102
|
-
if Spree::Config.use_legacy_events && !ENV['CI']
|
103
|
-
Spree::Deprecation.warn <<~MSG
|
104
|
-
Your Solidus store is using the legacy event system. You're
|
105
|
-
encouraged to switch to the new event bus. After you're done, you
|
106
|
-
can remove the `use_legacy_events` setting from `spree.rb`.
|
107
|
-
MSG
|
108
|
-
end
|
109
|
-
end
|
110
90
|
end
|
111
91
|
end
|
112
92
|
end
|
@@ -12,10 +12,6 @@ module Spree
|
|
12
12
|
# end
|
13
13
|
#
|
14
14
|
class EmailValidator < ActiveModel::EachValidator
|
15
|
-
EMAIL_REGEXP = URI::MailTo::EMAIL_REGEXP
|
16
|
-
# Use Spree::Config.default_email_regexp instead
|
17
|
-
deprecate_constant :EMAIL_REGEXP
|
18
|
-
|
19
15
|
def validate_each(record, attribute, value)
|
20
16
|
unless Spree::Config.default_email_regexp.match? value
|
21
17
|
record.errors.add(attribute, :invalid, **{ value: value }.merge!(options))
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
@@ -20,7 +20,6 @@ require 'ransack'
|
|
20
20
|
require 'state_machines-activerecord'
|
21
21
|
|
22
22
|
require 'spree/deprecation'
|
23
|
-
require 'spree/rails_compatibility'
|
24
23
|
|
25
24
|
# This is required because ActiveModel::Validations#invalid? conflicts with the
|
26
25
|
# invalid state of a Payment. In the future this should be removed.
|
@@ -94,7 +93,6 @@ require 'spree/core/environment/promotions'
|
|
94
93
|
require 'spree/core/environment'
|
95
94
|
require 'spree/migrations'
|
96
95
|
require 'spree/migration_helpers'
|
97
|
-
require 'spree/event'
|
98
96
|
require 'spree/bus'
|
99
97
|
require 'spree/core/engine'
|
100
98
|
|
@@ -6,9 +6,9 @@ module Spree
|
|
6
6
|
remove_index(table, column) if index_exists?(table, column)
|
7
7
|
end
|
8
8
|
|
9
|
-
def safe_add_index(table, column,
|
10
|
-
if columns_exist?(table, column) && !index_exists?(table, column,
|
11
|
-
add_index(table, column,
|
9
|
+
def safe_add_index(table, column, options = {})
|
10
|
+
if columns_exist?(table, column) && !index_exists?(table, column, options)
|
11
|
+
add_index(table, column, options)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|