mirror of
https://github.com/we-promise/sure.git
synced 2026-04-22 21:44:11 +00:00
* feat: add currency management for families with enabled currencies * feat: update currency selection logic and improve accessibility * feat: update currency preferences to use group moniker in titles --------- Signed-off-by: Ang Wei Feng (Ted) <hello@tedawf.com> Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
42 lines
1.8 KiB
Ruby
42 lines
1.8 KiB
Ruby
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
|
|
|
|
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
|
|
|
|
test "#currency_picker_options_for_family returns enabled family currencies" do
|
|
family = families(:dylan_family)
|
|
family.update!(currency: "SGD", enabled_currencies: [ "USD" ])
|
|
|
|
assert_equal [ "SGD", "USD" ], currency_picker_options_for_family(family)
|
|
end
|
|
|
|
test "#currency_picker_options_for_family keeps selected legacy currency visible" do
|
|
family = families(:dylan_family)
|
|
family.update!(currency: "SGD", enabled_currencies: [ "USD" ])
|
|
|
|
assert_equal [ "SGD", "USD", "EUR" ], currency_picker_options_for_family(family, extra: "EUR")
|
|
end
|
|
end
|