diff --git a/Gemfile b/Gemfile index 97422021a..5483f0c28 100644 --- a/Gemfile +++ b/Gemfile @@ -125,3 +125,5 @@ group :test do # api gem 'rswag-specs' end + +gem "activerecord-nulldb-adapter", "~> 0.9.0" diff --git a/Gemfile.lock b/Gemfile.lock index c66901cfd..9aa50e788 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -128,6 +128,8 @@ GEM activerecord (7.0.4) activemodel (= 7.0.4) activesupport (= 7.0.4) + activerecord-nulldb-adapter (0.9.0) + activerecord (>= 5.2.0, < 7.1) activestorage (7.0.4) actionpack (= 7.0.4) activejob (= 7.0.4) @@ -605,6 +607,7 @@ PLATFORMS DEPENDENCIES active_model_serializers (~> 0.10.0) + activerecord-nulldb-adapter (~> 0.9.0) acts_as_tree acts_as_versioned! apparition diff --git a/app/lib/foodsoft_config.rb b/app/lib/foodsoft_config.rb index c7dda5906..c1fc575c9 100644 --- a/app/lib/foodsoft_config.rb +++ b/app/lib/foodsoft_config.rb @@ -116,7 +116,7 @@ def select_multifoodcoop(foodcoop) # @param key [String, Symbol] # @return [Object] Value of the key. def [](key) - if RailsSettings::CachedSettings.table_exists? && allowed_key?(key) + if ActiveRecord::Base.connected? && RailsSettings::CachedSettings.table_exists? && allowed_key?(key) value = RailsSettings::CachedSettings["foodcoop.#{scope}.#{key}"] value = config[key] if value.nil? value diff --git a/config/application.rb b/config/application.rb index 696d66477..3ed7d4ee9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -58,10 +58,6 @@ class Application < Rails::Application # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' - # It would be nice not to enable database connection when precompiling assets, - # but i18n-js requires initialization, that's why it's on. - config.assets.initialize_on_precompile = true - # Load legacy scripts from vendor config.assets.precompile += ['vendor/assets/javascripts/*.js'] diff --git a/config/database.yml.NULLDB_SAMPLE b/config/database.yml.NULLDB_SAMPLE new file mode 100644 index 000000000..ad8ca182a --- /dev/null +++ b/config/database.yml.NULLDB_SAMPLE @@ -0,0 +1,2 @@ +test: + adapter: nulldb \ No newline at end of file