mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FIX: Don't log an error to logster if a topic could not be updated.
If for some reason an update did not go through (for example, concurrently updating the same topic twice), we were logging something like: ``` create_errors_json called with unrecognized type: #<Topic ``` This happened because we knew an error occurred but the active record object had no errors attached. This patch fixes the issue by attaching a proper error message in the event that this happens.
This commit is contained in:
@ -956,6 +956,16 @@ RSpec.describe TopicsController do
|
||||
expect(::JSON.parse(response.body)['basic_topic']).to be_present
|
||||
end
|
||||
|
||||
it "throws an error if it could not be saved" do
|
||||
PostRevisor.any_instance.stubs(:should_revise?).returns(false)
|
||||
put "/t/#{topic.slug}/#{topic.id}.json", params: { title: "brand new title" }
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(response.parsed_body['errors'].first).to eq(
|
||||
I18n.t("activerecord.errors.models.topic.attributes.base.unable_to_update")
|
||||
)
|
||||
end
|
||||
|
||||
it "can update a topic to an uncategorized topic" do
|
||||
topic.update!(category: Fabricate(:category))
|
||||
|
||||
|
Reference in New Issue
Block a user