2024-02-06 19:51:32 -06:00
|
|
|
require "test_helper"
|
|
|
|
|
|
|
|
class ApplicationHelperTest < ActionView::TestCase
|
|
|
|
test "#title(page_title)" do
|
|
|
|
title("Test Title")
|
|
|
|
assert_equal "Test Title", content_for(:title)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "#header_title(page_title)" do
|
|
|
|
header_title("Test Header Title")
|
|
|
|
assert_equal "Test Header Title", content_for(:header_title)
|
|
|
|
end
|
|
|
|
|
2024-06-24 16:56:44 +02:00
|
|
|
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)
|
2024-10-03 10:25:38 -04:00
|
|
|
assert_equal "$3.00 | -€7.00", totals_by_currency(collection: [ @account1, @account2, @account3 ], money_method: :balance_money)
|
2024-06-24 16:56:44 +02:00
|
|
|
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)
|
2024-10-03 10:25:38 -04:00
|
|
|
assert_equal "-$3.00 | €7.00", totals_by_currency(collection: [ @account1, @account2, @account3 ], money_method: :balance_money, negate: true)
|
2024-06-24 16:56:44 +02:00
|
|
|
end
|
2024-02-06 19:51:32 -06:00
|
|
|
end
|