spree_core 4.4.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/finders/spree/option_values/find_available.rb +1 -1
- data/app/finders/spree/product_properties/find_available.rb +1 -1
- data/app/finders/spree/products/find.rb +21 -15
- data/app/finders/spree/taxons/find.rb +11 -8
- data/app/helpers/spree/base_helper.rb +14 -11
- 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 +34 -28
- data/app/models/concerns/spree/translatable_resource.rb +25 -0
- data/app/models/concerns/spree/translatable_resource_scopes.rb +24 -0
- data/app/models/concerns/spree/translatable_resource_slug.rb +17 -0
- 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/base.rb +1 -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/data_feed/google.rb +15 -0
- data/app/models/spree/data_feed.rb +40 -0
- data/app/models/spree/digital.rb +4 -0
- data/app/models/spree/digital_link.rb +7 -0
- data/app/models/spree/fulfilment_changer.rb +1 -1
- 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 +9 -1
- data/app/models/spree/menu.rb +3 -0
- data/app/models/spree/menu_item.rb +7 -11
- data/app/models/spree/option_type.rb +8 -0
- data/app/models/spree/option_value.rb +9 -0
- data/app/models/spree/order/address_book.rb +1 -0
- data/app/models/spree/order.rb +12 -3
- 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 +97 -24
- data/app/models/spree/product_property.rb +13 -3
- 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 +10 -1
- 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 +8 -1
- 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 +39 -15
- 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 +26 -7
- 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 +8 -1
- data/app/models/spree/variant.rb +47 -21
- 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/data_feeds/google/optional_attributes.rb +23 -0
- data/app/services/spree/data_feeds/google/optional_sub_attributes.rb +21 -0
- data/app/services/spree/data_feeds/google/products_list.rb +14 -0
- data/app/services/spree/data_feeds/google/required_attributes.rb +67 -0
- data/app/services/spree/data_feeds/google/rss.rb +107 -0
- data/app/services/spree/variants/remove_line_items.rb +15 -0
- data/app/sorters/spree/products/sort.rb +23 -0
- data/brakeman.ignore +326 -18
- data/config/initializers/friendly_id.rb +2 -0
- data/config/initializers/mobility.rb +18 -0
- data/config/locales/en.yml +6 -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/db/migrate/20220706112554_create_product_name_and_description_translations_for_mobility_table_backend.rb +27 -0
- data/db/migrate/20220715083542_create_spree_product_translations_for_mobility.rb +7 -0
- data/db/migrate/20220715120222_change_product_name_null_to_true.rb +5 -0
- data/db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb +27 -0
- data/db/migrate/20220718100948_change_taxon_name_null_to_true.rb +5 -0
- data/db/migrate/20220802070609_add_locale_to_friendly_id_slugs.rb +11 -0
- data/db/migrate/20220802073225_create_spree_product_slug_translations_for_mobility_table_backend.rb +5 -0
- data/db/migrate/20220804073928_transfer_data_to_translatable_tables.rb +66 -0
- data/db/migrate/20221215151408_add_selected_locale_to_spree_users.rb +8 -0
- data/db/migrate/20221219123957_add_deleted_at_to_product_translations.rb +6 -0
- data/db/migrate/20221220133432_add_uniqueness_constraint_to_product_translations.rb +5 -0
- data/db/migrate/20221229132350_create_spree_data_feed_settings.rb +14 -0
- data/db/migrate/20230103144439_create_option_type_translations.rb +26 -0
- data/db/migrate/20230103151034_create_option_value_translations.rb +26 -0
- data/db/migrate/20230109084253_create_product_property_translations.rb +25 -0
- data/db/migrate/20230109094907_transfer_options_data_to_translatable_tables.rb +58 -0
- data/db/migrate/20230109105943_create_property_translations.rb +26 -0
- data/db/migrate/20230109110840_transfer_property_data_to_translatable_tables.rb +59 -0
- data/db/migrate/20230110142344_backfill_friendly_id_slug_locale.rb +15 -0
- data/db/migrate/20230111121534_add_additional_taxon_translation_fields.rb +8 -0
- data/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb +82 -0
- data/db/migrate/20230117115531_create_taxonomy_translations.rb +24 -0
- data/db/migrate/20230117120430_allow_null_taxonomy_name.rb +5 -0
- data/db/migrate/20230117121303_transfer_taxonomy_data_to_translatable_tables.rb +11 -0
- data/db/migrate/20230210142732_create_store_translations.rb +50 -0
- data/db/migrate/20230210142849_transfer_store_data_to_translatable_tables.rb +11 -0
- data/db/migrate/20230210230434_add_deleted_at_to_store_translations.rb +6 -0
- data/db/migrate/20230415155958_rename_data_feed_settings_table.rb +5 -0
- data/db/migrate/20230415160828_rename_data_feed_table_columns.rb +7 -0
- data/db/migrate/20230415161226_add_indexes_to_data_feeds_table.rb +5 -0
- data/db/migrate/20230512094803_rename_data_feeds_column_provider_to_type.rb +5 -0
- data/db/migrate/20230514162157_add_index_on_locale_and_permalink_to_spree_taxons.rb +5 -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 +91 -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 +34 -8
- 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 +106 -0
- data/lib/spree/core/dependencies_helper.rb +19 -0
- data/lib/spree/core/engine.rb +53 -38
- 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/product_duplicator.rb +1 -1
- data/lib/spree/core/product_filters.rb +7 -4
- data/lib/spree/core/search/base.rb +10 -6
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +27 -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/google_data_feed_factory.rb +8 -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 +12 -1
- data/lib/spree/testing_support/factories/product_property_factory.rb +1 -0
- data/lib/spree/testing_support/factories/product_translation_factory.rb +6 -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 +2 -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 +8 -0
- data/lib/spree/translation_migrations.rb +40 -0
- data/lib/spree_core.rb +2 -1
- data/lib/tasks/core.rake +12 -0
- data/spree_core.gemspec +5 -3
- metadata +152 -52
- data/app/models/friendly_id/slug_decorator.rb +0 -9
- data/app/models/spree/app_configuration.rb +0 -86
- 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
@@ -1,5 +1,15 @@
|
|
1
1
|
module Spree
|
2
2
|
module DependenciesHelper
|
3
|
+
def self.included(base)
|
4
|
+
injection_points = base::INJECTION_POINTS_WITH_DEFAULTS.keys.freeze
|
5
|
+
base.const_set(:INJECTION_POINTS, injection_points)
|
6
|
+
base.attr_accessor(*injection_points)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
set_default_values
|
11
|
+
end
|
12
|
+
|
3
13
|
def current_values
|
4
14
|
values = []
|
5
15
|
self.class::INJECTION_POINTS.each do |injection_point|
|
@@ -7,5 +17,14 @@ module Spree
|
|
7
17
|
end
|
8
18
|
values
|
9
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def set_default_values
|
24
|
+
self.class::INJECTION_POINTS_WITH_DEFAULTS.each do |injection_point, default_value|
|
25
|
+
value = default_value.respond_to?(:call) ? default_value.call : default_value
|
26
|
+
instance_variable_set("@#{injection_point}", value)
|
27
|
+
end
|
28
|
+
end
|
10
29
|
end
|
11
30
|
end
|
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
|
@@ -8,7 +11,8 @@ module Spree
|
|
8
11
|
:adjusters,
|
9
12
|
:stock_splitters,
|
10
13
|
:promotions,
|
11
|
-
:line_item_comparison_hooks
|
14
|
+
:line_item_comparison_hooks,
|
15
|
+
:data_feed_types)
|
12
16
|
SpreeCalculators = Struct.new(:shipping_methods, :tax_rates, :promotion_actions_create_adjustments, :promotion_actions_create_item_adjustments)
|
13
17
|
PromoEnvironment = Struct.new(:rules, :actions)
|
14
18
|
isolate_namespace Spree
|
@@ -19,13 +23,44 @@ module Spree
|
|
19
23
|
end
|
20
24
|
|
21
25
|
initializer 'spree.environment', before: :load_config_initializers do |app|
|
22
|
-
app.config.spree = Environment.new(SpreeCalculators.new, Spree::
|
26
|
+
app.config.spree = Environment.new(SpreeCalculators.new, Spree::Core::Configuration.new, Spree::Core::Dependencies.new)
|
27
|
+
app.config.active_record.yaml_column_permitted_classes = [Symbol, BigDecimal]
|
23
28
|
Spree::Config = app.config.spree.preferences
|
24
29
|
Spree::Dependencies = app.config.spree.dependencies
|
25
30
|
end
|
26
31
|
|
27
|
-
initializer 'spree.register.calculators' do |app|
|
28
|
-
|
32
|
+
initializer 'spree.register.calculators', before: :after_initialize do |app|
|
33
|
+
end
|
34
|
+
|
35
|
+
initializer 'spree.register.stock_splitters', before: :load_config_initializers do |app|
|
36
|
+
end
|
37
|
+
|
38
|
+
initializer 'spree.register.line_item_comparison_hooks', before: :load_config_initializers do |app|
|
39
|
+
app.config.spree.line_item_comparison_hooks = Set.new
|
40
|
+
end
|
41
|
+
|
42
|
+
initializer 'spree.register.payment_methods', after: 'acts_as_list.insert_into_active_record' do |app|
|
43
|
+
end
|
44
|
+
|
45
|
+
initializer 'spree.register.adjustable_adjusters' do |app|
|
46
|
+
end
|
47
|
+
|
48
|
+
# We need to define promotions rules here so extensions and existing apps
|
49
|
+
# can add their custom classes on their initializer files
|
50
|
+
initializer 'spree.promo.environment' do |app|
|
51
|
+
app.config.spree.promotions = PromoEnvironment.new
|
52
|
+
app.config.spree.promotions.rules = []
|
53
|
+
end
|
54
|
+
|
55
|
+
initializer 'spree.promo.register.promotion.calculators' do |app|
|
56
|
+
end
|
57
|
+
|
58
|
+
# Promotion rules need to be evaluated on after initialize otherwise
|
59
|
+
# Spree.user_class would be nil and users might experience errors related
|
60
|
+
# to malformed model associations (Spree.user_class is only defined on
|
61
|
+
# the app initializer)
|
62
|
+
config.after_initialize do
|
63
|
+
Rails.application.config.spree.calculators.shipping_methods = [
|
29
64
|
Spree::Calculator::Shipping::FlatPercentItemTotal,
|
30
65
|
Spree::Calculator::Shipping::FlatRate,
|
31
66
|
Spree::Calculator::Shipping::FlexiRate,
|
@@ -34,48 +69,29 @@ module Spree
|
|
34
69
|
Spree::Calculator::Shipping::DigitalDelivery,
|
35
70
|
]
|
36
71
|
|
37
|
-
|
72
|
+
Rails.application.config.spree.calculators.tax_rates = [
|
38
73
|
Spree::Calculator::DefaultTax
|
39
74
|
]
|
40
|
-
end
|
41
75
|
|
42
|
-
|
43
|
-
app.config.spree.stock_splitters = [
|
76
|
+
Rails.application.config.spree.stock_splitters = [
|
44
77
|
Spree::Stock::Splitter::ShippingCategory,
|
45
78
|
Spree::Stock::Splitter::Backordered,
|
46
79
|
Spree::Stock::Splitter::Digital
|
47
80
|
]
|
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
81
|
|
54
|
-
|
55
|
-
app.config.spree.payment_methods = [
|
82
|
+
Rails.application.config.spree.payment_methods = [
|
56
83
|
Spree::Gateway::Bogus,
|
57
84
|
Spree::Gateway::BogusSimple,
|
58
85
|
Spree::PaymentMethod::Check,
|
59
86
|
Spree::PaymentMethod::StoreCredit
|
60
87
|
]
|
61
|
-
end
|
62
88
|
|
63
|
-
|
64
|
-
app.config.spree.adjusters = [
|
89
|
+
Rails.application.config.spree.adjusters = [
|
65
90
|
Spree::Adjustable::Adjuster::Promotion,
|
66
91
|
Spree::Adjustable::Adjuster::Tax
|
67
92
|
]
|
68
|
-
end
|
69
93
|
|
70
|
-
|
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
|
-
|
77
|
-
initializer 'spree.promo.register.promotion.calculators' do |app|
|
78
|
-
app.config.spree.calculators.promotion_actions_create_adjustments = [
|
94
|
+
Rails.application.config.spree.calculators.promotion_actions_create_adjustments = [
|
79
95
|
Spree::Calculator::FlatPercentItemTotal,
|
80
96
|
Spree::Calculator::FlatRate,
|
81
97
|
Spree::Calculator::FlexiRate,
|
@@ -83,18 +99,12 @@ module Spree
|
|
83
99
|
Spree::Calculator::TieredFlatRate
|
84
100
|
]
|
85
101
|
|
86
|
-
|
102
|
+
Rails.application.config.spree.calculators.promotion_actions_create_item_adjustments = [
|
87
103
|
Spree::Calculator::PercentOnLineItem,
|
88
104
|
Spree::Calculator::FlatRate,
|
89
105
|
Spree::Calculator::FlexiRate
|
90
106
|
]
|
91
|
-
end
|
92
107
|
|
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
108
|
Rails.application.config.spree.promotions.rules.concat [
|
99
109
|
Spree::Promotion::Rules::ItemTotal,
|
100
110
|
Spree::Promotion::Rules::Product,
|
@@ -106,15 +116,20 @@ module Spree
|
|
106
116
|
Spree::Promotion::Rules::OptionValue,
|
107
117
|
Spree::Promotion::Rules::Country
|
108
118
|
]
|
109
|
-
end
|
110
119
|
|
111
|
-
|
112
|
-
app.config.spree.promotions.actions = [
|
120
|
+
Rails.application.config.spree.promotions.actions = [
|
113
121
|
Promotion::Actions::CreateAdjustment,
|
114
122
|
Promotion::Actions::CreateItemAdjustments,
|
115
123
|
Promotion::Actions::CreateLineItems,
|
116
124
|
Promotion::Actions::FreeShipping
|
117
125
|
]
|
126
|
+
|
127
|
+
Rails.application.config.spree.data_feed_types = [
|
128
|
+
Spree::DataFeed::Google
|
129
|
+
]
|
130
|
+
end
|
131
|
+
|
132
|
+
initializer 'spree.promo.register.promotions.actions' do |app|
|
118
133
|
end
|
119
134
|
|
120
135
|
# filter sensitive information during logging
|
@@ -26,7 +26,7 @@ module Spree
|
|
26
26
|
|
27
27
|
def duplicate_product
|
28
28
|
product.dup.tap do |new_product|
|
29
|
-
new_product.name
|
29
|
+
product.translations.each { |t| new_product.send(:name=, "COPY OF #{t.name}", locale: t.locale) }
|
30
30
|
new_product.taxons = product.taxons
|
31
31
|
new_product.stores = product.stores
|
32
32
|
new_product.created_at = nil
|
@@ -98,18 +98,21 @@ module Spree
|
|
98
98
|
conds.each do |new_scope|
|
99
99
|
scope = scope.or(new_scope)
|
100
100
|
end
|
101
|
-
|
101
|
+
Product.with_property('brand').join_translation_table(ProductProperty).where(scope)
|
102
102
|
end
|
103
103
|
|
104
104
|
def self.brand_filter
|
105
105
|
brand_property = Spree::Property.find_by(name: 'brand')
|
106
106
|
brands = brand_property ? Spree::ProductProperty.where(property_id: brand_property.id).pluck(:value).uniq.map(&:to_s) : []
|
107
|
-
|
108
|
-
|
107
|
+
|
108
|
+
conditions = brands.map do |brand|
|
109
|
+
[brand, { ProductProperty.translation_table_alias => { value: brand } }]
|
110
|
+
end.to_h
|
111
|
+
|
109
112
|
{
|
110
113
|
name: I18n.t('spree.taxonomy_brands_name'),
|
111
114
|
scope: :brand_any,
|
112
|
-
conds:
|
115
|
+
conds: conditions,
|
113
116
|
labels: brands.sort.map { |k| [k, k] }
|
114
117
|
}
|
115
118
|
end
|
@@ -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)
|
@@ -79,7 +83,7 @@ module Spree
|
|
79
83
|
# method should return new scope based on base_scope
|
80
84
|
def get_products_conditions_for(base_scope, query)
|
81
85
|
unless query.blank?
|
82
|
-
base_scope = base_scope.
|
86
|
+
base_scope = base_scope.i18n { name.matches("%#{query}%").or(description.matches("%#{query}%")) }
|
83
87
|
end
|
84
88
|
base_scope
|
85
89
|
end
|
@@ -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
@@ -13,8 +13,8 @@ require 'cancan'
|
|
13
13
|
require 'friendly_id'
|
14
14
|
require 'kaminari'
|
15
15
|
require 'monetize'
|
16
|
+
require 'mobility'
|
16
17
|
require 'paranoia'
|
17
|
-
require 'mini_magick'
|
18
18
|
require 'ransack'
|
19
19
|
require 'state_machines-activerecord'
|
20
20
|
require 'active_storage_validations'
|
@@ -25,7 +25,8 @@ require 'activerecord-typedstore'
|
|
25
25
|
StateMachines::Machine.ignore_method_conflicts = true
|
26
26
|
|
27
27
|
module Spree
|
28
|
-
mattr_accessor :user_class, :admin_user_class, :private_storage_service_name
|
28
|
+
mattr_accessor :user_class, :admin_user_class, :private_storage_service_name,
|
29
|
+
:public_storage_service_name, :cdn_host, :searcher_class
|
29
30
|
|
30
31
|
def self.user_class(constantize: true)
|
31
32
|
if @@user_class.is_a?(Class)
|
@@ -55,6 +56,26 @@ module Spree
|
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
59
|
+
def self.public_storage_service_name
|
60
|
+
if @@public_storage_service_name
|
61
|
+
if @@public_storage_service_name.is_a?(String) || @@public_storage_service_name.is_a?(Symbol)
|
62
|
+
@@public_storage_service_name.to_sym
|
63
|
+
else
|
64
|
+
raise 'Spree.public_storage_service_name MUST be a String or Symbol object.'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.searcher_class(constantize: true)
|
70
|
+
@@searcher_class ||= 'Spree::Core::Search::Base'
|
71
|
+
|
72
|
+
if @@searcher_class.is_a?(Class)
|
73
|
+
raise 'Spree.searcher_class MUST be a String or Symbol object, not a Class object.'
|
74
|
+
elsif @@searcher_class.is_a?(String) || @@searcher_class.is_a?(Symbol)
|
75
|
+
constantize ? @@searcher_class.to_s.constantize : @@searcher_class.to_s
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
58
79
|
# Used to configure Spree.
|
59
80
|
#
|
60
81
|
# Example:
|
@@ -96,6 +117,7 @@ require 'spree/core/version'
|
|
96
117
|
|
97
118
|
require 'spree/core/number_generator'
|
98
119
|
require 'spree/migrations'
|
120
|
+
require 'spree/translation_migrations'
|
99
121
|
require 'spree/core/engine'
|
100
122
|
|
101
123
|
require 'spree/i18n'
|
@@ -105,9 +127,6 @@ require 'spree/permitted_attributes'
|
|
105
127
|
require 'spree/service_module'
|
106
128
|
require 'spree/database_type_utilities'
|
107
129
|
|
108
|
-
require 'spree/core/dependencies_helper'
|
109
|
-
require 'spree/core/app_dependencies'
|
110
|
-
|
111
130
|
require 'spree/core/importer'
|
112
131
|
require 'spree/core/query_filters'
|
113
132
|
require 'spree/core/product_duplicator'
|
@@ -119,3 +138,6 @@ require 'spree/core/controller_helpers/store'
|
|
119
138
|
require 'spree/core/controller_helpers/strong_parameters'
|
120
139
|
require 'spree/core/controller_helpers/locale'
|
121
140
|
require 'spree/core/controller_helpers/currency'
|
141
|
+
|
142
|
+
require 'spree/core/preferences/store'
|
143
|
+
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: {} }, :selected_locale]
|
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' }
|
@@ -47,6 +52,12 @@ FactoryBot.define do
|
|
47
52
|
factory :product_with_option_types do
|
48
53
|
after(:create) { |product| create(:product_option_type, product: product) }
|
49
54
|
end
|
55
|
+
factory :product_with_properties do
|
56
|
+
after(:create) do |product|
|
57
|
+
create(:property, :brand, id: 10)
|
58
|
+
create(:product_property, product: product, property_id: 10, value: 'Epsilon')
|
59
|
+
end
|
60
|
+
end
|
50
61
|
end
|
51
62
|
end
|
52
63
|
end
|
@@ -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
|
@@ -12,6 +12,7 @@ FactoryBot.define do
|
|
12
12
|
facebook { 'spreecommerce' }
|
13
13
|
twitter { 'spreecommerce' }
|
14
14
|
instagram { 'spreecommerce' }
|
15
|
+
meta_description { 'Sample store description.' }
|
15
16
|
|
16
17
|
trait :with_favicon do
|
17
18
|
transient do
|
@@ -20,7 +21,7 @@ FactoryBot.define do
|
|
20
21
|
end
|
21
22
|
|
22
23
|
favicon_image do
|
23
|
-
Rack::Test::UploadedFile.new(filepath, image_type)
|
24
|
+
create(:favicon_image, attachment: Rack::Test::UploadedFile.new(filepath, image_type))
|
24
25
|
end
|
25
26
|
end
|
26
27
|
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
|
|