From 1fd65c80fcdc6080b9efa27f41dbb7f7d95a17c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 5 Aug 2009 12:36:43 +0200 Subject: Encapsulate respond_with behavior in a presenter. --- actionpack/test/controller/mime_responds_test.rb | 40 +++++++++++------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index faa84e1971..157e837503 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -497,16 +497,14 @@ class RespondWithController < ActionController::Base respond_with(Customer.new("david", 13)) end - def using_resource_with_options - respond_with(Customer.new("david", 13), :status => :unprocessable_entity) do |format| - format.js - end - end - def using_resource_with_parent respond_with([Quiz::Store.new("developer?", 11), Customer.new("david", 13)]) end + def using_resource_with_location + respond_with(Customer.new("david", 13), :location => "http://test.host/") + end + protected def _render_js(js, options) @@ -654,7 +652,6 @@ class RespondWithControllerTest < ActionController::TestCase assert_equal "application/xml", @response.content_type assert_equal 200, @response.status assert_equal " ", @response.body - assert_equal "http://www.example.com/customers/13", @response.location errors = { :name => :invalid } Customer.any_instance.stubs(:errors).returns(errors) @@ -680,21 +677,6 @@ class RespondWithControllerTest < ActionController::TestCase assert_equal "application/xml", @response.content_type assert_equal 200, @response.status assert_equal " ", @response.body - assert_equal "http://www.example.com/customers", @response.location - end - - def test_using_resource_with_options - @request.accept = "application/xml" - get :using_resource_with_options - assert_equal "application/xml", @response.content_type - assert_equal 422, @response.status - assert_equal "XML", @response.body - - @request.accept = "text/javascript" - get :using_resource_with_options - assert_equal "text/javascript", @response.content_type - assert_equal 422, @response.status - assert_equal "JS", @response.body end def test_using_resource_with_parent_for_get @@ -738,6 +720,20 @@ class RespondWithControllerTest < ActionController::TestCase assert_equal "XML", @response.body end + def test_no_double_render_is_raised + @request.accept = "text/html" + assert_raise ActionView::MissingTemplate do + get :using_resource + end + end + + def test_using_resource_with_location + @request.accept = "text/html" + post :using_resource_with_location + assert @response.redirect? + assert_equal "http://test.host/", @response.location + end + def test_not_acceptable @request.accept = "application/xml" get :using_defaults -- cgit v1.2.3