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:
parent
2a6f8c99da
commit
7ca53e1d31
1 changed files with 24 additions and 0 deletions
|
@ -126,6 +126,18 @@ class RespondToController < ActionController::Base
|
||||||
Mime.send :remove_const, :IPHONE
|
Mime.send :remove_const, :IPHONE
|
||||||
end
|
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)
|
def rescue_action(e)
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
@ -134,6 +146,8 @@ class RespondToController < ActionController::Base
|
||||||
def set_layout
|
def set_layout
|
||||||
if ["all_types_with_layout", "iphone_with_html_response_type"].include?(action_name)
|
if ["all_types_with_layout", "iphone_with_html_response_type"].include?(action_name)
|
||||||
"respond_to/layouts/standard"
|
"respond_to/layouts/standard"
|
||||||
|
elsif action_name == "iphone_with_html_response_type_without_layout"
|
||||||
|
"respond_to/layouts/missing"
|
||||||
end
|
end
|
||||||
end
|
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 '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
|
||||||
assert_equal "text/html", @response.content_type
|
assert_equal "text/html", @response.content_type
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue