Create comments notification subscription upon creation (#3167)
* Create comments notification subscription upon creation * Fix test
This commit is contained in:
parent
c81bc8e66f
commit
85e3be1f48
2 changed files with 9 additions and 0 deletions
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue