mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-25 08:09:38 +02:00
Add formatting for EUR locales (#1231)
* Add formatting for EUR locales * Fix formatting assertion for EUR in english locales
This commit is contained in:
parent
ab40289eb4
commit
82c298307d
6 changed files with 42 additions and 59 deletions
|
@ -25,9 +25,9 @@ class ApplicationHelperTest < ActionView::TestCase
|
|||
|
||||
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 "$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)
|
||||
assert_equal "-$3.00 | €7.00", totals_by_currency(collection: [ @account1, @account2, @account3 ], money_method: :balance_money, negate: true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,25 +28,6 @@ class Money::CurrencyTest < ActiveSupport::TestCase
|
|||
assert_equal 2, @currency.default_precision
|
||||
end
|
||||
|
||||
test "can extract cents string from amount" do
|
||||
value1 = Money.new(100)
|
||||
value2 = Money.new(100.1)
|
||||
value3 = Money.new(100.12)
|
||||
value4 = Money.new(100.123)
|
||||
value5 = Money.new(200, :jpy)
|
||||
|
||||
assert_equal "00", value1.cents_str
|
||||
assert_equal "10", value2.cents_str
|
||||
assert_equal "12", value3.cents_str
|
||||
assert_equal "12", value4.cents_str
|
||||
assert_equal "", value5.cents_str
|
||||
|
||||
assert_equal "", value4.cents_str(0)
|
||||
assert_equal "1", value4.cents_str(1)
|
||||
assert_equal "12", value4.cents_str(2)
|
||||
assert_equal "123", value4.cents_str(3)
|
||||
end
|
||||
|
||||
test "step returns the smallest value of the currency" do
|
||||
assert_equal 0.01, @currency.step
|
||||
end
|
||||
|
|
|
@ -85,8 +85,8 @@ class MoneyTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test "can cast to string with basic formatting" do
|
||||
assert_equal "$1,000.90", Money.new(1000.899).format
|
||||
assert_equal "€1.000,12", Money.new(1000.12, :eur).format
|
||||
assert_equal "$1,000.90", Money.new(1000.899).to_s
|
||||
assert_equal "€1.000,12", Money.new(1000.12, :eur).to_s
|
||||
end
|
||||
|
||||
test "converts currency when rate available" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue