diff --git a/app/views/spree/admin/shared/_version.html.erb b/app/views/spree/admin/shared/_version.html.erb index fd95a498f7..7636acf388 100644 --- a/app/views/spree/admin/shared/_version.html.erb +++ b/app/views/spree/admin/shared/_version.html.erb @@ -1,4 +1,4 @@ -<% if can?(:admin, current_store) && Spree::Backend::Config[:admin_show_version] %> +<% if can?(:admin, current_store) && Spree::Backend::RuntimeConfig[:admin_show_version] %>
diff --git a/lib/spree/backend/configuration.rb b/lib/spree/backend/configuration.rb index cbec1e2be9..cf859c3075 100644 --- a/lib/spree/backend/configuration.rb +++ b/lib/spree/backend/configuration.rb @@ -1,14 +1,12 @@ module Spree module Backend class Configuration < Preferences::Configuration - preference :admin_path, :string, default: '/admin' preference :admin_products_per_page, :integer, default: Kaminari.config.default_per_page preference :admin_orders_per_page, :integer, default: Kaminari.config.default_per_page preference :admin_properties_per_page, :integer, default: Kaminari.config.default_per_page preference :admin_promotions_per_page, :integer, default: Kaminari.config.default_per_page preference :admin_customer_returns_per_page, :integer, default: Kaminari.config.default_per_page preference :admin_users_per_page, :integer, default: Kaminari.config.default_per_page - preference :admin_show_version, :boolean, default: true preference :locale, :string preference :variants_per_page, :integer, default: Kaminari.config.default_per_page preference :menus_per_page, :integer, default: Kaminari.config.default_per_page diff --git a/lib/spree/backend/engine.rb b/lib/spree/backend/engine.rb index 1a33437459..49887afbff 100644 --- a/lib/spree/backend/engine.rb +++ b/lib/spree/backend/engine.rb @@ -1,4 +1,5 @@ require_relative 'configuration' +require_relative 'runtime_configuration' module Spree module Backend @@ -9,6 +10,7 @@ class Engine < ::Rails::Engine initializer 'spree.backend.environment', before: :load_config_initializers do |app| Spree::Backend::Config = Spree::Backend::Configuration.new + Spree::Backend::RuntimeConfig = Spree::Backend::RuntimeConfiguration.new app.config.spree_backend = Environment.new end diff --git a/lib/spree/backend/runtime_configuration.rb b/lib/spree/backend/runtime_configuration.rb new file mode 100644 index 0000000000..db8c12ee94 --- /dev/null +++ b/lib/spree/backend/runtime_configuration.rb @@ -0,0 +1,8 @@ +module Spree + module Backend + class RuntimeConfiguration < ::Spree::Preferences::RuntimeConfiguration + preference :admin_path, :string, default: '/admin' + preference :admin_show_version, :boolean, default: true + end + end +end diff --git a/lib/spree_backend.rb b/lib/spree_backend.rb index 258273bfb1..1fc3ddf136 100644 --- a/lib/spree_backend.rb +++ b/lib/spree_backend.rb @@ -2,7 +2,7 @@ module Spree def self.admin_path - Spree::Backend::Config[:admin_path] + Spree::Backend::RuntimeConfig[:admin_path] end # Used to configure admin_path for Spree @@ -13,6 +13,6 @@ def self.admin_path # Spree.admin_path = '/custom-path' def self.admin_path=(path) - Spree::Backend::Config[:admin_path] = path + Spree::Backend::RuntimeConfig[:admin_path] = path end end diff --git a/spec/features/admin/homepage_spec.rb b/spec/features/admin/homepage_spec.rb index 631e6cc8d7..74e5141140 100644 --- a/spec/features/admin/homepage_spec.rb +++ b/spec/features/admin/homepage_spec.rb @@ -39,7 +39,7 @@ end context 'if turned off' do - before { Spree::Backend::Config[:admin_show_version] = false } + before { Spree::Backend::RuntimeConfig[:admin_show_version] = false } it 'is not displayed' do visit spree.admin_path diff --git a/spec/lib/spree/core_spec.rb b/spec/lib/spree/core_spec.rb index c629eda897..1747bbe630 100644 --- a/spec/lib/spree/core_spec.rb +++ b/spec/lib/spree/core_spec.rb @@ -2,7 +2,7 @@ describe Spree do describe '.admin_path' do - it { expect(described_class.admin_path).to eq(Spree::Backend::Config[:admin_path]) } + it { expect(described_class.admin_path).to eq(Spree::Backend::RuntimeConfig[:admin_path]) } end describe '.admin_path=' do @@ -18,6 +18,6 @@ end it { expect(described_class.admin_path).to eq(new_admin_path) } - it { expect(Spree::Backend::Config[:admin_path]).to eq(new_admin_path) } + it { expect(Spree::Backend::RuntimeConfig[:admin_path]).to eq(new_admin_path) } end end