diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-09-30 15:02:59 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-09-30 16:07:46 -0700 |
commit | e87d9decb82fbbde50926911167fecebd4bcc25e (patch) | |
tree | 34e4eda8f2152fc931621929596352cfae7d3a68 /test/rails/test_rails.rb | |
parent | e417bd2d262f703212d4d671498420e554105639 (diff) | |
download | unicorn-e87d9decb82fbbde50926911167fecebd4bcc25e.tar.gz |
Since Unicorn config files are written in Ruby, setting RAILS_RELATIVE_URL_ROOT should be possible (and even encouraged) in the config file if it is done at all.
Diffstat (limited to 'test/rails/test_rails.rb')
-rw-r--r-- | test/rails/test_rails.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/rails/test_rails.rb b/test/rails/test_rails.rb index 8ff97f6..9502dcb 100644 --- a/test/rails/test_rails.rb +++ b/test/rails/test_rails.rb @@ -231,6 +231,31 @@ logger Logger.new('#{COMMON_TMP.path}') assert_equal '404 Not Found', res['Status'] end + def test_alt_url_root_config_env + # cbf to actually work on this since I never use this feature (ewong) + return unless ROR_V[0] >= 2 && ROR_V[1] >= 3 + tmp = Tempfile.new(nil) + tmp.syswrite("ENV['RAILS_RELATIVE_URL_ROOT'] = '/poo'\n") + redirect_test_io do + @pid = fork { exec 'unicorn_rails', "-l#@addr:#@port", "-c", tmp.path } + end + wait_master_ready("test_stderr.#$$.log") + res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/poo/foo")) + 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'] + + res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/foo")) + assert_equal "404", res.code + assert_equal '404 Not Found', res['Status'] + + res = Net::HTTP.get_response(URI.parse("http://#@addr:#@port/poo/x.txt")) + assert_equal "200", res.code + assert_equal "HELLO\n", res.body + end + def teardown return if @start_pid != $$ |