From c8c86af3bc84e98ebaffbc94907ab10b541574fa Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Wed, 27 Mar 2024 17:04:42 +0900 Subject: [PATCH 1/9] =?UTF-8?q?Newspaper=E3=82=92=E4=BD=BF=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E9=80=9A=E7=9F=A5=E3=83=97=E3=83=AD=E3=82=BB=E3=82=B9?= =?UTF-8?q?=E3=82=92=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/articles_controller.rb | 7 ++++++- app/mailers/activity_mailer.rb | 17 +++++++++++++++++ config/initializers/newspaper.rb | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index e8bdfa688fa..7185ffaa012 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -32,6 +32,7 @@ def create @article.user = current_user if @article.user.nil? set_wip if @article.save + Newspaper.publish(:create_article, { article: @article }) redirect_to redirect_url(@article), notice: notice_message(@article) else render :new @@ -41,6 +42,7 @@ def create def update set_wip if @article.update(article_params) + Newspaper.publish(:create_article, { article: @article }) redirect_to redirect_url(@article), notice: notice_message(@article) else render :edit @@ -55,7 +57,10 @@ def destroy private def set_article - @article = Article.find(params[:id]) + @article = Article.find_by(id: params[:id]) + return if @article.present? + + redirect_to articles_path, alert: '該当する記事が見つかりませんでした。' end def list_articles diff --git a/app/mailers/activity_mailer.rb b/app/mailers/activity_mailer.rb index c6db253ee7b..ded28ecf249 100644 --- a/app/mailers/activity_mailer.rb +++ b/app/mailers/activity_mailer.rb @@ -414,4 +414,21 @@ def product_update(args = {}) message end + + # required params: article, receiver + def create_article(args = {}) + @article = params&.key?(:article) ? params[:article] : args[:article] + @receiver ||= args[:receiver] + + @user = @receiver + @link_url = notification_redirector_url( + link: "/article/#{@article.id}", + kind: Notification.kinds[:create_article] + ) + subject = "新しいブログ「#{@article.title}」を#{@article.user.login_name}さんが投稿しました!" + message = mail(to: @user.email, subject:) + message.perform_deliveries = @user.mail_notification? && !@user.retired? + + message + end end diff --git a/config/initializers/newspaper.rb b/config/initializers/newspaper.rb index 1dfe2d6590d..0dd69e6b880 100644 --- a/config/initializers/newspaper.rb +++ b/config/initializers/newspaper.rb @@ -70,4 +70,6 @@ Newspaper.subscribe(:product_update, ProductUpdateNotifierForChecker.new) Newspaper.subscribe(:came_comment, CommentNotifier.new) Newspaper.subscribe(:came_comment_in_talk, CommentNotifierForAdmin.new) + + Newspaper.subscribe(:create_article, CreateArticleNotifier.new) end From 427e5dd44360b34736ce599dd3bb9aa36d6199f0 Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Wed, 27 Mar 2024 17:10:53 +0900 Subject: [PATCH 2/9] =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=88=E5=86=85?= =?UTF-8?q?=E3=83=BB=E3=83=A1=E3=83=BC=E3=83=AB=E3=81=AE=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E3=82=92=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/article.rb | 1 + app/models/create_article_notifier.rb | 19 +++++++++++++++++++ app/models/notification.rb | 3 ++- app/notifiers/activity_notifier.rb | 15 +++++++++++++++ .../activity_mailer/create_article.html.slim | 4 ++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 app/models/create_article_notifier.rb create mode 100644 app/views/activity_mailer/create_article.html.slim diff --git a/app/models/article.rb b/app/models/article.rb index 763b1cea859..f662c38dc45 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -18,6 +18,7 @@ class Article < ApplicationRecord } belongs_to :user + alias sender user include ActionView::Helpers::AssetUrlHelper THUMBNAIL_SIZE = [1200, 630].freeze diff --git a/app/models/create_article_notifier.rb b/app/models/create_article_notifier.rb new file mode 100644 index 00000000000..f93b2f5bb5a --- /dev/null +++ b/app/models/create_article_notifier.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class CreateArticleNotifier + def call(payload) + article = payload[:article] + return if article.wip? || article.published_at? + + receivers = User.students_trainees_mentors_and_admins.reject { |receiver| receiver == article.user } + send_notification(article:, receivers:) + end + + private + + def send_notification(article:, receivers:) + receivers.each do |receiver| + ActivityDelivery.with(article:, receiver:).notify(:create_article) + end + end +end diff --git a/app/models/notification.rb b/app/models/notification.rb index 3a6e2eaedbd..7e572826413 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -39,7 +39,8 @@ class Notification < ApplicationRecord signed_up: 20, regular_event_updated: 21, no_correct_answer: 22, - comebacked: 23 + comebacked: 23, + create_article: 24 } scope :unreads, -> { where(read: false) } diff --git a/app/notifiers/activity_notifier.rb b/app/notifiers/activity_notifier.rb index b4f679d6439..018683d5a55 100644 --- a/app/notifiers/activity_notifier.rb +++ b/app/notifiers/activity_notifier.rb @@ -352,4 +352,19 @@ def moved_up_event_waiting_user(params = {}) read: false ) end + + def create_article(params = {}) + params.merge!(@params) + article = params[:article] + receiver = params[:receiver] + + notification( + body: "#{article.user.login_name}さんがブログに「#{article.title}」を投稿しました。", + kind: :create_article, + receiver:, + sender: article.user, + link: Rails.application.routes.url_helpers.polymorphic_path(article), + read: false + ) + end end diff --git a/app/views/activity_mailer/create_article.html.slim b/app/views/activity_mailer/create_article.html.slim new file mode 100644 index 00000000000..855aa3d3e56 --- /dev/null +++ b/app/views/activity_mailer/create_article.html.slim @@ -0,0 +1,4 @@ += render '/notification_mailer/notification_mailer_template', + title: "#{@article.user.login_name}さんがブログに「#{@article.title}」を投稿しました。", + link_url: @link_url, link_text: 'ブログへ' do + = md2html(@article.body) From 84f91a503b4c7a165247f2201aaeebc389178781 Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Thu, 28 Mar 2024 22:27:46 +0900 Subject: [PATCH 3/9] =?UTF-8?q?WIP=E3=81=AE=E3=81=A8=E3=81=8D=E3=81=AF?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E3=82=92=E3=82=B9=E3=82=AD=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E5=87=A6=E7=90=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/create_article_notifier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/create_article_notifier.rb b/app/models/create_article_notifier.rb index f93b2f5bb5a..4e7aa770148 100644 --- a/app/models/create_article_notifier.rb +++ b/app/models/create_article_notifier.rb @@ -3,7 +3,7 @@ class CreateArticleNotifier def call(payload) article = payload[:article] - return if article.wip? || article.published_at? + return if article.wip? receivers = User.students_trainees_mentors_and_admins.reject { |receiver| receiver == article.user } send_notification(article:, receivers:) From a84dfe405ca2b901d71e0c60fa836aa767b06c1f Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Fri, 29 Mar 2024 18:41:42 +0900 Subject: [PATCH 4/9] =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=88=E5=86=85?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E3=83=BB=E3=83=A1=E3=83=BC=E3=83=AB=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/deliveries/activity_delivery_test.rb | 23 +++++++++ test/mailers/activity_mailer_test.rb | 62 +++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/test/deliveries/activity_delivery_test.rb b/test/deliveries/activity_delivery_test.rb index 8c634c6f100..d66f6e719b6 100644 --- a/test/deliveries/activity_delivery_test.rb +++ b/test/deliveries/activity_delivery_test.rb @@ -452,4 +452,27 @@ class ActivityDeliveryTest < ActiveSupport::TestCase ActivityDelivery.with(**params).notify(:came_comment) end end + + test '.notify(:create_article)' do + params = { + article: articles(:article1), + receiver: users(:kimura) + } + + assert_difference -> { AbstractNotifier::Testing::Driver.deliveries.count }, 1 do + ActivityDelivery.notify!(:create_article, **params) + end + + assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 1 do + ActivityDelivery.notify(:create_article, **params) + end + + assert_difference -> { AbstractNotifier::Testing::Driver.deliveries.count }, 1 do + ActivityDelivery.with(**params).notify!(:create_article) + end + + assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 1 do + ActivityDelivery.with(**params).notify(:create_article) + end + end end diff --git a/test/mailers/activity_mailer_test.rb b/test/mailers/activity_mailer_test.rb index b4f8e4489e2..8bd53bfe796 100644 --- a/test/mailers/activity_mailer_test.rb +++ b/test/mailers/activity_mailer_test.rb @@ -1115,4 +1115,66 @@ class ActivityMailerTest < ActionMailer::TestCase assert_empty ActionMailer::Base.deliveries end + + test 'create_article notifies students, trainees, mentors, and admins' do + target_users = %i[hatsuno kensyu mentormentaro machida] + + target_users.each do |target_user| + article = articles(:article1) + receiver = users(target_user) + + ActivityMailer.create_article( + article:, + receiver: + ).deliver_now + + assert_not ActionMailer::Base.deliveries.empty? + email = ActionMailer::Base.deliveries.last + query = CGI.escapeHTML({ kind: 24, link: "/article/#{article.id}" }.to_param) + assert_equal ['noreply@bootcamp.fjord.jp'], email.from + assert_equal [receiver.email], email.to + assert_equal "新しいブログ「#{article.title}」を#{article.user.login_name}さんが投稿しました!", email.subject + assert_match(%r{ブログへ}, email.body.to_s) + end + end + + test 'create_article notifies students, trainees, mentors, and admins with params' do + target_users = %i[hatsuno kensyu mentormentaro machida] + + target_users.each do |target_user| + article = articles(:article1) + receiver = users(target_user) + + mailer = ActivityMailer.with( + article:, + receiver: + ).create_article + + perform_enqueued_jobs do + mailer.deliver_later + end + + assert_not ActionMailer::Base.deliveries.empty? + email = ActionMailer::Base.deliveries.last + query = CGI.escapeHTML({ kind: 24, link: "/article/#{article.id}" }.to_param) + assert_equal ['noreply@bootcamp.fjord.jp'], email.from + assert_equal [receiver.email], email.to + assert_equal "新しいブログ「#{article.title}」を#{article.user.login_name}さんが投稿しました!", email.subject + assert_match(%r{ブログへ}, email.body.to_s) + end + end + + test 'create_article notifies students, trainees, mentors, and admins with mail_notification off' do + article = articles(:article1) + receiver = users(:mentormentaro) + receiver.update(mail_notification: false) + + ActivityMailer.create_article( + sender: article.user, + receiver:, + article: + ).deliver_now + + assert_empty ActionMailer::Base.deliveries + end end From 9eb1e363292106d1f6afe91afa6fdfff85a54501 Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Tue, 2 Apr 2024 16:50:51 +0900 Subject: [PATCH 5/9] =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=83=AB=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E3=81=AE=E3=83=97=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/mailers/previews/activity_mailer_preview.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/mailers/previews/activity_mailer_preview.rb b/test/mailers/previews/activity_mailer_preview.rb index 98b4aa8ef9e..0d28d39bcf8 100644 --- a/test/mailers/previews/activity_mailer_preview.rb +++ b/test/mailers/previews/activity_mailer_preview.rb @@ -170,4 +170,12 @@ def no_correct_answer ActivityMailer.with(question:, receiver:).no_correct_answer end + + def create_article + article = Article.find(ActiveRecord::FixtureSet.identify(:article1)) + receiver = User.find(ActiveRecord::FixtureSet.identify(:kimura)) + user = User.find(article.user_id) + + ActivityMailer.with(article:, receiver:, sender: user).create_article + end end From ad2b540ad6e4ade81870084a81767ec66c25b1ac Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Tue, 2 Apr 2024 22:50:15 +0900 Subject: [PATCH 6/9] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=83=BB=E3=82=AF=E3=83=A9=E3=82=B9=E5=90=8D=E3=82=92=E4=BB=96?= =?UTF-8?q?=E3=81=AE=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AE=E3=83=AB?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=81=A8=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/{create_article_notifier.rb => article_notifier.rb} | 2 +- config/initializers/newspaper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename app/models/{create_article_notifier.rb => article_notifier.rb} (94%) diff --git a/app/models/create_article_notifier.rb b/app/models/article_notifier.rb similarity index 94% rename from app/models/create_article_notifier.rb rename to app/models/article_notifier.rb index 4e7aa770148..f85ee675170 100644 --- a/app/models/create_article_notifier.rb +++ b/app/models/article_notifier.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateArticleNotifier +class ArticleNotifier def call(payload) article = payload[:article] return if article.wip? diff --git a/config/initializers/newspaper.rb b/config/initializers/newspaper.rb index 0dd69e6b880..d1f23f7de64 100644 --- a/config/initializers/newspaper.rb +++ b/config/initializers/newspaper.rb @@ -71,5 +71,5 @@ Newspaper.subscribe(:came_comment, CommentNotifier.new) Newspaper.subscribe(:came_comment_in_talk, CommentNotifierForAdmin.new) - Newspaper.subscribe(:create_article, CreateArticleNotifier.new) + Newspaper.subscribe(:create_article, ArticleNotifier.new) end From 12b2aa8567e9c25c0ca8ea7b86e9226915a9373e Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Tue, 2 Apr 2024 23:19:17 +0900 Subject: [PATCH 7/9] =?UTF-8?q?=E3=80=90=E4=BB=96=E3=81=AE=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E3=81=A8=E7=B5=B1=E4=B8=80=E3=80=91=E3=83=96=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=81=8C=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=80=81=E9=80=9A=E7=9F=A5=E3=81=AE=E3=83=AA?= =?UTF-8?q?=E3=83=B3=E3=82=AF=E3=81=8B=E3=82=89=E8=A9=B3=E7=B4=B0=E3=81=B8?= =?UTF-8?q?=E9=A3=9B=E3=81=B6=E3=81=A8=E3=83=96=E3=83=AD=E3=82=B0=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=81=AB=E3=83=AA=E3=83=80=E3=82=A4=E3=83=AC=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=81=99=E3=82=8B=E6=8C=99=E5=8B=95=E3=81=8B=E3=82=89?= =?UTF-8?q?=E3=80=81=E3=82=B5=E3=82=A4=E3=83=88=E5=86=85=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E8=87=AA=E4=BD=93=E3=82=92=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/articles_controller.rb | 1 + app/models/article_notification_destroyer.rb | 8 ++++++++ config/initializers/newspaper.rb | 1 + 3 files changed, 10 insertions(+) create mode 100644 app/models/article_notification_destroyer.rb diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index 7185ffaa012..54e2052b965 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -51,6 +51,7 @@ def update def destroy @article.destroy + Newspaper.publish(:destroy_article, { article: @article }) redirect_to articles_url, notice: '記事を削除しました' end diff --git a/app/models/article_notification_destroyer.rb b/app/models/article_notification_destroyer.rb new file mode 100644 index 00000000000..e8537d32aad --- /dev/null +++ b/app/models/article_notification_destroyer.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class ArticleNotificationDestroyer + def call(payload) + article = payload[:article] + Notification.where(link: "/articles/#{article.id}").destroy_all + end +end diff --git a/config/initializers/newspaper.rb b/config/initializers/newspaper.rb index d1f23f7de64..3fe9d9115c2 100644 --- a/config/initializers/newspaper.rb +++ b/config/initializers/newspaper.rb @@ -72,4 +72,5 @@ Newspaper.subscribe(:came_comment_in_talk, CommentNotifierForAdmin.new) Newspaper.subscribe(:create_article, ArticleNotifier.new) + Newspaper.subscribe(:destroy_article, ArticleNotificationDestroyer.new) end From 75b78053af8b1279f143efb55ab352e2a7fc6fb7 Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Wed, 3 Apr 2024 16:24:13 +0900 Subject: [PATCH 8/9] =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=83=AB=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E3=81=AE=E3=83=AA=E3=83=B3=E3=82=AF=E3=81=8B=E3=82=89?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C=E3=81=9F=E3=83=96=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=81=AB=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9=E3=81=97?= =?UTF-8?q?=E3=81=9F=E5=A0=B4=E5=90=88404=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/articles_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index 54e2052b965..3cd53ef7d76 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -58,10 +58,7 @@ def destroy private def set_article - @article = Article.find_by(id: params[:id]) - return if @article.present? - - redirect_to articles_path, alert: '該当する記事が見つかりませんでした。' + @article = Article.find(params[:id]) end def list_articles From ff33b8f4cd2f19fda930b00d3cc8e8f07bd7f087 Mon Sep 17 00:00:00 2001 From: hirano-vm4 Date: Wed, 3 Apr 2024 19:39:26 +0900 Subject: [PATCH 9/9] =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=83=AB=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E3=81=AB=E5=90=AB=E3=81=BE=E3=82=8C=E3=82=8B=E3=83=96?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=81=B8=E3=81=AE=E3=83=AA=E3=83=B3=E3=82=AF?= =?UTF-8?q?URL=E3=81=AE=E3=82=BF=E3=82=A4=E3=83=9D=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mailers/activity_mailer.rb | 2 +- test/mailers/activity_mailer_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/mailers/activity_mailer.rb b/app/mailers/activity_mailer.rb index ded28ecf249..5923ba19c83 100644 --- a/app/mailers/activity_mailer.rb +++ b/app/mailers/activity_mailer.rb @@ -422,7 +422,7 @@ def create_article(args = {}) @user = @receiver @link_url = notification_redirector_url( - link: "/article/#{@article.id}", + link: "/articles/#{@article.id}", kind: Notification.kinds[:create_article] ) subject = "新しいブログ「#{@article.title}」を#{@article.user.login_name}さんが投稿しました!" diff --git a/test/mailers/activity_mailer_test.rb b/test/mailers/activity_mailer_test.rb index 8bd53bfe796..01914dbcb81 100644 --- a/test/mailers/activity_mailer_test.rb +++ b/test/mailers/activity_mailer_test.rb @@ -1130,7 +1130,7 @@ class ActivityMailerTest < ActionMailer::TestCase assert_not ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - query = CGI.escapeHTML({ kind: 24, link: "/article/#{article.id}" }.to_param) + query = CGI.escapeHTML({ kind: 24, link: "/articles/#{article.id}" }.to_param) assert_equal ['noreply@bootcamp.fjord.jp'], email.from assert_equal [receiver.email], email.to assert_equal "新しいブログ「#{article.title}」を#{article.user.login_name}さんが投稿しました!", email.subject @@ -1156,7 +1156,7 @@ class ActivityMailerTest < ActionMailer::TestCase assert_not ActionMailer::Base.deliveries.empty? email = ActionMailer::Base.deliveries.last - query = CGI.escapeHTML({ kind: 24, link: "/article/#{article.id}" }.to_param) + query = CGI.escapeHTML({ kind: 24, link: "/articles/#{article.id}" }.to_param) assert_equal ['noreply@bootcamp.fjord.jp'], email.from assert_equal [receiver.email], email.to assert_equal "新しいブログ「#{article.title}」を#{article.user.login_name}さんが投稿しました!", email.subject