mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Add test coverage and changelog
This commit is contained in:
parent
be5fbf3d54
commit
7f751fc1f7
@ -7,6 +7,7 @@ Breaking changes:
|
||||
Features:
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user