mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:41:25 +08:00
PERF: run post timings in background
This means that if a very large amount of registered users hit a single topic we will handle it gracefully, even if db gets slow.
This commit is contained in:
@ -141,36 +141,43 @@ describe Hijack do
|
||||
end
|
||||
|
||||
it "renders a redirect correctly" do
|
||||
Process.stubs(:clock_gettime).returns(1.0)
|
||||
tester.hijack_test do
|
||||
Process.stubs(:clock_gettime).returns(2.0)
|
||||
redirect_to 'http://awesome.com'
|
||||
end
|
||||
|
||||
result = "HTTP/1.1 302 Found\r\nLocation: http://awesome.com\r\nContent-Type: text/html\r\nContent-Length: 84\r\nConnection: close\r\n\r\n<html><body>You are being <a href=\"http://awesome.com\">redirected</a>.</body></html>"
|
||||
result = "HTTP/1.1 302 Found\r\nLocation: http://awesome.com\r\nContent-Type: text/html\r\nContent-Length: 84\r\nConnection: close\r\nX-Runtime: 1.000000\r\n\r\n<html><body>You are being <a href=\"http://awesome.com\">redirected</a>.</body></html>"
|
||||
expect(tester.io.string).to eq(result)
|
||||
end
|
||||
|
||||
it "renders stuff correctly if is empty" do
|
||||
Process.stubs(:clock_gettime).returns(1.0)
|
||||
tester.hijack_test do
|
||||
Process.stubs(:clock_gettime).returns(2.0)
|
||||
render body: nil
|
||||
end
|
||||
|
||||
result = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"
|
||||
result = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 0\r\nConnection: close\r\nX-Runtime: 1.000000\r\n\r\n"
|
||||
expect(tester.io.string).to eq(result)
|
||||
end
|
||||
|
||||
it "renders stuff correctly if it works" do
|
||||
Process.stubs(:clock_gettime).returns(1.0)
|
||||
tester.hijack_test do
|
||||
Process.stubs(:clock_gettime).returns(2.0)
|
||||
render plain: "hello world"
|
||||
end
|
||||
|
||||
result = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 11\r\nConnection: close\r\n\r\nhello world"
|
||||
result = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 11\r\nConnection: close\r\nX-Runtime: 1.000000\r\n\r\nhello world"
|
||||
expect(tester.io.string).to eq(result)
|
||||
end
|
||||
|
||||
it "returns 500 by default" do
|
||||
Process.stubs(:clock_gettime).returns(1.0)
|
||||
tester.hijack_test
|
||||
|
||||
expected = "HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/html\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"
|
||||
expected = "HTTP/1.1 500 Internal Server Error\r\nContent-Type: text/html\r\nContent-Length: 0\r\nConnection: close\r\nX-Runtime: 0.000000\r\n\r\n"
|
||||
expect(tester.io.string).to eq(expected)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user