@@ -26,12 +26,17 @@ class ActionCachingTestController < CachingController
26
26
# Eliminate uninitialized ivar warning
27
27
before_filter { @title = nil }
28
28
29
+ before_filter only : :with_symbol_format do
30
+ request . params [ :format ] = :json
31
+ end
32
+
29
33
caches_action :index , :redirected , :forbidden , if : Proc . new { |c | c . request . format && !c . request . format . json? } , expires_in : 1 . hour
30
34
caches_action :show , cache_path : 'http://test.host/custom/show'
31
35
caches_action :edit , cache_path : Proc . new { |c | c . params [ :id ] ? "http://test.host/#{ c . params [ :id ] } ;edit" : 'http://test.host/edit' }
32
36
caches_action :custom_cache_path , cache_path : CachePath . new
33
37
caches_action :with_layout
34
38
caches_action :with_format_and_http_param , cache_path : Proc . new { |c | { key : 'value' } }
39
+ caches_action :with_symbol_format , cache_path : 'http://test.host/action_caching_test/with_symbol_format'
35
40
caches_action :layout_false , layout : false
36
41
caches_action :with_layout_proc_param , layout : Proc . new { |c | c . params [ :layout ] }
37
42
caches_action :record_not_found , :four_oh_four , :simple_runtime_error
@@ -65,6 +70,11 @@ def with_format_and_http_param
65
70
render text : @cache_this
66
71
end
67
72
73
+ def with_symbol_format
74
+ @cache_this = MockTime . now . to_f . to_s
75
+ render json : { timestamp : @cache_this }
76
+ end
77
+
68
78
def record_not_found
69
79
raise ActiveRecord ::RecordNotFound , 'oops!'
70
80
end
@@ -269,6 +279,13 @@ def test_action_cache_with_format_and_http_param
269
279
assert fragment_exist? ( 'hostname.com/action_caching_test/with_format_and_http_param.json?key=value' )
270
280
end
271
281
282
+ def test_action_cache_with_symbol_format
283
+ get :with_symbol_format
284
+ assert_response :success
285
+ assert !fragment_exist? ( 'test.host/action_caching_test/with_symbol_format' )
286
+ assert fragment_exist? ( 'test.host/action_caching_test/with_symbol_format.json' )
287
+ end
288
+
272
289
def test_action_cache_with_store_options
273
290
MockTime . expects ( :now ) . returns ( 12345 ) . once
274
291
@controller . expects ( :read_fragment ) . with ( 'hostname.com/action_caching_test' , expires_in : 1 . hour ) . once
0 commit comments