@@ -27,9 +27,6 @@ class ActionCachingTestController < CachingController
27
27
28
28
self . view_paths = FIXTURE_LOAD_PATH
29
29
30
- # Eliminate uninitialized ivar warning
31
- before_action { @title = nil }
32
-
33
30
before_action only : :with_symbol_format do
34
31
request . params [ :format ] = :json
35
32
end
@@ -68,8 +65,7 @@ def forbidden
68
65
69
66
def with_layout
70
67
@cache_this = MockTime . now . to_f . to_s
71
- @title = nil
72
- render plain : @cache_this , layout : true
68
+ render html : @cache_this , layout : true
73
69
end
74
70
75
71
def with_format_and_http_param
@@ -198,7 +194,7 @@ def params
198
194
end
199
195
200
196
def request
201
- Object . new . instance_eval ( <<-EVAL )
197
+ Object . new . instance_eval <<-EVAL
202
198
def path; "#{ @mock_path } " end
203
199
def format; "all" end
204
200
def parameters; { format: nil }; end
@@ -296,15 +292,15 @@ def test_action_cache_with_layout_and_layout_cache_false
296
292
get "/action_caching_test/layout_false" , to : "action_caching_test#layout_false"
297
293
end
298
294
299
- get :layout_false
295
+ get :layout_false , params : { title : "Request 1" }
300
296
assert_response :success
301
297
cached_time = content_to_cache
302
- assert_not_equal cached_time , @response . body
303
- assert fragment_exist? ( "hostname.com/action_caching_test/layout_false" )
298
+ assert_equal "<title>Request 1</title> \n #{ cached_time } " , @response . body
299
+ assert_equal cached_time , read_fragment ( "hostname.com/action_caching_test/layout_false" )
304
300
305
- get :layout_false
301
+ get :layout_false , params : { title : "Request 2" }
306
302
assert_response :success
307
- assert_not_equal cached_time , @response . body
303
+ assert_equal "<title>Request 2</title> \n #{ cached_time } " , @response . body
308
304
assert_equal cached_time , read_fragment ( "hostname.com/action_caching_test/layout_false" )
309
305
end
310
306
@@ -313,15 +309,15 @@ def test_action_cache_with_layout_and_layout_cache_false_via_proc
313
309
get "/action_caching_test/with_layout_proc_param" , to : "action_caching_test#with_layout_proc_param"
314
310
end
315
311
316
- get :with_layout_proc_param , params : { layout : "false" }
312
+ get :with_layout_proc_param , params : { title : "Request 1" , layout : "false" }
317
313
assert_response :success
318
314
cached_time = content_to_cache
319
- assert_not_equal cached_time , @response . body
320
- assert fragment_exist? ( "hostname.com/action_caching_test/with_layout_proc_param" )
315
+ assert_equal "<title>Request 1</title> \n #{ cached_time } " , @response . body
316
+ assert_equal cached_time , read_fragment ( "hostname.com/action_caching_test/with_layout_proc_param" )
321
317
322
- get :with_layout_proc_param , params : { layout : "false" }
318
+ get :with_layout_proc_param , params : { title : "Request 2" , layout : "false" }
323
319
assert_response :success
324
- assert_not_equal cached_time , @response . body
320
+ assert_equal "<title>Request 2</title> \n #{ cached_time } " , @response . body
325
321
assert_equal cached_time , read_fragment ( "hostname.com/action_caching_test/with_layout_proc_param" )
326
322
end
327
323
@@ -330,16 +326,16 @@ def test_action_cache_with_layout_and_layout_cache_true_via_proc
330
326
get "/action_caching_test/with_layout_proc_param" , to : "action_caching_test#with_layout_proc_param"
331
327
end
332
328
333
- get :with_layout_proc_param , params : { layout : "true" }
329
+ get :with_layout_proc_param , params : { title : "Request 1" , layout : "true" }
334
330
assert_response :success
335
331
cached_time = content_to_cache
336
- assert_not_equal cached_time , @response . body
337
- assert fragment_exist? ( "hostname.com/action_caching_test/with_layout_proc_param" )
332
+ assert_equal "<title>Request 1</title> \n #{ cached_time } " , @response . body
333
+ assert_equal "<title>Request 1</title> \n #{ cached_time } " , read_fragment ( "hostname.com/action_caching_test/with_layout_proc_param" )
338
334
339
- get :with_layout_proc_param , params : { layout : "true" }
335
+ get :with_layout_proc_param , params : { title : "Request 2" , layout : "true" }
340
336
assert_response :success
341
- assert_not_equal cached_time , @response . body
342
- assert_equal @response . body , read_fragment ( "hostname.com/action_caching_test/with_layout_proc_param" )
337
+ assert_equal "<title>Request 1</title> \n #{ cached_time } " , @response . body
338
+ assert_equal "<title>Request 1</title> \n #{ cached_time } " , read_fragment ( "hostname.com/action_caching_test/with_layout_proc_param" )
343
339
end
344
340
345
341
def test_action_cache_conditional_options
0 commit comments