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.rbindex aefb7daf4e..3fe35d0ddc 100644--- a/app/controllers/chats_controller.rb+++ b/app/controllers/chats_controller.rb@@ -13,7 +13,9 @@ class ChatsController < ApplicationControllerenddef 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"))+ )enddef creatediff --git a/config/locales/views/chats/de.yml b/config/locales/views/chats/de.ymlindex ff5aee7ddf..8373fe2a39 100644--- a/config/locales/views/chats/de.yml+++ b/config/locales/views/chats/de.yml@@ -33,6 +33,8 @@ de:index:chats: Chatsnew_chat: Neuer Chat+ new:+ default_title: "Neuer Chat %{timestamp}"update:success: Chat aktualisiertworker_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.ymlindex 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.rbindex 79b3641f3a..ee12cfe103 100644--- a/test/controllers/chats_controller_test.rb+++ b/test/controllers/chats_controller_test.rb@@ -12,12 +12,38 @@ class ChatsControllerTest < ActionDispatch::IntegrationTestassert_response :successend+ 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" doassert_difference("Chat.count") dopost 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").contentendtest "shows chat" do