diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2013-03-30 15:47:38 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2013-03-30 15:47:38 +0530 |
commit | e63086c135bf17a43e0807ecdef3e54b22048152 (patch) | |
tree | 89f51923c9ea02d49f4ea97e8ec3dc0f5e3c5119 /actionpack/test/controller/test_case_test.rb | |
parent | 06e22c01e86e47ebe0835e4c6ec351175cf91b96 (diff) | |
parent | 6d8c070821bc846eb263b8c045ae652ebd751569 (diff) | |
download | rails-e63086c135bf17a43e0807ecdef3e54b22048152.tar.gz rails-e63086c135bf17a43e0807ecdef3e54b22048152.tar.bz2 rails-e63086c135bf17a43e0807ecdef3e54b22048152.zip |
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'actionpack/test/controller/test_case_test.rb')
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index df31338f09..38b9794b4d 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -57,6 +57,10 @@ class TestCaseTest < ActionController::TestCase render :text => request.protocol end + def test_headers + render text: request.headers.env.to_json + end + def test_html_output render :text => <<HTML <html> @@ -626,6 +630,24 @@ XML assert_equal 2004, page[:year] end + test "set additional HTTP headers" do + @request.headers['Referer'] = "http://nohost.com/home" + @request.headers['Content-Type'] = "application/rss+xml" + get :test_headers + parsed_env = JSON.parse(@response.body) + assert_equal "http://nohost.com/home", parsed_env["HTTP_REFERER"] + assert_equal "application/rss+xml", parsed_env["CONTENT_TYPE"] + end + + test "set additional env variables" do + @request.headers['HTTP_REFERER'] = "http://example.com/about" + @request.headers['CONTENT_TYPE'] = "application/json" + get :test_headers + parsed_env = JSON.parse(@response.body) + assert_equal "http://example.com/about", parsed_env["HTTP_REFERER"] + assert_equal "application/json", parsed_env["CONTENT_TYPE"] + end + def test_id_converted_to_string get :test_params, :id => 20, :foo => Object.new assert_kind_of String, @request.path_parameters['id'] |