Skip to content

Commit

Permalink
Add tests to ensure cache works with collection
Browse files Browse the repository at this point in the history
  • Loading branch information
okuramasafumi committed Mar 5, 2021
1 parent 9a35011 commit 037f5f1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/usecases/cache_test.rb
Expand Up @@ -45,6 +45,29 @@ def test_it_works_correctly_with_object_without_update_at_change
refute_equal before_update_result, after_update_result
end

def test_it_works_correctly_with_collection_add
users = []
user = User.new(1, 'Test', 'test@example.org')
users << user
before_update_result = UserResource.new(users).serialize
user2 = User.new(2, 'Test2', 'test2@example.org')
users << user2
after_update_result = UserResource.new(users).serialize
refute_equal before_update_result, after_update_result
end

def test_it_works_correctly_with_collection_remove
users = []
user = User.new(1, 'Test', 'test@example.org')
user2 = User.new(2, 'Test2', 'test2@example.org')
users << user
users << user2
before_update_result = UserResource.new(users).serialize
users.delete_at(0)
after_update_result = UserResource.new(users).serialize
refute_equal before_update_result, after_update_result
end

def test_without_cache
Alba.without_cache do
assert_equal Alba::NullCacheStore, Alba.cache.class
Expand Down

0 comments on commit 037f5f1

Please sign in to comment.