mirror of
https://github.com/we-promise/sure.git
synced 2026-09-05 23:01:26 +00:00
fix(messages): handle chat not found during message creation (#2896)
* fix(messages): handle chat not found during message creation * test(messages): cover missing chat race --------- Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com> Co-authored-by: sure-admin <sure-admin@splashblot.com>
This commit is contained in:
co-authored by
sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
sure-admin
parent
705878807b
commit
521946b9d6
@@ -12,6 +12,15 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_redirected_to chat_path(@chat, thinking: true)
|
||||
end
|
||||
|
||||
test "redirects to chats when message save races with chat deletion" do
|
||||
UserMessage.any_instance.stubs(:save).raises(ActiveRecord::InvalidForeignKey)
|
||||
|
||||
post chat_messages_url(@chat), params: { message: { content: "Hello", ai_model: "gpt-4.1" } }
|
||||
|
||||
assert_redirected_to chats_path
|
||||
assert_equal I18n.t("messages.create.chat_not_found"), flash[:alert]
|
||||
end
|
||||
|
||||
test "cannot create a message if AI is disabled" do
|
||||
@user.update!(ai_enabled: false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user