-
Notifications
You must be signed in to change notification settings - Fork 22k
Closed
Labels
Description
I am not sure how to create a simple Minimal Working Example.
This happens when testing my caching behavior, and something along these lines fails:
context "without cache" do
it "should return the appropriate result, computing it every time", :caching => false do
p ActionController::Base.perform_caching
Object.should_receive(:where).exactly(4).and_call_original
result1 = SomeService.action(args1, args2)
result2 = SomeService.action(args1, args2)
end
end
...even though false is printed out for the ActionController::Base.perform_caching.
[I set this to false by the :caching => false option of the bloc (I use a hook)]
If I annihilate caching by switching from the default :memory_store to the :null_store for the testing environment, the test passes as expected.
[I just add config.cache_store = :null_store in test.rb]
My action method uses the core caching from Rails:
def action(args1, args2):
...
objects = Rails.cache.fetch(cache_key, expires_in: 5.days) do
object.where(id: args1).where(charac: args2).includes(...).to_a
end
...
end