mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Merge pull request #1 from wasifhossain/collection-cache-expiry
Test cache expiration in collection on update of a record
This commit is contained in:
commit
f815d3e9f8
@ -173,6 +173,27 @@ module ActiveModelSerializers
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_cache_expiration_in_collection_on_update_of_record
|
||||||
|
if ARModels::Author.respond_to?(:cache_versioning)
|
||||||
|
ARModels::Author.cache_versioning = true
|
||||||
|
end
|
||||||
|
|
||||||
|
foo = 'Foo'
|
||||||
|
foo2 = 'Foo2'
|
||||||
|
author = ARModels::Author.create(name: foo)
|
||||||
|
author2 = ARModels::Author.create(name: foo2)
|
||||||
|
author_collection = [author, author, author2]
|
||||||
|
|
||||||
|
collection_json = render_object_with_cache(author_collection, each_serializer: AuthorSerializerWithCache)
|
||||||
|
assert_equal [{ name: foo }, { name: foo }, { name: foo2 }], collection_json
|
||||||
|
|
||||||
|
bar = 'Bar'
|
||||||
|
author.update_attributes(name: bar)
|
||||||
|
|
||||||
|
collection_json = render_object_with_cache(author_collection, each_serializer: AuthorSerializerWithCache)
|
||||||
|
assert_equal [{ name: bar }, { name: bar }, { name: foo2 }], collection_json
|
||||||
|
end
|
||||||
|
|
||||||
def test_explicit_cache_store
|
def test_explicit_cache_store
|
||||||
default_store = Class.new(ActiveModel::Serializer) do
|
default_store = Class.new(ActiveModel::Serializer) do
|
||||||
cache
|
cache
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user