Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

List connected Wise and CoinSpot under Your connections (#3834)

Guillem Arias Fauste3813f8a1c8f1
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index ef94df42dc..981b28cece 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -81,6 +81,9 @@ module SettingsHelper
when "coinstats"
return { status: :off } unless @coinstats_items&.any?
sync_based_summary(key)
+ when "wise"
+ return { status: :off } unless @wise_items&.any?
+ sync_based_summary(key)
when "mercury"
return { status: :off } unless @mercury_items&.any?
sync_based_summary(key)
@@ -99,6 +102,9 @@ module SettingsHelper
when "kraken"
return { status: :off } unless @kraken_items&.any?
sync_based_summary(key)
+ when "coinspot"
+ return { status: :off } unless @coinspot_items&.any?
+ sync_based_summary(key)
when "onchain_wallet"
return { status: :off } unless @onchain_wallet_items&.any?
sync_based_summary(key)
diff --git a/test/controllers/settings/providers_controller_test.rb b/test/controllers/settings/providers_controller_test.rb
index a2f5e00333..1f156190a7 100644
--- a/test/controllers/settings/providers_controller_test.rb
+++ b/test/controllers/settings/providers_controller_test.rb
@@ -193,6 +193,28 @@ class Settings::ProvidersControllerTest < ActionDispatch::IntegrationTest
refute_includes response.body, "Test Brex Connection"
end
+ test "lists active Wise and CoinSpot connections under your connections" do
+ get settings_providers_url
+
+ assert_response :success
+ %w[wise coinspot].each do |key|
+ assert_select "turbo-frame##{key}-providers-panel"
+ assert_select "a[href=?]", connect_form_settings_providers_path(provider_key: key), count: 0
+ end
+ end
+
+ test "lists Wise and CoinSpot as available when the family has no connections" do
+ sign_in users(:empty)
+
+ get settings_providers_url
+
+ assert_response :success
+ %w[wise coinspot].each do |key|
+ assert_select "turbo-frame##{key}-providers-panel", count: 0
+ assert_select "a[href=?]", connect_form_settings_providers_path(provider_key: key)
+ end
+ end
+
# The provider card reads its tagline with `default: nil`, so a missing key
# renders a bare name rather than failing. Up shipped that way.
test "every family panel provider has an English tagline" do
diff --git a/test/helpers/settings_helper_test.rb b/test/helpers/settings_helper_test.rb
index d077f220ed..20b39d1ee3 100644
--- a/test/helpers/settings_helper_test.rb
+++ b/test/helpers/settings_helper_test.rb
@@ -36,4 +36,21 @@ class SettingsHelperTest < ActionView::TestCase
assert_equal({ status: :off }, provider_summary("trading212"))
end
+
+ # A key provider_summary doesn't handle falls through to { status: :off },
+ # which lists a connected provider under Available. Wise and CoinSpot
+ # shipped that way. One key at a time, so a branch that reads another
+ # provider's items fails too.
+ test "provider_summary is not off for any connected family panel provider" do
+ item = OpenStruct.new(oauth_configured?: true)
+
+ off = Settings::ProvidersController::FAMILY_PANEL_KEYS.select do |key|
+ instance_variable_set(:"@#{key}_items", [ item ])
+ status = provider_summary(key)[:status]
+ instance_variable_set(:"@#{key}_items", nil)
+ status == :off
+ end
+
+ assert_empty off
+ end
end