Merge pull request #5547 from consuldemocracy/empty_cache_when_upgrading

Clear Rails cache when upgrading Consul Democracy
This commit is contained in:
Javi Martín
2024-06-17 15:11:00 +02:00
committed by GitHub
3 changed files with 23 additions and 0 deletions

7
lib/tasks/cache.rake Normal file
View File

@@ -0,0 +1,7 @@
namespace :cache do
desc "Clears the Rails cache"
task clear: :environment do
ApplicationLogger.new.info "Clearing Rails cache"
Rails.cache.clear
end
end

View File

@@ -2,6 +2,7 @@ namespace :consul do
desc "Runs tasks needed to upgrade to the latest version" desc "Runs tasks needed to upgrade to the latest version"
task execute_release_tasks: ["settings:rename_setting_keys", task execute_release_tasks: ["settings:rename_setting_keys",
"settings:add_new_settings", "settings:add_new_settings",
"cache:clear",
"execute_release_2.2.0_tasks"] "execute_release_2.2.0_tasks"]
desc "Runs tasks needed to upgrade from 2.1.1 to 2.2.0" desc "Runs tasks needed to upgrade from 2.1.1 to 2.2.0"

View File

@@ -0,0 +1,15 @@
require "rails_helper"
describe "rake cache:clear" do
before { Rake::Task["cache:clear"].reenable }
it "clears the cache", :with_cache do
Rails.cache.write("tests/cache_exists", true)
expect(Rails.cache.fetch("tests/cache_exists") { false }).to be true
Rake.application.invoke_task("cache:clear")
expect(Rails.cache.fetch("tests/cache_exists") { false }).to be false
end
end