Skip to content

Commit fc82145

Browse files
authored
Merge pull request #24 from SoftSwiss/cache_key
Add test for non url cache_key
2 parents 30ae10c + 30c550a commit fc82145

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/caching_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ActionCachingTestController < CachingController
3838
caches_action :with_layout
3939
caches_action :with_format_and_http_param, cache_path: Proc.new { |c| { key: 'value' } }
4040
caches_action :with_symbol_format, cache_path: 'http://test.host/action_caching_test/with_symbol_format'
41+
caches_action :not_url_cache_path, cache_path: Proc.new { |c| "#{c.params[:action]}_key" }
4142
caches_action :layout_false, layout: false
4243
caches_action :with_layout_proc_param, layout: Proc.new { |c| c.params[:layout] }
4344
caches_action :record_not_found, :four_oh_four, :simple_runtime_error
@@ -76,6 +77,10 @@ def with_symbol_format
7677
render json: { timestamp: @cache_this }
7778
end
7879

80+
def not_url_cache_path
81+
render text: 'cache_this'
82+
end
83+
7984
def record_not_found
8085
raise ActiveRecord::RecordNotFound, 'oops!'
8186
end
@@ -287,6 +292,13 @@ def test_action_cache_with_symbol_format
287292
assert fragment_exist?('test.host/action_caching_test/with_symbol_format.json')
288293
end
289294

295+
def test_action_cache_not_url_cache_path
296+
get :not_url_cache_path
297+
assert_response :success
298+
assert !fragment_exist?('test.host/action_caching_test/not_url_cache_path')
299+
assert fragment_exist?('not_url_cache_path_key')
300+
end
301+
290302
def test_action_cache_with_store_options
291303
MockTime.expects(:now).returns(12345).once
292304
@controller.expects(:read_fragment).with('hostname.com/action_caching_test', expires_in: 1.hour).once

0 commit comments

Comments
 (0)