File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,27 @@ def test_expiring_of_cache_at_update_of_record
173173 end
174174 end
175175
176+ def test_cache_expiration_in_collection_on_update_of_record
177+ if ARModels ::Author . respond_to? ( :cache_versioning )
178+ ARModels ::Author . cache_versioning = true
179+ end
180+
181+ foo = 'Foo'
182+ foo2 = 'Foo2'
183+ author = ARModels ::Author . create ( name : foo )
184+ author2 = ARModels ::Author . create ( name : foo2 )
185+ author_collection = [ author , author , author2 ]
186+
187+ collection_json = render_object_with_cache ( author_collection , each_serializer : AuthorSerializerWithCache )
188+ assert_equal [ { name : foo } , { name : foo } , { name : foo2 } ] , collection_json
189+
190+ bar = 'Bar'
191+ author . update_attributes ( name : bar )
192+
193+ collection_json = render_object_with_cache ( author_collection , each_serializer : AuthorSerializerWithCache )
194+ assert_equal [ { name : bar } , { name : bar } , { name : foo2 } ] , collection_json
195+ end
196+
176197 def test_explicit_cache_store
177198 default_store = Class . new ( ActiveModel ::Serializer ) do
178199 cache
You can’t perform that action at this time.
0 commit comments