FIX: Replies to PMs should never been enqueued
This commit is contained in:
parent
bb29bff5d8
commit
5fdbc6c4b2
|
@ -52,6 +52,9 @@ class NewPostManager
|
||||||
|
|
||||||
# We never queue private messages
|
# We never queue private messages
|
||||||
return perform_create_post if @args[:archetype] == Archetype.private_message
|
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
|
# Perform handlers until one returns a result
|
||||||
handled = NewPostManager.handlers.any? do |handler|
|
handled = NewPostManager.handlers.any? do |handler|
|
||||||
|
|
|
@ -21,13 +21,27 @@ describe NewPostManager do
|
||||||
let(:other_user) { Fabricate(:user) }
|
let(:other_user) { Fabricate(:user) }
|
||||||
|
|
||||||
it "doesn't enqueue private messages" do
|
it "doesn't enqueue private messages" do
|
||||||
|
SiteSetting.approve_unless_trust_level = 4
|
||||||
|
|
||||||
manager = NewPostManager.new(topic.user,
|
manager = NewPostManager.new(topic.user,
|
||||||
raw: 'this is a new post',
|
raw: 'this is a new post',
|
||||||
title: 'this is a new title',
|
title: 'this is a new title',
|
||||||
archetype: Archetype.private_message,
|
archetype: Archetype.private_message,
|
||||||
target_usernames: other_user.username)
|
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
|
result = manager.perform
|
||||||
|
|
||||||
expect(result.action).to eq(:create_post)
|
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.topic.private_message?).to eq(true)
|
||||||
expect(result.post).to be_a(Post)
|
expect(result.post).to be_a(Post)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "default handler" do
|
context "default handler" do
|
||||||
|
|
Loading…
Reference in New Issue