1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Handle missing exchange rate provider, allow fallback for missing rates (#955)

* Clean up exchange rate logic

* Remove stale method
This commit is contained in:
Zach Gollwitzer 2024-07-08 09:04:59 -04:00 committed by GitHub
parent bef335c631
commit 6767aaed1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 383 additions and 609 deletions

View file

@ -1,9 +1,26 @@
require "test_helper"
require "ostruct"
class Provider::SynthTest < ActiveSupport::TestCase
include ExchangeRateProviderInterfaceTest
setup do
@subject = Provider::Synth.new
@subject = @synth = Provider::Synth.new("fookey")
end
test "retries then provides failed response" do
Faraday.expects(:get).returns(OpenStruct.new(success?: false)).times(3)
response = @synth.fetch_exchange_rate from: "USD", to: "MXN", date: Date.current
assert_match "Failed to fetch exchange rate from Provider::Synth", response.error.message
end
test "retrying, then raising on network error" do
Faraday.expects(:get).raises(Faraday::TimeoutError).times(3)
assert_raises Faraday::TimeoutError do
@synth.fetch_exchange_rate from: "USD", to: "MXN", date: Date.current
end
end
end