aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/mime_responds_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/mime_responds_test.rb')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb62
1 files changed, 31 insertions, 31 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 1701431858..0d508eb8df 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -177,7 +177,7 @@ class MimeControllerTest < Test::Unit::TestCase
end
def test_html
- @request.env["HTTP_ACCEPT"] = "text/html"
+ @request.accept = "text/html"
get :js_or_html
assert_equal 'HTML', @response.body
@@ -189,7 +189,7 @@ class MimeControllerTest < Test::Unit::TestCase
end
def test_all
- @request.env["HTTP_ACCEPT"] = "*/*"
+ @request.accept = "*/*"
get :js_or_html
assert_equal 'HTML', @response.body # js is not part of all
@@ -201,13 +201,13 @@ class MimeControllerTest < Test::Unit::TestCase
end
def test_xml
- @request.env["HTTP_ACCEPT"] = "application/xml"
+ @request.accept = "application/xml"
get :html_xml_or_rss
assert_equal 'XML', @response.body
end
def test_js_or_html
- @request.env["HTTP_ACCEPT"] = "text/javascript, text/html"
+ @request.accept = "text/javascript, text/html"
get :js_or_html
assert_equal 'JS', @response.body
@@ -232,7 +232,7 @@ class MimeControllerTest < Test::Unit::TestCase
'JSON' => %w(application/json text/x-json)
}.each do |body, content_types|
content_types.each do |content_type|
- @request.env['HTTP_ACCEPT'] = content_type
+ @request.accept = content_type
get :json_or_yaml
assert_equal body, @response.body
end
@@ -240,7 +240,7 @@ class MimeControllerTest < Test::Unit::TestCase
end
def test_js_or_anything
- @request.env["HTTP_ACCEPT"] = "text/javascript, */*"
+ @request.accept = "text/javascript, */*"
get :js_or_html
assert_equal 'JS', @response.body
@@ -252,34 +252,34 @@ class MimeControllerTest < Test::Unit::TestCase
end
def test_using_defaults
- @request.env["HTTP_ACCEPT"] = "*/*"
+ @request.accept = "*/*"
get :using_defaults
assert_equal "text/html", @response.content_type
assert_equal 'Hello world!', @response.body
- @request.env["HTTP_ACCEPT"] = "text/javascript"
+ @request.accept = "text/javascript"
get :using_defaults
assert_equal "text/javascript", @response.content_type
assert_equal '$("body").visualEffect("highlight");', @response.body
- @request.env["HTTP_ACCEPT"] = "application/xml"
+ @request.accept = "application/xml"
get :using_defaults
assert_equal "application/xml", @response.content_type
assert_equal "<p>Hello world!</p>\n", @response.body
end
def test_using_defaults_with_type_list
- @request.env["HTTP_ACCEPT"] = "*/*"
+ @request.accept = "*/*"
get :using_defaults_with_type_list
assert_equal "text/html", @response.content_type
assert_equal 'Hello world!', @response.body
- @request.env["HTTP_ACCEPT"] = "text/javascript"
+ @request.accept = "text/javascript"
get :using_defaults_with_type_list
assert_equal "text/javascript", @response.content_type
assert_equal '$("body").visualEffect("highlight");', @response.body
- @request.env["HTTP_ACCEPT"] = "application/xml"
+ @request.accept = "application/xml"
get :using_defaults_with_type_list
assert_equal "application/xml", @response.content_type
assert_equal "<p>Hello world!</p>\n", @response.body
@@ -298,55 +298,55 @@ class MimeControllerTest < Test::Unit::TestCase
end
def test_synonyms
- @request.env["HTTP_ACCEPT"] = "application/javascript"
+ @request.accept = "application/javascript"
get :js_or_html
assert_equal 'JS', @response.body
- @request.env["HTTP_ACCEPT"] = "application/x-xml"
+ @request.accept = "application/x-xml"
get :html_xml_or_rss
assert_equal "XML", @response.body
end
def test_custom_types
- @request.env["HTTP_ACCEPT"] = "application/crazy-xml"
+ @request.accept = "application/crazy-xml"
get :custom_type_handling
assert_equal "application/crazy-xml", @response.content_type
assert_equal 'Crazy XML', @response.body
- @request.env["HTTP_ACCEPT"] = "text/html"
+ @request.accept = "text/html"
get :custom_type_handling
assert_equal "text/html", @response.content_type
assert_equal 'HTML', @response.body
end
def test_xhtml_alias
- @request.env["HTTP_ACCEPT"] = "application/xhtml+xml,application/xml"
+ @request.accept = "application/xhtml+xml,application/xml"
get :html_or_xml
assert_equal 'HTML', @response.body
end
def test_firefox_simulation
- @request.env["HTTP_ACCEPT"] = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
+ @request.accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
get :html_or_xml
assert_equal 'HTML', @response.body
end
def test_handle_any
- @request.env["HTTP_ACCEPT"] = "*/*"
+ @request.accept = "*/*"
get :handle_any
assert_equal 'HTML', @response.body
- @request.env["HTTP_ACCEPT"] = "text/javascript"
+ @request.accept = "text/javascript"
get :handle_any
assert_equal 'Either JS or XML', @response.body
- @request.env["HTTP_ACCEPT"] = "text/xml"
+ @request.accept = "text/xml"
get :handle_any
assert_equal 'Either JS or XML', @response.body
end
def test_handle_any_any
- @request.env["HTTP_ACCEPT"] = "*/*"
+ @request.accept = "*/*"
get :handle_any_any
assert_equal 'HTML', @response.body
end
@@ -357,31 +357,31 @@ class MimeControllerTest < Test::Unit::TestCase
end
def test_handle_any_any_explicit_html
- @request.env["HTTP_ACCEPT"] = "text/html"
+ @request.accept = "text/html"
get :handle_any_any
assert_equal 'HTML', @response.body
end
def test_handle_any_any_javascript
- @request.env["HTTP_ACCEPT"] = "text/javascript"
+ @request.accept = "text/javascript"
get :handle_any_any
assert_equal 'Whatever you ask for, I got it', @response.body
end
def test_handle_any_any_xml
- @request.env["HTTP_ACCEPT"] = "text/xml"
+ @request.accept = "text/xml"
get :handle_any_any
assert_equal 'Whatever you ask for, I got it', @response.body
end
def test_rjs_type_skips_layout
- @request.env["HTTP_ACCEPT"] = "text/javascript"
+ @request.accept = "text/javascript"
get :all_types_with_layout
assert_equal 'RJS for all_types_with_layout', @response.body
end
def test_html_type_with_layout
- @request.env["HTTP_ACCEPT"] = "text/html"
+ @request.accept = "text/html"
get :all_types_with_layout
assert_equal '<html><div id="html">HTML for all_types_with_layout</div></html>', @response.body
end
@@ -460,7 +460,7 @@ class MimeControllerTest < Test::Unit::TestCase
end
def test_format_with_custom_response_type_and_request_headers
- @request.env["HTTP_ACCEPT"] = "text/iphone"
+ @request.accept = "text/iphone"
get :iphone_with_html_response_type
assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
assert_equal "text/html", @response.content_type
@@ -470,7 +470,7 @@ class MimeControllerTest < Test::Unit::TestCase
get :iphone_with_html_response_type_without_layout
assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body
- @request.env["HTTP_ACCEPT"] = "text/iphone"
+ @request.accept = "text/iphone"
assert_raises(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
end
end
@@ -522,7 +522,7 @@ class MimeControllerLayoutsTest < Test::Unit::TestCase
get :index
assert_equal '<html><div id="html">Hello Firefox</div></html>', @response.body
- @request.env["HTTP_ACCEPT"] = "text/iphone"
+ @request.accept = "text/iphone"
get :index
assert_equal 'Hello iPhone', @response.body
end
@@ -533,7 +533,7 @@ class MimeControllerLayoutsTest < Test::Unit::TestCase
get :index
assert_equal 'Super Firefox', @response.body
- @request.env["HTTP_ACCEPT"] = "text/iphone"
+ @request.accept = "text/iphone"
get :index
assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body
end