mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
BUGFIX: web crawlers messing with anon caching
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user