aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/dirty_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2017-04-14 13:06:26 -0700
committerGitHub <noreply@github.com>2017-04-14 13:06:26 -0700
commite7f45d370ab10ad86a748ff2ec8b34c54d87b0bf (patch)
treeabde4f8ae9236998c617aa1ccfb31e72665a8960 /activerecord/test/cases/dirty_test.rb
parente447c8c80a3f99a29286661eb47762535c249181 (diff)
parent83d6cc4815debe2086073387ecbf38c0f47cfec5 (diff)
downloadrails-e7f45d370ab10ad86a748ff2ec8b34c54d87b0bf.tar.gz
rails-e7f45d370ab10ad86a748ff2ec8b34c54d87b0bf.tar.bz2
rails-e7f45d370ab10ad86a748ff2ec8b34c54d87b0bf.zip
Merge pull request #28760 from rails/fix-attributes_name
Move around AR::Dirty and fix _attribute method
Diffstat (limited to 'activerecord/test/cases/dirty_test.rb')
-rw-r--r--activerecord/test/cases/dirty_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index 15d7a32e21..721861975a 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -671,6 +671,28 @@ class DirtyTest < ActiveRecord::TestCase
assert binary.changed?
end
+ test "changes is correct for subclass" do
+ foo = Class.new(Pirate) do
+ def catchphrase
+ super.upcase
+ end
+ end
+
+ pirate = foo.create!(catchphrase: "arrrr")
+
+ new_catchphrase = "arrrr matey!"
+
+ pirate.catchphrase = new_catchphrase
+ assert pirate.catchphrase_changed?
+
+ expected_changes = {
+ "catchphrase" => ["arrrr", new_catchphrase]
+ }
+
+ assert_equal new_catchphrase.upcase, pirate.catchphrase
+ assert_equal expected_changes, pirate.changes
+ end
+
test "changes is correct if override attribute reader" do
pirate = Pirate.create!(catchphrase: "arrrr")
def pirate.catchphrase