mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: ensures we don't attempt to create a new PM on an existing topic (#9029)
This fix attempts to both fix it at UI level and server side. A previous attempt related to this behavior has been made in commit: 49c750ca78
This commit is contained in:
@@ -1126,6 +1126,27 @@ describe PostsController do
|
||||
end
|
||||
end
|
||||
|
||||
context "when topic_id is set" do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
|
||||
it "errors when creating a private post" do
|
||||
user_2 = Fabricate(:user)
|
||||
|
||||
post "/posts.json", params: {
|
||||
raw: 'this is the test content',
|
||||
archetype: 'private_message',
|
||||
title: "this is some post",
|
||||
target_recipients: user_2.username,
|
||||
topic_id: topic.id
|
||||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["errors"]).to include(
|
||||
I18n.t("create_pm_on_existing_topic")
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "errors" do
|
||||
it "does not succeed" do
|
||||
post "/posts.json", params: { raw: 'test' }
|
||||
|
||||
Reference in New Issue
Block a user