Add test coverage and changelog

This commit is contained in:
cintamani
2018-10-01 14:37:09 +01:00
parent be5fbf3d54
commit 7f751fc1f7
2 changed files with 19 additions and 0 deletions

View File

@@ -55,6 +55,11 @@ module ActiveModelSerializers
has_many :roles
has_one :bio
end
class AuthorSerializerWithCache < ActiveModel::Serializer
cache
attributes :name
end
class Blog < ::Model
attributes :name
@@ -146,6 +151,19 @@ module ActiveModelSerializers
@blog_serializer = BlogSerializer.new(@blog)
end
def test_expire_of_cache
ARModels::Author.cache_versioning = true
author = ARModels::Author.create(name: 'Foo')
author_json = AuthorSerializerWithCache.new(author).as_json
assert_equal 'Foo', author_json[:name]
author.update_attributes(name: 'Bar')
author_json = AuthorSerializerWithCache.new(author).as_json
assert_equal 'Bar', author_json[:name]
end
def test_explicit_cache_store
default_store = Class.new(ActiveModel::Serializer) do
cache