diff options
Diffstat (limited to 'actionpack/test/controller/caching_test.rb')
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index a792752ef4..f0ad652d50 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -285,6 +285,8 @@ class ActionCacheTest < ActionController::TestCase assert_not_equal cached_time, @response.body end + include RackTestUtils + def test_action_cache_with_layout get :with_layout cached_time = content_to_cache @@ -294,8 +296,8 @@ class ActionCacheTest < ActionController::TestCase get :with_layout assert_not_equal cached_time, @response.body - - assert_equal @response.body, read_fragment('hostname.com/action_caching_test/with_layout') + body = body_to_string(read_fragment('hostname.com/action_caching_test/with_layout')) + assert_equal @response.body, body end def test_action_cache_with_layout_and_layout_cache_false @@ -308,7 +310,8 @@ class ActionCacheTest < ActionController::TestCase get :layout_false assert_not_equal cached_time, @response.body - assert_equal cached_time, read_fragment('hostname.com/action_caching_test/layout_false') + body = body_to_string(read_fragment('hostname.com/action_caching_test/layout_false')) + assert_equal cached_time, body end def test_action_cache_conditional_options @@ -616,8 +619,10 @@ class FragmentCachingTest < ActionController::TestCase @store.write('views/expensive', 'fragment content') fragment_computed = false + view_context = @controller.view_context + buffer = 'generated till now -> '.html_safe - @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } + buffer << view_context.send(:fragment_for, 'expensive') { fragment_computed = true } assert fragment_computed assert_equal 'generated till now -> ', buffer @@ -627,8 +632,10 @@ class FragmentCachingTest < ActionController::TestCase @store.write('views/expensive', 'fragment content') fragment_computed = false + view_context = @controller.view_context + buffer = 'generated till now -> '.html_safe - @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } + buffer << view_context.send(:fragment_for, 'expensive') { fragment_computed = true } assert !fragment_computed assert_equal 'generated till now -> fragment content', buffer @@ -704,8 +711,8 @@ CACHED def test_fragment_caching_in_partials get :html_fragment_cached_with_partial assert_response :success - assert_match /Fragment caching in a partial/, @response.body - assert_match "Fragment caching in a partial", @store.read('views/test.host/functional_caching/html_fragment_cached_with_partial') + assert_match /Old fragment caching in a partial/, @response.body + assert_match "Old fragment caching in a partial", @store.read('views/test.host/functional_caching/html_fragment_cached_with_partial') end def test_render_inline_before_fragment_caching @@ -719,14 +726,14 @@ CACHED def test_fragment_caching_in_rjs_partials xhr :get, :js_fragment_cached_with_partial assert_response :success - assert_match /Fragment caching in a partial/, @response.body - assert_match "Fragment caching in a partial", @store.read('views/test.host/functional_caching/js_fragment_cached_with_partial') + assert_match /Old fragment caching in a partial/, @response.body + assert_match "Old fragment caching in a partial", @store.read('views/test.host/functional_caching/js_fragment_cached_with_partial') end def test_html_formatted_fragment_caching get :formatted_fragment_cached, :format => "html" assert_response :success - expected_body = "<body>\n<p>ERB</p>\n</body>" + expected_body = "<body>\n<p>ERB</p>\n</body>\n" assert_equal expected_body, @response.body @@ -742,15 +749,4 @@ CACHED assert_equal " <p>Builder</p>\n", @store.read('views/test.host/functional_caching/formatted_fragment_cached') end - - def test_js_formatted_fragment_caching - get :formatted_fragment_cached, :format => "js" - assert_response :success - expected_body = %(title = "Hey";\n$("element_1").visualEffect("highlight");\n) + - %($("element_2").visualEffect("highlight");\nfooter = "Bye";) - assert_equal expected_body, @response.body - - assert_equal ['$("element_1").visualEffect("highlight");', '$("element_2").visualEffect("highlight");'], - @store.read('views/test.host/functional_caching/formatted_fragment_cached') - end end |