From 920e284183095a460d8524056f6d4251200e0858 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 16 Apr 2009 16:43:30 -0700 Subject: Fix forgotten Rails tests This was broken in 66841a0164bc03eddb7a6ac31e3923302dbc5146: ensure responses always have the "Status:" header --- test/rails/test_rails.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/rails/test_rails.rb b/test/rails/test_rails.rb index f6bc67e..c7add20 100644 --- a/test/rails/test_rails.rb +++ b/test/rails/test_rails.rb @@ -98,12 +98,12 @@ logger Logger.new('#{COMMON_TMP.path}') assert_equal "FOO\n", res.body assert_match %r{^text/html\b}, res['Content-Type'] assert_equal "4", res['Content-Length'] - assert_nil res['Status'] + assert_equal "200 OK", res['Status'] # can we set cookies? res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/foo/xcookie")) assert_equal "200", res.code - assert_nil res['Status'] + assert_equal "200 OK", res['Status'] cookies = res.get_fields('Set-Cookie') assert_equal 2, cookies.size assert_equal 1, cookies.grep(/\A_unicorn_rails_test\./).size @@ -112,7 +112,7 @@ logger Logger.new('#{COMMON_TMP.path}') # how about just a session? res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/foo/xnotice")) assert_equal "200", res.code - assert_nil res['Status'] + assert_equal "200 OK", res['Status'] cookies = res.get_fields('Set-Cookie') assert_equal 1, cookies.size assert_equal 1, cookies.grep(/\A_unicorn_rails_test\./).size @@ -128,7 +128,7 @@ logger Logger.new('#{COMMON_TMP.path}') assert_equal Hash, params.class assert_equal 'b', params['a'] assert_equal 'd', params['c'] - assert_nil res['Status'] + assert_equal "200 OK", res['Status'] # try uploading a big file tmp = Tempfile.new('random') @@ -153,52 +153,52 @@ logger Logger.new('#{COMMON_TMP.path}') assert_equal 1, grepped.size assert_match %r{^text/plain}, grepped.first.split(/\s*:\s*/)[1] - assert_equal 0, resp.grep(/^Status:/i).size # Rack hates "Status: " lines + assert_equal 1, resp.grep(/^Status:/i).size # make sure we can get 403 responses, too uri = URI.parse("http://#@addr:#@port/foo/xpost") wait_master_ready("test_stderr.#$$.log") res = Net::HTTP.get_response(uri) assert_equal "403", res.code - assert_nil res['Status'] + assert_equal "403 Forbidden", res['Status'] # non existent controller uri = URI.parse("http://#@addr:#@port/asdf") res = Net::HTTP.get_response(uri) assert_equal "404", res.code - assert_nil res['Status'] + assert_equal "404 Not Found", res['Status'] # static files # ensure file we're about to serve is not there yet res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/pid.txt")) - assert_nil res['Status'] + assert_equal "404 Not Found", res['Status'] assert_equal '404', res.code # can we serve text files based on suffix? File.open("public/pid.txt", "wb") { |fp| fp.syswrite("#$$\n") } res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/pid.txt")) assert_equal '200', res.code + assert_equal "200 OK", res['Status'] assert_match %r{^text/plain}, res['Content-Type'] assert_equal "#$$\n", res.body - assert_nil res['Status'] # can we serve HTML files based on suffix? assert File.exist?("public/500.html") res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/500.html")) assert_equal '200', res.code + assert_equal '200 OK', res['Status'] assert_match %r{^text/html}, res['Content-Type'] five_hundred_body = res.body - assert_nil res['Status'] # lets try pretending 500 is a controller that got cached assert ! File.exist?("public/500") assert_equal five_hundred_body, File.read("public/500.html") res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/500")) assert_equal '200', res.code + assert_equal '200 OK', res['Status'] assert_match %r{^text/html}, res['Content-Type'] assert_equal five_hundred_body, res.body - assert_nil res['Status'] end def test_alt_url_root @@ -213,14 +213,14 @@ logger Logger.new('#{COMMON_TMP.path}') # p res.body # system 'cat', 'log/development.log' assert_equal "200", res.code + assert_equal '200 OK', res['Status'] assert_equal "FOO\n", res.body assert_match %r{^text/html\b}, res['Content-Type'] assert_equal "4", res['Content-Length'] - assert_nil res['Status'] res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/foo")) assert_equal "404", res.code - assert_nil res['Status'] + assert_equal '404 Not Found', res['Status'] end def teardown -- cgit v1.2.3-24-ge0c7