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:
7
7
Features:
8
8
9
9
Fixes:
10
+ - [ #2288 ] ( https://github.com/rails-api/active_model_serializers/pull/2288 ) . Fixes #2287 . (@cintamani )
10
11
11
12
- [ #2307 ] ( https://github.com/rails-api/active_model_serializers/pull/2307 ) Falsey attribute values should not be reevaluated.
12
13
Original file line number Diff line number Diff line change @@ -55,6 +55,11 @@ class AuthorSerializer < ActiveModel::Serializer
55
55
has_many :roles
56
56
has_one :bio
57
57
end
58
+ class AuthorSerializerWithCache < ActiveModel ::Serializer
59
+ cache
60
+
61
+ attributes :name
62
+ end
58
63
59
64
class Blog < ::Model
60
65
attributes :name
@@ -146,6 +151,19 @@ class InheritedRoleSerializer < RoleSerializer
146
151
@blog_serializer = BlogSerializer . new ( @blog )
147
152
end
148
153
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
+
149
167
def test_explicit_cache_store
150
168
default_store = Class . new ( ActiveModel ::Serializer ) do
151
169
cache
You can’t perform that action at this time.
0 commit comments