FIX: Replies to PMs should never been enqueued

This commit is contained in:
Robin Ward 2015-05-13 12:08:39 -04:00
parent bb29bff5d8
commit 5fdbc6c4b2
2 changed files with 19 additions and 1 deletions

View File

@ -52,6 +52,9 @@ class NewPostManager
# We never queue private messages
return perform_create_post if @args[:archetype] == Archetype.private_message
if args[:topic_id] && Topic.where(id: args[:topic_id], archetype: Archetype.private_message).exists?
return perform_create_post
end
# Perform handlers until one returns a result
handled = NewPostManager.handlers.any? do |handler|

View File

@ -21,13 +21,27 @@ describe NewPostManager do
let(:other_user) { Fabricate(:user) }
it "doesn't enqueue private messages" do
SiteSetting.approve_unless_trust_level = 4
manager = NewPostManager.new(topic.user,
raw: 'this is a new post',
title: 'this is a new title',
archetype: Archetype.private_message,
target_usernames: other_user.username)
SiteSetting.approve_unless_trust_level = 4
result = manager.perform
expect(result.action).to eq(:create_post)
expect(result).to be_success
expect(result.post).to be_present
expect(result.post.topic.private_message?).to eq(true)
expect(result.post).to be_a(Post)
# It doesn't enqueue replies to the private message either
manager = NewPostManager.new(topic.user,
raw: 'this is a new reply',
topic_id: result.post.topic_id)
result = manager.perform
expect(result.action).to eq(:create_post)
@ -36,6 +50,7 @@ describe NewPostManager do
expect(result.post.topic.private_message?).to eq(true)
expect(result.post).to be_a(Post)
end
end
context "default handler" do