From fcb45e5ec3c8ab7b11391c0639609918876ddbb2 Mon Sep 17 00:00:00 2001 From: Tim Harper Date: Mon, 20 Oct 2008 13:21:59 -0500 Subject: Ensure ActionView::Helpers::AssetTagHelper::AssetTag::Cache is cleared before loading so changes to asset files are picked up by the broswer [#1233 state:resolved] Signed-off-by: Joshua Peek --- actionpack/test/controller/dispatcher_test.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb index 911fcab67b..3ee78a6156 100644 --- a/actionpack/test/controller/dispatcher_test.rb +++ b/actionpack/test/controller/dispatcher_test.rb @@ -26,9 +26,17 @@ class DispatcherTest < Test::Unit::TestCase end def test_clears_dependencies_after_dispatch_if_in_loading_mode - ActionController::Routing::Routes.expects(:reload).once ActiveSupport::Dependencies.expects(:clear).once + dispatch(@output, false) + end + + def test_reloads_routes_before_dispatch_if_in_loading_mode + ActionController::Routing::Routes.expects(:reload).once + dispatch(@output, false) + end + def test_clears_asset_tag_cache_before_dispatch_if_in_loading_mode + ActionView::Helpers::AssetTagHelper::AssetTag::Cache.expects(:clear).once dispatch(@output, false) end -- cgit v1.2.3 From 9acb88e666269204821b78bec7b72d3d16597096 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 21 Oct 2008 02:30:13 +0200 Subject: Added stale?/fresh? and fresh_when methods to provide a layer of abstraction above request.fresh? and friends [DHH] --- actionpack/test/controller/render_test.rb | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 7b8bb6856b..98d4cb3ffe 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -30,24 +30,20 @@ class TestController < ActionController::Base end def conditional_hello - response.last_modified = Time.now.utc.beginning_of_day - response.etag = [:foo, 123] - - if request.fresh?(response) - head :not_modified - else + if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag => [:foo, 123]) render :action => 'hello_world' end end - + def conditional_hello_with_bangs render :action => 'hello_world' end before_filter :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs def handle_last_modified_and_etags - last_modified! Time.now.utc.beginning_of_day - etag! [:foo, 123] + if fresh?(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ]) + head :not_modified + end end def render_hello_world @@ -248,7 +244,7 @@ class TestController < ActionController::Base if @alternate_default_render @alternate_default_render.call else - render + super end end @@ -1422,6 +1418,13 @@ class LastModifiedRenderTest < Test::Unit::TestCase assert_equal @last_modified, @response.headers['Last-Modified'] end + def test_request_not_modified_but_etag_differs + @request.if_modified_since = @last_modified + @request.if_none_match = "234" + get :conditional_hello + assert_response :success + end + def test_request_modified @request.if_modified_since = 'Thu, 16 Jul 2008 00:00:00 GMT' get :conditional_hello @@ -1445,7 +1448,7 @@ class LastModifiedRenderTest < Test::Unit::TestCase def test_last_modified_works_with_less_than_too @request.if_modified_since = 5.years.ago.httpdate get :conditional_hello_with_bangs - assert_response :not_modified + assert_response :success end end -- cgit v1.2.3 From 448e7e7c04260c34b816eb951427fc4409843cc8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 21 Oct 2008 02:54:55 +0200 Subject: Let fresh_when actually do the head(:not_modified). Cleaner and we get the filter halting for free then. --- actionpack/test/controller/render_test.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 98d4cb3ffe..35d9b19cc0 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -41,9 +41,7 @@ class TestController < ActionController::Base before_filter :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs def handle_last_modified_and_etags - if fresh?(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ]) - head :not_modified - end + fresh_when(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ]) end def render_hello_world -- cgit v1.2.3