@@ -52,7 +52,7 @@ class ActionCachingTestController < CachingController
5252 layout "talk_from_action"
5353
5454 def index
55- @cache_this = MockTime . now . to_f . to_s
55+ @cache_this = CacheContent . to_s
5656 render plain : @cache_this
5757 end
5858
@@ -66,17 +66,17 @@ def forbidden
6666 end
6767
6868 def with_layout
69- @cache_this = MockTime . now . to_f . to_s
69+ @cache_this = CacheContent . to_s
7070 render html : @cache_this , layout : true
7171 end
7272
7373 def with_format_and_http_param
74- @cache_this = MockTime . now . to_f . to_s
74+ @cache_this = CacheContent . to_s
7575 render plain : @cache_this
7676 end
7777
7878 def with_symbol_format
79- @cache_this = MockTime . now . to_f . to_s
79+ @cache_this = CacheContent . to_s
8080 render json : { timestamp : @cache_this }
8181 end
8282
@@ -126,15 +126,15 @@ def streaming
126126 end
127127
128128 def invalid
129- @cache_this = MockTime . now . to_f . to_s
129+ @cache_this = CacheContent . to_s
130130
131131 respond_to do |format |
132132 format . json { render json : @cache_this }
133133 end
134134 end
135135
136136 def accept
137- @cache_this = MockTime . now . to_f . to_s
137+ @cache_this = CacheContent . to_s
138138
139139 respond_to do |format |
140140 format . html { render html : @cache_this }
@@ -174,10 +174,11 @@ def render(options)
174174 end
175175end
176176
177- class MockTime < Time
178- # Let Time spicy to assure that Time.now != Time.now
179- def to_f
180- super + rand
177+ class CacheContent
178+ def self . to_s
179+ # Let Time spicy to assure that Time.now != Time.now
180+ time = Time . now . to_f + rand
181+ ( time . to_s + "<div />" ) . html_safe
181182 end
182183end
183184
@@ -391,7 +392,7 @@ def test_action_cache_with_store_options
391392 get "/action_caching_test" , to : "action_caching_test#index"
392393 end
393394
394- MockTime . expects ( :now ) . returns ( 12345 ) . once
395+ CacheContent . expects ( :to_s ) . returns ( ' 12345.0' ) . once
395396 @controller . expects ( :read_fragment ) . with ( "hostname.com/action_caching_test" , expires_in : 1 . hour ) . once
396397 @controller . expects ( :write_fragment ) . with ( "hostname.com/action_caching_test" , "12345.0" , expires_in : 1 . hour ) . once
397398 get :index
0 commit comments