Sha256: 2812846a2918f88db9bbd22ea93a826dba4d457fa927e32291da22aac8bed2b7
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
# -*- coding: utf-8 -*- require "cases/helper" require 'support/connection_helper' class PostgresqlDomainTest < ActiveRecord::TestCase include ConnectionHelper class PostgresqlDomain < ActiveRecord::Base self.table_name = "postgresql_domains" end def setup @connection = ActiveRecord::Base.connection @connection.transaction do @connection.execute "CREATE DOMAIN custom_money as numeric(8,2)" @connection.create_table('postgresql_domains') do |t| t.column :price, :custom_money end end end teardown do @connection.execute 'DROP TABLE IF EXISTS postgresql_domains' @connection.execute 'DROP DOMAIN IF EXISTS custom_money' reset_connection end def test_column column = PostgresqlDomain.columns_hash["price"] assert_equal :decimal, column.type assert_equal "custom_money", column.sql_type assert column.number? assert_not column.binary? assert_not column.array end def test_domain_acts_like_basetype PostgresqlDomain.create price: "" record = PostgresqlDomain.first assert_nil record.price record.price = "34.15" record.save! assert_equal BigDecimal.new("34.15"), record.reload.price end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activejob-lock-0.0.2 | rails/activerecord/test/cases/adapters/postgresql/domain_test.rb |
activejob-lock-0.0.1 | rails/activerecord/test/cases/adapters/postgresql/domain_test.rb |