Skip to content

Commit

Permalink
Set up all spree initializers before config/init
Browse files Browse the repository at this point in the history
We want to ensure that any of these initializers are ran before
applications' config/initializers/* attempt to use what should be set up
in these initializers
  • Loading branch information
Clarke Brunsdon committed May 24, 2016
1 parent 2ef9f54 commit 5b3e064
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions core/lib/spree/core/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class Engine < ::Rails::Engine
Spree::Config = app.config.spree.preferences # legacy access
end

initializer "spree.default_permissions" do |_app|
initializer "spree.default_permissions", before: :load_config_initializers do |_app|
Spree::RoleConfiguration.configure do |config|
config.assign_permissions :default, [Spree::PermissionSets::DefaultCustomer]
config.assign_permissions :admin, [Spree::PermissionSets::SuperUser]
end
end

initializer "spree.register.calculators" do |app|
initializer "spree.register.calculators", before: :load_config_initializers do |app|
app.config.spree.calculators.shipping_methods = [
Spree::Calculator::Shipping::FlatPercentItemTotal,
Spree::Calculator::Shipping::FlatRate,
Expand All @@ -36,14 +36,14 @@ class Engine < ::Rails::Engine
Spree::Calculator::DefaultTax]
end

initializer "spree.register.stock_splitters" do |app|
initializer "spree.register.stock_splitters", before: :load_config_initializers do |app|
app.config.spree.stock_splitters = [
Spree::Stock::Splitter::ShippingCategory,
Spree::Stock::Splitter::Backordered
]
end

initializer "spree.register.payment_methods" do |app|
initializer "spree.register.payment_methods", before: :load_config_initializers do |app|
app.config.spree.payment_methods = [
Spree::Gateway::Bogus,
Spree::Gateway::BogusSimple,
Expand All @@ -53,13 +53,13 @@ class Engine < ::Rails::Engine

# We need to define promotions rules here so extensions and existing apps
# can add their custom classes on their initializer files
initializer 'spree.promo.environment' do |app|
initializer 'spree.promo.environment', before: :load_config_initializers do |app|
app.config.spree.add_class('promotions')
app.config.spree.promotions = Spree::Promo::Environment.new
app.config.spree.promotions.rules = []
end

initializer 'spree.promo.register.promotion.calculators' do |app|
initializer 'spree.promo.register.promotion.calculators', before: :load_config_initializers do |app|
app.config.spree.calculators.add_class('promotion_actions_create_adjustments')
app.config.spree.calculators.promotion_actions_create_adjustments = [
Spree::Calculator::FlatPercentItemTotal,
Expand Down Expand Up @@ -103,7 +103,7 @@ class Engine < ::Rails::Engine
]
end

initializer 'spree.promo.register.promotions.actions' do |app|
initializer 'spree.promo.register.promotions.actions', before: :load_config_initializers do |app|
app.config.spree.promotions.actions = [
Promotion::Actions::CreateAdjustment,
Promotion::Actions::CreateItemAdjustments,
Expand All @@ -112,15 +112,15 @@ class Engine < ::Rails::Engine
end

# filter sensitive information during logging
initializer "spree.params.filter" do |app|
initializer "spree.params.filter", before: :load_config_initializers do |app|
app.config.filter_parameters += [
:password,
:password_confirmation,
:number,
:verification_value]
end

initializer "spree.core.checking_migrations" do |_app|
initializer "spree.core.checking_migrations", before: :load_config_initializers do |_app|
Migrations.new(config, engine_name).check
end
end
Expand Down

0 comments on commit 5b3e064

Please sign in to comment.