docbrown/spec/models/shared_examples/sync_reactions_count.rb
Andy Zhao c42fd3461e
[deploy] Rename positive_reactions_count to public_reactions_count in logic (#7926)
* Rename positive_reactions_count to public_reactions_count

* Add positive reactions count back in so we can remove it

* Use public_category method for reactions

* Add positive_reactions_count in case any old caches rely on it

* Add positive_rxn_count to account for API endpoints

* Remove unused method

* One more spot...

* Add method back in because of caches

* Update specs to match new functionality

* Fix typo

* Remove unused methods
2020-05-26 12:36:28 -04:00

18 lines
597 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.public_reactions_count).to eq(0)
reactable.sync_reactions_count
reactable.reload
expected_count = reactable.reactions.public_category.size
expect(reactable.public_reactions_count).to eq(expected_count)
end
end
end