diff options
author | lulalala <mark@goodlife.tw> | 2018-12-26 22:35:45 +0800 |
---|---|---|
committer | lulalala <mark@goodlife.tw> | 2019-03-31 22:59:12 +0800 |
commit | 23dd7c0285fb81a675f8e18ee3be60397060655d (patch) | |
tree | e70a8cd8faf2e7ff84d7fff6663871b17e7749cd | |
parent | ba38b40e83302cb9da17c95086d93e5071426668 (diff) | |
download | rails-23dd7c0285fb81a675f8e18ee3be60397060655d.tar.gz rails-23dd7c0285fb81a675f8e18ee3be60397060655d.tar.bz2 rails-23dd7c0285fb81a675f8e18ee3be60397060655d.zip |
Assert deprecation
-rw-r--r-- | activemodel/test/cases/validations_test.rb | 12 | ||||
-rw-r--r-- | activerecord/test/cases/persistence_test.rb | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index 82bb66b550..0b9e1b7005 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -53,7 +53,7 @@ class ValidationsTest < ActiveModel::TestCase r = Reply.new r.valid? - errors = r.errors.collect { |attr, messages| [attr.to_s, messages] } + errors = assert_deprecated { r.errors.collect { |attr, messages| [attr.to_s, messages] } } assert_includes errors, ["title", "is Empty"] assert_includes errors, ["content", "is Empty"] @@ -216,7 +216,7 @@ class ValidationsTest < ActiveModel::TestCase t = Topic.new assert_predicate t, :invalid? - xml = t.errors.to_xml + xml = assert_deprecated { t.errors.to_xml } assert_match %r{<errors>}, xml assert_match %r{<error>Title can't be blank</error>}, xml assert_match %r{<error>Content can't be blank</error>}, xml @@ -241,14 +241,14 @@ class ValidationsTest < ActiveModel::TestCase t = Topic.new title: "" assert_predicate t, :invalid? - assert_equal :title, key = t.errors.keys[0] + assert_equal :title, key = assert_deprecated { t.errors.keys[0] } assert_equal "can't be blank", t.errors[key][0] assert_equal "is too short (minimum is 2 characters)", t.errors[key][1] - assert_equal :author_name, key = t.errors.keys[1] + assert_equal :author_name, key = assert_deprecated { t.errors.keys[1] } assert_equal "can't be blank", t.errors[key][0] - assert_equal :author_email_address, key = t.errors.keys[2] + assert_equal :author_email_address, key = assert_deprecated { t.errors.keys[2] } assert_equal "will never be valid", t.errors[key][0] - assert_equal :content, key = t.errors.keys[3] + assert_equal :content, key = assert_deprecated { t.errors.keys[3] } assert_equal "is too short (minimum is 2 characters)", t.errors[key][0] end diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index d5057ad381..7b7aa7e9b7 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -183,7 +183,7 @@ class PersistenceTest < ActiveRecord::TestCase assert_not_predicate company, :valid? original_errors = company.errors client = company.becomes(Client) - assert_equal original_errors.keys, client.errors.keys + assert_equal assert_deprecated { original_errors.keys }, assert_deprecated { client.errors.keys } end def test_becomes_errors_base @@ -197,7 +197,7 @@ class PersistenceTest < ActiveRecord::TestCase admin.errors.add :token, :invalid child = admin.becomes(child_class) - assert_equal [:token], child.errors.keys + assert_equal [:token], assert_deprecated { child.errors.keys } assert_nothing_raised do child.errors.add :foo, :invalid end |