aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-08-05 12:36:43 +0200
committerJosé Valim <jose.valim@gmail.com>2009-08-07 17:16:16 +0200
commit1fd65c80fcdc6080b9efa27f41dbb7f7d95a17c6 (patch)
treedf2fedc4a692e484f8d854fe4c15a4dd407ed991 /actionpack/test
parent7034272354ad41dd4d1c90138a79e7f14ebc2bed (diff)
downloadrails-1fd65c80fcdc6080b9efa27f41dbb7f7d95a17c6.tar.gz
rails-1fd65c80fcdc6080b9efa27f41dbb7f7d95a17c6.tar.bz2
rails-1fd65c80fcdc6080b9efa27f41dbb7f7d95a17c6.zip
Encapsulate respond_with behavior in a presenter.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb40
1 files changed, 18 insertions, 22 deletions
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