[15-min-fix] Don't prevent reaction notifications from being sent (#13351)

* Don't prevent rxn notifications

* Update specs to match new behavior
This commit is contained in:
Andy Zhao 2021-04-12 09:35:07 -04:00 committed by GitHub
parent 7b119057b3
commit bee3a97aa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 11 deletions

View file

@ -65,10 +65,8 @@ class Reaction < ApplicationRecord
# - reaction is negative
# - receiver is the same user as the one who reacted
# - receive_notification is disabled
def skip_notification_for?(receiver)
points.negative? ||
(user_id == reactable.user_id) ||
(receiver.is_a?(User) && reactable.receive_notifications == false)
def skip_notification_for?(_receiver)
points.negative? || (user_id == reactable.user_id)
end
def vomit_on_user?

View file

@ -344,13 +344,13 @@ RSpec.describe Notification, type: :model do
end.to change(user.notifications, :count).by(0)
end
it "does not send a notification to the author of an article" do
it "does send a notification to the author of an article" do
article.update(receive_notifications: false)
reaction = create(:reaction, reactable: article, user: user2)
expect do
described_class.send_reaction_notification_without_delay(reaction, reaction.reactable.user)
end.to change(user.notifications, :count).by(0)
end.to change(user.notifications, :count).by(1)
end
end

View file

@ -124,11 +124,6 @@ RSpec.describe Reaction, type: :model do
reaction.reactable.user_id = user_id
expect(reaction.skip_notification_for?(user)).to be(true)
end
it "is true when the receive_notifications is false" do
reaction.reactable.receive_notifications = false
expect(reaction.skip_notification_for?(receiver)).to be(true)
end
end
end