Skip to content

armgit / sure

Public Imported from GitHub
0

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.rb
index 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::WalletLinker
balance_data = fetch_balance_data
tokens = 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 = 0
errors = []
diff --git a/config/locales/models/coinstats_item/de.yml b/config/locales/models/coinstats_item/de.yml
index 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.yml
index 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 wallet
syncer:
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.rb
index 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::IntegrationTest
setup 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::IntegrationTest
assert_response :unprocessable_entity
end
- test "link_wallet handles no tokens found" do
+ test "link_wallet preserves no tokens found error in English" do
Provider::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)
end
test "link_exchange filters unexpected connection fields" do