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

Integrate money-rails gem (#268)

* Integrate money-rails gem

* Fix Lint issues

* Basic test for monetize feature

* Merge main branch

* Changes to monetize balance field

---------

Co-authored-by: Zach Gollwitzer <zach.gollwitzer@gmail.com>
This commit is contained in:
Nidhi Sarvaiya 2024-02-06 12:30:51 -05:00 committed by GitHub
parent 323a8ccf50
commit 1182ab39bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 176 additions and 14 deletions

View file

@ -1,11 +1,31 @@
require "test_helper"
class AccountTest < ActiveSupport::TestCase
test "new account should be valid" do
def setup
depository = Account::Depository.create!
account = Account.create!(family: families(:dylan_family), name: "Explicit Checking", balance: 1200, accountable: depository)
assert account.valid?
assert_not_nil account.accountable_id
assert_not_nil account.accountable
@account = Account.create!(family: families(:dylan_family), name: "Explicit Checking", balance_cents: 1200, accountable: depository)
end
test "new account should be valid" do
assert @account.valid?
assert_not_nil @account.accountable_id
assert_not_nil @account.accountable
end
test "balance returns Money object" do
@account.balance = 10
assert_instance_of Money, @account.balance
assert_equal :usd, @account.balance.currency.id
end
test "correctly assigns Money objects to the attribute" do
@account.balance = Money.new(2500, "USD")
assert_equal 2500, @account.balance_cents
end
test "balance_cents can be updated" do
new_balance = Money.new(10000, "USD")
@account.balance = new_balance
assert_equal new_balance, @account.balance
end
end