Merge branch 'we-promise:main' into Transfer-charges

This commit is contained in:
Shibu M
2026-06-29 11:45:02 +05:30
committed by GitHub
19 changed files with 761 additions and 111 deletions

View File

@@ -129,6 +129,40 @@ class AccountTest < ActiveSupport::TestCase
assert_equal "checking", account.subtype
end
test "subtype assigned before accountable_type is not dropped" do
# The real controller path: strong-params `permit` preserves filter order,
# and `account_params` lists `:subtype` before `:accountable_type`, so the
# subtype writer runs while the type is still unknown.
account = Account.new
account.subtype = "savings"
account.accountable_type = "Depository"
assert_not_nil account.accountable
assert_equal "savings", account.subtype
assert_equal "savings", account.accountable.subtype
end
test "subtype persists on create when attributes arrive in permit order" do
Account.any_instance.stubs(:sync_later)
# Mirrors `account_params`: `permit` yields keys in filter order, so the
# create hash carries `subtype` before `accountable_type` — the ordering
# that previously dropped the subtype on create.
account = Account.create_and_sync({
family: @family,
owner: @admin,
name: "Savings Account",
balance: 100,
subtype: "savings",
currency: "USD",
accountable_type: "Depository"
})
assert account.persisted?
assert_equal "savings", account.reload.subtype
assert_equal "savings", account.accountable.subtype
end
test "accountable display names expose singular and group contexts" do
assert_equal "Investment", Investment.singular_display_name
assert_equal "Investments", Investment.display_name

View File

@@ -11,18 +11,23 @@ class SnaptradeItemTest < ActiveSupport::TestCase
assert_includes item.errors[:name], "can't be blank"
end
test "validates presence of client_id on create" do
test "requires client_id when consumer_key is present" do
item = SnaptradeItem.new(family: @family, name: "Test", consumer_key: "test")
assert_not item.valid?
assert_includes item.errors[:client_id], "can't be blank"
end
test "validates presence of consumer_key on create" do
test "requires consumer_key when client_id is present" do
item = SnaptradeItem.new(family: @family, name: "Test", client_id: "test")
assert_not item.valid?
assert_includes item.errors[:consumer_key], "can't be blank"
end
test "allows oauth-only items without api credentials" do
item = SnaptradeItem.new(family: @family, name: "Test")
assert item.valid?
end
test "credentials_configured? returns true when credentials are set" do
item = SnaptradeItem.new(
family: @family,