mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:11:08 +08:00
Add rubocop to our build. (#5004)
This commit is contained in:
@ -3,7 +3,7 @@ require_dependency "middleware/anonymous_cache"
|
||||
|
||||
describe Middleware::AnonymousCache::Helper do
|
||||
|
||||
def env(opts={})
|
||||
def env(opts = {})
|
||||
{
|
||||
"HTTP_HOST" => "http://test.com",
|
||||
"REQUEST_URI" => "/path?bla=1",
|
||||
@ -12,11 +12,10 @@ describe Middleware::AnonymousCache::Helper do
|
||||
}.merge(opts)
|
||||
end
|
||||
|
||||
def new_helper(opts={})
|
||||
def new_helper(opts = {})
|
||||
Middleware::AnonymousCache::Helper.new(env(opts))
|
||||
end
|
||||
|
||||
|
||||
context "cachable?" do
|
||||
it "true by default" do
|
||||
expect(new_helper.cacheable?).to eq(true)
|
||||
@ -27,7 +26,7 @@ describe Middleware::AnonymousCache::Helper do
|
||||
end
|
||||
|
||||
it "is false if it has an auth cookie" do
|
||||
expect(new_helper("HTTP_COOKIE" => "jack=1; _t=#{"1"*32}; jill=2").cacheable?).to eq(false)
|
||||
expect(new_helper("HTTP_COOKIE" => "jack=1; _t=#{"1" * 32}; jill=2").cacheable?).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
@ -61,10 +60,10 @@ describe Middleware::AnonymousCache::Helper do
|
||||
end
|
||||
|
||||
it "handles brotli switching" do
|
||||
helper.cache([200, {"HELLO" => "WORLD"}, ["hello ", "my world"]])
|
||||
helper.cache([200, { "HELLO" => "WORLD" }, ["hello ", "my world"]])
|
||||
|
||||
helper = new_helper("ANON_CACHE_DURATION" => 10)
|
||||
expect(helper.cached).to eq([200, {"X-Discourse-Cached" => "true", "HELLO" => "WORLD"}, ["hello my world"]])
|
||||
expect(helper.cached).to eq([200, { "X-Discourse-Cached" => "true", "HELLO" => "WORLD" }, ["hello my world"]])
|
||||
|
||||
helper = new_helper("ANON_CACHE_DURATION" => 10, "HTTP_ACCEPT_ENCODING" => "gz, br")
|
||||
expect(helper.cached).to eq(nil)
|
||||
@ -73,17 +72,16 @@ describe Middleware::AnonymousCache::Helper do
|
||||
it "returns cached data for cached requests" do
|
||||
helper.is_mobile = true
|
||||
expect(helper.cached).to eq(nil)
|
||||
helper.cache([200, {"HELLO" => "WORLD"}, ["hello ", "my world"]])
|
||||
helper.cache([200, { "HELLO" => "WORLD" }, ["hello ", "my world"]])
|
||||
|
||||
helper = new_helper("ANON_CACHE_DURATION" => 10)
|
||||
helper.is_mobile = true
|
||||
expect(helper.cached).to eq([200, {"X-Discourse-Cached" => "true", "HELLO" => "WORLD"}, ["hello my world"]])
|
||||
expect(helper.cached).to eq([200, { "X-Discourse-Cached" => "true", "HELLO" => "WORLD" }, ["hello my world"]])
|
||||
|
||||
expect(crawler.cached).to eq(nil)
|
||||
crawler.cache([200, {"HELLO" => "WORLD"}, ["hello ", "world"]])
|
||||
expect(crawler.cached).to eq([200, {"X-Discourse-Cached" => "true", "HELLO" => "WORLD"}, ["hello world"]])
|
||||
crawler.cache([200, { "HELLO" => "WORLD" }, ["hello ", "world"]])
|
||||
expect(crawler.cached).to eq([200, { "X-Discourse-Cached" => "true", "HELLO" => "WORLD" }, ["hello world"]])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user