mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Mercury integration (#723)
* Initial mercury impl * FIX both mercury and generator class * Finish mercury integration and provider generator * Fix schema * Fix linter and tags * Update routes.rb * Avoid schema drift --------- Signed-off-by: soky srm <sokysrm@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
38
test/models/provider/mercury_adapter_test.rb
Normal file
38
test/models/provider/mercury_adapter_test.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
require "test_helper"
|
||||
|
||||
class Provider::MercuryAdapterTest < ActiveSupport::TestCase
|
||||
test "supports Depository accounts" do
|
||||
assert_includes Provider::MercuryAdapter.supported_account_types, "Depository"
|
||||
end
|
||||
|
||||
test "does not support Investment accounts" do
|
||||
assert_not_includes Provider::MercuryAdapter.supported_account_types, "Investment"
|
||||
end
|
||||
|
||||
test "returns connection configs for any family" do
|
||||
# Mercury is a per-family provider - any family can connect
|
||||
family = families(:dylan_family)
|
||||
configs = Provider::MercuryAdapter.connection_configs(family: family)
|
||||
|
||||
assert_equal 1, configs.length
|
||||
assert_equal "mercury", configs.first[:key]
|
||||
assert_equal "Mercury", configs.first[:name]
|
||||
assert configs.first[:can_connect]
|
||||
end
|
||||
|
||||
test "build_provider returns nil when family is nil" do
|
||||
assert_nil Provider::MercuryAdapter.build_provider(family: nil)
|
||||
end
|
||||
|
||||
test "build_provider returns nil when family has no mercury items" do
|
||||
family = families(:empty)
|
||||
assert_nil Provider::MercuryAdapter.build_provider(family: family)
|
||||
end
|
||||
|
||||
test "build_provider returns Mercury provider when credentials configured" do
|
||||
family = families(:dylan_family)
|
||||
provider = Provider::MercuryAdapter.build_provider(family: family)
|
||||
|
||||
assert_instance_of Provider::Mercury, provider
|
||||
end
|
||||
end
|
||||
29
test/models/provider/mercury_test.rb
Normal file
29
test/models/provider/mercury_test.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
require "test_helper"
|
||||
|
||||
class Provider::MercuryTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@provider = Provider::Mercury.new("test_token", base_url: "https://api-sandbox.mercury.com/api/v1")
|
||||
end
|
||||
|
||||
test "initializes with token and default base_url" do
|
||||
provider = Provider::Mercury.new("my_token")
|
||||
assert_equal "my_token", provider.token
|
||||
assert_equal "https://api.mercury.com/api/v1", provider.base_url
|
||||
end
|
||||
|
||||
test "initializes with custom base_url" do
|
||||
assert_equal "test_token", @provider.token
|
||||
assert_equal "https://api-sandbox.mercury.com/api/v1", @provider.base_url
|
||||
end
|
||||
|
||||
test "MercuryError includes error_type" do
|
||||
error = Provider::Mercury::MercuryError.new("Test error", :unauthorized)
|
||||
assert_equal "Test error", error.message
|
||||
assert_equal :unauthorized, error.error_type
|
||||
end
|
||||
|
||||
test "MercuryError defaults error_type to unknown" do
|
||||
error = Provider::Mercury::MercuryError.new("Test error")
|
||||
assert_equal :unknown, error.error_type
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user