This commit is contained in:
Sam 2013-04-12 18:14:36 +10:00
parent 0054416786
commit 86b317ea73
2 changed files with 10 additions and 1 deletions

View File

@ -78,7 +78,7 @@ class PostAction < ActiveRecord::Base
if message
[:notify_moderators, :notify_user].each do |k|
if post_action_type_id == PostActionType.types[k]
target_usernames = target_moderators(user)
target_usernames = k == :notify_moderators ? target_moderators(user) : post.user.username
title = I18n.t("post_action_types.#{k}.email_title",
title: post.topic.title)
body = I18n.t("post_action_types.#{k}.email_body",

View File

@ -20,6 +20,15 @@ describe PostAction do
PostCreator.any_instance.expects(:create).returns(nil)
PostAction.act(build(:user), build(:post), PostActionType.types[:notify_moderators], "this is my special message");
end
it "sends an email to user if selected" do
PostAction.stubs(:create)
PostAction.expects(:target_moderators).returns("bob")
PostCreator.any_instance.expects(:create).returns(nil)
post = build(:post)
post.user = build(:user)
PostAction.act(build(:user), build(:post), PostActionType.types[:notify_user], "this is my special message");
end
end
describe "flag counts" do