spree_core 4.4.1 → 4.5.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/app/finders/spree/products/find.rb +1 -3
- data/app/finders/spree/taxons/find.rb +1 -1
- data/app/helpers/spree/base_helper.rb +12 -9
- data/app/helpers/spree/locale_helper.rb +6 -2
- data/app/helpers/spree/products_helper.rb +9 -4
- data/app/jobs/spree/variants/remove_from_incomplete_orders_job.rb +9 -0
- data/app/jobs/spree/variants/remove_line_item_job.rb +9 -0
- data/app/models/concerns/spree/calculated_adjustments.rb +1 -1
- data/app/models/concerns/spree/display_link.rb +17 -29
- data/app/models/concerns/spree/image_methods.rb +21 -9
- data/app/models/concerns/spree/metadata.rb +2 -2
- data/app/models/concerns/spree/product_scopes.rb +10 -8
- data/app/models/spree/address.rb +7 -1
- data/app/models/spree/asset/support/active_storage.rb +3 -2
- data/app/models/spree/asset.rb +3 -0
- data/app/models/spree/cms_page.rb +4 -0
- data/app/models/spree/cms_section.rb +12 -12
- data/app/models/spree/cms_section_image.rb +15 -0
- data/app/models/spree/cms_section_image_one.rb +4 -0
- data/app/models/spree/cms_section_image_three.rb +4 -0
- data/app/models/spree/cms_section_image_two.rb +4 -0
- data/app/models/spree/credit_card.rb +10 -4
- data/app/models/spree/customer_return.rb +3 -0
- data/app/models/spree/digital.rb +4 -0
- data/app/models/spree/digital_link.rb +7 -0
- data/app/models/spree/gateway/bogus.rb +1 -1
- data/app/models/spree/icon.rb +5 -1
- data/app/models/spree/image/configuration/active_storage.rb +5 -1
- data/app/models/spree/image.rb +3 -3
- data/app/models/spree/inventory_unit.rb +5 -2
- data/app/models/spree/legacy_user.rb +1 -2
- data/app/models/spree/line_item.rb +4 -1
- data/app/models/spree/linkable/homepage.rb +3 -0
- data/app/models/spree/linkable/uri.rb +3 -0
- data/app/models/spree/log_entry.rb +4 -0
- data/app/models/spree/menu.rb +3 -0
- data/app/models/spree/menu_item.rb +7 -11
- data/app/models/spree/option_type.rb +4 -0
- data/app/models/spree/option_value.rb +5 -0
- data/app/models/spree/order/address_book.rb +1 -0
- data/app/models/spree/order/store_credit.rb +0 -8
- data/app/models/spree/order.rb +11 -2
- data/app/models/spree/order_merger.rb +1 -1
- data/app/models/spree/payment/processing.rb +1 -1
- data/app/models/spree/payment.rb +7 -1
- data/app/models/spree/payment_capture_event.rb +4 -0
- data/app/models/spree/payment_method/store_credit.rb +1 -1
- data/app/models/spree/payment_method.rb +3 -0
- data/app/models/spree/payment_source.rb +10 -0
- data/app/models/spree/preference.rb +4 -0
- data/app/models/spree/price.rb +3 -0
- data/app/models/spree/product.rb +56 -14
- data/app/models/spree/product_property.rb +1 -0
- data/app/models/spree/promotion/rules/option_value.rb +2 -2
- data/app/models/spree/promotion.rb +6 -0
- data/app/models/spree/promotion_rule.rb +1 -1
- data/app/models/spree/promotion_rule_user.rb +1 -1
- data/app/models/spree/property.rb +3 -0
- data/app/models/spree/prototype.rb +3 -0
- data/app/models/spree/refund.rb +8 -0
- data/app/models/spree/reimbursement.rb +3 -0
- data/app/models/spree/return_authorization.rb +3 -0
- data/app/models/spree/return_item.rb +4 -0
- data/app/models/spree/role.rb +1 -1
- data/app/models/spree/role_user.rb +1 -1
- data/app/models/spree/shipment.rb +7 -0
- data/app/models/spree/shipping_category.rb +3 -0
- data/app/models/spree/shipping_method.rb +6 -0
- data/app/models/spree/state_change.rb +1 -1
- data/app/models/spree/stock/availability_validator.rb +9 -3
- data/app/models/spree/stock/content_item.rb +1 -1
- data/app/models/spree/stock/quantifier.rb +1 -1
- data/app/models/spree/stock_item.rb +5 -0
- data/app/models/spree/stock_location.rb +19 -5
- data/app/models/spree/stock_movement.rb +4 -0
- data/app/models/spree/stock_transfer.rb +3 -0
- data/app/models/spree/store.rb +19 -14
- data/app/models/spree/store_credit.rb +4 -1
- data/app/models/spree/store_favicon_image.rb +17 -0
- data/app/models/spree/store_logo.rb +9 -0
- data/app/models/spree/store_mailer_logo.rb +13 -0
- data/app/models/spree/tax_category.rb +6 -0
- data/app/models/spree/tax_rate.rb +6 -1
- data/app/models/spree/taxon.rb +4 -1
- data/app/models/spree/taxon_image/configuration/active_storage.rb +5 -1
- data/app/models/spree/taxon_image.rb +3 -2
- data/app/models/spree/taxonomy.rb +4 -1
- data/app/models/spree/variant.rb +43 -14
- data/app/models/spree/wished_item.rb +4 -0
- data/app/models/spree/wishlist.rb +4 -1
- data/app/models/spree/zone.rb +3 -0
- data/app/services/spree/addresses/create.rb +1 -1
- data/app/services/spree/addresses/update.rb +7 -2
- data/app/services/spree/cart/remove_line_item.rb +1 -0
- data/app/services/spree/variants/remove_line_items.rb +15 -0
- data/config/locales/en.yml +5 -2
- data/config/routes.rb +43 -0
- data/db/migrate/20211201202851_update_linkable_resource_types.rb +10 -0
- data/db/migrate/20211203082008_add_settings_to_payment_methods.rb +11 -0
- data/db/migrate/20211229162122_disable_propagate_all_variants_by_default.rb +5 -0
- data/db/migrate/20220103082046_add_status_and_make_active_at_to_spree_products.rb +7 -0
- data/db/migrate/20220106230929_add_internal_note_to_spree_orders.rb +5 -0
- data/db/migrate/20220113052823_create_payment_sources.rb +22 -0
- data/db/migrate/20220117100333_add_make_active_at_to_spree_products.rb +17 -0
- data/db/migrate/20220120092821_add_metadata_to_spree_tax_rates.rb +13 -0
- data/db/migrate/20220201103922_add_first_name_and_last_name_to_spree_users.rb +9 -0
- data/db/migrate/20220222083546_add_barcode_to_spree_variants.rb +6 -0
- data/db/migrate/20220329113557_fix_cms_pages_unique_indexes.rb +8 -0
- data/db/migrate/20220613133029_add_metadata_to_spree_stock_items.rb +13 -0
- data/lib/friendly_id/paranoia.rb +4 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +13 -2
- data/lib/generators/spree/dummy/templates/package.json +12 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/core/configuration.rb +90 -0
- data/lib/spree/core/controller_helpers/auth.rb +3 -1
- data/lib/spree/core/controller_helpers/currency.rb +7 -5
- data/lib/spree/core/controller_helpers/locale.rb +8 -6
- data/lib/spree/core/controller_helpers/order.rb +4 -2
- data/lib/spree/core/controller_helpers/search.rb +1 -1
- data/lib/spree/core/controller_helpers/store.rb +5 -3
- data/lib/spree/core/dependencies.rb +130 -0
- data/lib/spree/core/engine.rb +47 -37
- data/{app/models/spree → lib/spree/core}/preferences/configuration.rb +3 -0
- data/{app/models/spree → lib/spree/core}/preferences/preferable.rb +3 -0
- data/lib/spree/core/search/base.rb +9 -5
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +25 -5
- data/lib/spree/permitted_attributes.rb +9 -7
- data/lib/spree/testing_support/common_rake.rb +1 -0
- data/lib/spree/testing_support/factories/favicon_image_factory.rb +9 -0
- data/lib/spree/testing_support/factories/icon_factory.rb +3 -1
- data/lib/spree/testing_support/factories/image_factory.rb +3 -1
- data/lib/spree/testing_support/factories/menu_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/order_factory.rb +2 -1
- data/lib/spree/testing_support/factories/product_factory.rb +6 -1
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -0
- data/lib/spree/testing_support/factories/refund_factory.rb +1 -1
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +1 -1
- data/lib/spree/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipping_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +3 -2
- data/lib/spree/testing_support/factories/store_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_image_factory.rb +3 -1
- data/lib/spree/testing_support/factories/user_factory.rb +4 -0
- data/lib/spree/testing_support/factories/variant_factory.rb +4 -0
- data/lib/spree_core.rb +2 -1
- data/lib/tasks/core.rake +12 -0
- data/spree_core.gemspec +2 -3
- metadata +64 -53
- data/app/models/friendly_id/slug_decorator.rb +0 -9
- data/app/models/spree/app_configuration.rb +0 -86
- data/app/models/spree/order_contents.rb +0 -31
- data/lib/friendly_id/slug_rails5_patch.rb +0 -11
- data/lib/spree/core/app_dependencies.rb +0 -126
- /data/{app/models/spree → lib/spree/core}/preferences/preferable_class_methods.rb +0 -0
- /data/{app/models/spree → lib/spree/core}/preferences/scoped_store.rb +0 -0
- /data/{app/models/spree → lib/spree/core}/preferences/store.rb +0 -0
data/lib/spree/core/engine.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require_relative 'dependencies'
|
|
2
|
+
require_relative 'configuration'
|
|
3
|
+
|
|
1
4
|
module Spree
|
|
2
5
|
module Core
|
|
3
6
|
class Engine < ::Rails::Engine
|
|
@@ -19,13 +22,44 @@ module Spree
|
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
initializer 'spree.environment', before: :load_config_initializers do |app|
|
|
22
|
-
app.config.spree = Environment.new(SpreeCalculators.new, Spree::
|
|
25
|
+
app.config.spree = Environment.new(SpreeCalculators.new, Spree::Core::Configuration.new, Spree::Core::Dependencies.new)
|
|
26
|
+
app.config.active_record.yaml_column_permitted_classes = [Symbol, BigDecimal]
|
|
23
27
|
Spree::Config = app.config.spree.preferences
|
|
24
28
|
Spree::Dependencies = app.config.spree.dependencies
|
|
25
29
|
end
|
|
26
30
|
|
|
27
|
-
initializer 'spree.register.calculators' do |app|
|
|
28
|
-
|
|
31
|
+
initializer 'spree.register.calculators', before: :after_initialize do |app|
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
initializer 'spree.register.stock_splitters', before: :load_config_initializers do |app|
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
initializer 'spree.register.line_item_comparison_hooks', before: :load_config_initializers do |app|
|
|
38
|
+
app.config.spree.line_item_comparison_hooks = Set.new
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
initializer 'spree.register.payment_methods', after: 'acts_as_list.insert_into_active_record' do |app|
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
initializer 'spree.register.adjustable_adjusters' do |app|
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# We need to define promotions rules here so extensions and existing apps
|
|
48
|
+
# can add their custom classes on their initializer files
|
|
49
|
+
initializer 'spree.promo.environment' do |app|
|
|
50
|
+
app.config.spree.promotions = PromoEnvironment.new
|
|
51
|
+
app.config.spree.promotions.rules = []
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
initializer 'spree.promo.register.promotion.calculators' do |app|
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Promotion rules need to be evaluated on after initialize otherwise
|
|
58
|
+
# Spree.user_class would be nil and users might experience errors related
|
|
59
|
+
# to malformed model associations (Spree.user_class is only defined on
|
|
60
|
+
# the app initializer)
|
|
61
|
+
config.after_initialize do
|
|
62
|
+
Rails.application.config.spree.calculators.shipping_methods = [
|
|
29
63
|
Spree::Calculator::Shipping::FlatPercentItemTotal,
|
|
30
64
|
Spree::Calculator::Shipping::FlatRate,
|
|
31
65
|
Spree::Calculator::Shipping::FlexiRate,
|
|
@@ -34,48 +68,29 @@ module Spree
|
|
|
34
68
|
Spree::Calculator::Shipping::DigitalDelivery,
|
|
35
69
|
]
|
|
36
70
|
|
|
37
|
-
|
|
71
|
+
Rails.application.config.spree.calculators.tax_rates = [
|
|
38
72
|
Spree::Calculator::DefaultTax
|
|
39
73
|
]
|
|
40
|
-
end
|
|
41
74
|
|
|
42
|
-
|
|
43
|
-
app.config.spree.stock_splitters = [
|
|
75
|
+
Rails.application.config.spree.stock_splitters = [
|
|
44
76
|
Spree::Stock::Splitter::ShippingCategory,
|
|
45
77
|
Spree::Stock::Splitter::Backordered,
|
|
46
78
|
Spree::Stock::Splitter::Digital
|
|
47
79
|
]
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
initializer 'spree.register.line_item_comparison_hooks', before: :load_config_initializers do |app|
|
|
51
|
-
app.config.spree.line_item_comparison_hooks = Set.new
|
|
52
|
-
end
|
|
53
80
|
|
|
54
|
-
|
|
55
|
-
app.config.spree.payment_methods = [
|
|
81
|
+
Rails.application.config.spree.payment_methods = [
|
|
56
82
|
Spree::Gateway::Bogus,
|
|
57
83
|
Spree::Gateway::BogusSimple,
|
|
58
84
|
Spree::PaymentMethod::Check,
|
|
59
85
|
Spree::PaymentMethod::StoreCredit
|
|
60
86
|
]
|
|
61
|
-
end
|
|
62
87
|
|
|
63
|
-
|
|
64
|
-
app.config.spree.adjusters = [
|
|
88
|
+
Rails.application.config.spree.adjusters = [
|
|
65
89
|
Spree::Adjustable::Adjuster::Promotion,
|
|
66
90
|
Spree::Adjustable::Adjuster::Tax
|
|
67
91
|
]
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# We need to define promotions rules here so extensions and existing apps
|
|
71
|
-
# can add their custom classes on their initializer files
|
|
72
|
-
initializer 'spree.promo.environment' do |app|
|
|
73
|
-
app.config.spree.promotions = PromoEnvironment.new
|
|
74
|
-
app.config.spree.promotions.rules = []
|
|
75
|
-
end
|
|
76
92
|
|
|
77
|
-
|
|
78
|
-
app.config.spree.calculators.promotion_actions_create_adjustments = [
|
|
93
|
+
Rails.application.config.spree.calculators.promotion_actions_create_adjustments = [
|
|
79
94
|
Spree::Calculator::FlatPercentItemTotal,
|
|
80
95
|
Spree::Calculator::FlatRate,
|
|
81
96
|
Spree::Calculator::FlexiRate,
|
|
@@ -83,18 +98,12 @@ module Spree
|
|
|
83
98
|
Spree::Calculator::TieredFlatRate
|
|
84
99
|
]
|
|
85
100
|
|
|
86
|
-
|
|
101
|
+
Rails.application.config.spree.calculators.promotion_actions_create_item_adjustments = [
|
|
87
102
|
Spree::Calculator::PercentOnLineItem,
|
|
88
103
|
Spree::Calculator::FlatRate,
|
|
89
104
|
Spree::Calculator::FlexiRate
|
|
90
105
|
]
|
|
91
|
-
end
|
|
92
106
|
|
|
93
|
-
# Promotion rules need to be evaluated on after initialize otherwise
|
|
94
|
-
# Spree.user_class would be nil and users might experience errors related
|
|
95
|
-
# to malformed model associations (Spree.user_class is only defined on
|
|
96
|
-
# the app initializer)
|
|
97
|
-
config.after_initialize do
|
|
98
107
|
Rails.application.config.spree.promotions.rules.concat [
|
|
99
108
|
Spree::Promotion::Rules::ItemTotal,
|
|
100
109
|
Spree::Promotion::Rules::Product,
|
|
@@ -106,10 +115,8 @@ module Spree
|
|
|
106
115
|
Spree::Promotion::Rules::OptionValue,
|
|
107
116
|
Spree::Promotion::Rules::Country
|
|
108
117
|
]
|
|
109
|
-
end
|
|
110
118
|
|
|
111
|
-
|
|
112
|
-
app.config.spree.promotions.actions = [
|
|
119
|
+
Rails.application.config.spree.promotions.actions = [
|
|
113
120
|
Promotion::Actions::CreateAdjustment,
|
|
114
121
|
Promotion::Actions::CreateItemAdjustments,
|
|
115
122
|
Promotion::Actions::CreateLineItems,
|
|
@@ -117,6 +124,9 @@ module Spree
|
|
|
117
124
|
]
|
|
118
125
|
end
|
|
119
126
|
|
|
127
|
+
initializer 'spree.promo.register.promotions.actions' do |app|
|
|
128
|
+
end
|
|
129
|
+
|
|
120
130
|
# filter sensitive information during logging
|
|
121
131
|
initializer 'spree.params.filter' do |app|
|
|
122
132
|
app.config.filter_parameters += [
|
|
@@ -30,7 +30,13 @@ module Spree
|
|
|
30
30
|
def extended_base_scope
|
|
31
31
|
base_scope = current_store.products.spree_base_scopes
|
|
32
32
|
base_scope = get_products_conditions_for(base_scope, keywords)
|
|
33
|
-
base_scope = Spree::Dependencies.products_finder.constantize.new(
|
|
33
|
+
base_scope = Spree::Dependencies.products_finder.constantize.new(**product_finder_params(base_scope)).execute
|
|
34
|
+
base_scope = add_search_scopes(base_scope)
|
|
35
|
+
add_eagerload_scopes(base_scope)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def product_finder_params(base_scope)
|
|
39
|
+
{
|
|
34
40
|
scope: base_scope,
|
|
35
41
|
params: {
|
|
36
42
|
store: current_store,
|
|
@@ -43,9 +49,7 @@ module Spree
|
|
|
43
49
|
},
|
|
44
50
|
sort_by: sort_by
|
|
45
51
|
}
|
|
46
|
-
|
|
47
|
-
base_scope = add_search_scopes(base_scope)
|
|
48
|
-
add_eagerload_scopes(base_scope)
|
|
52
|
+
}
|
|
49
53
|
end
|
|
50
54
|
|
|
51
55
|
def add_eagerload_scopes(scope)
|
|
@@ -101,7 +105,7 @@ module Spree
|
|
|
101
105
|
high_price = Monetize.parse(price_param.remove("#{less_than_string} ")).to_i
|
|
102
106
|
else
|
|
103
107
|
low_price, high_price = Monetize.parse_collection(price_param).map(&:to_i)
|
|
104
|
-
high_price =
|
|
108
|
+
high_price = BigDecimal::INFINITY if high_price&.zero?
|
|
105
109
|
end
|
|
106
110
|
|
|
107
111
|
"#{low_price},#{high_price}"
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
|
@@ -14,7 +14,6 @@ require 'friendly_id'
|
|
|
14
14
|
require 'kaminari'
|
|
15
15
|
require 'monetize'
|
|
16
16
|
require 'paranoia'
|
|
17
|
-
require 'mini_magick'
|
|
18
17
|
require 'ransack'
|
|
19
18
|
require 'state_machines-activerecord'
|
|
20
19
|
require 'active_storage_validations'
|
|
@@ -25,7 +24,8 @@ require 'activerecord-typedstore'
|
|
|
25
24
|
StateMachines::Machine.ignore_method_conflicts = true
|
|
26
25
|
|
|
27
26
|
module Spree
|
|
28
|
-
mattr_accessor :user_class, :admin_user_class, :private_storage_service_name
|
|
27
|
+
mattr_accessor :user_class, :admin_user_class, :private_storage_service_name,
|
|
28
|
+
:public_storage_service_name, :cdn_host, :searcher_class
|
|
29
29
|
|
|
30
30
|
def self.user_class(constantize: true)
|
|
31
31
|
if @@user_class.is_a?(Class)
|
|
@@ -55,6 +55,26 @@ module Spree
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
def self.public_storage_service_name
|
|
59
|
+
if @@public_storage_service_name
|
|
60
|
+
if @@public_storage_service_name.is_a?(String) || @@public_storage_service_name.is_a?(Symbol)
|
|
61
|
+
@@public_storage_service_name.to_sym
|
|
62
|
+
else
|
|
63
|
+
raise 'Spree.public_storage_service_name MUST be a String or Symbol object.'
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.searcher_class(constantize: true)
|
|
69
|
+
@@searcher_class ||= 'Spree::Core::Search::Base'
|
|
70
|
+
|
|
71
|
+
if @@searcher_class.is_a?(Class)
|
|
72
|
+
raise 'Spree.searcher_class MUST be a String or Symbol object, not a Class object.'
|
|
73
|
+
elsif @@searcher_class.is_a?(String) || @@searcher_class.is_a?(Symbol)
|
|
74
|
+
constantize ? @@searcher_class.to_s.constantize : @@searcher_class.to_s
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
58
78
|
# Used to configure Spree.
|
|
59
79
|
#
|
|
60
80
|
# Example:
|
|
@@ -105,9 +125,6 @@ require 'spree/permitted_attributes'
|
|
|
105
125
|
require 'spree/service_module'
|
|
106
126
|
require 'spree/database_type_utilities'
|
|
107
127
|
|
|
108
|
-
require 'spree/core/dependencies_helper'
|
|
109
|
-
require 'spree/core/app_dependencies'
|
|
110
|
-
|
|
111
128
|
require 'spree/core/importer'
|
|
112
129
|
require 'spree/core/query_filters'
|
|
113
130
|
require 'spree/core/product_duplicator'
|
|
@@ -119,3 +136,6 @@ require 'spree/core/controller_helpers/store'
|
|
|
119
136
|
require 'spree/core/controller_helpers/strong_parameters'
|
|
120
137
|
require 'spree/core/controller_helpers/locale'
|
|
121
138
|
require 'spree/core/controller_helpers/currency'
|
|
139
|
+
|
|
140
|
+
require 'spree/core/preferences/store'
|
|
141
|
+
require 'spree/core/preferences/scoped_store'
|
|
@@ -89,7 +89,7 @@ module Spree
|
|
|
89
89
|
@@product_properties_attributes = [:property_name, :value, :position]
|
|
90
90
|
|
|
91
91
|
@@product_attributes = [
|
|
92
|
-
:name, :description, :available_on, :discontinue_on, :permalink, :meta_description,
|
|
92
|
+
:name, :description, :available_on, :make_active_at, :discontinue_on, :permalink, :meta_description,
|
|
93
93
|
:meta_keywords, :price, :sku, :deleted_at, :prototype_id,
|
|
94
94
|
:option_values_hash, :weight, :height, :width, :depth,
|
|
95
95
|
:shipping_category_id, :tax_category_id,
|
|
@@ -126,14 +126,15 @@ module Spree
|
|
|
126
126
|
:quantity, :stock_item, :stock_item_id, :originator, :action
|
|
127
127
|
]
|
|
128
128
|
|
|
129
|
-
@@store_attributes = [:name, :url, :seo_title, :code, :meta_keywords,
|
|
129
|
+
@@store_attributes = [:name, :url, :seo_title, :code, :meta_keywords,
|
|
130
130
|
:meta_description, :default_currency, :mail_from_address,
|
|
131
131
|
:customer_support_email, :facebook, :twitter, :instagram,
|
|
132
132
|
:description, :address, :contact_phone, :supported_locales,
|
|
133
133
|
:default_locale, :default_country_id, :supported_currencies,
|
|
134
|
-
:new_order_notifications_email, :
|
|
135
|
-
:
|
|
136
|
-
:
|
|
134
|
+
:new_order_notifications_email, :checkout_zone_id, :seo_robots,
|
|
135
|
+
:digital_asset_authorized_clicks, :digital_asset_authorized_days,
|
|
136
|
+
:limit_digital_download_count, :limit_digital_download_days, :digital_asset_link_expire_time,
|
|
137
|
+
{ mailer_logo_attributes: {}, favicon_image_attributes: {}, logo_attributes: {} }]
|
|
137
138
|
|
|
138
139
|
@@store_credit_attributes = %i[amount currency category_id memo]
|
|
139
140
|
|
|
@@ -145,13 +146,14 @@ module Spree
|
|
|
145
146
|
]
|
|
146
147
|
|
|
147
148
|
# TODO: Should probably use something like Spree.user_class.attributes
|
|
148
|
-
@@user_attributes = [:email, :bill_address_id, :ship_address_id, :password, :
|
|
149
|
+
@@user_attributes = [:email, :bill_address_id, :ship_address_id, :password, :first_name, :last_name,
|
|
150
|
+
:password_confirmation, { public_metadata: {}, private_metadata: {} }]
|
|
149
151
|
|
|
150
152
|
@@variant_attributes = [
|
|
151
153
|
:name, :presentation, :cost_price, :discontinue_on, :lock_version,
|
|
152
154
|
:position, :track_inventory,
|
|
153
155
|
:product_id, :product, :option_values_attributes, :price, :compare_at_price,
|
|
154
|
-
:weight, :height, :width, :depth, :sku, :cost_currency,
|
|
156
|
+
:weight, :height, :width, :depth, :sku, :barcode, :cost_currency,
|
|
155
157
|
{ options: [:name, :value], option_value_ids: [] }
|
|
156
158
|
]
|
|
157
159
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :icon, class: Spree::Icon do
|
|
3
3
|
before(:create) do |icon|
|
|
4
|
-
icon.
|
|
4
|
+
if icon.respond_to? :attachment
|
|
5
|
+
icon.attachment.attach(io: File.new(Spree::Core::Engine.root + 'spec/fixtures' + 'thinking-cat.jpg'), filename: 'thinking-cat.jpg')
|
|
6
|
+
end
|
|
5
7
|
end
|
|
6
8
|
end
|
|
7
9
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :image, class: Spree::Image do
|
|
3
3
|
before(:create) do |image|
|
|
4
|
-
image.
|
|
4
|
+
if image.class.method_defined?(:attachment)
|
|
5
|
+
image.attachment.attach(io: File.new(Spree::Core::Engine.root + 'spec/fixtures' + 'thinking-cat.jpg'), filename: 'thinking-cat.jpg')
|
|
6
|
+
end
|
|
5
7
|
end
|
|
6
8
|
end
|
|
7
9
|
end
|
|
@@ -55,7 +55,8 @@ FactoryBot.define do
|
|
|
55
55
|
order.line_items.reload
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
stock_location = order.line_items&.first&.variant&.stock_items&.first&.stock_location || create(:stock_location)
|
|
59
|
+
create(:shipment, order: order, cost: evaluator.shipment_cost, stock_location: stock_location)
|
|
59
60
|
order.shipments.reload
|
|
60
61
|
|
|
61
62
|
order.update_with_updater!
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :base_product, class: Spree::Product do
|
|
3
|
-
sequence(:name) { |n| "Product
|
|
3
|
+
sequence(:name) { |n| "Product #{n}#{Kernel.rand(9999)}" }
|
|
4
4
|
description { generate(:random_description) }
|
|
5
5
|
price { 19.99 }
|
|
6
6
|
cost_price { 17.00 }
|
|
7
7
|
sku { generate(:sku) }
|
|
8
8
|
available_on { 1.year.ago }
|
|
9
|
+
make_active_at { 1.year.ago }
|
|
9
10
|
deleted_at { nil }
|
|
10
11
|
shipping_category { |r| Spree::ShippingCategory.first || r.association(:shipping_category) }
|
|
12
|
+
status { 'active' }
|
|
11
13
|
|
|
12
14
|
# ensure stock item will be created for this products master
|
|
13
15
|
# also attach this product to the default store if no stores are passed in
|
|
@@ -21,6 +23,9 @@ FactoryBot.define do
|
|
|
21
23
|
product.stores << [store]
|
|
22
24
|
end
|
|
23
25
|
end
|
|
26
|
+
after(:create) do |product|
|
|
27
|
+
Spree::StockLocation.all.each { |stock_location| stock_location.propagate_variant(product.master) unless stock_location.stock_items.exists?(variant: product.master) }
|
|
28
|
+
end
|
|
24
29
|
|
|
25
30
|
factory :custom_product do
|
|
26
31
|
name { 'Custom Product' }
|
|
@@ -7,6 +7,7 @@ FactoryBot.define do
|
|
|
7
7
|
phone { '(202) 456-1111' }
|
|
8
8
|
active { true }
|
|
9
9
|
backorderable_default { true }
|
|
10
|
+
propagate_all_variants { false }
|
|
10
11
|
|
|
11
12
|
country { |stock_location| Spree::Country.first || stock_location.association(:country) }
|
|
12
13
|
state do |stock_location|
|
|
@@ -21,8 +22,8 @@ FactoryBot.define do
|
|
|
21
22
|
product_1 = create(:product, stores: [store])
|
|
22
23
|
product_2 = create(:product, stores: [store])
|
|
23
24
|
|
|
24
|
-
stock_location.
|
|
25
|
-
stock_location.
|
|
25
|
+
stock_location.stock_item_or_create(product_1.master).adjust_count_on_hand(10)
|
|
26
|
+
stock_location.stock_item_or_create(product_2.master).adjust_count_on_hand(20)
|
|
26
27
|
end
|
|
27
28
|
end
|
|
28
29
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
FactoryBot.define do
|
|
2
2
|
factory :taxon_image, class: Spree::TaxonImage do
|
|
3
3
|
before(:create) do |taxon_image|
|
|
4
|
-
taxon_image.
|
|
4
|
+
if taxon_image.class.method_defined?(:attachment)
|
|
5
|
+
taxon_image.attachment.attach(io: File.new(Spree::Core::Engine.root + 'spec/fixtures/thinking-cat.jpg'), filename: 'thinking-cat.jpg')
|
|
6
|
+
end
|
|
5
7
|
end
|
|
6
8
|
end
|
|
7
9
|
end
|
|
@@ -9,6 +9,10 @@ FactoryBot.define do
|
|
|
9
9
|
password { 'secret' }
|
|
10
10
|
password_confirmation { password }
|
|
11
11
|
authentication_token { generate(:user_authentication_token) } if Spree.user_class.attribute_method? :authentication_token
|
|
12
|
+
|
|
13
|
+
first_name { FFaker::Name.first_name }
|
|
14
|
+
last_name { FFaker::Name.last_name }
|
|
15
|
+
|
|
12
16
|
public_metadata { {} }
|
|
13
17
|
private_metadata { {} }
|
|
14
18
|
|
|
@@ -18,6 +18,10 @@ FactoryBot.define do
|
|
|
18
18
|
# ensure stock item will be created for this variant
|
|
19
19
|
before(:create) { create(:stock_location) unless Spree::StockLocation.any? }
|
|
20
20
|
|
|
21
|
+
after(:create) do |variant|
|
|
22
|
+
Spree::StockLocation.all.each { |stock_location| stock_location.propagate_variant(variant) }
|
|
23
|
+
end
|
|
24
|
+
|
|
21
25
|
factory :variant do
|
|
22
26
|
# on_hand 5
|
|
23
27
|
product { |p| p.association(:product, stores: [create(:store)]) }
|
data/lib/spree_core.rb
CHANGED
data/lib/tasks/core.rake
CHANGED
|
@@ -185,3 +185,15 @@ use rake db:load_file[/absolute/path/to/sample/filename.rb]}
|
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
end
|
|
188
|
+
|
|
189
|
+
namespace :core do
|
|
190
|
+
desc 'Set "active" status on draft products where make_active_at is in the past'
|
|
191
|
+
task activate_products: :environment do |_t, _args|
|
|
192
|
+
Spree::Product.where('make_active_at <= ?', Time.current).where(status: 'draft').update_all(status: 'active', updated_at: Time.current)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
desc 'Set "archived" status on active products where discontinue_on is in the past'
|
|
196
|
+
task archive_products: :environment do |_t, _args|
|
|
197
|
+
Spree::Product.where('discontinue_on <= ?', Time.current).where.not(status: 'archived').update_all(status: 'archived', updated_at: Time.current)
|
|
198
|
+
end
|
|
199
|
+
end
|
data/spree_core.gemspec
CHANGED
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
|
|
|
30
30
|
actionpack actionview activejob activemodel activerecord
|
|
31
31
|
activestorage activesupport railties
|
|
32
32
|
].each do |rails_gem|
|
|
33
|
-
s.add_dependency rails_gem, '>=
|
|
33
|
+
s.add_dependency rails_gem, '>= 6.1'
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
s.add_dependency 'activemerchant', '~> 1.67'
|
|
@@ -45,13 +45,12 @@ Gem::Specification.new do |s|
|
|
|
45
45
|
s.add_dependency 'money', '~> 6.13'
|
|
46
46
|
s.add_dependency 'monetize', '~> 1.9'
|
|
47
47
|
s.add_dependency 'paranoia', '~> 2.4'
|
|
48
|
-
s.add_dependency 'ransack', '
|
|
48
|
+
s.add_dependency 'ransack', '>= 2.3', '< 3.0'
|
|
49
49
|
s.add_dependency 'rexml'
|
|
50
50
|
s.add_dependency 'state_machines-activerecord', '~> 0.6'
|
|
51
51
|
s.add_dependency 'state_machines-activemodel', '~> 0.7'
|
|
52
52
|
s.add_dependency 'stringex'
|
|
53
53
|
s.add_dependency 'validates_zipcode'
|
|
54
|
-
s.add_dependency 'mini_magick', '~> 4.9', '>= 4.9.4'
|
|
55
54
|
s.add_dependency 'image_processing', '~> 1.2'
|
|
56
55
|
s.add_dependency 'active_storage_validations', '~> 0.9', '<= 0.9.5'
|
|
57
56
|
s.add_dependency 'activerecord-typedstore'
|