diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-12-04 15:50:31 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-12-04 15:50:31 -0700 |
commit | d1f003e67b6438a0c5367962fa1a35cd22e7cc8c (patch) | |
tree | 477fba294e0701df58387306c4e3b5b1707a43fe /activerecord | |
parent | 08ff4ccbbb3fb143a02e6752efb974a4bcfcd3bb (diff) | |
download | rails-d1f003e67b6438a0c5367962fa1a35cd22e7cc8c.tar.gz rails-d1f003e67b6438a0c5367962fa1a35cd22e7cc8c.tar.bz2 rails-d1f003e67b6438a0c5367962fa1a35cd22e7cc8c.zip |
Correctly handle multiple attribute method prefix/suffixes which match
Active Record defines `attribute_method_suffix :?`. That suffix will
match any predicate method when the lookup occurs in Active Model. This
will make it incorrectly decide that `id_changed?` should not exist,
because it attempts to determine if the attribute `id_changed` is
present, rather than `id` with the `_changed?` suffix. Instead, we will
look for any correct match.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 67bb405629..6acd9aa39f 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1527,4 +1527,14 @@ class BasicsTest < ActiveRecord::TestCase test "records without an id have unique hashes" do assert_not_equal Post.new.hash, Post.new.hash end + + test "resetting column information doesn't remove attribute methods" do + topic = topics(:first) + + assert_not topic.id_changed? + + Topic.reset_column_information + + assert_not topic.id_changed? + end end |