From fe3a69c27122e25e4b459cb526f0302e92173d4e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 7 Aug 2013 13:02:49 -0400 Subject: [PATCH] Private message emails now include the history --- app/mailers/user_notifications.rb | 39 ++++++++++++++----------------- app/models/user_email_observer.rb | 18 ++++++++++---- config/locales/server.cs.yml | 13 +---------- config/locales/server.da.yml | 13 +---------- config/locales/server.de.yml | 13 +---------- config/locales/server.en.yml | 12 +--------- config/locales/server.es.yml | 13 +---------- config/locales/server.fr.yml | 13 +---------- config/locales/server.id.yml | 13 +---------- config/locales/server.it.yml | 13 +---------- config/locales/server.ko.yml | 13 +---------- config/locales/server.nl.yml | 13 +---------- config/locales/server.pseudo.yml | 12 +--------- config/locales/server.pt.yml | 13 +---------- config/locales/server.pt_BR.yml | 11 +-------- config/locales/server.ru.yml | 11 +-------- config/locales/server.sv.yml | 13 +---------- config/locales/server.zh_CN.yml | 13 +---------- config/locales/server.zh_TW.yml | 13 +---------- lib/post_creator.rb | 18 ++++---------- spec/models/topic_spec.rb | 23 ------------------ 21 files changed, 53 insertions(+), 260 deletions(-) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index 2cd2726515..e22aa32da7 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -28,22 +28,6 @@ class UserNotifications < ActionMailer::Base build_email(user.email, template: "user_notifications.forgot_password", email_token: opts[:email_token]) end - def private_message(user, opts={}) - post = opts[:post] - build_email user.email, - template: "user_notifications.private_message", - message: post.raw, - url: post.url, - subject_prefix: "[#{I18n.t('private_message_abbrev')}] #{post.post_number != 1 ? 're: ' : ''}", - topic_title: post.topic.title, - private_message_from: post.user.name, - from_alias: I18n.t(:via, username: post.user.name, site_name: SiteSetting.title), - add_unsubscribe_link: true, - allow_reply_by_email: true, - post_id: post.id, - topic_id: post.topic_id - end - def digest(user, opts={}) @user = user @base_url = Discourse.base_url @@ -92,6 +76,15 @@ class UserNotifications < ActionMailer::Base notification_email(user, opts) end + def user_private_message(user, opts) + opts[:allow_reply_by_email] = true + + # We use the 'user_posted' event when you are emailed a post in a PM. + opts[:notification_type] = 'posted' + + notification_email(user, opts) + end + protected def email_post_markdown(post) @@ -112,7 +105,7 @@ class UserNotifications < ActionMailer::Base return unless @post = opts[:post] username = @notification.data_hash[:display_username] - notification_type = Notification.types[@notification.notification_type].to_s + notification_type = opts[:notification_type] || Notification.types[@notification.notification_type].to_s context = "" context_posts = Post.where(topic_id: @post.topic_id) @@ -128,11 +121,14 @@ class UserNotifications < ActionMailer::Base end html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render( - template: 'email/notification', - format: :html, - locals: { context_posts: context_posts, post: @post } + template: 'email/notification', + format: :html, + locals: { context_posts: context_posts, post: @post } ) + if @post.topic.private_message? + opts[:subject_prefix] = "[#{I18n.t('private_message_abbrev')}] " + end email_opts = { topic_title: @notification.data_hash[:topic_title], @@ -146,7 +142,8 @@ class UserNotifications < ActionMailer::Base allow_reply_by_email: opts[:allow_reply_by_email], template: "user_notifications.user_#{notification_type}", html_override: html, - style: :notification + style: :notification, + subject_prefix: opts[:subject_prefix] || '' } # If we have a display name, change the from address diff --git a/app/models/user_email_observer.rb b/app/models/user_email_observer.rb index aa36cfd01a..23c3999b0c 100644 --- a/app/models/user_email_observer.rb +++ b/app/models/user_email_observer.rb @@ -16,6 +16,7 @@ class UserEmailObserver < ActiveRecord::Observer # Delegate to email_user_{{NOTIFICATION_TYPE}} if exists email_method = :"email_user_#{notification_type.to_s}" + send(email_method, notification) if respond_to?(email_method) end end @@ -57,12 +58,21 @@ class UserEmailObserver < ActiveRecord::Observer notification_id: notification.id) end + def email_user_private_message(notification) + return unless (notification.user.email_direct? && notification.user.email_private_messages?) + Jobs.enqueue_in(SiteSetting.email_time_window_mins.minutes, + :user_email, + type: :user_private_message, + user_id: notification.user_id, + notification_id: notification.id) + end + def email_user_invited_to_private_message(notification) return unless notification.user.email_direct? Jobs.enqueue_in(SiteSetting.email_time_window_mins.minutes, - :user_email, - type: :user_invited_to_private_message, - user_id: notification.user_id, - notification_id: notification.id) + :user_email, + type: :user_invited_to_private_message, + user_id: notification.user_id, + notification_id: notification.id) end end diff --git a/config/locales/server.cs.yml b/config/locales/server.cs.yml index 03fcd05c41..5b564833c8 100644 --- a/config/locales/server.cs.yml +++ b/config/locales/server.cs.yml @@ -1016,7 +1016,7 @@ cs: Prosím navšivte tento odkaz, chcete-li odpovědět: %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] %{username} přispěl do tématu '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} přispěl do tématu '%{topic_title}'" text_body_template: | %{username} přispěl do tématu '%{topic_title}' na %{site_name}: @@ -1036,17 +1036,6 @@ cs: from: "souhrn z %{site_name}" read_more: "Číst dále" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{from} vám právě zaslal soukromou zprávu - - --- - %{message} - - --- - Prosím navšivte tento odkaz, chcete-li odpovědět: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Obnovení hesla" text_body_template: | diff --git a/config/locales/server.da.yml b/config/locales/server.da.yml index 95fcde2a34..3ef3974928 100644 --- a/config/locales/server.da.yml +++ b/config/locales/server.da.yml @@ -714,7 +714,7 @@ da: Klik her for at svare: %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] %{username} skrev et indlæg i emnet '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} skrev et indlæg i emnet '%{topic_title}'" text_body_template: | %{username} skrev et indlæg i emnet '%{topic_title}' på %{site_name}: @@ -733,17 +733,6 @@ da: click_here: "klik her" from: "%{site_name} opsummering" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} har sendt dig en privat besked - - --- - %{message} - - --- - Klik her for at svare: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Nulstil kodeord" text_body_template: | diff --git a/config/locales/server.de.yml b/config/locales/server.de.yml index c470072dc7..7138c09279 100644 --- a/config/locales/server.de.yml +++ b/config/locales/server.de.yml @@ -903,7 +903,7 @@ de: Um zu antworten, besuche den folgenden Link: %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] %{username} hat auf '%{topic_title}' geantwortet" + subject_template: "[%{site_name}] %{subject_prefix}%{username} hat auf '%{topic_title}' geantwortet" text_body_template: | %{username} hat in '%{topic_title}' auf %{site_name} geantwortet: @@ -923,17 +923,6 @@ de: from: "%{site_name} Übersicht" read_more: "Weiterlesen" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} hat Die eine private Nachricht geschickt: - - --- - %{message} - - --- - Um zu antworten, besuche den folgenden Link: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Passwort zurückgesetzt" text_body_template: | diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 3fae19782d..35372e1b3e 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -985,7 +985,7 @@ en: %{respond_instructions} user_posted: - subject_template: "[%{site_name}] new post in '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}new post in '%{topic_title}'" text_body_template: | %{message} @@ -1004,16 +1004,6 @@ en: from: "%{site_name} digest" read_more: "Read More" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} just sent you a private message - - %{message} - - --- - %{respond_instructions} - forgot_password: subject_template: "[%{site_name}] Password reset" text_body_template: | diff --git a/config/locales/server.es.yml b/config/locales/server.es.yml index 1f76374ef6..db26ed8a60 100644 --- a/config/locales/server.es.yml +++ b/config/locales/server.es.yml @@ -694,7 +694,7 @@ es: Por favor visita este link para contestar: %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] %{username} posteó en '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} posteó en '%{topic_title}'" text_body_template: | %{username} posteó en '%{topic_title}' en %{site_name}: @@ -713,17 +713,6 @@ es: click_here: "click aquí" from: "%{site_name} digest" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} te acaba de mandar un mensaje privado - - --- - %{message} - - --- - Por favor visita este link para contestar: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Resetear el password" text_body_template: | diff --git a/config/locales/server.fr.yml b/config/locales/server.fr.yml index f0f3ece742..e9ceb93200 100644 --- a/config/locales/server.fr.yml +++ b/config/locales/server.fr.yml @@ -883,7 +883,7 @@ fr: Merci de suivre ce lien pour répondre : %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] nouveau message dans '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}nouveau message dans '%{topic_title}'" text_body_template: | %{username} à répondu à '%{topic_title}' sur %{site_name}: @@ -902,17 +902,6 @@ fr: click_here: "cliquez ici" from: "Résumé de %{site_name}" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{from} vous a envoyé un message privé - - --- - %{message} - - --- - Merci de suivre ce lien pour répondre : %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Réinitialisation du mot de passe" text_body_template: | diff --git a/config/locales/server.id.yml b/config/locales/server.id.yml index 6b98fd065e..1e22262568 100644 --- a/config/locales/server.id.yml +++ b/config/locales/server.id.yml @@ -711,7 +711,7 @@ id: Please visit this link to respond: %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] %{username} posted in '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} posted in '%{topic_title}'" text_body_template: | %{username} posted in '%{topic_title}' on %{site_name}: @@ -730,17 +730,6 @@ id: click_here: "click here" from: "%{site_name} digest" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} just sent you a private message - - --- - %{message} - - --- - Please visit this link to respond: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Password reset" text_body_template: | diff --git a/config/locales/server.it.yml b/config/locales/server.it.yml index 128033b80e..a95fa0fa7e 100644 --- a/config/locales/server.it.yml +++ b/config/locales/server.it.yml @@ -840,7 +840,7 @@ it: Perfavore visita questo link per rispondere: %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] %{username} ha postato in '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} ha postato in '%{topic_title}'" text_body_template: | %{username} ha postato in '%{topic_title}' su %{site_name}: @@ -859,17 +859,6 @@ it: click_here: "clicca qui" from: "%{site_name} riepilogo" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} ti ha appena inviato un messaggio privato - - --- - %{message} - - --- - Perfavore visita questo link per rispondere: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Reset Password" text_body_template: | diff --git a/config/locales/server.ko.yml b/config/locales/server.ko.yml index 0905e64d0b..4f5179ac3b 100644 --- a/config/locales/server.ko.yml +++ b/config/locales/server.ko.yml @@ -856,7 +856,7 @@ ko: Please visit this link to respond: %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] %{username} posted in '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} posted in '%{topic_title}'" text_body_template: | %{username} posted in '%{topic_title}' on %{site_name}: @@ -875,17 +875,6 @@ ko: click_here: "click here" from: "%{site_name} digest" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} just sent you a private message - - --- - %{message} - - --- - Please visit this link to respond: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Password reset" text_body_template: | diff --git a/config/locales/server.nl.yml b/config/locales/server.nl.yml index 08c08622b4..7edfe3b3bc 100644 --- a/config/locales/server.nl.yml +++ b/config/locales/server.nl.yml @@ -974,7 +974,7 @@ nl: %{respond_instructions} user_posted: - subject_template: "[%{site_name}] %{username} nieuw bericht in '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} nieuw bericht in '%{topic_title}'" text_body_template: | %{username} schreef een bericht in '%{topic_title}' op %{site_name}: @@ -994,17 +994,6 @@ nl: click_here: klik hier from: "%{site_name} Digest" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{from} heeft je net een privé-bericht gestuurd - - --- - %{message} - - --- - %{respond_instructions} - forgot_password: subject_template: "[%{site_name}] Wachtwoord herstellen" text_body_template: | diff --git a/config/locales/server.pseudo.yml b/config/locales/server.pseudo.yml index 29915fa65d..41d8782ba9 100644 --- a/config/locales/server.pseudo.yml +++ b/config/locales/server.pseudo.yml @@ -1144,7 +1144,7 @@ pseudo: %{respond_instructions} ]] user_posted: - subject_template: '[[ [%{site_name}] %{username} ƿóšťéď íɳ ''%{topic_title}'' + subject_template: '[[ [%{site_name}] %{subject_prefix}%{username} ƿóšťéď íɳ ''%{topic_title}'' ]]' text_body_template: |- [[ %{username} ƿóšťéď íɳ '%{topic_title}' óɳ %{site_name}: @@ -1167,17 +1167,7 @@ pseudo: click_here: '[[ čłíčǩ ĥéřé ]]' from: '[[ %{site_name} ďíǧéšť ]]' read_more: '[[ Řéáď Ϻóřé ]]' - private_message: - subject_template: '[[ [%{site_name}] %{subject_prefix}%{topic_title} ]]' - text_body_template: |- - [[ %{private_message_from} ʲůšť šéɳť ýóů á ƿříνáťé ɱéššáǧé - --- - %{message} - - --- - %{respond_instructions} - ]] forgot_password: subject_template: '[[ [%{site_name}] Рáššŵóřď řéšéť ]]' text_body_template: |- diff --git a/config/locales/server.pt.yml b/config/locales/server.pt.yml index eeda18c50b..3884734062 100644 --- a/config/locales/server.pt.yml +++ b/config/locales/server.pt.yml @@ -622,7 +622,7 @@ pt: Por-favor visita este link para responder: %{base_url}%{url} user_mentioned: - subject_template: "[%{site_name}] %{username} mencionou-te em '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} mencionou-te em '%{topic_title}'" text_body_template: | %{username} mencionou-te em '%{topic_title}' em %{site_name}: @@ -640,17 +640,6 @@ pt: new_topics: "Tópicos novos:" unsubscribe: "Este email sumário é enviado como uma notificação de cortesia de %{site_link} quando não te vemos há de 7 dias.\nCaso quiseres desliga-lo ou alterar as configurações de email, %{unsubscribe_link}." - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{from} acabou de te enviar uma mensagem privada - - --- - %{message} - - --- - Por-favor vista este link para responder: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Repor password" text_body_template: | diff --git a/config/locales/server.pt_BR.yml b/config/locales/server.pt_BR.yml index 2473cc9347..030d9bb2b9 100644 --- a/config/locales/server.pt_BR.yml +++ b/config/locales/server.pt_BR.yml @@ -865,7 +865,7 @@ pt_BR: --- %{respond_instructions} user_posted: - subject_template: "[%{site_name}] nova postagem no tópico '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}nova postagem no tópico '%{topic_title}'" text_body_template: | %{username} postou no tópico '%{topic_title}' de %{site_name}: @@ -883,16 +883,7 @@ pt_BR: click_here: "clique aqui" from: "resumo de %{site_name}" read_more: "Leia Mais" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} enviou uma mensagem particular para você - --- - %{message} - - --- - %{respond_instructions} forgot_password: subject_template: "[%{site_name}] Redefinição de senha" text_body_template: | diff --git a/config/locales/server.ru.yml b/config/locales/server.ru.yml index 8d4503e2c7..d7e98e81fe 100644 --- a/config/locales/server.ru.yml +++ b/config/locales/server.ru.yml @@ -984,7 +984,7 @@ ru: %{respond_instructions} user_posted: - subject_template: "[%{site_name}] новое сообщение в теме '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}новое сообщение в теме '%{topic_title}'" text_body_template: | %{message} @@ -1005,15 +1005,6 @@ ru: click_here: нажмите здесь from: 'Cводка новостей сайта %{site_name}' read_more: Читать еще - private_message: - subject_template: '[%{site_name}] %{subject_prefix}%{topic_title}' - text_body_template: | - %{private_message_from} отправил(а) вам личное сообщение - - %{message} - - --- - %{respond_instructions} forgot_password: subject_template: '[%{site_name}] Сброс пароля' diff --git a/config/locales/server.sv.yml b/config/locales/server.sv.yml index dc8a55ab5c..7ce4a61f84 100644 --- a/config/locales/server.sv.yml +++ b/config/locales/server.sv.yml @@ -769,7 +769,7 @@ sv: Please visit this link to respond: %{base_url}%{url} user_posted: - subject_template: "[%{site_name}] %{username} posted in '%{topic_title}'" + subject_template: "[%{site_name}] %{subject_prefix}%{username} posted in '%{topic_title}'" text_body_template: | %{username} posted in '%{topic_title}' on %{site_name}: @@ -788,17 +788,6 @@ sv: click_here: "click here" from: "%{site_name} digest" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} just sent you a private message - - --- - %{message} - - --- - Please visit this link to respond: %{base_url}%{url} - forgot_password: subject_template: "[%{site_name}] Password reset" text_body_template: | diff --git a/config/locales/server.zh_CN.yml b/config/locales/server.zh_CN.yml index 7f8153bddc..5361b3178f 100644 --- a/config/locales/server.zh_CN.yml +++ b/config/locales/server.zh_CN.yml @@ -857,7 +857,7 @@ zh_CN: 请访问 %{base_url}%{url} 来回复。 user_posted: - subject_template: "[%{site_name}] %{username} 在 '%{topic_title}' 主题发表了帖子" + subject_template: "[%{site_name}] %{subject_prefix}%{username} 在 '%{topic_title}' 主题发表了帖子" text_body_template: | %{username} 在 %{site_name} 的 '%{topic_title}' 主题中发表了帖子: @@ -876,17 +876,6 @@ zh_CN: click_here: "点击此处" from: "%{site_name} 摘要" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} 刚刚发送了一条私信给你 - - --- - %{message} - - --- - 请访问 %{base_url}%{url} 来回复。 - forgot_password: subject_template: "[%{site_name}] 密码重置" text_body_template: | diff --git a/config/locales/server.zh_TW.yml b/config/locales/server.zh_TW.yml index b959bf449a..6ecdf10c96 100644 --- a/config/locales/server.zh_TW.yml +++ b/config/locales/server.zh_TW.yml @@ -840,7 +840,7 @@ zh_TW: 請訪問 %{base_url}%{url} 來回複。 user_posted: - subject_template: "[%{site_name}] %{username} 在 '%{topic_title}' 主題發表了帖子" + subject_template: "[%{site_name}] %{subject_prefix}%{username} 在 '%{topic_title}' 主題發表了帖子" text_body_template: | %{username} 在 %{site_name} 的 '%{topic_title}' 主題中發表了帖子: @@ -859,17 +859,6 @@ zh_TW: click_here: "點擊此處" from: "%{site_name} 摘要" - private_message: - subject_template: "[%{site_name}] %{subject_prefix}%{topic_title}" - text_body_template: | - %{private_message_from} 剛剛發送了一條私信給你 - - --- - %{message} - - --- - 請訪問 %{base_url}%{url} 來回複。 - forgot_password: subject_template: "[%{site_name}] 密碼重置" text_body_template: | diff --git a/lib/post_creator.rb b/lib/post_creator.rb index dbde279b48..f159f89201 100644 --- a/lib/post_creator.rb +++ b/lib/post_creator.rb @@ -64,7 +64,7 @@ class PostCreator save_post extract_links store_unique_post_key - send_notifications_for_private_message + consider_clearing_flags track_topic update_topic_stats update_user_counts @@ -216,19 +216,9 @@ class PostCreator end end - def send_notifications_for_private_message - # send a mail to notify users in case of a private message - if @topic.private_message? - @topic.allowed_users.where(["users.email_private_messages = true and users.id != ?", @user.id]).each do |u| - Jobs.enqueue_in(SiteSetting.email_time_window_mins.minutes, - :user_email, - type: :private_message, - user_id: u.id, - post_id: @post.id - ) - end - - clear_possible_flags(@topic) if @post.post_number > 1 && @topic.user_id != @post.user_id + def consider_clearing_flags + if @topic.private_message? && @post.post_number > 1 && @topic.user_id != @post.user_id + clear_possible_flags(@topic) end end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index 3f2cb5147c..e4c84ccd18 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -303,29 +303,6 @@ describe Topic do end - context "other user" do - - before do - # let! is weird, this test need a refactor - t = topic - end - - let(:creator) { PostCreator.new(topic.user, raw: Fabricate.build(:post).raw, topic_id: topic.id )} - - it "sends the other user an email when there's a new post" do - UserNotifications.expects(:private_message).with(coding_horror, has_key(:post)) - creator.create - end - - it "doesn't send the user an email when they have them disabled" do - coding_horror.update_column(:email_private_messages, false) - UserNotifications.expects(:private_message).with(coding_horror, has_key(:post)).never - creator.create - end - - end - - end