diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index d8f89efbf..e98858d6c 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -60,6 +60,7 @@ class CommentsController < ApplicationController current_user.update(checked_code_of_conduct: true) if params[:checked_code_of_conduct].present? && !current_user.checked_code_of_conduct Mention.create_all(@comment) + NotificationSubscription.create(user: current_user, notifiable_id: @comment.id, notifiable_type: "Comment", config: "all_comments") Notification.send_new_comment_notifications_without_delay(@comment) if @comment.invalid? diff --git a/spec/requests/comments_create_spec.rb b/spec/requests/comments_create_spec.rb index 457b3a7bd..5a97a9467 100644 --- a/spec/requests/comments_create_spec.rb +++ b/spec/requests/comments_create_spec.rb @@ -15,4 +15,12 @@ RSpec.describe "CommentsCreate", type: :request do } expect(Comment.last.user_id).to eq(user.id) end + + it "creates NotificationSubscription for comment" do + new_body = "NEW BODY #{rand(100)}" + post "/comments", params: { + comment: { body_markdown: new_body, commentable_id: article.id, commentable_type: "Article" } + } + expect(NotificationSubscription.last.notifiable).to eq(Comment.last) + end end