diff options
author | Matthew Draper <matthew@trebex.net> | 2017-12-19 11:54:38 +1030 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-19 11:54:38 +1030 |
commit | d9e4bffb60f69d972311fa7d23f4ce540adc54a9 (patch) | |
tree | c4e68a892ceba11e5fc3edec939b06435884b768 /activerecord/test | |
parent | 373a5683240f85d3538fbeeb3eca624c4cb0c90a (diff) | |
parent | 876865aba7c0ca2c069ff4be88e9916f5f0f28bd (diff) | |
download | rails-d9e4bffb60f69d972311fa7d23f4ce540adc54a9.tar.gz rails-d9e4bffb60f69d972311fa7d23f4ce540adc54a9.tar.bz2 rails-d9e4bffb60f69d972311fa7d23f4ce540adc54a9.zip |
Merge pull request #31475 from shioyama/reset_column_information_redefine_child_attribute_methods
Undefine attribute methods of descendants when resetting column information
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/persistence_test.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index c0b9a3ef76..068d80eb3b 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -1106,13 +1106,18 @@ class PersistenceTest < ActiveRecord::TestCase end def test_reset_column_information_resets_children - child = Class.new(Topic) - child.new # force schema to load + child_class = Class.new(Topic) + child_class.new # force schema to load ActiveRecord::Base.connection.add_column(:topics, :foo, :string) 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 ActiveRecord::Base.connection.remove_column(:topics, :foo) Topic.reset_column_information |