BUGFIX: web crawlers messing with anon caching

This commit is contained in:
Sam
2014-04-29 10:48:09 +10:00
parent ba683bc611
commit 35952055e2
2 changed files with 33 additions and 6 deletions

View File

@@ -30,15 +30,27 @@ describe Middleware::AnonymousCache::Helper do
new_helper("ANON_CACHE_DURATION" => 10)
end
let!(:crawler) do
new_helper("ANON_CACHE_DURATION" => 10, "HTTP_USER_AGENT" => "AdsBot-Google (+http://www.google.com/adsbot.html)")
end
after do
helper.clear_cache
crawler.clear_cache
end
it "returns cached data for cached requests" do
helper.is_mobile = true
helper.cached.should be_nil
helper.cache([200, {"HELLO" => "WORLD"}, ["hello ", "world"]])
helper.cached.should == [200, {"HELLO" => "WORLD"}, ["hello world"]]
helper.cache([200, {"HELLO" => "WORLD"}, ["hello ", "my world"]])
helper = new_helper("ANON_CACHE_DURATION" => 10)
helper.is_mobile = true
helper.cached.should == [200, {"HELLO" => "WORLD"}, ["hello my world"]]
crawler.cached.should be_nil
crawler.cache([200, {"HELLO" => "WORLD"}, ["hello ", "world"]])
crawler.cached.should == [200, {"HELLO" => "WORLD"}, ["hello world"]]
end
end