diff options
author | Christopher Meiklejohn <christopher.meiklejohn@gmail.com> | 2011-07-30 00:49:36 -0400 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-10-31 15:10:07 -0400 |
commit | 6cbe4223a77d7ea364b4d2dc46cec6a0c58c9537 (patch) | |
tree | 686c05a79a785da3a4ea7ddbcf01be796777e5b9 /actionpack/test | |
parent | 1afe269a4aa18a815c509d3f0348ed99a9b4b560 (diff) | |
download | rails-6cbe4223a77d7ea364b4d2dc46cec6a0c58c9537.tar.gz rails-6cbe4223a77d7ea364b4d2dc46cec6a0c58c9537.tar.bz2 rails-6cbe4223a77d7ea364b4d2dc46cec6a0c58c9537.zip |
Ensure that the format isn't applied twice to the cache key, else it becomes impossible to target with expire_action.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 618e7b77b2..2364bbf3a3 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -194,6 +194,7 @@ class ActionCachingTestController < CachingController caches_action :show, :cache_path => 'http://test.host/custom/show' caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" } caches_action :with_layout + caches_action :with_format_and_http_param, :cache_path => Proc.new { |c| { :key => 'value' } } caches_action :layout_false, :layout => false caches_action :record_not_found, :four_oh_four, :simple_runtime_error @@ -219,6 +220,11 @@ class ActionCachingTestController < CachingController render :text => @cache_this, :layout => true end + def with_format_and_http_param + @cache_this = MockTime.now.to_f.to_s + render :text => @cache_this + end + def record_not_found raise ActiveRecord::RecordNotFound, "oops!" end @@ -359,6 +365,13 @@ class ActionCacheTest < ActionController::TestCase assert !fragment_exist?('hostname.com/action_caching_test') end + def test_action_cache_with_format_and_http_param + get :with_format_and_http_param, :format => 'json' + assert_response :success + assert !fragment_exist?('hostname.com/action_caching_test/with_format_and_http_param.json?key=value.json') + assert fragment_exist?('hostname.com/action_caching_test/with_format_and_http_param.json?key=value') + end + def test_action_cache_with_store_options MockTime.expects(:now).returns(12345).once @controller.expects(:read_fragment).with('hostname.com/action_caching_test', :expires_in => 1.hour).once |