Skip to content

Commit 26bba19

Browse files
committed
Ensure that CacheVersioning is setted up only in the context of relevant tests
1 parent 6fd5c66 commit 26bba19

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/cache_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ class InheritedRoleSerializer < RoleSerializer
152152
end
153153

154154
def test_expiring_of_cache_at_update_of_record
155+
original_cache_versioning = :none
156+
155157
if ARModels::Author.respond_to?(:cache_versioning)
158+
original_cache_versioning = ARModels::Author.cache_versioning
156159
ARModels::Author.cache_versioning = true
157160
end
158161

@@ -171,10 +174,15 @@ def test_expiring_of_cache_at_update_of_record
171174
else
172175
assert_equal expected, actual
173176
end
177+
ensure
178+
ARModels::Author.cache_versioning = original_cache_versioning unless original_cache_versioning == :none
174179
end
175180

176181
def test_cache_expiration_in_collection_on_update_of_record
182+
original_cache_versioning = :none
183+
177184
if ARModels::Author.respond_to?(:cache_versioning)
185+
original_cache_versioning = ARModels::Author.cache_versioning
178186
ARModels::Author.cache_versioning = true
179187
end
180188

@@ -198,6 +206,8 @@ def test_cache_expiration_in_collection_on_update_of_record
198206

199207
collection_json = render_object_with_cache(author_collection, each_serializer: AuthorSerializerWithCache)
200208
assert_equal [{ name: bar }, { name: bar }, { name: foo2 }], collection_json
209+
ensure
210+
ARModels::Author.cache_versioning = original_cache_versioning unless original_cache_versioning == :none
201211
end
202212

203213
def test_explicit_cache_store

0 commit comments

Comments
 (0)