docbrown/spec/models/shared_examples/sync_reactions_count.rb
Anna Buianova 875114395c Fix delayed job errors related to reactions #1621 (#1883)
* Add delayed_job_web to dev environment for debugging

* Add specs for the current Follow callbacks implementation

* Move follower touching to ActiveJob

* Spec for the touch followers job

* Move Follow#create_chat_channel to ActiveJob and make the job safe

* Add ActiveJob to send email notifications about follows

* Enqueue SendEmailNotificationJob after the follow is created

* Specs to wnsure jobs are enqueued on Follow creation

* Make CreateChatChannelJob queue name more specific

* Reaction specs for Reaction after_save callbacks logic

* Touch user job

* Call Users::TouchJob on reaction create

* Move updating reactable to a separate job

* Move busting reactable cache to a separate job

* Bust homepage cache after reaction save in a separate job

* Spec for enqueueing Users::TouchJob on reaction create

* Refactor Reactions::UpdateReactable job

* Fix observer spec
2019-02-27 16:19:01 -08:00

18 lines
575 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_list(:reaction, 4, points: 1, reactable: reactable)
reaction = create(:reaction, reactable: reactable)
reaction.update_column(:points, 0)
end
it "syncs reactions count" do
reactable.update_column(:positive_reactions_count, 1)
reactable.sync_reactions_count
reactable.reload
expect(reactable.positive_reactions_count).to eq(4)
end
end
end