From c8b770254790fc5d8b5d504997b33dbf9e23f434 Mon Sep 17 00:00:00 2001 From: Pablo Brasero Date: Wed, 11 Mar 2026 16:40:56 +0000 Subject: [PATCH] Convert `UserMailer#diary_comment_notification` to new style --- app/controllers/diary_comments_controller.rb | 2 +- app/mailers/user_mailer.rb | 4 +++- test/mailers/previews/user_mailer_preview.rb | 2 +- test/mailers/user_mailer_test.rb | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/diary_comments_controller.rb b/app/controllers/diary_comments_controller.rb index e98d93a09..1b4b4c370 100644 --- a/app/controllers/diary_comments_controller.rb +++ b/app/controllers/diary_comments_controller.rb @@ -22,7 +22,7 @@ class DiaryCommentsController < ApplicationController # Notify current subscribers of the new comment @diary_entry.subscribers.visible.each do |user| - UserMailer.diary_comment_notification(@diary_comment, user).deliver_later if current_user != user + UserMailer.with(:comment => @diary_comment, :recipient => user).diary_comment_notification.deliver_later if current_user != user end # Add the commenter to the subscribers if necessary diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index bd686eaec..012c3473a 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -98,7 +98,9 @@ class UserMailer < ApplicationMailer end end - def diary_comment_notification(comment, recipient) + def diary_comment_notification + comment, recipient = params.fetch_values(:comment, :recipient) + with_recipient_locale recipient do @to_user = recipient.display_name @from_user = comment.user.display_name diff --git a/test/mailers/previews/user_mailer_preview.rb b/test/mailers/previews/user_mailer_preview.rb index 379f0079b..7e6578559 100644 --- a/test/mailers/previews/user_mailer_preview.rb +++ b/test/mailers/previews/user_mailer_preview.rb @@ -63,7 +63,7 @@ class UserMailerPreview < ActionMailer::Preview recipient = create(:user, :languages => [I18n.locale]) diary_entry = create(:diary_entry) diary_comment = create(:diary_comment, :diary_entry => diary_entry) - UserMailer.diary_comment_notification(diary_comment, recipient) + UserMailer.with(:comment => diary_comment, :recipient => recipient).diary_comment_notification end def follow_notification diff --git a/test/mailers/user_mailer_test.rb b/test/mailers/user_mailer_test.rb index b9c382573..dc6126a06 100644 --- a/test/mailers/user_mailer_test.rb +++ b/test/mailers/user_mailer_test.rb @@ -104,7 +104,7 @@ class UserMailerTest < ActionMailer::TestCase other_user = create(:user) diary_entry = create(:diary_entry, :user => user) diary_comment = create(:diary_comment, :diary_entry => diary_entry) - email = UserMailer.diary_comment_notification(diary_comment, other_user) + email = UserMailer.with(:comment => diary_comment, :recipient => other_user).diary_comment_notification body = parse_html_body(email) url = url_helpers.diary_entry_url(user, diary_entry) -- 2.39.5