aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-04-25 09:11:41 -0400
committerJosé Valim <jose.valim@gmail.com>2010-04-29 12:48:34 +0200
commitd793d30776737e46ead49d90dcba411c3dfd6edf (patch)
treeb743089fce82ddcd9279370593a60ee9c892a534 /actionpack/test/controller
parent2e9af3638d950ef840e1287f99e323887ec6a4c4 (diff)
downloadrails-d793d30776737e46ead49d90dcba411c3dfd6edf.tar.gz
rails-d793d30776737e46ead49d90dcba411c3dfd6edf.tar.bz2
rails-d793d30776737e46ead49d90dcba411c3dfd6edf.zip
ActionCachingTestController rescues from all exceptions. Making sure that all the tests check for valid response. [#4468 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/caching_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 115cc91467..4431eb2e2a 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -265,23 +265,27 @@ class ActionCacheTest < ActionController::TestCase
def test_simple_action_cache
get :index
+ assert_response :success
cached_time = content_to_cache
assert_equal cached_time, @response.body
assert fragment_exist?('hostname.com/action_caching_test')
reset!
get :index
+ assert_response :success
assert_equal cached_time, @response.body
end
def test_simple_action_not_cached
get :destroy
+ assert_response :success
cached_time = content_to_cache
assert_equal cached_time, @response.body
assert !fragment_exist?('hostname.com/action_caching_test/destroy')
reset!
get :destroy
+ assert_response :success
assert_not_equal cached_time, @response.body
end
@@ -289,12 +293,14 @@ class ActionCacheTest < ActionController::TestCase
def test_action_cache_with_layout
get :with_layout
+ assert_response :success
cached_time = content_to_cache
assert_not_equal cached_time, @response.body
assert fragment_exist?('hostname.com/action_caching_test/with_layout')
reset!
get :with_layout
+ assert_response :success
assert_not_equal cached_time, @response.body
body = body_to_string(read_fragment('hostname.com/action_caching_test/with_layout'))
assert_equal @response.body, body
@@ -302,12 +308,14 @@ class ActionCacheTest < ActionController::TestCase
def test_action_cache_with_layout_and_layout_cache_false
get :layout_false
+ assert_response :success
cached_time = content_to_cache
assert_not_equal cached_time, @response.body
assert fragment_exist?('hostname.com/action_caching_test/layout_false')
reset!
get :layout_false
+ assert_response :success
assert_not_equal cached_time, @response.body
body = body_to_string(read_fragment('hostname.com/action_caching_test/layout_false'))
@@ -317,6 +325,7 @@ class ActionCacheTest < ActionController::TestCase
def test_action_cache_conditional_options
@request.env['HTTP_ACCEPT'] = 'application/json'
get :index
+ assert_response :success
assert !fragment_exist?('hostname.com/action_caching_test')
end
@@ -325,41 +334,50 @@ class ActionCacheTest < ActionController::TestCase
@controller.expects(:read_fragment).with('hostname.com/action_caching_test', :expires_in => 1.hour).once
@controller.expects(:write_fragment).with('hostname.com/action_caching_test', '12345.0', :expires_in => 1.hour).once
get :index
+ assert_response :success
end
def test_action_cache_with_custom_cache_path
get :show
+ assert_response :success
cached_time = content_to_cache
assert_equal cached_time, @response.body
assert fragment_exist?('test.host/custom/show')
reset!
get :show
+ assert_response :success
assert_equal cached_time, @response.body
end
def test_action_cache_with_custom_cache_path_in_block
get :edit
+ assert_response :success
assert fragment_exist?('test.host/edit')
reset!
get :edit, :id => 1
+ assert_response :success
assert fragment_exist?('test.host/1;edit')
end
def test_cache_expiration
get :index
+ assert_response :success
cached_time = content_to_cache
reset!
get :index
+ assert_response :success
assert_equal cached_time, @response.body
reset!
get :expire
+ assert_response :success
reset!
get :index
+ assert_response :success
new_cached_time = content_to_cache
assert_not_equal cached_time, @response.body
reset!
@@ -376,9 +394,11 @@ class ActionCacheTest < ActionController::TestCase
@request.request_uri = "/action_caching_test/expire.xml"
get :expire, :format => :xml
+ assert_response :success
reset!
get :index
+ assert_response :success
new_cached_time = content_to_cache
assert_not_equal cached_time, @response.body
end
@@ -386,12 +406,14 @@ class ActionCacheTest < ActionController::TestCase
def test_cache_is_scoped_by_subdomain
@request.host = 'jamis.hostname.com'
get :index
+ assert_response :success
jamis_cache = content_to_cache
reset!
@request.host = 'david.hostname.com'
get :index
+ assert_response :success
david_cache = content_to_cache
assert_not_equal jamis_cache, @response.body
@@ -399,12 +421,14 @@ class ActionCacheTest < ActionController::TestCase
@request.host = 'jamis.hostname.com'
get :index
+ assert_response :success
assert_equal jamis_cache, @response.body
reset!
@request.host = 'david.hostname.com'
get :index
+ assert_response :success
assert_equal david_cache, @response.body
end
@@ -433,20 +457,24 @@ class ActionCacheTest < ActionController::TestCase
end
get :index, :format => 'xml'
+ assert_response :success
cached_time = content_to_cache
assert_equal cached_time, @response.body
assert fragment_exist?('hostname.com/action_caching_test/index.xml')
reset!
get :index, :format => 'xml'
+ assert_response :success
assert_equal cached_time, @response.body
assert_equal 'application/xml', @response.content_type
reset!
get :expire_xml
+ assert_response :success
reset!
get :index, :format => 'xml'
+ assert_response :success
assert_not_equal cached_time, @response.body
end
end
@@ -455,6 +483,7 @@ class ActionCacheTest < ActionController::TestCase
# run it twice to cache it the first time
get :index, :id => 'content-type', :format => 'xml'
get :index, :id => 'content-type', :format => 'xml'
+ assert_response :success
assert_equal 'application/xml', @response.content_type
end
@@ -462,6 +491,7 @@ class ActionCacheTest < ActionController::TestCase
# run it twice to cache it the first time
get :show, :format => 'xml'
get :show, :format => 'xml'
+ assert_response :success
assert_equal 'application/xml', @response.content_type
end
@@ -469,6 +499,7 @@ class ActionCacheTest < ActionController::TestCase
# run it twice to cache it the first time
get :edit, :id => 1, :format => 'xml'
get :edit, :id => 1, :format => 'xml'
+ assert_response :success
assert_equal 'application/xml', @response.content_type
end