Files
sure/test/models/provider/akahu_adapter_test.rb
Brad 1b8b21760b feat(provider): Akahu integration (#1921)
* First pass of Akahu

* fix up sync all

* conflicts

* fix db migration issue? - fix auto selection of akahu account type

* Address Akahu PR feedback

* Complete provider metadata

* Fix PR 1921 CI tests

* PR feedback

* PR feedback

* post merge

---------

Co-authored-by: failing <failing@users.noreply.github.com>
Co-authored-by: Juan José Mata <jjmata@jjmata.com>
Co-authored-by: sure-admin <sure-admin@splashblot.com>
2026-06-02 21:44:57 +02:00

38 lines
1.5 KiB
Ruby

require "test_helper"
require "uri"
class Provider::AkahuAdapterTest < ActiveSupport::TestCase
test "supports Investment accounts" do
assert_includes Provider::AkahuAdapter.supported_account_types, "Investment"
end
test "returns one connection config per credentialed Akahu item" do
family = families(:dylan_family)
first_item = AkahuItem.create!(
family: family,
name: "Main Akahu",
app_token: "akahu-app-credential",
user_token: "akahu-user-credential"
)
second_item = AkahuItem.create!(
family: family,
name: "Secondary Akahu",
app_token: "second-akahu-app-credential",
user_token: "second-akahu-user-credential"
)
configs = Provider::AkahuAdapter.connection_configs(family: family)
assert_equal [ "akahu_#{second_item.id}", "akahu_#{first_item.id}" ], configs.map { |config| config[:key] }
assert_equal [ second_item.name, first_item.name ], configs.map { |config| config[:name] }
new_account_uri = URI.parse(configs.first[:new_account_path].call("Depository", "/accounts"))
assert_equal "/akahu_items/select_accounts", new_account_uri.path
assert_includes new_account_uri.query, "akahu_item_id=#{second_item.id}"
existing_account_uri = URI.parse(configs.first[:existing_account_path].call(accounts(:depository).id))
assert_equal "/akahu_items/select_existing_account", existing_account_uri.path
assert_includes existing_account_uri.query, "akahu_item_id=#{second_item.id}"
end
end