mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: prevents creating post from impacting the app (#28518)
Create a topic can fail in many different ways and we don't want this to impact the rest of the application, the call will now be wrapped in a begin/rescue block and log an error if it fails.
This commit is contained in:
@ -165,5 +165,25 @@ describe "Topic" do
|
||||
}.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context "when creating the post fails" do
|
||||
before do
|
||||
@orig_logger = Rails.logger
|
||||
Rails.logger = @fake_logger = FakeLogger.new
|
||||
end
|
||||
|
||||
after { Rails.logger = @orig_logger }
|
||||
|
||||
it "logs a warning" do
|
||||
expect { UserUpdater.new(user, user).update(location: "Japan") }.to change {
|
||||
Topic.count
|
||||
}.by(1)
|
||||
expect { UserUpdater.new(user, user).update(location: "Japan") }.not_to change {
|
||||
Topic.count
|
||||
}
|
||||
|
||||
expect(Rails.logger.warnings.first).to match(/Title has already been used/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user