solidus_core 2.8.6 → 2.9.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/assets/images/logo/solidus.svg +1 -18
- data/app/assets/images/logo/solidus_logo.png +0 -0
- data/app/mailers/spree/test_mailer.rb +2 -0
- data/app/models/concerns/spree/default_price.rb +1 -1
- data/app/models/concerns/spree/ransackable_attributes.rb +1 -1
- data/app/models/concerns/spree/user_reporting.rb +1 -1
- data/app/models/spree/billing_integration.rb +7 -2
- data/app/models/spree/country.rb +2 -0
- data/app/models/spree/customer_return.rb +1 -1
- data/app/models/spree/image/paperclip_attachment.rb +55 -0
- data/app/models/spree/image.rb +2 -44
- data/app/models/spree/inventory_unit.rb +0 -1
- data/app/models/spree/option_type.rb +2 -0
- data/app/models/spree/option_value.rb +1 -1
- data/app/models/spree/order.rb +8 -13
- data/app/models/spree/payment.rb +1 -1
- data/app/models/spree/payment_method.rb +8 -4
- data/app/models/spree/product.rb +1 -1
- data/app/models/spree/promotion/rules/first_order.rb +1 -3
- data/app/models/spree/promotion/rules/item_total.rb +9 -1
- data/app/models/spree/promotion/rules/one_use_per_user.rb +2 -2
- data/app/models/spree/promotion/rules/product.rb +3 -3
- data/app/models/spree/promotion/rules/taxon.rb +5 -8
- data/app/models/spree/promotion/rules/user_logged_in.rb +1 -1
- data/app/models/spree/promotion.rb +18 -11
- data/app/models/spree/promotion_handler/coupon.rb +19 -3
- data/app/models/spree/property.rb +2 -0
- data/app/models/spree/reimbursement.rb +5 -5
- data/app/models/spree/return_item.rb +6 -2
- data/app/models/spree/state.rb +6 -0
- data/app/models/spree/stock/location_filter/active.rb +14 -0
- data/app/models/spree/stock/location_filter/base.rb +43 -0
- data/app/models/spree/stock/simple_coordinator.rb +4 -1
- data/app/models/spree/stock_location.rb +2 -0
- data/app/models/spree/tax_category.rb +11 -0
- data/app/models/spree/taxon/paperclip_attachment.rb +21 -0
- data/app/models/spree/taxon.rb +4 -11
- data/app/models/spree/taxonomy.rb +2 -0
- data/app/models/spree/unit_cancel.rb +12 -1
- data/app/models/spree/variant/pricing_options.rb +10 -0
- data/app/models/spree/variant.rb +1 -1
- data/app/models/spree/wallet_payment_source.rb +26 -10
- data/app/models/spree/zone.rb +1 -1
- data/app/subscribers/spree/mailer_subscriber.rb +25 -0
- data/app/views/spree/order_mailer/inventory_cancellation_email.text.erb +3 -3
- data/config/locales/en.yml +26 -53
- data/db/default/spree/store_credit.rb +1 -0
- data/db/migrate/20161123154034_add_available_to_users_and_remove_display_on_from_shipping_methods.rb +1 -1
- data/db/migrate/20170608074534_rename_bogus_gateways.rb +9 -8
- data/db/migrate/20190220093635_drop_spree_store_credit_update_reasons.rb +19 -0
- data/lib/generators/spree/install/install_generator.rb +21 -19
- data/lib/generators/spree/install/templates/config/initializers/spree.rb.tt +29 -1
- data/lib/solidus/migrations/rename_gateways.rb +2 -0
- data/lib/spree/app_configuration.rb +69 -47
- data/lib/spree/core/class_constantizer.rb +6 -0
- data/lib/spree/core/controller_helpers/pricing.rb +1 -4
- data/lib/spree/core/controller_helpers/strong_parameters.rb +7 -21
- data/lib/spree/core/engine.rb +11 -0
- data/lib/spree/core/environment/promotions.rb +15 -0
- data/lib/spree/core/environment.rb +1 -1
- data/lib/spree/core/environment_extension.rb +0 -4
- data/lib/spree/core/importer/order.rb +1 -3
- data/lib/spree/core/stock_configuration.rb +5 -0
- data/lib/spree/core/version.rb +3 -1
- data/lib/spree/core.rb +2 -0
- data/lib/spree/deprecation.rb +50 -0
- data/lib/spree/event/adapters/active_support_notifications.rb +35 -0
- data/lib/spree/event/configuration.rb +25 -0
- data/lib/spree/event/subscriber.rb +84 -0
- data/lib/spree/event.rb +117 -0
- data/lib/spree/permitted_attributes.rb +7 -76
- data/lib/spree/promo/environment.rb +6 -7
- data/lib/spree/testing_support/capybara_ext.rb +15 -0
- data/lib/spree/testing_support/common_rake.rb +1 -1
- data/lib/spree/testing_support/dummy_app.rb +3 -10
- data/lib/spree/testing_support/factories/promotion_factory.rb +10 -0
- data/lib/spree/testing_support/factories/return_item_factory.rb +1 -0
- data/lib/spree/testing_support/preferences.rb +62 -0
- data/lib/tasks/email.rake +2 -0
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +4 -0
- data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +2 -0
- data/lib/tasks/migrations/migrate_user_addresses.rake +3 -0
- data/lib/tasks/migrations/rename_gateways.rake +2 -0
- data/lib/tasks/order_capturing.rake +2 -0
- data/spec/helpers/base_helper_spec.rb +3 -3
- data/spec/helpers/products_helper_spec.rb +2 -2
- data/spec/lib/spree/app_configuration_spec.rb +140 -0
- data/spec/lib/spree/core/class_constantizer_spec.rb +20 -0
- data/spec/lib/spree/core/controller_helpers/pricing_spec.rb +13 -0
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +1 -8
- data/spec/lib/spree/core/environment_extension_spec.rb +22 -23
- data/spec/lib/spree/core/testing_support/factories/shipping_method_factory_spec.rb +1 -1
- data/spec/lib/spree/core/testing_support/preferences_spec.rb +33 -0
- data/spec/lib/spree/event/subscriber_spec.rb +85 -0
- data/spec/lib/spree/event_spec.rb +118 -0
- data/spec/lib/spree/money_spec.rb +3 -9
- data/spec/lib/spree/promo/environment_spec.rb +53 -0
- data/spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb +5 -3
- data/spec/mailers/order_mailer_spec.rb +1 -1
- data/spec/mailers/test_mailer_spec.rb +3 -1
- data/spec/models/spree/address_spec.rb +5 -4
- data/spec/models/spree/concerns/user_address_book_spec.rb +4 -4
- data/spec/models/spree/country_spec.rb +5 -5
- data/spec/models/spree/customer_return_spec.rb +1 -1
- data/spec/models/spree/order/checkout_spec.rb +3 -7
- data/spec/models/spree/order/finalizing_spec.rb +1 -1
- data/spec/models/spree/order/payment_spec.rb +3 -3
- data/spec/models/spree/order_inventory_spec.rb +1 -1
- data/spec/models/spree/order_spec.rb +67 -2
- data/spec/models/spree/order_updater_spec.rb +2 -2
- data/spec/models/spree/payment_spec.rb +12 -0
- data/spec/models/spree/product_spec.rb +3 -3
- data/spec/models/spree/promotion/rules/first_order_spec.rb +13 -3
- data/spec/models/spree/promotion/rules/item_total_spec.rb +15 -0
- data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +10 -0
- data/spec/models/spree/promotion/rules/product_spec.rb +15 -0
- data/spec/models/spree/promotion/rules/taxon_spec.rb +59 -8
- data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +5 -0
- data/spec/models/spree/promotion_handler/shipping_spec.rb +1 -1
- data/spec/models/spree/promotion_spec.rb +80 -0
- data/spec/models/spree/reimbursement_spec.rb +3 -2
- data/spec/models/spree/return_item_spec.rb +9 -0
- data/spec/models/spree/shipment_spec.rb +3 -3
- data/spec/models/spree/stock/availability_spec.rb +1 -1
- data/spec/models/spree/stock/estimator_spec.rb +5 -7
- data/spec/models/spree/stock/location_filter/active_spec.rb +22 -0
- data/spec/models/spree/stock/location_sorter/default_first_spec.rb +4 -2
- data/spec/models/spree/stock/location_sorter/unsorted_spec.rb +3 -1
- data/spec/models/spree/stock/quantifier_spec.rb +1 -1
- data/spec/models/spree/stock/simple_coordinator_spec.rb +5 -0
- data/spec/models/spree/stock_item_spec.rb +3 -2
- data/spec/models/spree/stock_movement_spec.rb +1 -1
- data/spec/models/spree/store_credit_spec.rb +1 -1
- data/spec/models/spree/tax/order_adjuster_spec.rb +1 -1
- data/spec/models/spree/tax/taxation_integration_spec.rb +1 -1
- data/spec/models/spree/tax_category_spec.rb +21 -0
- data/spec/models/spree/taxon_spec.rb +28 -0
- data/spec/models/spree/unit_cancel_spec.rb +41 -0
- data/spec/models/spree/user_spec.rb +3 -3
- data/spec/models/spree/variant/pricing_options_spec.rb +23 -0
- data/spec/models/spree/variant/vat_price_generator_spec.rb +1 -1
- data/spec/models/spree/variant_spec.rb +11 -8
- data/spec/models/spree/wallet_payment_source_spec.rb +35 -6
- data/spec/models/spree/wallet_spec.rb +1 -1
- data/spec/rails_helper.rb +1 -0
- data/spec/spec_helper.rb +0 -4
- data/spec/support/concerns/default_price.rb +8 -0
- metadata +21 -6
- data/spec/lib/spree/permitted_attributes_spec.rb +0 -41
- data/spec/models/spree/app_configuration_spec.rb +0 -55
- /data/{spec/support/shared_contexts → lib/spree/testing_support}/rake.rb +0 -0
|
@@ -58,9 +58,6 @@ module Spree
|
|
|
58
58
|
|
|
59
59
|
def setup_assets
|
|
60
60
|
@lib_name = 'spree'
|
|
61
|
-
|
|
62
|
-
empty_directory 'app/assets/images'
|
|
63
|
-
|
|
64
61
|
%w{javascripts stylesheets images}.each do |path|
|
|
65
62
|
empty_directory "vendor/assets/#{path}/spree/frontend" if defined? Spree::Frontend || Rails.env.test?
|
|
66
63
|
empty_directory "vendor/assets/#{path}/spree/backend" if defined? Spree::Backend || Rails.env.test?
|
|
@@ -82,35 +79,40 @@ module Spree
|
|
|
82
79
|
end
|
|
83
80
|
|
|
84
81
|
def configure_application
|
|
85
|
-
application <<-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
application <<-RUBY
|
|
83
|
+
# Load application's model / class decorators
|
|
84
|
+
initializer 'spree.decorators' do |app|
|
|
85
|
+
config.to_prepare do
|
|
86
|
+
Dir.glob(Rails.root.join('app/**/*_decorator*.rb')) do |path|
|
|
87
|
+
require_dependency(path)
|
|
88
|
+
end
|
|
91
89
|
end
|
|
90
|
+
end
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
# Load application's view overrides
|
|
93
|
+
initializer 'spree.overrides' do |app|
|
|
94
|
+
config.to_prepare do
|
|
95
|
+
Dir.glob(Rails.root.join('app/overrides/*.rb')) do |path|
|
|
96
|
+
require_dependency(path)
|
|
97
|
+
end
|
|
96
98
|
end
|
|
97
99
|
end
|
|
98
|
-
|
|
100
|
+
RUBY
|
|
99
101
|
|
|
100
102
|
if !options[:enforce_available_locales].nil?
|
|
101
|
-
application <<-
|
|
103
|
+
application <<-RUBY
|
|
102
104
|
# Prevent this deprecation message: https://github.com/svenfuchs/i18n/commit/3b6e56e
|
|
103
105
|
I18n.enforce_available_locales = #{options[:enforce_available_locales]}
|
|
104
|
-
|
|
106
|
+
RUBY
|
|
105
107
|
end
|
|
106
108
|
end
|
|
107
109
|
|
|
108
110
|
def include_seed_data
|
|
109
|
-
append_file "db/seeds.rb", <<-
|
|
111
|
+
append_file "db/seeds.rb", <<-RUBY.strip_heredoc
|
|
110
112
|
|
|
111
113
|
Spree::Core::Engine.load_seed if defined?(Spree::Core)
|
|
112
114
|
Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
|
|
113
|
-
|
|
115
|
+
RUBY
|
|
114
116
|
end
|
|
115
117
|
|
|
116
118
|
def install_migrations
|
|
@@ -160,7 +162,7 @@ module Spree
|
|
|
160
162
|
routes_file_path = File.join('config', 'routes.rb')
|
|
161
163
|
unless File.read(routes_file_path).include? CORE_MOUNT_ROUTE
|
|
162
164
|
insert_into_file routes_file_path, after: "Rails.application.routes.draw do\n" do
|
|
163
|
-
<<-
|
|
165
|
+
<<-RUBY
|
|
164
166
|
# This line mounts Solidus's routes at the root of your application.
|
|
165
167
|
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
|
|
166
168
|
# If you would like to change where this engine is mounted, simply change the :at option to something different.
|
|
@@ -168,7 +170,7 @@ module Spree
|
|
|
168
170
|
# We ask that you don't use the :as option here, as Solidus relies on it being the default of "spree"
|
|
169
171
|
#{CORE_MOUNT_ROUTE}, at: '/'
|
|
170
172
|
|
|
171
|
-
|
|
173
|
+
RUBY
|
|
172
174
|
end
|
|
173
175
|
end
|
|
174
176
|
|
|
@@ -18,6 +18,17 @@ Spree.config do |config|
|
|
|
18
18
|
# any inventory changes.
|
|
19
19
|
# config.inventory_cache_threshold = 3
|
|
20
20
|
|
|
21
|
+
# Enable Paperclip adapter for attachments on images and taxons
|
|
22
|
+
config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
|
|
23
|
+
config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Permission Sets:
|
|
27
|
+
|
|
28
|
+
# Uncomment and customize the following line to add custom permission sets
|
|
29
|
+
# to a custom users role:
|
|
30
|
+
# config.roles.assign_permissions :role_name, ['Spree::PermissionSets::CustomPermissionSet']
|
|
31
|
+
|
|
21
32
|
|
|
22
33
|
# Frontend:
|
|
23
34
|
|
|
@@ -36,8 +47,11 @@ Spree.config do |config|
|
|
|
36
47
|
# Gateway credentials can be configured statically here and referenced from
|
|
37
48
|
# the admin. They can also be fully configured from the admin.
|
|
38
49
|
#
|
|
50
|
+
# Please note that you need to use the solidus_stripe gem to have
|
|
51
|
+
# Stripe working: https://github.com/solidusio-contrib/solidus_stripe
|
|
52
|
+
#
|
|
39
53
|
# config.static_model_preferences.add(
|
|
40
|
-
# Spree::
|
|
54
|
+
# Spree::PaymentMethod::StripeCreditCard,
|
|
41
55
|
# 'stripe_env_credentials',
|
|
42
56
|
# secret_key: ENV['STRIPE_SECRET_KEY'],
|
|
43
57
|
# publishable_key: ENV['STRIPE_PUBLISHABLE_KEY'],
|
|
@@ -55,6 +69,15 @@ end
|
|
|
55
69
|
<% if defined?(Spree::Backend::Engine) -%>
|
|
56
70
|
Spree::Backend::Config.configure do |config|
|
|
57
71
|
config.locale = 'en'
|
|
72
|
+
|
|
73
|
+
# Uncomment and change the following configuration if you want to add
|
|
74
|
+
# a new menu item:
|
|
75
|
+
#
|
|
76
|
+
# config.menu_items << config.class::MenuItem.new(
|
|
77
|
+
# [:section],
|
|
78
|
+
# 'icon-name',
|
|
79
|
+
# url: 'https://solidus.io/'
|
|
80
|
+
# )
|
|
58
81
|
end
|
|
59
82
|
<% end -%>
|
|
60
83
|
|
|
@@ -65,3 +88,8 @@ end
|
|
|
65
88
|
<% end -%>
|
|
66
89
|
|
|
67
90
|
Spree.user_class = <%= (options[:user_class].blank? ? "Spree::LegacyUser" : options[:user_class]).inspect %>
|
|
91
|
+
|
|
92
|
+
# If you want to add a field to the whitelisted ransackable attributes,
|
|
93
|
+
# just uncomment the following code and change it as you need.
|
|
94
|
+
#
|
|
95
|
+
# Spree::Model.whitelisted_ransackable_attributes << 'field'
|
|
@@ -12,6 +12,8 @@ module Solidus
|
|
|
12
12
|
attr_reader :gateway_mapping
|
|
13
13
|
|
|
14
14
|
def initialize(gateway_mapping = DEFAULT_MAPPING)
|
|
15
|
+
Spree::Deprecation.warn 'Solidus::Migrations::RenameGateways is deprecated and will be removed with Solidus 3.0.'
|
|
16
|
+
|
|
15
17
|
@gateway_mapping = gateway_mapping
|
|
16
18
|
end
|
|
17
19
|
|
|
@@ -423,6 +423,26 @@ module Spree
|
|
|
423
423
|
# Enumerable of images adhering to the present_image_class interface
|
|
424
424
|
class_name_attribute :product_gallery_class, default: 'Spree::Gallery::ProductGallery'
|
|
425
425
|
|
|
426
|
+
# Allows switching attachment library for Image
|
|
427
|
+
#
|
|
428
|
+
# `Spree::Image::PaperclipAttachment`
|
|
429
|
+
# is the default and provides the classic Paperclip implementation.
|
|
430
|
+
#
|
|
431
|
+
# @!attribute [rw] image_attachment_module
|
|
432
|
+
# @return [Module] a module that can be included into Spree::Image to allow attachments
|
|
433
|
+
# Enumerable of images adhering to the present_image_class interface
|
|
434
|
+
class_name_attribute :image_attachment_module, default: 'Spree::Image::PaperclipAttachment'
|
|
435
|
+
|
|
436
|
+
# Allows switching attachment library for Taxon
|
|
437
|
+
#
|
|
438
|
+
# `Spree::Taxon::PaperclipAttachment`
|
|
439
|
+
# is the default and provides the classic Paperclip implementation.
|
|
440
|
+
#
|
|
441
|
+
# @!attribute [rw] taxon_attachment_module
|
|
442
|
+
# @return [Module] a module that can be included into Spree::Taxon to allow attachments
|
|
443
|
+
# Enumerable of taxons adhering to the present_taxon_class interface
|
|
444
|
+
class_name_attribute :taxon_attachment_module, default: 'Spree::Taxon::PaperclipAttachment'
|
|
445
|
+
|
|
426
446
|
# Allows providing your own class instance for generating order numbers.
|
|
427
447
|
#
|
|
428
448
|
# @!attribute [rw] order_number_generator
|
|
@@ -449,8 +469,33 @@ module Spree
|
|
|
449
469
|
end
|
|
450
470
|
end
|
|
451
471
|
|
|
472
|
+
def events
|
|
473
|
+
@events_configuration ||= Spree::Event::Configuration.new
|
|
474
|
+
end
|
|
475
|
+
|
|
452
476
|
def environment
|
|
453
477
|
@environment ||= Spree::Core::Environment.new(self).tap do |env|
|
|
478
|
+
env.calculators.promotion_actions_create_adjustments = %w[
|
|
479
|
+
Spree::Calculator::FlatPercentItemTotal
|
|
480
|
+
Spree::Calculator::FlatRate
|
|
481
|
+
Spree::Calculator::FlexiRate
|
|
482
|
+
Spree::Calculator::TieredPercent
|
|
483
|
+
Spree::Calculator::TieredFlatRate
|
|
484
|
+
]
|
|
485
|
+
|
|
486
|
+
env.calculators.promotion_actions_create_item_adjustments = %w[
|
|
487
|
+
Spree::Calculator::DistributedAmount
|
|
488
|
+
Spree::Calculator::FlatRate
|
|
489
|
+
Spree::Calculator::FlexiRate
|
|
490
|
+
Spree::Calculator::PercentOnLineItem
|
|
491
|
+
Spree::Calculator::TieredPercent
|
|
492
|
+
]
|
|
493
|
+
|
|
494
|
+
env.calculators.promotion_actions_create_quantity_adjustments = %w[
|
|
495
|
+
Spree::Calculator::PercentOnLineItem
|
|
496
|
+
Spree::Calculator::FlatRate
|
|
497
|
+
]
|
|
498
|
+
|
|
454
499
|
env.calculators.shipping_methods = %w[
|
|
455
500
|
Spree::Calculator::Shipping::FlatPercentItemTotal
|
|
456
501
|
Spree::Calculator::Shipping::FlatRate
|
|
@@ -463,11 +508,6 @@ module Spree
|
|
|
463
508
|
Spree::Calculator::DefaultTax
|
|
464
509
|
]
|
|
465
510
|
|
|
466
|
-
env.stock_splitters = %w[
|
|
467
|
-
Spree::Stock::Splitter::ShippingCategory
|
|
468
|
-
Spree::Stock::Splitter::Backordered
|
|
469
|
-
]
|
|
470
|
-
|
|
471
511
|
env.payment_methods = %w[
|
|
472
512
|
Spree::PaymentMethod::BogusCreditCard
|
|
473
513
|
Spree::PaymentMethod::SimpleBogusCreditCard
|
|
@@ -475,53 +515,35 @@ module Spree
|
|
|
475
515
|
Spree::PaymentMethod::Check
|
|
476
516
|
]
|
|
477
517
|
|
|
478
|
-
env.promotions =
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
]
|
|
493
|
-
|
|
494
|
-
promos.actions = %w[
|
|
495
|
-
Spree::Promotion::Actions::CreateAdjustment
|
|
496
|
-
Spree::Promotion::Actions::CreateItemAdjustments
|
|
497
|
-
Spree::Promotion::Actions::CreateQuantityAdjustments
|
|
498
|
-
Spree::Promotion::Actions::FreeShipping
|
|
499
|
-
]
|
|
500
|
-
|
|
501
|
-
promos.shipping_actions = %w[
|
|
502
|
-
Spree::Promotion::Actions::FreeShipping
|
|
503
|
-
]
|
|
504
|
-
end
|
|
518
|
+
env.promotions.rules = %w[
|
|
519
|
+
Spree::Promotion::Rules::ItemTotal
|
|
520
|
+
Spree::Promotion::Rules::Product
|
|
521
|
+
Spree::Promotion::Rules::User
|
|
522
|
+
Spree::Promotion::Rules::FirstOrder
|
|
523
|
+
Spree::Promotion::Rules::UserLoggedIn
|
|
524
|
+
Spree::Promotion::Rules::OneUsePerUser
|
|
525
|
+
Spree::Promotion::Rules::Taxon
|
|
526
|
+
Spree::Promotion::Rules::NthOrder
|
|
527
|
+
Spree::Promotion::Rules::OptionValue
|
|
528
|
+
Spree::Promotion::Rules::FirstRepeatPurchaseSince
|
|
529
|
+
Spree::Promotion::Rules::UserRole
|
|
530
|
+
Spree::Promotion::Rules::Store
|
|
531
|
+
]
|
|
505
532
|
|
|
506
|
-
env.
|
|
507
|
-
Spree::
|
|
508
|
-
Spree::
|
|
509
|
-
Spree::
|
|
510
|
-
Spree::
|
|
511
|
-
Spree::Calculator::TieredFlatRate
|
|
533
|
+
env.promotions.actions = %w[
|
|
534
|
+
Spree::Promotion::Actions::CreateAdjustment
|
|
535
|
+
Spree::Promotion::Actions::CreateItemAdjustments
|
|
536
|
+
Spree::Promotion::Actions::CreateQuantityAdjustments
|
|
537
|
+
Spree::Promotion::Actions::FreeShipping
|
|
512
538
|
]
|
|
513
539
|
|
|
514
|
-
env.
|
|
515
|
-
Spree::
|
|
516
|
-
Spree::Calculator::FlatRate
|
|
517
|
-
Spree::Calculator::FlexiRate
|
|
518
|
-
Spree::Calculator::PercentOnLineItem
|
|
519
|
-
Spree::Calculator::TieredPercent
|
|
540
|
+
env.promotions.shipping_actions = %w[
|
|
541
|
+
Spree::Promotion::Actions::FreeShipping
|
|
520
542
|
]
|
|
521
543
|
|
|
522
|
-
env.
|
|
523
|
-
Spree::
|
|
524
|
-
Spree::
|
|
544
|
+
env.stock_splitters = %w[
|
|
545
|
+
Spree::Stock::Splitter::ShippingCategory
|
|
546
|
+
Spree::Stock::Splitter::Backordered
|
|
525
547
|
]
|
|
526
548
|
end
|
|
527
549
|
end
|
|
@@ -18,10 +18,16 @@ module Spree
|
|
|
18
18
|
klasses.each do |klass|
|
|
19
19
|
self << klass
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
self
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
delegate :clear, :empty?, to: :@collection
|
|
24
26
|
|
|
27
|
+
def delete(object)
|
|
28
|
+
@collection.delete(object.to_s)
|
|
29
|
+
end
|
|
30
|
+
|
|
25
31
|
def each
|
|
26
32
|
@collection.each do |klass|
|
|
27
33
|
yield klass.constantize
|
|
@@ -14,10 +14,7 @@ module Spree
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def current_pricing_options
|
|
17
|
-
Spree::Config.pricing_options_class.
|
|
18
|
-
currency: current_store.try!(:default_currency).presence || Spree::Config[:currency],
|
|
19
|
-
country_iso: current_store.try!(:cart_tax_country_iso).presence
|
|
20
|
-
)
|
|
17
|
+
Spree::Config.pricing_options_class.from_context(self)
|
|
21
18
|
end
|
|
22
19
|
|
|
23
20
|
def current_currency
|
|
@@ -31,30 +31,16 @@ module Spree
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def permitted_checkout_attributes
|
|
34
|
-
permitted_attributes.checkout_attributes
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def permitted_checkout_delivery_attributes
|
|
42
|
-
permitted_attributes.checkout_delivery_attributes
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def permitted_checkout_payment_attributes
|
|
46
|
-
permitted_attributes.checkout_payment_attributes
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def permitted_checkout_confirm_attributes
|
|
50
|
-
permitted_attributes.checkout_confirm_attributes
|
|
34
|
+
permitted_attributes.checkout_attributes + [
|
|
35
|
+
bill_address_attributes: permitted_address_attributes,
|
|
36
|
+
ship_address_attributes: permitted_address_attributes,
|
|
37
|
+
payments_attributes: permitted_payment_attributes,
|
|
38
|
+
shipments_attributes: permitted_shipment_attributes
|
|
39
|
+
]
|
|
51
40
|
end
|
|
52
41
|
|
|
53
42
|
def permitted_order_attributes
|
|
54
|
-
|
|
55
|
-
permitted_checkout_delivery_attributes +
|
|
56
|
-
permitted_checkout_payment_attributes +
|
|
57
|
-
permitted_checkout_confirm_attributes + [
|
|
43
|
+
permitted_checkout_attributes + [
|
|
58
44
|
line_items_attributes: permitted_line_item_attributes
|
|
59
45
|
]
|
|
60
46
|
end
|
data/lib/spree/core/engine.rb
CHANGED
|
@@ -44,6 +44,17 @@ module Spree
|
|
|
44
44
|
Migrations.new(config, engine_name).check
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
# Setup Event Subscribers
|
|
48
|
+
initializer 'spree.core.initialize_subscribers' do |app|
|
|
49
|
+
app.reloader.to_prepare do
|
|
50
|
+
Spree::Event.subscribers.each(&:subscribe!)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
app.reloader.before_class_unload do
|
|
54
|
+
Spree::Event.subscribers.each(&:unsubscribe!)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
47
58
|
# Load in mailer previews for apps to use in development.
|
|
48
59
|
# We need to make sure we call `Preview.all` before requiring our
|
|
49
60
|
# previews, otherwise any previews the app attempts to add need to be
|
|
@@ -133,9 +133,7 @@ module Spree
|
|
|
133
133
|
# spree_wombat serializes payment state as status so imported orders should fall back to status field.
|
|
134
134
|
payment.state = p[:state] || p[:status] || 'completed'
|
|
135
135
|
payment.payment_method = Spree::PaymentMethod.find_by!(name: p[:payment_method])
|
|
136
|
-
|
|
137
|
-
payment.source = create_source_payment_from_params(source_attributes, payment) if source_attributes
|
|
138
|
-
|
|
136
|
+
payment.source = create_source_payment_from_params(p[:source], payment) if p[:source]
|
|
139
137
|
payment.save!
|
|
140
138
|
end
|
|
141
139
|
end
|
|
@@ -18,6 +18,11 @@ module Spree
|
|
|
18
18
|
@estimator_class.constantize
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def location_filter_class
|
|
22
|
+
@location_filter_class ||= '::Spree::Stock::LocationFilter::Active'
|
|
23
|
+
@location_filter_class.constantize
|
|
24
|
+
end
|
|
25
|
+
|
|
21
26
|
def location_sorter_class
|
|
22
27
|
@location_sorter_class ||= '::Spree::Stock::LocationSorter::Unsorted'
|
|
23
28
|
@location_sorter_class.constantize
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
|
@@ -59,10 +59,12 @@ require 'spree/core/active_merchant_dependencies'
|
|
|
59
59
|
require 'spree/core/class_constantizer'
|
|
60
60
|
require 'spree/core/environment_extension'
|
|
61
61
|
require 'spree/core/environment/calculators'
|
|
62
|
+
require 'spree/core/environment/promotions'
|
|
62
63
|
require 'spree/core/environment'
|
|
63
64
|
require 'spree/promo/environment'
|
|
64
65
|
require 'spree/migrations'
|
|
65
66
|
require 'spree/migration_helpers'
|
|
67
|
+
require 'spree/event'
|
|
66
68
|
require 'spree/core/engine'
|
|
67
69
|
|
|
68
70
|
require 'spree/i18n'
|
data/lib/spree/deprecation.rb
CHANGED
|
@@ -4,4 +4,54 @@ require 'active_support/deprecation'
|
|
|
4
4
|
|
|
5
5
|
module Spree
|
|
6
6
|
Deprecation = ActiveSupport::Deprecation.new('3.0', 'Solidus')
|
|
7
|
+
|
|
8
|
+
# This DeprecatedInstanceVariableProxy transforms instance variable to
|
|
9
|
+
# deprecated instance variable.
|
|
10
|
+
#
|
|
11
|
+
# It differs from ActiveSupport::DeprecatedInstanceVariableProxy since
|
|
12
|
+
# it allows to define a custom message.
|
|
13
|
+
#
|
|
14
|
+
# class Example
|
|
15
|
+
# def initialize(deprecator)
|
|
16
|
+
# @request = Spree::DeprecatedInstanceVariableProxy.new(self, :request, :@request, deprecator, "Please, do not use this thing.")
|
|
17
|
+
# @_request = :a_request
|
|
18
|
+
# end
|
|
19
|
+
#
|
|
20
|
+
# def request
|
|
21
|
+
# @_request
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# def old_request
|
|
25
|
+
# @request
|
|
26
|
+
# end
|
|
27
|
+
# end
|
|
28
|
+
#
|
|
29
|
+
# When someone execute any method on @request variable this will trigger
|
|
30
|
+
# +warn+ method on +deprecator_instance+ and will fetch <tt>@_request</tt>
|
|
31
|
+
# variable via +request+ method and execute the same method on non-proxy
|
|
32
|
+
# instance variable.
|
|
33
|
+
#
|
|
34
|
+
# Default deprecator is <tt>Spree::Deprecation</tt>.
|
|
35
|
+
class DeprecatedInstanceVariableProxy < ActiveSupport::Deprecation::DeprecationProxy
|
|
36
|
+
def initialize(instance, method, var = "@#{method}", deprecator = Spree::Deprecation, message = nil)
|
|
37
|
+
@instance = instance
|
|
38
|
+
@method = method
|
|
39
|
+
@var = var
|
|
40
|
+
@deprecator = deprecator
|
|
41
|
+
@message = message
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def target
|
|
47
|
+
@instance.__send__(@method)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def warn(callstack, called, args)
|
|
51
|
+
message = @message || "#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}."
|
|
52
|
+
message = [message, "Args: #{args.inspect}"].join(" ")
|
|
53
|
+
|
|
54
|
+
@deprecator.warn(message, callstack)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
7
57
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spree
|
|
4
|
+
module Event
|
|
5
|
+
module Adapters
|
|
6
|
+
module ActiveSupportNotifications
|
|
7
|
+
extend self
|
|
8
|
+
|
|
9
|
+
def fire(event_name, opts)
|
|
10
|
+
ActiveSupport::Notifications.instrument event_name, opts do
|
|
11
|
+
yield opts if block_given?
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def subscribe(event_name)
|
|
16
|
+
ActiveSupport::Notifications.subscribe event_name do |*args|
|
|
17
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
|
18
|
+
yield event
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def unsubscribe(subscriber_or_name)
|
|
23
|
+
ActiveSupport::Notifications.unsubscribe(subscriber_or_name)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def listeners_for(names)
|
|
27
|
+
names.each_with_object({}) do |name, memo|
|
|
28
|
+
listeners = ActiveSupport::Notifications.notifier.listeners_for(name)
|
|
29
|
+
memo[name] = listeners if listeners.present?
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spree/core/class_constantizer'
|
|
4
|
+
|
|
5
|
+
module Spree
|
|
6
|
+
module Event
|
|
7
|
+
class Configuration
|
|
8
|
+
def subscribers
|
|
9
|
+
@subscribers ||= ::Spree::Core::ClassConstantizer::Set.new.tap do |set|
|
|
10
|
+
set << 'Spree::MailerSubscriber'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
attr_writer :adapter, :suffix
|
|
15
|
+
|
|
16
|
+
def adapter
|
|
17
|
+
@adapter ||= Spree::Event::Adapters::ActiveSupportNotifications
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def suffix
|
|
21
|
+
@suffix ||= '.spree'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Spree
|
|
4
|
+
module Event
|
|
5
|
+
# This module simplifies adding and removing subscriptions to {Spree::Event} events.
|
|
6
|
+
# Here's a complete example:
|
|
7
|
+
# module EmailSender
|
|
8
|
+
# include Spree::Event::Subscriber
|
|
9
|
+
#
|
|
10
|
+
# event_action :order_finalized
|
|
11
|
+
# event_action :confirm_reimbursement, event_name: :reimbursement_reimbursed
|
|
12
|
+
#
|
|
13
|
+
# def order_finalized(event)
|
|
14
|
+
# Mailer.send_email(event.payload[:order])
|
|
15
|
+
# end
|
|
16
|
+
#
|
|
17
|
+
# def confirm_reimbursement(event)
|
|
18
|
+
# Mailer.send_email(event.payload[:reimbursement])
|
|
19
|
+
# end
|
|
20
|
+
# end
|
|
21
|
+
#
|
|
22
|
+
# EmailSender.subscribe!
|
|
23
|
+
module Subscriber
|
|
24
|
+
def self.included(base)
|
|
25
|
+
base.extend base
|
|
26
|
+
|
|
27
|
+
base.mattr_accessor :event_actions
|
|
28
|
+
base.event_actions = {}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Declares a method name in the including module that can be subscribed/unsubscribed
|
|
32
|
+
# to an event.
|
|
33
|
+
#
|
|
34
|
+
# @param method_name [String, Symbol] the method that will be called when the subscribed event is fired
|
|
35
|
+
# @param event_name [String, Symbol] the name of the event to be subscribed
|
|
36
|
+
#
|
|
37
|
+
# @example Declares 'send_email' as an event action that can subscribe the event 'order_finalized'
|
|
38
|
+
# module EmailSender
|
|
39
|
+
# event_action :send_email, event_name: :order_finalized
|
|
40
|
+
#
|
|
41
|
+
# def send_email(event)
|
|
42
|
+
# Mailer.send_email(event.payload[:order])
|
|
43
|
+
# end
|
|
44
|
+
# end
|
|
45
|
+
#
|
|
46
|
+
# @example Same as above, but the method name is same as the event name:
|
|
47
|
+
# module EmailSender
|
|
48
|
+
# event_action :order_completed
|
|
49
|
+
#
|
|
50
|
+
# def order_completed(event)
|
|
51
|
+
# Mailer.send_email(event.payload[:order])
|
|
52
|
+
# end
|
|
53
|
+
# end
|
|
54
|
+
def event_action(method_name, event_name: nil)
|
|
55
|
+
mattr_accessor "#{method_name}_handler"
|
|
56
|
+
event_actions[method_name] = (event_name || method_name).to_s
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Subscribes all declared event actions to their events. Only actions that are subscribed
|
|
60
|
+
# will be called when their event fires.
|
|
61
|
+
#
|
|
62
|
+
# @example subscribe all event actions for module 'EmailSender'
|
|
63
|
+
# EmailSender.subscribe!
|
|
64
|
+
def subscribe!
|
|
65
|
+
unsubscribe!
|
|
66
|
+
event_actions.each do |event_action, event_name|
|
|
67
|
+
send "#{event_action}_handler=", Spree::Event.subscribe(event_name) { |event|
|
|
68
|
+
send event_action, event
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Unsubscribes all declared event actions from their events. This means that when an event
|
|
74
|
+
# fires then none of its unsubscribed event actions will be called.
|
|
75
|
+
# @example unsubscribe all event actions for module 'EmailSender'
|
|
76
|
+
# EmailSender.unsubscribe!
|
|
77
|
+
def unsubscribe!
|
|
78
|
+
event_actions.keys.each do |event_action|
|
|
79
|
+
Spree::Event.unsubscribe send("#{event_action}_handler")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|