Skip to content

Instantly share code, notes, and snippets.

@zhuyifan2013
Created March 26, 2014 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuyifan2013/9777647 to your computer and use it in GitHub Desktop.
Save zhuyifan2013/9777647 to your computer and use it in GitHub Desktop.
A test for rails issue #14305
# Activate the gem you are reporting the issue against.
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'test')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
execute <<_SQL
CREATE DOMAIN custom_money as numeric(8,2);
CREATE TABLE postgresql_numeric_domains (
id SERIAL PRIMARY KEY,
amount numeric(8,2),
custom_amount custom_money
);
_SQL
end
class PostgresqlNumericDomain < ActiveRecord::Base
end
class BugTest < Minitest::Unit::TestCase
def teardown
[PostgresqlNumericDomain].each(&:delete_all)
end
# works, not using domain
def test_numeric
d = PostgresqlNumericDomain.create!(amount: '')
assert_equal nil, d.amount
assert_equal nil, d.custom_amount
end
# Currently fails, using domain
def test_numeric_domain
d = PostgresqlNumericDomain.create!(custom_amount: '')
assert_equal nil, d.amount
assert_equal nil, d.custom_amount
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment