A platform for community discussion. Free, open, simple.
FIX: EmberCli cache clearance issue in production (#24343)
David Taylor4982f9547240
diff --git a/lib/ember_cli.rb b/lib/ember_cli.rbindex 7c35936c6ca..a097bffcee6 100644--- a/lib/ember_cli.rb+++ b/lib/ember_cli.rb@@ -69,7 +69,7 @@ class EmberCli < ActiveSupport::CurrentAttributesenddef self.clear_cache!- self.request.cache = nil+ self.request_cache = nil@production_cache = nilendenddiff --git a/spec/lib/ember_cli_spec.rb b/spec/lib/ember_cli_spec.rbindex 2079f9f483e..8fa37e20462 100644--- a/spec/lib/ember_cli_spec.rb+++ b/spec/lib/ember_cli_spec.rb@@ -6,4 +6,45 @@ describe EmberCli doexpect(EmberCli.ember_version).to match(/\A\d+\.\d+/)endend++ describe "cache" do+ after { EmberCli.clear_cache! }++ def simulate_request_cache_clearance+ # this method is defined by ActiveSupport::CurrentAttributes+ # and is called before/after every web request+ EmberCli.reset+ end++ context "in development" do+ before { Rails.env.stubs(:development?).returns(true) }++ it "cache works, and is cleared before/after each web request" do+ EmberCli.cache[:foo] = "bar"+ expect(EmberCli.cache[:foo]).to eq("bar")++ simulate_request_cache_clearance++ expect(EmberCli.cache[:foo]).to eq(nil)+ end+ end++ context "in production" do+ before { Rails.env.stubs(:development?).returns(false) }++ it "cache works, and can be cleared" do+ EmberCli.cache[:foo] = "bar"+ expect(EmberCli.cache[:foo]).to eq("bar")++ simulate_request_cache_clearance++ # In production, persists across requests+ expect(EmberCli.cache[:foo]).to eq("bar")++ # But still can be manually cleared+ EmberCli.clear_cache!+ expect(EmberCli.cache[:foo]).to eq(nil)+ end+ end+ endend