A platform for community discussion. Free, open, simple.
FIX: Do not create a double like notification. (#7999)
Dan Ungureanu2a98becfde23
diff --git a/lib/post_action_creator.rb b/lib/post_action_creator.rbindex 5d7d92aee17..120ee3a4560 100644--- a/lib/post_action_creator.rb+++ b/lib/post_action_creator.rb@@ -205,7 +205,6 @@ privatepost_action.recover!action_attrs.each { |attr, val| post_action.public_send("#{attr}=", val) }post_action.save- PostActionNotifier.post_action_created(post_action)elsepost_action = PostAction.create(where_attrs.merge(action_attrs))if post_action && post_action.errors.count == 0diff --git a/spec/components/post_action_creator_spec.rb b/spec/components/post_action_creator_spec.rbindex ab0d2d8c8df..74031a639a4 100644--- a/spec/components/post_action_creator_spec.rb+++ b/spec/components/post_action_creator_spec.rb@@ -65,6 +65,20 @@ describe PostActionCreator doresult = PostActionCreator.new(user, nil, like_type_id).performexpect(result.failed?).to eq(true)end++ it 'does not create a double like notification' do+ PostActionNotifier.enable+ post.user.user_option.update!(like_notification_frequency: UserOption.like_notification_frequency_type[:always])++ expect(PostActionCreator.new(user, post, like_type_id).perform.success).to eq(true)+ expect(PostActionDestroyer.new(user, post, like_type_id).perform.success).to eq(true)+ expect(PostActionCreator.new(user, post, like_type_id).perform.success).to eq(true)++ notification = Notification.last+ notification_data = JSON.parse(notification.data)+ expect(notification_data['display_username']).to eq(user.username)+ expect(notification_data['username2']).to eq(nil)+ endendcontext "flags" do