1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 21:15:19 +02:00

Show UI warning to user when they need provider data but have not setup Synth yet (#1926)

* Simplify provider concerns

* Update tests

* Add UI warning for missing Synth key if family requires external data
This commit is contained in:
Zach Gollwitzer 2025-02-28 11:35:10 -05:00 committed by GitHub
parent 624faa10d0
commit fa0248056d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 184 additions and 136 deletions

View file

@ -5,14 +5,16 @@ class Security::PriceTest < ActiveSupport::TestCase
setup do
@provider = mock
Security::Price.stubs(:security_prices_provider).returns(@provider)
Security::Price.stubs(:provider).returns(@provider)
end
test "security price provider nil if no api key provided" do
Security::Price.unstub(:security_prices_provider)
Security::Price.unstub(:provider)
Setting.stubs(:synth_api_key).returns(nil)
with_env_overrides SYNTH_API_KEY: nil do
assert_not Security::Price.security_prices_provider
assert_not Security::Price.provider
end
end
@ -60,7 +62,10 @@ class Security::PriceTest < ActiveSupport::TestCase
end
test "returns nil if price not found in DB and provider disabled" do
Security::Price.unstub(:security_prices_provider)
Security::Price.unstub(:provider)
Setting.stubs(:synth_api_key).returns(nil)
security = Security.new(ticker: "NVDA")
with_env_overrides SYNTH_API_KEY: nil do
@ -105,7 +110,9 @@ class Security::PriceTest < ActiveSupport::TestCase
end
test "returns empty array if no prices found in DB or from provider" do
Security::Price.unstub(:security_prices_provider)
Security::Price.unstub(:provider)
Setting.stubs(:synth_api_key).returns(nil)
with_env_overrides SYNTH_API_KEY: nil do
assert_equal [], Security::Price.find_prices(security: Security.new(ticker: "NVDA"), start_date: 10.days.ago.to_date, end_date: Date.current)