DEV: Use proper wording for contexts in specs

This commit is contained in:
Loïc Guitaut
2022-07-27 18:14:14 +02:00
committed by Loïc Guitaut
parent 02987e05d5
commit 3eaac56797
337 changed files with 2172 additions and 2723 deletions

View File

@ -12,7 +12,7 @@ RSpec.describe Middleware::AnonymousCache do
Middleware::AnonymousCache::Helper.new(env(opts))
end
context "cacheable?" do
describe "#cacheable?" do
it "true by default" do
expect(new_helper.cacheable?).to eq(true)
end
@ -38,7 +38,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
context "per theme cache" do
describe "per theme cache" do
it "handles theme keys" do
theme = Fabricate(:theme, user_selectable: true)
@ -93,7 +93,7 @@ RSpec.describe Middleware::AnonymousCache do
expect(key1).not_to eq(key2)
end
context "cached" do
context "when cached" do
let!(:helper) do
new_helper("ANON_CACHE_DURATION" => 10)
end
@ -151,7 +151,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
context 'background request rate limit' do
describe 'background request rate limit' do
it 'will rate limit background requests' do
app = Middleware::AnonymousCache.new(
@ -194,7 +194,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
context 'force_anonymous!' do
describe '#force_anonymous!' do
before do
RateLimiter.enable
end
@ -260,7 +260,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
context 'invalid request payload' do
describe 'invalid request payload' do
it 'returns 413 for GET request with payload' do
status, headers, _ = middleware.call(env.tap do |environment|
environment[Rack::RACK_INPUT].write("test")
@ -271,7 +271,7 @@ RSpec.describe Middleware::AnonymousCache do
end
end
context "crawler blocking" do
describe "crawler blocking" do
let :non_crawler do
{
"HTTP_USER_AGENT" =>

View File

@ -23,7 +23,7 @@ RSpec.describe Middleware::RequestTracker do
CachedCounting.disable
end
context "full request" do
describe "full request" do
it "can handle rogue user agents" do
agent = (+"Evil Googlebot String \xc3\x28").force_encoding("Windows-1252")
@ -36,7 +36,7 @@ RSpec.describe Middleware::RequestTracker do
end
end
context "log_request" do
describe "log_request" do
before do
freeze_time
ApplicationRequest.clear_cache!
@ -126,7 +126,7 @@ RSpec.describe Middleware::RequestTracker do
expect(ApplicationRequest.page_view_anon.first.count).to eq(1)
end
context "ignore anonymous page views" do
context "when ignoring anonymous page views" do
let(:anon_data) do
Middleware::RequestTracker.get_data(env(
"HTTP_USER_AGENT" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
@ -180,7 +180,7 @@ RSpec.describe Middleware::RequestTracker do
end
end
context "rate limiting" do
describe "rate limiting" do
before do
RateLimiter.enable
RateLimiter.clear_all_global!
@ -549,7 +549,7 @@ RSpec.describe Middleware::RequestTracker do
end
end
context "callbacks" do
describe "callbacks" do
def app(result, sql_calls: 0, redis_calls: 0)
lambda do |env|
sql_calls.times do