Skip to content

Commit

Permalink
Use consistent method name to clear cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Oct 20, 2023
1 parent 5bd3211 commit e6b6695
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/config_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def modify
custom_config[:scraper_request_rate_limit] = custom_config[:scraper_request_rate_limit].tr(",", ".").to_f if custom_config[:scraper_request_rate_limit]

Config.write_custom_config(custom_config)
Config.force_reload
Config.reset_cache
redirect_back fallback_location: config_index_path
end
end
2 changes: 1 addition & 1 deletion app/logical/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def write_custom_config(new_values)
File.write(custom_config_path, data)
end

def force_reload
def reset_cache
@default_config = nil
@custom_config = nil
end
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/yml_autload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Rails.application.config.after_initialize do
Listen.to(Rails.root.join("config"), only: /reverser.*\.yml/) do
Config.force_reload
Config.reset_cache
end.start

Listen.to(Rails.root.join("app/logical/sites/definitions"), only: /.*\.yml/) do
Expand Down
6 changes: 3 additions & 3 deletions test/logical/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
class ConfigTest < ActiveSupport::TestCase
setup do
Config.stubs(:default_config).returns(app_name: "DefaultName", bool?: true)
Config.force_reload
Config.reset_cache
end

teardown do
Config.force_reload
Config.reset_cache
end

def stub_custom_config(**params, &)
Expand All @@ -19,7 +19,7 @@ def stub_custom_config(**params, &)
f.flush
Config.unstub(:custom_config)
yield
Config.force_reload
Config.reset_cache
end
end

Expand Down

0 comments on commit e6b6695

Please sign in to comment.