From 82a75c00c02534fb111b2834e6ba9e8ceedf688b Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Tue, 9 Feb 2016 13:39:10 +0530 Subject: [PATCH] UX: change 'Visit Topic' to 'Visit Message' for message notification email --- config/locales/server.en.yml | 2 ++ lib/email/message_builder.rb | 4 ++-- spec/components/email/message_builder_spec.rb | 2 +- spec/mailers/user_notifications_spec.rb | 6 ++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 482721e68..0c70dfc9d 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1984,6 +1984,8 @@ en: header_instructions: '' reply_by_email: "[Visit Topic](%{base_url}%{url}) or reply to this email to respond" visit_link_to_respond: "[Visit Topic](%{base_url}%{url}) to respond" + reply_by_email_pm: "[Visit Message](%{base_url}%{url}) or reply to this email to respond" + visit_link_to_respond_pm: "[Visit Message](%{base_url}%{url}) to respond" posted_by: "Posted by %{username} on %{post_date}" diff --git a/lib/email/message_builder.rb b/lib/email/message_builder.rb index 28b38f9fa..76754654c 100644 --- a/lib/email/message_builder.rb +++ b/lib/email/message_builder.rb @@ -34,9 +34,9 @@ module Email @template_args[:respond_instructions] = '' else @template_args[:respond_instructions] = if allow_reply_by_email? - I18n.t('user_notifications.reply_by_email', @template_args) + @opts[:private_reply] ? I18n.t('user_notifications.reply_by_email_pm', @template_args) : I18n.t('user_notifications.reply_by_email', @template_args) else - I18n.t('user_notifications.visit_link_to_respond', @template_args) + @opts[:private_reply] ? I18n.t('user_notifications.visit_link_to_respond_pm', @template_args) : I18n.t('user_notifications.visit_link_to_respond', @template_args) end end end diff --git a/spec/components/email/message_builder_spec.rb b/spec/components/email/message_builder_spec.rb index 8ff2dc511..05a4abd92 100644 --- a/spec/components/email/message_builder_spec.rb +++ b/spec/components/email/message_builder_spec.rb @@ -194,7 +194,7 @@ describe Email::MessageBuilder do end it "does not add unsubscribe via email link without site setting set" do - expect(message_with_unsubscribe_via_email.body).to_not match(/mailto:reply@#{Discourse.current_hostname}\?subject=unsubscribe/) + expect(message_with_unsubscribe_via_email.body).to_not match(/mailto:reply@#{Discourse.current_hostname}\?subject=unsubscribe/) end end diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb index 5cb260787..393484954 100644 --- a/spec/mailers/user_notifications_spec.rb +++ b/spec/mailers/user_notifications_spec.rb @@ -111,6 +111,9 @@ describe UserNotifications do # subject should include category name expect(mail.subject).to match(/India/) + # 2 "visit topic" link + expect(mail.html_part.to_s.scan(/Visit Topic/).count).to eq(2) + # 2 respond to links cause we have 1 context post expect(mail.html_part.to_s.scan(/to respond/).count).to eq(2) @@ -181,6 +184,9 @@ describe UserNotifications do # subject should include "[PM]" expect(mail.subject).to match("[PM]") + # 1 "visit message" link + expect(mail.html_part.to_s.scan(/Visit Message/).count).to eq(1) + # 1 respond to link expect(mail.html_part.to_s.scan(/to respond/).count).to eq(1)