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

@ -7,6 +7,7 @@ Breaking changes:
Features: Features:
Fixes: Fixes:
- [#2288](https://github.com/rails-api/active_model_serializers/pull/2288). Fixes #2287. (@cintamani)
- [#2307](https://github.com/rails-api/active_model_serializers/pull/2307) Falsey attribute values should not be reevaluated. - [#2307](https://github.com/rails-api/active_model_serializers/pull/2307) Falsey attribute values should not be reevaluated.

View File

@ -55,6 +55,11 @@ module ActiveModelSerializers
has_many :roles has_many :roles
has_one :bio has_one :bio
end end
class AuthorSerializerWithCache < ActiveModel::Serializer
cache
attributes :name
end
class Blog < ::Model class Blog < ::Model
attributes :name attributes :name
@ -146,6 +151,19 @@ module ActiveModelSerializers
@blog_serializer = BlogSerializer.new(@blog) @blog_serializer = BlogSerializer.new(@blog)
end 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 def test_explicit_cache_store
default_store = Class.new(ActiveModel::Serializer) do default_store = Class.new(ActiveModel::Serializer) do
cache cache