aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/mime_responds_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-08-13 10:27:41 +0200
committerJosé Valim <jose.valim@gmail.com>2009-08-13 10:27:41 +0200
commit4f9047ecc8f0e2c3d4491bae0051679569da71dc (patch)
treed6ee2c4f473b4ef5558e7d01325f7be5d5ce9ec7 /actionpack/test/controller/mime_responds_test.rb
parent5f7cfffc5377824e03432d7773ed8864a872b18c (diff)
downloadrails-4f9047ecc8f0e2c3d4491bae0051679569da71dc.tar.gz
rails-4f9047ecc8f0e2c3d4491bae0051679569da71dc.tar.bz2
rails-4f9047ecc8f0e2c3d4491bae0051679569da71dc.zip
Ensure collections are not treated as nested resources.
Diffstat (limited to 'actionpack/test/controller/mime_responds_test.rb')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb27
1 files changed, 20 insertions, 7 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 8319b5c573..2e2dba5aae 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -497,8 +497,12 @@ class RespondWithController < ActionController::Base
respond_with(Customer.new("david", 13))
end
+ def using_resource_with_collection
+ respond_with([Customer.new("david", 13), Customer.new("jamis", 9)])
+ end
+
def using_resource_with_parent
- respond_with([Quiz::Store.new("developer?", 11), Customer.new("david", 13)])
+ respond_with(Quiz::Store.new("developer?", 11), Customer.new("david", 13))
end
def using_resource_with_status_and_location
@@ -506,7 +510,7 @@ class RespondWithController < ActionController::Base
end
def using_resource_with_responder
- responder = proc { |c, r, o| c.render :text => "Resource name is #{r.name}" }
+ responder = proc { |c, r, o| c.render :text => "Resource name is #{r.first.name}" }
respond_with(Customer.new("david", 13), :responder => responder)
end
@@ -592,7 +596,7 @@ class RespondWithControllerTest < ActionController::TestCase
@request.accept = "application/xml"
get :using_resource
assert_equal "application/xml", @response.content_type
- assert_equal "XML", @response.body
+ assert_equal "<name>david</name>", @response.body
@request.accept = "application/json"
assert_raise ActionView::MissingTemplate do
@@ -622,7 +626,7 @@ class RespondWithControllerTest < ActionController::TestCase
post :using_resource
assert_equal "application/xml", @response.content_type
assert_equal 201, @response.status
- assert_equal "XML", @response.body
+ assert_equal "<name>david</name>", @response.body
assert_equal "http://www.example.com/customers/13", @response.location
errors = { :name => :invalid }
@@ -689,7 +693,7 @@ class RespondWithControllerTest < ActionController::TestCase
get :using_resource_with_parent
assert_equal "application/xml", @response.content_type
assert_equal 200, @response.status
- assert_equal "XML", @response.body
+ assert_equal "<name>david</name>", @response.body
end
def test_using_resource_with_parent_for_post
@@ -698,7 +702,7 @@ class RespondWithControllerTest < ActionController::TestCase
post :using_resource_with_parent
assert_equal "application/xml", @response.content_type
assert_equal 201, @response.status
- assert_equal "XML", @response.body
+ assert_equal "<name>david</name>", @response.body
assert_equal "http://www.example.com/quiz_stores/11/customers/13", @response.location
errors = { :name => :invalid }
@@ -710,6 +714,15 @@ class RespondWithControllerTest < ActionController::TestCase
assert_nil @response.location
end
+ def test_using_resource_with_collection
+ @request.accept = "application/xml"
+ get :using_resource_with_collection
+ assert_equal "application/xml", @response.content_type
+ assert_equal 200, @response.status
+ assert_match /<name>david<\/name>/, @response.body
+ assert_match /<name>jamis<\/name>/, @response.body
+ end
+
def test_clear_respond_to
@controller = InheritedRespondWithController.new
@request.accept = "text/html"
@@ -722,7 +735,7 @@ class RespondWithControllerTest < ActionController::TestCase
@request.accept = "*/*"
get :index
assert_equal "application/xml", @response.content_type
- assert_equal "XML", @response.body
+ assert_equal "<name>david</name>", @response.body
end
def test_no_double_render_is_raised