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:
Joffrey JAFFEUX
2020-02-24 15:55:12 +01:00
committed by GitHub
parent 31f3ed8d36
commit 0ea11a9d49
6 changed files with 35 additions and 5 deletions

View File

@@ -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' }