docbrown/spec/models/shared_examples/sync_reactions_count.rb
rhymes 87116dcc56 Increase efficiency in models/article_spec.rb (#4882) [deploy]
* Add test sampler

* Use let! and let_it_be for article_spec.rb

* Regroup and restructure expectations and tests

* Move private methods in private

* Decrease the needed objects in .seo_boostable test

* Re-use the user

* Newlined
2019-11-26 10:32:39 -05:00

18 lines
608 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.where("points > ?", 0).size
expect(reactable.positive_reactions_count).to eq(expected_count)
end
end
end