The personal finance app for everyone (by everyone)
Ruby
fix(i18n): localize empty CoinStats wallet result (#3355)
Thomas Steiblab787eb8237a
diff --git a/app/models/coinstats_item/wallet_linker.rb b/app/models/coinstats_item/wallet_linker.rbindex 0d2c372c67..8b58b10e1c 100644--- a/app/models/coinstats_item/wallet_linker.rb+++ b/app/models/coinstats_item/wallet_linker.rb@@ -22,7 +22,7 @@ class CoinstatsItem::WalletLinkerbalance_data = fetch_balance_datatokens = normalize_tokens(balance_data)- return Result.new(success?: false, created_count: 0, errors: [ "No tokens found for wallet" ]) if tokens.empty?+ return Result.new(success?: false, created_count: 0, errors: [ I18n.t("models.coinstats_item.wallet_linker.no_tokens_found") ]) if tokens.empty?created_count = 0errors = []diff --git a/config/locales/models/coinstats_item/de.yml b/config/locales/models/coinstats_item/de.ymlindex ee9307f5ef..f4ef2b9d76 100644--- a/config/locales/models/coinstats_item/de.yml+++ b/config/locales/models/coinstats_item/de.yml@@ -2,6 +2,8 @@de:models:coinstats_item:+ wallet_linker:+ no_tokens_found: Für dieses Krypto-Wallet wurden keine Token gefunden.syncer:importing_wallets: Wallets werden von CoinStats importiert...checking_configuration: Wallet-Konfiguration wird geprüft...diff --git a/config/locales/models/coinstats_item/en.yml b/config/locales/models/coinstats_item/en.ymlindex b5feb82176..ffe4126ca4 100644--- a/config/locales/models/coinstats_item/en.yml+++ b/config/locales/models/coinstats_item/en.yml@@ -2,6 +2,8 @@en:models:coinstats_item:+ wallet_linker:+ no_tokens_found: No tokens found for walletsyncer:importing_wallets: Importing crypto accounts from CoinStats...checking_configuration: Checking CoinStats account configuration...diff --git a/test/controllers/coinstats_items_controller_test.rb b/test/controllers/coinstats_items_controller_test.rbindex 13c1d7d4e9..916a963347 100644--- a/test/controllers/coinstats_items_controller_test.rb+++ b/test/controllers/coinstats_items_controller_test.rb@@ -2,7 +2,7 @@ require "test_helper"class CoinstatsItemsControllerTest < ActionDispatch::IntegrationTestsetup do- sign_in users(:family_admin)+ sign_in @user = users(:family_admin)@family = families(:dylan_family)@coinstats_item = CoinstatsItem.create!(family: @family,@@ -160,7 +160,7 @@ class CoinstatsItemsControllerTest < ActionDispatch::IntegrationTestassert_response :unprocessable_entityend- test "link_wallet handles no tokens found" do+ test "link_wallet preserves no tokens found error in English" doProvider::Coinstats.any_instance.expects(:get_wallet_balances).returns(success_response([]))@@ -174,7 +174,28 @@ class CoinstatsItemsControllerTest < ActionDispatch::IntegrationTest}assert_response :unprocessable_entity- assert_match(/No tokens found/, response.body)+ assert_includes response.body, "No tokens found for wallet"+ end++ test "link_wallet localizes no tokens found error in German" do+ @user.update!(locale: "de")+ Provider::Coinstats.any_instance.expects(:get_wallet_balances)+ .returns(success_response([]))++ Provider::Coinstats.any_instance.expects(:extract_wallet_balance)+ .returns([])++ post link_wallet_coinstats_items_url, params: {+ coinstats_item_id: @coinstats_item.id,+ address: "0x123abc",+ blockchain: "ethereum"+ }++ assert_response :unprocessable_entity+ assert_includes response.body, "Für dieses Krypto-Wallet wurden keine Token gefunden."+ refute_includes response.body, "No tokens found for wallet"+ assert_equal "Für dieses Krypto-Wallet wurden keine Token gefunden.",+ I18n.t("models.coinstats_item.wallet_linker.no_tokens_found", locale: :de, fallback: false)endtest "link_exchange filters unexpected connection fields" do