Merge pull request #5547 from consuldemocracy/empty_cache_when_upgrading
Clear Rails cache when upgrading Consul Democracy
This commit is contained in:
7
lib/tasks/cache.rake
Normal file
7
lib/tasks/cache.rake
Normal 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
|
||||||
@@ -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"
|
||||||
|
|||||||
15
spec/lib/tasks/cache_spec.rb
Normal file
15
spec/lib/tasks/cache_spec.rb
Normal 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
|
||||||
Reference in New Issue
Block a user