docbrown/spec/models/shared_examples/sync_reactions_count.rb
rhymes 33a11adca8
Various optimizations (#6249) [deploy]
* Pluck over map
* Explain why map makes sense there
* Refactor reactions controller a bit and iterate only once
* Use group by instead of N counting queries
* More positive
* Simplify BufferedArticlesController
* Less queries for MailchimpBot
* Use Rails instead of SQL
* Build comment_ids only when needed
2020-02-25 13:42:24 -05:00

18 lines
594 B
Ruby

RSpec.shared_examples "#sync_reactions_count" do |reactable_type|
context "with syncable reactions count" do
let(:reactable) { create(reactable_type) }
before do
create(:reaction, points: 1, reactable: reactable)
create(:reaction, points: 0, reactable: reactable)
end
it "syncs reactions count" do
expect(reactable.positive_reactions_count).to eq(0)
reactable.sync_reactions_count
reactable.reload
expected_count = reactable.reactions.positive.size
expect(reactable.positive_reactions_count).to eq(expected_count)
end
end
end