mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
FIX: display validation errors when converting topics (#27064)
When converting a PM to a public topic (and vice versa), if there was a validation error (like a topic already used, or a tag required or not allowed) the error message wasn't bubbled up nor shown to the user. This fix ensures we properly stop the conversion whenever a validation error happens and bubble up the errors back to the user so they can be informed. Internal ref - t/128795
This commit is contained in:
@ -4613,7 +4613,7 @@ RSpec.describe TopicsController do
|
||||
end
|
||||
|
||||
context "with success" do
|
||||
it "returns success" do
|
||||
it "returns success and the new url" do
|
||||
sign_in(admin)
|
||||
put "/t/#{topic.id}/convert-topic/public.json?category_id=#{category.id}"
|
||||
|
||||
@ -4627,6 +4627,20 @@ RSpec.describe TopicsController do
|
||||
expect(result["url"]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context "with some errors" do
|
||||
it "returns the error messages" do
|
||||
Fabricate(:topic, title: topic.title, category: category)
|
||||
|
||||
sign_in(admin)
|
||||
put "/t/#{topic.id}/convert-topic/public.json?category_id=#{category.id}"
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(response.parsed_body["errors"][0]).to end_with(
|
||||
I18n.t("errors.messages.has_already_been_used"),
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user