Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

fix(i18n): localize new chat default title (U9) (#3256)

Thomas Steiblc6789a0fed75
diff --git a/app/controllers/chats_controller.rb b/app/controllers/chats_controller.rb
index aefb7daf4e..3fe35d0ddc 100644
--- a/app/controllers/chats_controller.rb
+++ b/app/controllers/chats_controller.rb
@@ -13,7 +13,9 @@ class ChatsController < ApplicationController
end
def new
- @chat = Current.user.chats.new(title: "New chat #{Time.current.strftime("%Y-%m-%d %H:%M")}")
+ @chat = Current.user.chats.new(
+ title: t(".default_title", timestamp: Time.current.strftime("%Y-%m-%d %H:%M"))
+ )
end
def create
diff --git a/config/locales/views/chats/de.yml b/config/locales/views/chats/de.yml
index ff5aee7ddf..8373fe2a39 100644
--- a/config/locales/views/chats/de.yml
+++ b/config/locales/views/chats/de.yml
@@ -33,6 +33,8 @@ de:
index:
chats: Chats
new_chat: Neuer Chat
+ new:
+ default_title: "Neuer Chat %{timestamp}"
update:
success: Chat aktualisiert
worker_unhealthy_warning: KI-Antworten kommen gerade womöglich nicht an – der Hintergrundprozess scheint gestoppt oder überlastet. Prüf, ob dein Sidekiq-Worker läuft.
diff --git a/config/locales/views/chats/en.yml b/config/locales/views/chats/en.yml
index 261b41d4ff..b247a0a191 100644
--- a/config/locales/views/chats/en.yml
+++ b/config/locales/views/chats/en.yml
@@ -28,6 +28,8 @@ en:
index:
chats: "Chats"
new_chat: "New chat"
+ new:
+ default_title: "New chat %{timestamp}"
update:
success: "Chat updated"
ai_consent:
diff --git a/test/controllers/chats_controller_test.rb b/test/controllers/chats_controller_test.rb
index 79b3641f3a..ee12cfe103 100644
--- a/test/controllers/chats_controller_test.rb
+++ b/test/controllers/chats_controller_test.rb
@@ -12,12 +12,38 @@ class ChatsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
+ test "gets new chat with a localized German default title" do
+ @user.update!(locale: "de")
+
+ travel_to Time.zone.local(2026, 8, 29, 12, 34) do
+ get new_chat_url
+
+ assert_response :success
+ assert_select "turbo-frame#title_chat h3", text: "Neuer Chat 2026-08-29 12:34"
+ end
+ end
+
+ test "gets new chat with the existing English default title" do
+ @user.update!(locale: "en")
+
+ travel_to Time.zone.local(2026, 8, 29, 12, 34) do
+ get new_chat_url
+
+ assert_response :success
+ assert_select "turbo-frame#title_chat h3", text: "New chat 2026-08-29 12:34"
+ end
+ end
+
test "creates chat" do
assert_difference("Chat.count") do
post chats_url, params: { chat: { content: "Hello", ai_model: "gpt-4.1" } }
end
- assert_redirected_to chat_path(Chat.order(created_at: :desc).first, thinking: true)
+ chat = Chat.order(created_at: :desc).first
+
+ assert_redirected_to chat_path(chat, thinking: true)
+ assert_equal "Hello", chat.title
+ assert_equal "Hello", chat.messages.find_by!(type: "UserMessage").content
end
test "shows chat" do