Utilize NewComment::Send in Notification model (#5565) [deploy]

This commit is contained in:
Dainius Stankevicius 2020-01-20 23:38:42 +02:00 committed by Mac Siri
parent cde25ec8d1
commit 8c43c3d484
3 changed files with 3 additions and 10 deletions

View file

@ -43,18 +43,11 @@ class Notification < ApplicationRecord
Notifications::NotifiableActionJob.perform_later(notifiable.id, notifiable.class.name, action)
end
def send_new_comment_notifications(comment)
return if comment.commentable_type == "PodcastEpisode"
return if UserBlock.blocking?(comment.commentable.user_id, comment.user_id)
Notifications::NewCommentJob.perform_later(comment.id)
end
def send_new_comment_notifications_without_delay(comment)
return if comment.commentable_type == "PodcastEpisode"
return if UserBlock.blocking?(comment.commentable.user_id, comment.user_id)
Notifications::NewCommentJob.perform_now(comment.id)
Notifications::NewComment::Send.call(comment)
end
def send_new_badge_achievement_notification(badge_achievement)

View file

@ -187,7 +187,7 @@ RSpec.describe Notification, type: :model do
end
end
describe "#send_new_comment_notifications" do
describe "#send_new_comment_notifications_without_delay" do
let_it_be_changeable(:comment) { create(:comment, user: user2, commentable: article) }
let_it_be_readonly(:child_comment) { create(:comment, user: user3, commentable: article, parent: comment) }

View file

@ -7,7 +7,7 @@ RSpec.describe "CommentsUpdate", type: :request do
before do
sign_in user
Notification.send_new_comment_notifications(comment)
Notification.send_new_comment_notifications_without_delay(comment)
end
it "updates ordinary article with proper params" do