mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
remove rack cache, it has been causing trouble
instead implement an aggressive anonymous cache that is stored in redis this cache is sitting in the front of the middleware stack enabled only in production TODO: expire it more intelligently when stuff is created
This commit is contained in:
41
spec/components/middleware/anonymous_cache_spec.rb
Normal file
41
spec/components/middleware/anonymous_cache_spec.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
require "spec_helper"
|
||||
require_dependency "middleware/anonymous_cache"
|
||||
|
||||
describe Middleware::AnonymousCache::Helper do
|
||||
|
||||
def new_helper(env={})
|
||||
Middleware::AnonymousCache::Helper.new({
|
||||
"HTTP_HOST" => "http://test.com",
|
||||
"REQUEST_URI" => "/path?bla=1",
|
||||
"REQUEST_METHOD" => "GET"
|
||||
}.merge(env))
|
||||
end
|
||||
|
||||
context "cachable?" do
|
||||
it "true by default" do
|
||||
new_helper.cacheable?.should be_true
|
||||
end
|
||||
|
||||
it "is false for non GET" do
|
||||
new_helper("ANON_CACHE_DURATION" => 10, "REQUEST_METHOD" => "POST").cacheable?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context "cached" do
|
||||
let!(:helper) do
|
||||
new_helper("ANON_CACHE_DURATION" => 10)
|
||||
end
|
||||
|
||||
after do
|
||||
helper.clear_cache
|
||||
end
|
||||
|
||||
it "returns cached data for cached requests" do
|
||||
helper.cached.should be_nil
|
||||
helper.cache([200, {"HELLO" => "WORLD"}, ["hello ", "world"]])
|
||||
helper.cached.should == [200, {"HELLO" => "WORLD"}, ["hello world"]]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user