diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake new file mode 100644 index 000000000..30832696a --- /dev/null +++ b/lib/tasks/cache.rake @@ -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 diff --git a/lib/tasks/consul.rake b/lib/tasks/consul.rake index fcc23ff26..73296660a 100644 --- a/lib/tasks/consul.rake +++ b/lib/tasks/consul.rake @@ -2,6 +2,7 @@ namespace :consul do desc "Runs tasks needed to upgrade to the latest version" task execute_release_tasks: ["settings:rename_setting_keys", "settings:add_new_settings", + "cache:clear", "execute_release_2.2.0_tasks"] desc "Runs tasks needed to upgrade from 2.1.1 to 2.2.0" diff --git a/spec/lib/tasks/cache_spec.rb b/spec/lib/tasks/cache_spec.rb new file mode 100644 index 000000000..3aef942d2 --- /dev/null +++ b/spec/lib/tasks/cache_spec.rb @@ -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