@@ -52,7 +52,7 @@ class ActionCachingTestController < CachingController
52
52
layout "talk_from_action"
53
53
54
54
def index
55
- @cache_this = MockTime . now . to_f . to_s
55
+ @cache_this = CacheContent . to_s
56
56
render plain : @cache_this
57
57
end
58
58
@@ -66,17 +66,17 @@ def forbidden
66
66
end
67
67
68
68
def with_layout
69
- @cache_this = MockTime . now . to_f . to_s
69
+ @cache_this = CacheContent . to_s
70
70
render html : @cache_this , layout : true
71
71
end
72
72
73
73
def with_format_and_http_param
74
- @cache_this = MockTime . now . to_f . to_s
74
+ @cache_this = CacheContent . to_s
75
75
render plain : @cache_this
76
76
end
77
77
78
78
def with_symbol_format
79
- @cache_this = MockTime . now . to_f . to_s
79
+ @cache_this = CacheContent . to_s
80
80
render json : { timestamp : @cache_this }
81
81
end
82
82
@@ -126,15 +126,15 @@ def streaming
126
126
end
127
127
128
128
def invalid
129
- @cache_this = MockTime . now . to_f . to_s
129
+ @cache_this = CacheContent . to_s
130
130
131
131
respond_to do |format |
132
132
format . json { render json : @cache_this }
133
133
end
134
134
end
135
135
136
136
def accept
137
- @cache_this = MockTime . now . to_f . to_s
137
+ @cache_this = CacheContent . to_s
138
138
139
139
respond_to do |format |
140
140
format . html { render html : @cache_this }
@@ -174,10 +174,11 @@ def render(options)
174
174
end
175
175
end
176
176
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
181
182
end
182
183
end
183
184
@@ -391,7 +392,7 @@ def test_action_cache_with_store_options
391
392
get "/action_caching_test" , to : "action_caching_test#index"
392
393
end
393
394
394
- MockTime . expects ( :now ) . returns ( 12345 ) . once
395
+ CacheContent . expects ( :to_s ) . returns ( ' 12345.0' ) . once
395
396
@controller . expects ( :read_fragment ) . with ( "hostname.com/action_caching_test" , expires_in : 1 . hour ) . once
396
397
@controller . expects ( :write_fragment ) . with ( "hostname.com/action_caching_test" , "12345.0" , expires_in : 1 . hour ) . once
397
398
get :index
0 commit comments