diff --git a/app/models/account.rb b/app/models/account.rb index eef2a9571..9dcfc3e9b 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -111,6 +111,8 @@ def switch_host!(cname) Hyrax::Engine.routes.default_url_options[:host] = cname end + DEFAULT_FILE_CACHE_STORE = ENV.fetch('HYKU_CACHE_ROOT', '/app/samvera/file_cache') + def setup_tenant_cache(is_enabled) Rails.application.config.action_controller.perform_caching = is_enabled ActionController::Base.perform_caching = is_enabled @@ -118,7 +120,7 @@ def setup_tenant_cache(is_enabled) if is_enabled Rails.application.config.cache_store = :redis_cache_store, { url: Redis.current.id } else - Rails.application.config.cache_store = :file_store, ENV.fetch('HYKU_CACHE_ROOT', '/app/samvera/file_cache') + Rails.application.config.cache_store = :file_store, DEFAULT_FILE_CACHE_STORE end # rubocop:enable Style/ConditionalAssignment Rails.cache = ActiveSupport::Cache.lookup_store(Rails.application.config.cache_store) diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index c5499ef65..18375619a 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -130,7 +130,7 @@ it "reverts to using file store when cache is off" do account.settings[:cache_api] = false account.switch! - expect(Rails.application.config.cache_store).to eq([:file_store, kind_of(String)]) + expect(Rails.application.config.cache_store).to eq([:file_store, described_class::DEFAULT_FILE_CACHE_STORE]) end end @@ -140,7 +140,7 @@ it "uses the file store" do expect(Rails.application.config.action_controller.perform_caching).to be_falsey expect(ActionController::Base.perform_caching).to be_falsey - expect(Rails.application.config.cache_store).to eq([:file_store, kind_of(String)]) + expect(Rails.application.config.cache_store).to eq([:file_store, described_class::DEFAULT_FILE_CACHE_STORE]) end end