diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 21:17:14 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-18 21:17:14 +0000 |
commit | cc6e8ae57a4a886d68cfa95829fcb7a65a273cab (patch) | |
tree | 8c08cf15e86164cc301472fbb86b214b10cba827 /actionpack/test | |
parent | 3257a4b9b0081d0f86d630aeb107d8334730bb79 (diff) | |
download | rails-cc6e8ae57a4a886d68cfa95829fcb7a65a273cab.tar.gz rails-cc6e8ae57a4a886d68cfa95829fcb7a65a273cab.tar.bz2 rails-cc6e8ae57a4a886d68cfa95829fcb7a65a273cab.zip |
Removed XML argument style for respond_to, so type.xml(object.to_xml) no longer works -- it wasnt worth the exception
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3944 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
5 files changed, 31 insertions, 17 deletions
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index cffd4d388e..c7db19ccc9 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -70,5 +70,4 @@ class LayoutAutoDiscoveryTest < Test::Unit::TestCase assert_equal 'layouts/controller_name_space/nested', @controller.active_layout assert_equal 'controller_name_space/nested.rhtml hello.rhtml', @response.body end - end
\ No newline at end of file diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 06addad2ea..6fe14bf65b 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -1,6 +1,8 @@ require File.dirname(__FILE__) + '/../abstract_unit' class RespondToController < ActionController::Base + layout :set_layout + def html_xml_or_rss respond_to do |type| type.html { render :text => "HTML" } @@ -44,14 +46,6 @@ class RespondToController < ActionController::Base respond_to(:html, :js, :xml) end - def using_argument_defaults - person_in_xml = { :name => "David" }.to_xml(:root => "person") - respond_to do |type| - type.html - type.xml(person_in_xml) - end - end - def made_for_content_type respond_to do |type| type.rss { render :text => "RSS" } @@ -75,9 +69,23 @@ class RespondToController < ActionController::Base end end + def all_types_with_layout + respond_to do |type| + type.html + type.js + end + end + def rescue_action(e) raise end + + protected + def set_layout + if action_name == "all_types_with_layout" + "standard" + end + end end RespondToController.template_root = File.dirname(__FILE__) + "/../fixtures/" @@ -173,12 +181,6 @@ class MimeControllerTest < Test::Unit::TestCase assert_equal "<p>Hello world!</p>\n", @response.body end - def test_using_argument_defaults - @request.env["HTTP_ACCEPT"] = "application/xml" - get :using_argument_defaults - assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>David</name>\n</person>\n", @response.body - end - def test_with_content_type @request.env["CONTENT_TYPE"] = "application/atom+xml" get :made_for_content_type @@ -195,8 +197,8 @@ class MimeControllerTest < Test::Unit::TestCase assert_equal 'JS', @response.body @request.env["HTTP_ACCEPT"] = "application/x-xml" - get :using_argument_defaults - assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>David</name>\n</person>\n", @response.body + get :html_xml_or_rss + assert_equal "XML", @response.body end def test_custom_types @@ -234,4 +236,14 @@ class MimeControllerTest < Test::Unit::TestCase get :handle_any assert_equal 'Either JS or XML', @response.body end + + def test_all_types_with_layout + @request.env["HTTP_ACCEPT"] = "text/javascript" + get :all_types_with_layout + assert_equal 'RJS for all_types_with_layout', @response.body + + @request.env["HTTP_ACCEPT"] = "text/html" + get :all_types_with_layout + assert_equal '<html>HTML for all_types_with_layout</html>', @response.body + end end
\ No newline at end of file diff --git a/actionpack/test/fixtures/respond_to/all_types_with_layout.rhtml b/actionpack/test/fixtures/respond_to/all_types_with_layout.rhtml new file mode 100644 index 0000000000..84a84049f8 --- /dev/null +++ b/actionpack/test/fixtures/respond_to/all_types_with_layout.rhtml @@ -0,0 +1 @@ +HTML for all_types_with_layout
\ No newline at end of file diff --git a/actionpack/test/fixtures/respond_to/all_types_with_layout.rjs b/actionpack/test/fixtures/respond_to/all_types_with_layout.rjs new file mode 100644 index 0000000000..b7aec7c505 --- /dev/null +++ b/actionpack/test/fixtures/respond_to/all_types_with_layout.rjs @@ -0,0 +1 @@ +page << "RJS for all_types_with_layout"
\ No newline at end of file diff --git a/actionpack/test/fixtures/respond_to/layouts/standard.rhtml b/actionpack/test/fixtures/respond_to/layouts/standard.rhtml new file mode 100644 index 0000000000..fcb28ec755 --- /dev/null +++ b/actionpack/test/fixtures/respond_to/layouts/standard.rhtml @@ -0,0 +1 @@ +<html><%= @content_for_layout %></html>
\ No newline at end of file |