1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added another failing test

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7632 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2007-09-25 16:37:43 +00:00
parent 2a6f8c99da
commit 7ca53e1d31

View file

@ -126,6 +126,18 @@ class RespondToController < ActionController::Base
Mime.send :remove_const, :IPHONE
end
def iphone_with_html_response_type_without_layout
Mime::Type.register_alias("text/html", :iphone)
request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone"
respond_to do |type|
type.html { @type = "Firefox"; render :action => "iphone_with_html_response_type" }
type.iphone { @type = "iPhone" ; render :action => "iphone_with_html_response_type" }
end
Mime.send :remove_const, :IPHONE
end
def rescue_action(e)
raise
end
@ -134,6 +146,8 @@ class RespondToController < ActionController::Base
def set_layout
if ["all_types_with_layout", "iphone_with_html_response_type"].include?(action_name)
"respond_to/layouts/standard"
elsif action_name == "iphone_with_html_response_type_without_layout"
"respond_to/layouts/missing"
end
end
end
@ -409,4 +423,14 @@ class MimeControllerTest < Test::Unit::TestCase
assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
assert_equal "text/html", @response.content_type
end
def test_format_with_custom_response_type_and_request_headers_with_only_one_layout_present
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"
get :iphone_with_html_response_type_without_layout
assert_equal 'Hello iPhone future from iPhone!', @response.body
assert_equal "text/html", @response.content_type
end
end