solidus_core 3.2.4 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +6 -2
- data/app/controllers/spree/base_controller.rb +1 -1
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +4 -0
- data/app/models/concerns/spree/ransackable_attributes.rb +24 -4
- data/app/models/concerns/spree/user_methods.rb +2 -2
- data/app/models/spree/address.rb +1 -1
- data/app/models/spree/calculator/flat_fee.rb +21 -0
- data/app/models/spree/country.rb +1 -1
- data/app/models/spree/credit_card.rb +1 -1
- data/app/models/spree/customer_return.rb +1 -1
- data/app/models/spree/line_item.rb +2 -2
- data/app/models/spree/option_type.rb +1 -1
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/order/number_generator.rb +7 -1
- data/app/models/spree/order.rb +4 -3
- data/app/models/spree/order_promotion.rb +1 -1
- data/app/models/spree/order_updater.rb +11 -2
- data/app/models/spree/payment/processing.rb +58 -55
- data/app/models/spree/payment_method/bogus_credit_card.rb +6 -7
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +8 -0
- data/app/models/spree/payment_method.rb +16 -10
- data/app/models/spree/price.rb +1 -1
- data/app/models/spree/product.rb +3 -3
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -0
- data/app/models/spree/promotion/order_adjustments_recalculator.rb +92 -0
- data/app/models/spree/promotion.rb +2 -2
- data/app/models/spree/promotion_code.rb +1 -1
- data/app/models/spree/property.rb +1 -1
- data/app/models/spree/return_authorization.rb +1 -1
- data/app/models/spree/shipment.rb +2 -2
- data/app/models/spree/state.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_location.rb +1 -1
- data/app/models/spree/stock_movement.rb +2 -2
- data/app/models/spree/store_credit_prioritizer.rb +17 -0
- data/app/models/spree/tax/tax_helpers.rb +2 -2
- data/app/models/spree/tax_calculator/default.rb +31 -0
- data/app/models/spree/tax_rate.rb +8 -1
- data/app/models/spree/taxon.rb +1 -1
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/user_last_url_storer/rules/authentication_rule.rb +1 -1
- data/app/models/spree/variant.rb +25 -5
- data/app/models/spree/zone.rb +1 -1
- data/config/locales/en.yml +17 -2
- data/db/migrate/20220805202442_add_level_to_spree_tax_rates.rb +5 -0
- data/db/migrate/20221123152807_add_shipping_category_to_spree_variants.rb +5 -0
- data/db/seeds.rb +4 -1
- data/lib/generators/solidus/install/app_templates/authentication/custom.rb +21 -0
- data/lib/generators/solidus/install/app_templates/authentication/devise.rb +16 -0
- data/lib/generators/solidus/install/app_templates/authentication/existing.rb +10 -0
- data/lib/generators/solidus/install/app_templates/authentication/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/frontend/break_down_solidus_gem.rb +54 -0
- data/lib/generators/solidus/install/app_templates/frontend/classic.rb +16 -0
- data/lib/generators/solidus/install/app_templates/frontend/none.rb +2 -0
- data/lib/generators/solidus/install/app_templates/frontend/starter.rb +3 -0
- data/lib/generators/solidus/install/app_templates/payment_method/bolt.rb +13 -0
- data/lib/generators/solidus/install/app_templates/payment_method/none.rb +1 -0
- data/lib/generators/solidus/install/app_templates/payment_method/paypal.rb +10 -0
- data/lib/generators/solidus/install/install_generator.rb +233 -187
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -4
- data/lib/generators/spree/custom_user/custom_user_generator.rb +6 -4
- data/lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt +2 -6
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +7 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +10 -8
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -12
- data/lib/spree/app_configuration.rb +23 -0
- data/lib/spree/core/controller_helpers/current_host.rb +5 -1
- data/lib/spree/core/engine.rb +1 -0
- data/lib/spree/core/search/base.rb +17 -8
- data/lib/spree/core/version.rb +2 -2
- data/lib/spree/core.rb +1 -21
- data/lib/spree/migrations.rb +12 -10
- data/lib/spree/permitted_attributes.rb +4 -1
- data/lib/spree/preferences/preferable.rb +5 -0
- data/lib/spree/preferences/preferable_class_methods.rb +2 -2
- data/lib/spree/preferences/static_model_preferences.rb +25 -8
- data/lib/spree/rails_compatibility.rb +0 -17
- data/lib/spree/testing_support/common_rake.rb +27 -7
- data/lib/spree/testing_support/dummy_app.rb +2 -2
- data/lib/spree/testing_support/factories/address_factory.rb +9 -11
- data/lib/spree/testing_support/factories/calculator_factory.rb +3 -0
- data/lib/spree/testing_support/factories/country_factory.rb +1 -2
- data/lib/spree/testing_support/factories/promotion_factory.rb +28 -14
- data/lib/spree/testing_support/factories/state_factory.rb +8 -2
- data/lib/spree/testing_support/factory_bot.rb +1 -1
- data/lib/spree/testing_support/order_walkthrough.rb +1 -1
- data/lib/tasks/colorado_delivery_fee.rake +28 -0
- data/solidus_core.gemspec +2 -2
- metadata +37 -23
- data/lib/generators/solidus/install/install_generator/bundler_context.rb +0 -97
- data/lib/generators/solidus/install/install_generator/install_frontend.rb +0 -59
- data/lib/generators/solidus/install/install_generator/support_solidus_frontend_extraction.rb +0 -48
@@ -1,6 +1,3 @@
|
|
1
|
-
<% if agent_number = ENV['TC_AGENT_NUMBER']
|
2
|
-
database_prefix = agent_number + '_'
|
3
|
-
end %>
|
4
1
|
<% db = case ENV['DB']
|
5
2
|
when 'mysql'
|
6
3
|
'mysql'
|
@@ -22,14 +19,11 @@ end %>
|
|
22
19
|
<% db_username = ENV['DB_USERNAME'] %>
|
23
20
|
<% db_password = ENV['DB_PASSWORD'] %>
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
22
|
<% case ENV['DB']
|
29
23
|
when 'mysql' %>
|
30
24
|
development:
|
31
25
|
adapter: mysql2
|
32
|
-
database: <%=
|
26
|
+
database: <%= options[:lib_name] %>_solidus_development
|
33
27
|
<% unless db_username.blank? %>
|
34
28
|
username: <%= db_username %>
|
35
29
|
<% end %>
|
@@ -42,7 +36,7 @@ development:
|
|
42
36
|
encoding: utf8
|
43
37
|
test:
|
44
38
|
adapter: mysql2
|
45
|
-
database: <%=
|
39
|
+
database: <%= options[:lib_name] %>_solidus_test
|
46
40
|
<% unless db_username.blank? %>
|
47
41
|
username: <%= db_username %>
|
48
42
|
<% end %>
|
@@ -55,7 +49,7 @@ test:
|
|
55
49
|
encoding: utf8
|
56
50
|
production:
|
57
51
|
adapter: mysql2
|
58
|
-
database: <%=
|
52
|
+
database: <%= options[:lib_name] %>_solidus_production
|
59
53
|
<% unless db_username.blank? %>
|
60
54
|
username: <%= db_username %>
|
61
55
|
<% end %>
|
@@ -69,7 +63,7 @@ production:
|
|
69
63
|
<% when 'postgres', 'postgresql' %>
|
70
64
|
development:
|
71
65
|
adapter: postgresql
|
72
|
-
database: <%=
|
66
|
+
database: <%= options[:lib_name] %>_solidus_development
|
73
67
|
<% unless db_username.blank? %>
|
74
68
|
username: <%= db_username %>
|
75
69
|
<% end %>
|
@@ -82,7 +76,7 @@ development:
|
|
82
76
|
min_messages: warning
|
83
77
|
test:
|
84
78
|
adapter: postgresql
|
85
|
-
database: <%=
|
79
|
+
database: <%= options[:lib_name] %>_solidus_test
|
86
80
|
<% unless db_username.blank? %>
|
87
81
|
username: <%= db_username %>
|
88
82
|
<% end %>
|
@@ -95,7 +89,7 @@ test:
|
|
95
89
|
min_messages: warning
|
96
90
|
production:
|
97
91
|
adapter: postgresql
|
98
|
-
database: <%=
|
92
|
+
database: <%= options[:lib_name] %>_solidus_production
|
99
93
|
<% unless db_username.blank? %>
|
100
94
|
username: <%= db_username %>
|
101
95
|
<% end %>
|
@@ -193,7 +193,17 @@ module Spree
|
|
193
193
|
|
194
194
|
# @!attribute [rw] mails_from
|
195
195
|
# @return [String] Email address used as +From:+ field in transactional emails.
|
196
|
+
# @deprecated Spree::Store#mail_from_address is used instead
|
196
197
|
preference :mails_from, :string, default: 'solidus@example.com'
|
198
|
+
def mails_from=(value)
|
199
|
+
Spree::Deprecation.warn(<<~MSG) && preferences[:mail_from] = value
|
200
|
+
Solidus doesn't use `Spree::Config.mails_from` preference and it'll
|
201
|
+
removed on the next major release. Please, remove its definition in
|
202
|
+
`config/initializers/spree.rb`. Use the `Spree::Store#mail_from_address`
|
203
|
+
attribute for the default email address used as the 'From:' field in
|
204
|
+
transactional emails.
|
205
|
+
MSG
|
206
|
+
end
|
197
207
|
|
198
208
|
# @!attribute [rw] max_level_in_taxons_menu
|
199
209
|
# @return [Integer] maximum nesting level in taxons menu (default: +1+)
|
@@ -343,6 +353,9 @@ module Spree
|
|
343
353
|
# promotion_chooser_class allows extensions to provide their own PromotionChooser
|
344
354
|
class_name_attribute :promotion_chooser_class, default: 'Spree::PromotionChooser'
|
345
355
|
|
356
|
+
# promotion_adjuster_class allows extensions to provide their own Promotion Adjuster
|
357
|
+
class_name_attribute :promotion_adjuster_class, default: 'Spree::Promotion::OrderAdjustmentsRecalculator'
|
358
|
+
|
346
359
|
class_name_attribute :allocator_class, default: 'Spree::Stock::Allocator::OnHandFirst'
|
347
360
|
|
348
361
|
class_name_attribute :shipping_rate_sorter_class, default: 'Spree::Stock::ShippingRateSorter'
|
@@ -529,6 +542,15 @@ module Spree
|
|
529
542
|
small: '400x400>',
|
530
543
|
product: '680x680>',
|
531
544
|
large: '1200x1200>' }
|
545
|
+
|
546
|
+
# Allows providing your own class for prioritizing store credit application
|
547
|
+
# to an order.
|
548
|
+
#
|
549
|
+
# @!attribute [rw] store_credit_prioritizer_class
|
550
|
+
# @return [Class] a class with the same public interfaces as
|
551
|
+
# Spree::StoreCreditPrioritizer.
|
552
|
+
class_name_attribute :store_credit_prioritizer_class, default: 'Spree::StoreCreditPrioritizer'
|
553
|
+
|
532
554
|
# @!attribute [rw] taxon_image_style_default
|
533
555
|
#
|
534
556
|
# Defines which style to default to when style is not provided
|
@@ -642,6 +664,7 @@ module Spree
|
|
642
664
|
|
643
665
|
env.calculators.tax_rates = %w[
|
644
666
|
Spree::Calculator::DefaultTax
|
667
|
+
Spree::Calculator::FlatFee
|
645
668
|
]
|
646
669
|
|
647
670
|
env.payment_methods = %w[
|
@@ -7,7 +7,11 @@ module Spree
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
Spree::
|
10
|
+
Spree::Deprecation.warn <<~MSG
|
11
|
+
'Spree::Core::ControllerHelpers::CurrentHost' is deprecated.
|
12
|
+
Please, include 'ActiveStorage::SetCurrent' instead.
|
13
|
+
MSG
|
14
|
+
include ActiveStorage::SetCurrent
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
data/lib/spree/core/engine.rb
CHANGED
@@ -4,6 +4,12 @@ module Spree
|
|
4
4
|
module Core
|
5
5
|
module Search
|
6
6
|
class Base
|
7
|
+
class InvalidOptions < ArgumentError
|
8
|
+
def initialize(option)
|
9
|
+
super("Invalid option passed to the searcher: '#{option}'")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
7
13
|
attr_accessor :properties
|
8
14
|
attr_accessor :current_user
|
9
15
|
attr_accessor :pricing_options
|
@@ -57,16 +63,19 @@ module Spree
|
|
57
63
|
end
|
58
64
|
|
59
65
|
def add_search_scopes(base_scope)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
return base_scope unless @properties[:search].present?
|
67
|
+
raise InvalidOptions.new(:search) unless @properties[:search].respond_to?(:each_pair)
|
68
|
+
|
69
|
+
@properties[:search].each_pair do |name, scope_attribute|
|
70
|
+
scope_name = name.to_sym
|
71
|
+
|
72
|
+
if base_scope.respond_to?(:search_scopes) && base_scope.search_scopes.include?(scope_name.to_sym)
|
73
|
+
base_scope = base_scope.send(scope_name, *scope_attribute)
|
74
|
+
else
|
75
|
+
base_scope = base_scope.merge(Spree::Product.ransack({ scope_name => scope_attribute }).result)
|
68
76
|
end
|
69
77
|
end
|
78
|
+
|
70
79
|
base_scope
|
71
80
|
end
|
72
81
|
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
@@ -14,7 +14,6 @@ require 'awesome_nested_set'
|
|
14
14
|
require 'cancan'
|
15
15
|
require 'friendly_id'
|
16
16
|
require 'kaminari/activerecord'
|
17
|
-
require 'mail'
|
18
17
|
require 'monetize'
|
19
18
|
require 'paperclip'
|
20
19
|
require 'ransack'
|
@@ -28,7 +27,7 @@ require 'spree/rails_compatibility'
|
|
28
27
|
StateMachines::Machine.ignore_method_conflicts = true
|
29
28
|
|
30
29
|
module Spree
|
31
|
-
mattr_accessor :user_class
|
30
|
+
mattr_accessor :user_class, default: 'Spree::LegacyUser'
|
32
31
|
|
33
32
|
def self.user_class
|
34
33
|
if @@user_class.is_a?(Class)
|
@@ -85,24 +84,6 @@ module Spree
|
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
88
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7")
|
89
|
-
Spree::Deprecation.warn <<~HEREDOC
|
90
|
-
Ruby 2.5 & Ruby 2.6 (both EOL) are deprecated and will not be supported anymore from the next Solidus version.
|
91
|
-
Please, upgrade to a more recent Ruby version.
|
92
|
-
Read more on the release notes for different Ruby versions here:
|
93
|
-
https://www.ruby-lang.org/en/downloads/releases/
|
94
|
-
HEREDOC
|
95
|
-
end
|
96
|
-
|
97
|
-
if Gem::Version.new(Rails.version) < Gem::Version.new('6.0')
|
98
|
-
Spree::Deprecation.warn <<~HEREDOC
|
99
|
-
Rails 5.2 (EOL) is deprecated and will not be supported anymore from the next Solidus version.
|
100
|
-
Please, upgrade to a more recent Rails version.
|
101
|
-
Read more on upgrading from Rails 5.2 to Rails 6.0 here:
|
102
|
-
https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-5-2-to-rails-6-0
|
103
|
-
HEREDOC
|
104
|
-
end
|
105
|
-
|
106
87
|
require 'spree/core/version'
|
107
88
|
|
108
89
|
require 'spree/core/active_merchant_dependencies'
|
@@ -127,7 +108,6 @@ require 'spree/core/permalinks'
|
|
127
108
|
require 'spree/core/product_duplicator'
|
128
109
|
require 'spree/core/controller_helpers/auth'
|
129
110
|
require 'spree/core/controller_helpers/common'
|
130
|
-
require 'spree/core/controller_helpers/current_host'
|
131
111
|
require 'spree/core/controller_helpers/order'
|
132
112
|
require 'spree/core/controller_helpers/payment_parameters'
|
133
113
|
require 'spree/core/controller_helpers/pricing'
|
data/lib/spree/migrations.rb
CHANGED
@@ -23,16 +23,18 @@ module Spree
|
|
23
23
|
# Shouldn't run on test mode because migrations inside engine don't have
|
24
24
|
# engine name on the file name
|
25
25
|
def check
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
return unless File.directory?(app_dir)
|
27
|
+
return if missing_migrations.empty?
|
28
|
+
return if ENV['SOLIDUS_SKIP_MIGRATIONS_CHECK']
|
29
|
+
|
30
|
+
prefix = "[WARNING #{engine_name.capitalize}]"
|
31
|
+
warn <<~WARN
|
32
|
+
#{prefix} Missing migrations.
|
33
|
+
#{missing_migrations.map {|m| "#{prefix} - #{m}"}.join("\n")}
|
34
|
+
#{prefix}
|
35
|
+
#{prefix} Run `bin/rails railties:install:migrations` to get them.
|
36
|
+
#{prefix} You can silence this warning by setting the `SOLIDUS_SKIP_MIGRATIONS_CHECK` environment variable.
|
37
|
+
WARN
|
36
38
|
end
|
37
39
|
|
38
40
|
def missing_migrations
|
@@ -132,7 +132,10 @@ module Spree
|
|
132
132
|
:name, :presentation, :cost_price, :lock_version,
|
133
133
|
:position, :track_inventory,
|
134
134
|
:product_id, :product, :price,
|
135
|
-
:weight, :height, :width, :depth, :sku, :cost_currency,
|
135
|
+
:weight, :height, :width, :depth, :sku, :cost_currency,
|
136
|
+
:tax_category_id, :shipping_category_id,
|
137
|
+
option_value_ids: [],
|
138
|
+
options: [:name, :value]
|
136
139
|
]
|
137
140
|
|
138
141
|
@@checkout_address_attributes = [
|
@@ -10,6 +10,9 @@ module Spree
|
|
10
10
|
#
|
11
11
|
# A class including Preferable must implement #preferences which should return
|
12
12
|
# an object responding to .fetch(key), []=(key, val), and .delete(key).
|
13
|
+
# If #preferences is initialized with `default_preferences` and one of the
|
14
|
+
# preferences is another preference, it will cause a stack level too deep error.
|
15
|
+
# To avoid it do not memoize #preferences.
|
13
16
|
#
|
14
17
|
# It may also define a `#context_for_default` method. It should return an
|
15
18
|
# array with the arguments to be provided to a proc used as the `default:`
|
@@ -111,6 +114,8 @@ module Spree
|
|
111
114
|
end
|
112
115
|
|
113
116
|
# @return [Hash{Symbol => Object}] Default for all preferences defined on this class
|
117
|
+
# This may raise an infinite loop error if any of the defaults are
|
118
|
+
# dependent on other preferences defaults.
|
114
119
|
def default_preferences
|
115
120
|
Hash[
|
116
121
|
defined_preferences.map do |preference|
|
@@ -75,7 +75,7 @@ module Spree::Preferences
|
|
75
75
|
# is a pending preference before going to default
|
76
76
|
define_method preference_getter_method(name) do
|
77
77
|
value = preferences.fetch(name) do
|
78
|
-
|
78
|
+
instance_exec(*context_for_default, &default)
|
79
79
|
end
|
80
80
|
value = preference_encryptor.decrypt(value) if preference_encryptor.present?
|
81
81
|
value
|
@@ -92,7 +92,7 @@ module Spree::Preferences
|
|
92
92
|
end
|
93
93
|
|
94
94
|
define_method preference_default_getter_method(name) do
|
95
|
-
|
95
|
+
instance_exec(*context_for_default, &default)
|
96
96
|
end
|
97
97
|
|
98
98
|
define_method preference_type_getter_method(name) do
|
@@ -7,13 +7,8 @@ module Spree
|
|
7
7
|
attr_reader :preferences
|
8
8
|
|
9
9
|
def initialize(klass, hash)
|
10
|
-
|
11
|
-
hash.
|
12
|
-
if !klass.defined_preferences.include?(key)
|
13
|
-
raise "Preference #{key.inspect} is not defined on #{klass}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
@preferences = hash
|
10
|
+
@klass = klass
|
11
|
+
@preferences = hash.symbolize_keys
|
17
12
|
end
|
18
13
|
|
19
14
|
def fetch(key, &block)
|
@@ -27,6 +22,8 @@ module Spree
|
|
27
22
|
def to_hash
|
28
23
|
@preferences.deep_dup
|
29
24
|
end
|
25
|
+
|
26
|
+
delegate :keys, to: :@preferences
|
30
27
|
end
|
31
28
|
|
32
29
|
def initialize
|
@@ -36,12 +33,32 @@ module Spree
|
|
36
33
|
end
|
37
34
|
|
38
35
|
def add(klass, name, preferences)
|
39
|
-
@store[klass.to_s][name] = Definition.new(klass, preferences)
|
36
|
+
@store[klass.to_s][name] = Definition.new(klass.to_s, preferences)
|
40
37
|
end
|
41
38
|
|
42
39
|
def for_class(klass)
|
43
40
|
@store[klass.to_s]
|
44
41
|
end
|
42
|
+
|
43
|
+
def validate!
|
44
|
+
@store.keys.map(&:constantize).each do |klass|
|
45
|
+
validate_for_class!(klass)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def validate_for_class!(klass)
|
52
|
+
for_class(klass).each do |name, preferences|
|
53
|
+
klass_keys = klass.defined_preferences.map(&:to_s)
|
54
|
+
extra_keys = preferences.keys.map(&:to_s) - klass_keys
|
55
|
+
next if extra_keys.empty?
|
56
|
+
|
57
|
+
raise \
|
58
|
+
"Unexpected keys found for #{klass} under #{name}: #{extra_keys.sort.join(', ')} " \
|
59
|
+
"(expected keys: #{klass_keys.sort.join(', ')})"
|
60
|
+
end
|
61
|
+
end
|
45
62
|
end
|
46
63
|
end
|
47
64
|
end
|
@@ -72,23 +72,6 @@ module Spree
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
# Set current host for ActiveStorage in a controller
|
76
|
-
#
|
77
|
-
# Changed from `#host` to including a module in Rails 6
|
78
|
-
#
|
79
|
-
# See https://github.com/rails/rails/commit/e33c3cd8ccbecaca6c6af0438956431b02cb3fb2
|
80
|
-
#
|
81
|
-
# TODO: Remove when deprecating Rails 5.2
|
82
|
-
def self.active_storage_set_current(controller)
|
83
|
-
if version_gte?('6')
|
84
|
-
controller.include ActiveStorage::SetCurrent
|
85
|
-
else
|
86
|
-
controller.before_action do
|
87
|
-
ActiveStorage::Current.host = request.base_url
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
75
|
# Set current host for ActiveStorage
|
93
76
|
#
|
94
77
|
# Changed from `#host` to `#url_options` on Rails 7
|
@@ -1,9 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
unless defined?(Solidus::InstallGenerator)
|
4
|
-
require 'generators/solidus/install/install_generator'
|
5
|
-
end
|
6
|
-
|
7
3
|
require 'generators/spree/dummy/dummy_generator'
|
8
4
|
|
9
5
|
class CommonRakeTasks
|
@@ -13,12 +9,36 @@ class CommonRakeTasks
|
|
13
9
|
namespace :common do
|
14
10
|
task :test_app, :user_class do |_t, args|
|
15
11
|
args.with_defaults(user_class: "Spree::LegacyUser")
|
16
|
-
|
12
|
+
lib_name = ENV['LIB_NAME'] or
|
13
|
+
raise "Please provide a library name via the LIB_NAME environment variable."
|
14
|
+
|
15
|
+
require lib_name
|
17
16
|
|
18
17
|
force_rails_environment_to_test
|
19
18
|
|
20
|
-
Spree::DummyGenerator.start [
|
21
|
-
|
19
|
+
Spree::DummyGenerator.start [
|
20
|
+
"--lib-name=#{lib_name}",
|
21
|
+
"--quiet",
|
22
|
+
]
|
23
|
+
|
24
|
+
# While the dummy app is generated the current directory
|
25
|
+
# within ruby is changed to that of the dummy app.
|
26
|
+
sh({
|
27
|
+
'FRONTEND' => ENV['FRONTEND'] || 'classic',
|
28
|
+
}, [
|
29
|
+
'bin/rails',
|
30
|
+
'generate',
|
31
|
+
'solidus:install',
|
32
|
+
Dir.pwd, # use the current dir as Rails.root
|
33
|
+
"--auto-accept",
|
34
|
+
"--authentication=none",
|
35
|
+
"--payment-method=none",
|
36
|
+
"--migrate=false",
|
37
|
+
"--seed=false",
|
38
|
+
"--sample=false",
|
39
|
+
"--user-class=#{args[:user_class]}",
|
40
|
+
"--quiet",
|
41
|
+
].shelljoin)
|
22
42
|
|
23
43
|
puts "Setting up dummy database..."
|
24
44
|
|
@@ -38,7 +38,7 @@ module DummyApp
|
|
38
38
|
ENV["LIB_NAME"] = lib_name
|
39
39
|
DummyApp::Application.config.root = File.join(gem_root, 'spec', 'dummy')
|
40
40
|
|
41
|
-
DummyApp::Application.initialize!
|
41
|
+
DummyApp::Application.initialize! unless DummyApp::Application.initialized?
|
42
42
|
|
43
43
|
if auto_migrate
|
44
44
|
DummyApp::Migrations.auto_migrate
|
@@ -116,6 +116,7 @@ module DummyApp
|
|
116
116
|
end
|
117
117
|
config.paths['db/migrate'] = migration_dirs
|
118
118
|
ActiveRecord::Migrator.migrations_paths = migration_dirs
|
119
|
+
ActiveRecord::Migration.verbose = false
|
119
120
|
|
120
121
|
config.assets.paths << File.expand_path('dummy_app/assets/javascripts', __dir__)
|
121
122
|
config.assets.paths << File.expand_path('dummy_app/assets/stylesheets', __dir__)
|
@@ -137,7 +138,6 @@ end
|
|
137
138
|
Spree.user_class = 'Spree::LegacyUser'
|
138
139
|
Spree.load_defaults(Spree.solidus_version)
|
139
140
|
Spree.config do |config|
|
140
|
-
config.mails_from = "store@example.com"
|
141
141
|
config.use_legacy_events = ENV['USE_LEGACY_EVENTS'].present?
|
142
142
|
|
143
143
|
if ENV['DISABLE_ACTIVE_STORAGE']
|
@@ -24,21 +24,19 @@ FactoryBot.define do
|
|
24
24
|
phone { '555-555-0199' }
|
25
25
|
alternative_phone { '555-555-0199' }
|
26
26
|
|
27
|
-
state do |address|
|
28
|
-
Spree::State.joins(:country).where('spree_countries.iso = (?)', country_iso_code).find_by(abbr: state_code) ||
|
29
|
-
address.association(
|
30
|
-
:state,
|
31
|
-
strategy: :create,
|
32
|
-
country_iso: country_iso_code,
|
33
|
-
state_code: state_code
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
27
|
country do |address|
|
38
28
|
if address.state
|
39
29
|
address.state.country
|
40
30
|
else
|
41
|
-
|
31
|
+
Spree::Country.find_by(iso: country_iso_code) ||
|
32
|
+
address.association(:country, strategy: :create, iso: country_iso_code)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
after(:build) do |address, evaluator|
|
37
|
+
if address&.country&.states_required? && address.state.nil? && address.state_name.nil?
|
38
|
+
address.state = address.country.states.find_by(abbr: evaluator.state_code) ||
|
39
|
+
create(:state, country_iso: address.country.iso, state_code: evaluator.state_code)
|
42
40
|
end
|
43
41
|
end
|
44
42
|
end
|
@@ -17,6 +17,9 @@ FactoryBot.define do
|
|
17
17
|
factory :default_tax_calculator, class: 'Spree::Calculator::DefaultTax' do
|
18
18
|
end
|
19
19
|
|
20
|
+
factory :flat_fee_calculator, class: 'Spree::Calculator::FlatFee' do
|
21
|
+
end
|
22
|
+
|
20
23
|
factory :shipping_calculator, class: 'Spree::Calculator::Shipping::FlatRate' do
|
21
24
|
preferred_amount { 10.0 }
|
22
25
|
end
|
@@ -20,7 +20,6 @@ FactoryBot.define do
|
|
20
20
|
iso3 { carmen_country.alpha_3_code }
|
21
21
|
numcode { carmen_country.numeric_code }
|
22
22
|
|
23
|
-
|
24
|
-
# states_required { carmen_country.subregions? }
|
23
|
+
states_required { carmen_country.subregions? }
|
25
24
|
end
|
26
25
|
end
|
@@ -22,23 +22,40 @@ FactoryBot.define do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
trait :with_action do
|
25
|
-
|
26
|
-
|
25
|
+
transient do
|
26
|
+
promotion_action_class { Spree::Promotion::Actions::CreateAdjustment }
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:create) do |promotion, evaluator|
|
30
|
+
promotion.actions << evaluator.promotion_action_class.new
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
30
|
-
trait :
|
34
|
+
trait :with_adjustable_action do
|
31
35
|
transient do
|
32
|
-
|
36
|
+
preferred_amount { 10 }
|
37
|
+
calculator_class { Spree::Calculator::FlatRate }
|
38
|
+
promotion_action_class { Spree::Promotion::Actions::CreateItemAdjustments }
|
33
39
|
end
|
34
40
|
|
35
41
|
after(:create) do |promotion, evaluator|
|
36
|
-
calculator =
|
37
|
-
calculator.preferred_amount = evaluator.
|
38
|
-
|
42
|
+
calculator = evaluator.calculator_class.new
|
43
|
+
calculator.preferred_amount = evaluator.preferred_amount
|
44
|
+
evaluator.promotion_action_class.create!(calculator: calculator, promotion: promotion)
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
48
|
+
factory :promotion_with_action_adjustment, traits: [:with_adjustable_action]
|
49
|
+
|
50
|
+
trait :with_line_item_adjustment do
|
51
|
+
transient do
|
52
|
+
adjustment_rate { 10 }
|
53
|
+
end
|
54
|
+
|
55
|
+
with_adjustable_action
|
56
|
+
preferred_amount { adjustment_rate }
|
57
|
+
end
|
58
|
+
|
42
59
|
factory :promotion_with_item_adjustment, traits: [:with_line_item_adjustment]
|
43
60
|
|
44
61
|
trait :with_free_shipping do
|
@@ -52,14 +69,11 @@ FactoryBot.define do
|
|
52
69
|
weighted_order_adjustment_amount { 10 }
|
53
70
|
end
|
54
71
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
action = Spree::Promotion::Actions::CreateAdjustment.create!(calculator: calculator)
|
59
|
-
promotion.actions << action
|
60
|
-
promotion.save!
|
61
|
-
end
|
72
|
+
with_adjustable_action
|
73
|
+
preferred_amount { weighted_order_adjustment_amount }
|
74
|
+
promotion_action_class { Spree::Promotion::Actions::CreateAdjustment }
|
62
75
|
end
|
76
|
+
|
63
77
|
factory :promotion_with_order_adjustment, traits: [:with_order_adjustment]
|
64
78
|
|
65
79
|
trait :with_item_total_rule do
|
@@ -17,9 +17,15 @@ FactoryBot.define do
|
|
17
17
|
carmen_subregion do
|
18
18
|
carmen_country = Carmen::Country.coded(country.iso)
|
19
19
|
|
20
|
-
carmen_country.subregions
|
21
|
-
carmen_country.subregions.sort_by(&:name).first ||
|
20
|
+
unless carmen_country.subregions?
|
22
21
|
fail("Country #{country.iso} has no subregions")
|
22
|
+
end
|
23
|
+
|
24
|
+
carmen_regions = carmen_country.subregions
|
25
|
+
carmen_regions = carmen_regions.flat_map(&:subregions) if carmen_regions.first.subregions?
|
26
|
+
region_collection = Carmen::RegionCollection.new(carmen_regions)
|
27
|
+
|
28
|
+
region_collection.coded(state_code) || region_collection.sort_by(&:name).first
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
@@ -37,7 +37,7 @@ module Spree
|
|
37
37
|
Spree::Deprecation.warn(
|
38
38
|
"Please do not cherry-pick factories, this is not well supported by FactoryBot, " \
|
39
39
|
'follow the changelog instructions on how to migrate your current setup.',
|
40
|
-
callsites[index
|
40
|
+
callsites[index..]
|
41
41
|
)
|
42
42
|
end
|
43
43
|
|