Skip to content

Commit

Permalink
Merge pull request #6 from LukinEgor/feature/add-multiple-slotted-cou…
Browse files Browse the repository at this point in the history
…nter-support

add spec for using multiple counters
  • Loading branch information
egor-lukin authored Oct 4, 2022
2 parents 15b97dc + 5446c08 commit f7828e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ Using `counter_cache: true` on `belongs_to` associations also works as expected.

- Add `reset_counters` implementation
- Add `with_slotted_counters` scope
- Add multiple `has_slotted_counter` support
- Rails 6 support

## Contributing
Expand Down
12 changes: 12 additions & 0 deletions spec/slotted_counter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,16 @@
expect(article.specific_comments_count).to eq(1)
end
end

it "must update multiple counters in model" do
article = WithSlottedCounter::Article.create!

comments_count = rand(10)
views_count = rand(10)

WithSlottedCounter::Article.update_counters(article.id, comments_count: comments_count, views_count: views_count)

expect(article.comments_count).to eq(comments_count)
expect(article.views_count).to eq(views_count)
end
end

0 comments on commit f7828e4

Please sign in to comment.