File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Breaking changes:
77Features:
88
99Fixes:
10+ - [ #2288 ] ( https://github.com/rails-api/active_model_serializers/pull/2288 ) . Fixes #2287 . (@cintamani )
1011
1112- [ #2307 ] ( https://github.com/rails-api/active_model_serializers/pull/2307 ) Falsey attribute values should not be reevaluated.
1213
Original file line number Diff line number Diff line change @@ -55,6 +55,11 @@ class AuthorSerializer < ActiveModel::Serializer
5555 has_many :roles
5656 has_one :bio
5757 end
58+ class AuthorSerializerWithCache < ActiveModel ::Serializer
59+ cache
60+
61+ attributes :name
62+ end
5863
5964 class Blog < ::Model
6065 attributes :name
@@ -146,6 +151,19 @@ class InheritedRoleSerializer < RoleSerializer
146151 @blog_serializer = BlogSerializer . new ( @blog )
147152 end
148153
154+ def test_expire_of_cache
155+ ARModels ::Author . cache_versioning = true
156+ author = ARModels ::Author . create ( name : 'Foo' )
157+ author_json = AuthorSerializerWithCache . new ( author ) . as_json
158+
159+ assert_equal 'Foo' , author_json [ :name ]
160+
161+ author . update_attributes ( name : 'Bar' )
162+ author_json = AuthorSerializerWithCache . new ( author ) . as_json
163+
164+ assert_equal 'Bar' , author_json [ :name ]
165+ end
166+
149167 def test_explicit_cache_store
150168 default_store = Class . new ( ActiveModel ::Serializer ) do
151169 cache
You can’t perform that action at this time.
0 commit comments