diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2017-02-11 17:46:28 -0500 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2017-02-11 17:46:28 -0500 |
commit | 4fed08fa787a316fa51f14baca9eae11913f5050 (patch) | |
tree | b755a21b5cb56158bcababc26ce97b00b6332d35 /activerecord/test/cases/dirty_test.rb | |
parent | eb4aba0052a0a51d26ec31640fc833e3848dc9e8 (diff) | |
download | rails-4fed08fa787a316fa51f14baca9eae11913f5050.tar.gz rails-4fed08fa787a316fa51f14baca9eae11913f5050.tar.bz2 rails-4fed08fa787a316fa51f14baca9eae11913f5050.zip |
Deprecate calling `attr_will_change!` with non-attributes
This was never really intended to work (at least not without calling
`define_attribute_methods`, which is less common with Active Record). As
we move forward the intention is to require the use of `attribute` over
`attr_accessor` for more complex model behavior both on Active Record
and Active Model, so this behavior is deprecated.
Fixes #27956.
Close #27963.
[Alex Serban & Sean Griffin]
Diffstat (limited to 'activerecord/test/cases/dirty_test.rb')
-rw-r--r-- | activerecord/test/cases/dirty_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb index 0e58e65a07..c0d6ddcea7 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -301,6 +301,14 @@ class DirtyTest < ActiveRecord::TestCase assert_equal ["arr", "arr matey!"], pirate.catchphrase_change end + def test_virtual_attribute_will_change + assert_deprecated do + parrot = Parrot.create!(name: "Ruby") + parrot.send(:attribute_will_change!, :cancel_save_from_callback) + assert parrot.has_changes_to_save? + end + end + def test_association_assignment_changes_foreign_key pirate = Pirate.create!(catchphrase: "jarl") pirate.parrot = Parrot.create!(name: "Lorre") |