The personal finance app for everyone (by everyone)
Ruby
fix(i18n): localize Lunchflow fallback errors (U7) (#3358)
Thomas Steibl3035a69d7682
diff --git a/app/controllers/lunchflow_items_controller.rb b/app/controllers/lunchflow_items_controller.rbindex 8abfc525d2..cfbc8feb5c 100644--- a/app/controllers/lunchflow_items_controller.rb+++ b/app/controllers/lunchflow_items_controller.rb@@ -120,7 +120,7 @@ class LunchflowItemsController < ApplicationControllerlayout: falserescue StandardError => eRails.logger.error("Unexpected error in select_accounts: #{e.class}: #{e.message}")- @error_message = "An unexpected error occurred. Please try again later."+ @error_message = t("lunchflow_items.api_error.unexpected_error")@return_path = safe_return_to_pathrender partial: "lunchflow_items/api_error",locals: { error_message: @error_message, return_path: @return_path },@@ -324,7 +324,7 @@ class LunchflowItemsController < ApplicationControllerlayout: falserescue StandardError => eRails.logger.error("Unexpected error in select_existing_account: #{e.class}: #{e.message}")- @error_message = "An unexpected error occurred. Please try again later."+ @error_message = t("lunchflow_items.api_error.unexpected_error")render partial: "lunchflow_items/api_error",locals: { error_message: @error_message, return_path: accounts_path },layout: falsediff --git a/config/locales/views/lunchflow_items/de.yml b/config/locales/views/lunchflow_items/de.ymlindex b3448946dc..3afbe634b7 100644--- a/config/locales/views/lunchflow_items/de.yml+++ b/config/locales/views/lunchflow_items/de.yml@@ -187,6 +187,7 @@ de:service_down_label: Dienst nicht erreichbartitle: Fehler bei der Lunch-Flow-Verbindungunable_to_connect: Die Verbindung zu Lunch Flow kam nicht zustande+ unexpected_error: Ein unerwarteter Fehler ist aufgetreten. Versuch es später noch einmal.setup_required:api_key_description: Bevor du Lunch-Flow-Konten verknüpfen kannst, musst du deinen Lunch-Flow-API-Key hinterlegen.api_key_not_configured: API-Key nicht hinterlegtdiff --git a/config/locales/views/lunchflow_items/en.yml b/config/locales/views/lunchflow_items/en.ymlindex 28fdbef33b..7a1740c4e4 100644--- a/config/locales/views/lunchflow_items/en.yml+++ b/config/locales/views/lunchflow_items/en.yml@@ -14,6 +14,7 @@ en:service_down_label: Service Downservice_down_desc: Lunch Flow API may be temporarily unavailablecheck_provider_settings: Check Provider Settings+ unexpected_error: An unexpected error occurred. Please try again later.setup_required:title: Lunch Flow Setup Requiredapi_key_not_configured: API Key Not Configureddiff --git a/test/controllers/lunchflow_items_controller_test.rb b/test/controllers/lunchflow_items_controller_test.rbindex 1097630d95..e35ad45357 100644--- a/test/controllers/lunchflow_items_controller_test.rb+++ b/test/controllers/lunchflow_items_controller_test.rb@@ -82,6 +82,45 @@ class LunchflowItemsControllerTest < ActionDispatch::IntegrationTestassert_equal "Failed to create accounts: An unexpected error occurred", flash[:alert]end+ test "account selection localizes an unexpected error in German" do+ @user.update!(locale: "de")+ Provider::LunchflowAdapter.stubs(:build_provider).raises(StandardError, "Synthetic failure")++ get select_accounts_lunchflow_items_url++ assert_response :success+ assert_includes response.body, "Ein unerwarteter Fehler ist aufgetreten. Versuch es später noch einmal."+ refute_includes response.body, "An unexpected error occurred. Please try again later."+ assert I18n.exists?("lunchflow_items.api_error.unexpected_error", :de, fallback: false)+ assert_equal "An unexpected error occurred. Please try again later.",+ I18n.t("lunchflow_items.api_error.unexpected_error", locale: :en, fallback: false)+ end++ test "existing-account selection localizes an unexpected error in German" do+ @user.update!(locale: "de")+ Provider::LunchflowAdapter.stubs(:build_provider).raises(StandardError, "Synthetic failure")++ get select_existing_account_lunchflow_items_url(account_id: accounts(:depository).id)++ assert_response :success+ assert_includes response.body, "Ein unerwarteter Fehler ist aufgetreten. Versuch es später noch einmal."+ refute_includes response.body, "An unexpected error occurred. Please try again later."+ end++ test "account selection preserves provider error details" do+ @user.update!(locale: "de")+ Provider::LunchflowAdapter.stubs(:build_provider).raises(+ Provider::Lunchflow::LunchflowError,+ "Provider-specific failure"+ )++ get select_accounts_lunchflow_items_url++ assert_response :success+ assert_includes response.body, "Provider-specific failure"+ refute_includes response.body, "Ein unerwarteter Fehler ist aufgetreten. Versuch es später noch einmal."+ end+test "invalid non-Turbo create redirects instead of rendering a missing template" doassert_no_difference "LunchflowItem.count" dopost lunchflow_items_url, params: {