1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add failing test

This commit is contained in:
Chris Salzberg 2017-12-15 23:37:21 +09:00
parent 7b1dfac291
commit 4aee5fcbfb
No known key found for this signature in database
GPG key ID: 3F77FCF15E284672

View file

@ -1106,13 +1106,18 @@ class PersistenceTest < ActiveRecord::TestCase
end end
def test_reset_column_information_resets_children def test_reset_column_information_resets_children
child = Class.new(Topic) child_class = Class.new(Topic)
child.new # force schema to load child_class.new # force schema to load
ActiveRecord::Base.connection.add_column(:topics, :foo, :string) ActiveRecord::Base.connection.add_column(:topics, :foo, :string)
Topic.reset_column_information Topic.reset_column_information
assert_equal "bar", child.new(foo: :bar).foo # this should redefine attribute methods
child_class.new
assert child_class.instance_methods.include?(:foo)
assert child_class.instance_methods.include?(:foo_changed?)
assert_equal "bar", child_class.new(foo: :bar).foo
ensure ensure
ActiveRecord::Base.connection.remove_column(:topics, :foo) ActiveRecord::Base.connection.remove_column(:topics, :foo)
Topic.reset_column_information Topic.reset_column_information