File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11< p class ='cache-component__cache-key '> <%= view_cache_dependencies %> </ p >
2- < p class ='cache-component__cache-message '> <%= "#{ foo } #{ bar } " %> </ p >
2+ < p class ='cache-component__cache-message ' data-time = data-time =" <%= Time . zone . now %> " > <%= "#{ foo } #{ bar } " %> </ p >
Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ def controller_inline
1111 render ( ControllerInlineComponent . new ( message : "bar" ) )
1212 end
1313
14+ def controller_inline_cached
15+ foo = params [ :foo ] || "foo"
16+ bar = params [ :bar ] || "bar"
17+ render ( CacheComponent . new ( foo :, bar :) )
18+ end
19+
1420 def controller_inline_with_block
1521 render ( ControllerInlineWithBlockComponent . new ( message : "bar" ) . tap do |c |
1622 c . with_slot ( name : "baz" )
Original file line number Diff line number Diff line change 1111 get :inline_products , to : "integration_examples#inline_products"
1212 get :cached , to : "integration_examples#cached"
1313 get :render_check , to : "integration_examples#render_check"
14+ get :controller_inline_cached , to : "integration_examples#controller_inline_cached"
1415 get :controller_inline , to : "integration_examples#controller_inline"
1516 get :controller_inline_with_block , to : "integration_examples#controller_inline_with_block"
1617 get :controller_inline_baseline , to : "integration_examples#controller_inline_baseline"
Original file line number Diff line number Diff line change @@ -261,6 +261,26 @@ def test_rendering_component_with_caching
261261 Rails . cache . clear
262262 end
263263
264+ def test_rendering_cached_component
265+ Rails . cache . clear
266+ ActionController ::Base . perform_caching = true
267+
268+ get "/controller_inline_cached"
269+ assert_response :success
270+ body = response . body
271+ assert_select ( '.cache-component__cache-message' , text : "foo bar" )
272+
273+ get "/controller_inline_cached?foo=laser&bar=beams"
274+ assert ( response . body != body )
275+ assert_select ( '.cache-component__cache-message' , text : "laser beams" )
276+
277+ get "/controller_inline_cached"
278+ assert ( response . body === body )
279+
280+ ActionController ::Base . perform_caching = false
281+ Rails . cache . clear
282+ end
283+
264284 def test_optional_rendering_component_depending_on_request_context
265285 get "/render_check"
266286 assert_response :success
Original file line number Diff line number Diff line change @@ -1217,16 +1217,20 @@ def test_with_format
12171217 end
12181218
12191219 def test_cache_component
1220+ require 'pry'
12201221 component = CacheComponent . new ( foo : "foo" , bar : "bar" )
12211222 render_inline ( component )
12221223
1224+ binding . pry
12231225 assert_selector ( ".cache-component__cache-key" , text : component . view_cache_dependencies )
12241226 assert_selector ( ".cache-component__cache-message" , text : "foo bar" )
12251227
1228+ # Is this really testing caching?
12261229 render_inline ( CacheComponent . new ( foo : "foo" , bar : "bar" ) )
12271230
12281231 assert_selector ( ".cache-component__cache-key" , text : component . view_cache_dependencies )
12291232
1233+ # Now we use Foo, Baz and the original component hasn't changed.
12301234 render_inline ( CacheComponent . new ( foo : "foo" , bar : "baz" ) )
12311235
12321236 refute_selector ( ".cache-component__cache-key" , text : component . view_cache_dependencies )
You can’t perform that action at this time.
0 commit comments