* Add sidekiq version of the corresponding delayed job * Switch the invocation of the delayed job from `after_create` to `after_create_commit` to avoid the race condition where the worker can be executed before the comment is persisted. Added covering spec for this change.
12 lines
279 B
Ruby
12 lines
279 B
Ruby
module Comments
|
|
class SendEmailNotificationWorker
|
|
include Sidekiq::Worker
|
|
|
|
sidekiq_options queue: :mailers
|
|
|
|
def perform(comment_id)
|
|
comment = Comment.find_by(id: comment_id)
|
|
NotifyMailer.new_reply_email(comment).deliver_now if comment
|
|
end
|
|
end
|
|
end
|