FIX: auto-message shouldn't generate notifications
This commit is contained in:
parent
6cd4330335
commit
c8631a7a8b
|
@ -187,7 +187,7 @@ class PostAction < ActiveRecord::Base
|
|||
return if moderator_already_replied?(related_post.topic, moderator)
|
||||
message_key = "flags_dispositions.#{disposition}"
|
||||
message_key << "_and_deleted" if delete_post
|
||||
related_post.topic.add_moderator_post(moderator, I18n.t(message_key))
|
||||
related_post.topic.add_moderator_post(moderator, I18n.t(message_key), skip_notifications: true)
|
||||
end
|
||||
|
||||
def moderator_already_replied?(topic, moderator)
|
||||
|
|
|
@ -488,6 +488,7 @@ class Topic < ActiveRecord::Base
|
|||
raw: text,
|
||||
post_type: Post.types[:moderator_action],
|
||||
no_bump: opts[:bump].blank?,
|
||||
skip_notifications: opts[:skip_notifications],
|
||||
topic_id: self.id)
|
||||
new_post = creator.create
|
||||
increment!(:moderator_posts_count)
|
||||
|
|
|
@ -96,7 +96,7 @@ class PostCreator
|
|||
|
||||
if @post && @post.errors.empty?
|
||||
publish
|
||||
PostAlerter.post_created(@post) unless @opts[:import_mode]
|
||||
PostAlerter.post_created(@post) unless @opts[:import_mode] || @opts[:skip_notifications]
|
||||
|
||||
track_latest_on_category
|
||||
enqueue_jobs
|
||||
|
|
|
@ -28,7 +28,7 @@ describe PostAction do
|
|||
mod = moderator
|
||||
Group.refresh_automatic_groups!
|
||||
|
||||
action = PostAction.act(codinghorror, post, PostActionType.types[:notify_moderators], message: "this is my special long message");
|
||||
action = PostAction.act(codinghorror, post, PostActionType.types[:notify_moderators], message: "this is my special long message")
|
||||
|
||||
posts = Post.joins(:topic)
|
||||
.select('posts.id, topics.subtype, posts.topic_id')
|
||||
|
@ -76,7 +76,7 @@ describe PostAction do
|
|||
it "creates a pm if selected" do
|
||||
post = build(:post, id: 1000)
|
||||
PostCreator.any_instance.expects(:create).returns(post)
|
||||
PostAction.act(build(:user), build(:post), PostActionType.types[:notify_moderators], message: "this is my special message");
|
||||
PostAction.act(build(:user), build(:post), PostActionType.types[:notify_moderators], message: "this is my special message")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,7 +89,7 @@ describe PostAction do
|
|||
|
||||
it "sends an email to user if selected" do
|
||||
PostCreator.any_instance.expects(:create).returns(build(:post))
|
||||
PostAction.act(build(:user), post, PostActionType.types[:notify_user], message: "this is my special message");
|
||||
PostAction.act(build(:user), post, PostActionType.types[:notify_user], message: "this is my special message")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -458,4 +458,18 @@ describe PostAction do
|
|||
|
||||
end
|
||||
|
||||
describe ".add_moderator_post_if_needed" do
|
||||
|
||||
it "should not generate a notification for auto-message" do
|
||||
post = create_post
|
||||
|
||||
PostAction.act(moderator, post, PostActionType.types[:spam], message: "WAT")
|
||||
|
||||
PostAlerter.expects(:post_created).never
|
||||
|
||||
PostAction.agree_flags!(post, admin)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue