mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 15:19:38 +02:00
* Fix #910 * Unify helper for balance formatting in transactions and accounts views * Remove obsolete method * Rename helper method format_amount_by_curreny => totals_by_currency
This commit is contained in:
parent
ee53546c1b
commit
bbcd3881db
4 changed files with 23 additions and 7 deletions
|
@ -16,4 +16,18 @@ class ApplicationHelperTest < ActionView::TestCase
|
|||
assert_equal "user", permitted_accountable_partial("User")
|
||||
assert_equal "admin_user", permitted_accountable_partial("AdminUser")
|
||||
end
|
||||
|
||||
def setup
|
||||
@account1 = Account.new(currency: "USD", balance: 1)
|
||||
@account2 = Account.new(currency: "USD", balance: 2)
|
||||
@account3 = Account.new(currency: "EUR", balance: -7)
|
||||
end
|
||||
|
||||
test "#totals_by_currency(collection: collection, money_method: money_method)" do
|
||||
assert_equal "$3.00", totals_by_currency(collection: [ @account1, @account2 ], money_method: :balance_money)
|
||||
assert_equal "$3.00 | -€7,00", totals_by_currency(collection: [ @account1, @account2, @account3 ], money_method: :balance_money)
|
||||
assert_equal "", totals_by_currency(collection: [], money_method: :balance_money)
|
||||
assert_equal "$0.00", totals_by_currency(collection: [ Account.new(currency: "USD", balance: 0) ], money_method: :balance_money)
|
||||
assert_equal "-$3.00 | €7,00", totals_by_currency(collection: [ @account1, @account2, @account3 ], money_method: :balance_money, negate: true)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue