diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-08-26 11:14:56 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-08-26 11:14:56 +0200 |
commit | 27dc4fa28ee098d70a11829ad5fa4af0c54e880b (patch) | |
tree | ed7b7d52308c9bb1c80199804bd74f4b615b4ff5 /activerecord/test/cases/adapters | |
parent | 078da2b22de765f368a4257bce67ab4370754ee2 (diff) | |
download | rails-27dc4fa28ee098d70a11829ad5fa4af0c54e880b.tar.gz rails-27dc4fa28ee098d70a11829ad5fa4af0c54e880b.tar.bz2 rails-27dc4fa28ee098d70a11829ad5fa4af0c54e880b.zip |
PG adapter deals with negative money values formatted with parenthesis.
Closes #11899.
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/datatype_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/datatype_test.rb b/activerecord/test/cases/adapters/postgresql/datatype_test.rb index 75b6f4f8ce..3dbab08a99 100644 --- a/activerecord/test/cases/adapters/postgresql/datatype_test.rb +++ b/activerecord/test/cases/adapters/postgresql/datatype_test.rb @@ -298,6 +298,14 @@ _SQL assert_equal(-567.89, @second_money.wealth) end + def test_money_type_cast + column = PostgresqlMoney.columns.find { |c| c.name == 'wealth' } + assert_equal(12345678.12, column.type_cast("$12,345,678.12")) + assert_equal(12345678.12, column.type_cast("$12.345.678,12")) + assert_equal(-1.15, column.type_cast("-$1.15")) + assert_equal(-2.25, column.type_cast("($2.25)")) + end + def test_create_tstzrange skip "PostgreSQL 9.2 required for range datatypes" unless @connection.supports_ranges? tstzrange = Time.parse('2010-01-01 14:30:00 +0100')...Time.parse('2011-02-02 14:30:00 CDT') |