aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-25 16:37:43 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-25 16:37:43 +0000
commit7ca53e1d31551ea146023a47b7ab713616556685 (patch)
treeddffe736ac2847fc9449d57f7fea31f0886c8287 /actionpack
parent2a6f8c99da8082a9e2e1d43654d05c3e2c2b6536 (diff)
downloadrails-7ca53e1d31551ea146023a47b7ab713616556685.tar.gz
rails-7ca53e1d31551ea146023a47b7ab713616556685.tar.bz2
rails-7ca53e1d31551ea146023a47b7ab713616556685.zip
Added another failing test
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7632 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index ab5132bc45..0dc063a451 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -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