aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-18 23:10:34 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-18 23:10:34 +0000
commit0d99423727ce309ce4b2c5439575eab75dcf49eb (patch)
tree565635bb0b28e66291b446cf98aec132d8de9d70 /actionpack/test
parent2f60bb3327453ef214b78ed99c7e7c034774bb81 (diff)
downloadrails-0d99423727ce309ce4b2c5439575eab75dcf49eb.tar.gz
rails-0d99423727ce309ce4b2c5439575eab75dcf49eb.tar.bz2
rails-0d99423727ce309ce4b2c5439575eab75dcf49eb.zip
Fixed that default layouts did not take the format into account #9564 [lifofifo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7514 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb31
-rw-r--r--actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb1
2 files changed, 30 insertions, 2 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 144aff7d7c..d2c70ed477 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -112,6 +112,17 @@ class RespondToController < ActionController::Base
type.html
type.js
end
+ end
+
+ def iphone_with_html_response_type
+ Mime::Type.register("text/iphone", :iphone)
+
+ respond_to do |type|
+ type.html { @type = "Firefox" }
+ type.iphone { @type = "iPhone"; render :content_type => Mime::HTML }
+ end
+
+ Mime.send :remove_const, :IPHONE
end
def rescue_action(e)
@@ -120,7 +131,7 @@ class RespondToController < ActionController::Base
protected
def set_layout
- if action_name == "all_types_with_layout"
+ if ["all_types_with_layout", "iphone_with_html_response_type"].include?(action_name)
"standard"
end
end
@@ -380,5 +391,21 @@ class MimeControllerTest < Test::Unit::TestCase
get :using_defaults, :format => "xml"
assert_equal "using_defaults - xml", @response.body
- end
+ end
+
+ def test_format_with_custom_response_type
+ get :iphone_with_html_response_type
+ assert_equal "<html>Hello future from Firefox!</html>", @response.body
+
+ get :iphone_with_html_response_type, :format => "iphone"
+ assert_equal "text/html", @response.content_type
+ assert_equal "<html>Hello future from iPhone!</html>", @response.body
+ end
+
+ def test_format_with_custom_response_type_and_request_headers
+ @request.env["HTTP_ACCEPT"] = "text/iphone"
+ get :iphone_with_html_response_type
+ assert_equal "<html>Hello future from iPhone!</html>", @response.body
+ assert_equal "text/html", @response.content_type
+ end
end
diff --git a/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb b/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb
new file mode 100644
index 0000000000..1f3f1c6516
--- /dev/null
+++ b/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb
@@ -0,0 +1 @@
+Hello future from <%= @type -%>! \ No newline at end of file