diff options
author | Wojciech Wnętrzak <w.wnetrzak@gmail.com> | 2015-02-18 23:04:16 +0100 |
---|---|---|
committer | Wojciech Wnętrzak <w.wnetrzak@gmail.com> | 2015-02-19 14:10:38 +0100 |
commit | fd38838f29ff0f4514b711c65cafe55c6f21ad2a (patch) | |
tree | dea03ed3df1c23dcbe0989a86fdcb0021323836a /activemodel/test/cases | |
parent | 39c936b7605ac90c7e9643792cfe891a2d1afbf3 (diff) | |
download | rails-fd38838f29ff0f4514b711c65cafe55c6f21ad2a.tar.gz rails-fd38838f29ff0f4514b711c65cafe55c6f21ad2a.tar.bz2 rails-fd38838f29ff0f4514b711c65cafe55c6f21ad2a.zip |
Deprecate `ActiveModel::Errors` `add_on_empty` and `add_on_blank` methods
without replacement.
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/errors_test.rb | 28 | ||||
-rw-r--r-- | activemodel/test/cases/validations/i18n_generate_message_validation_test.rb | 2 |
2 files changed, 22 insertions, 8 deletions
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index e736ccf6a0..da142ea2c0 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -288,46 +288,60 @@ class ErrorsTest < ActiveModel::TestCase test "add_on_empty generates message" do person = Person.new person.errors.expects(:generate_message).with(:name, :empty, {}) - person.errors.add_on_empty :name + assert_deprecated do + person.errors.add_on_empty :name + end end test "add_on_empty generates message for multiple attributes" do person = Person.new person.errors.expects(:generate_message).with(:name, :empty, {}) person.errors.expects(:generate_message).with(:age, :empty, {}) - person.errors.add_on_empty [:name, :age] + assert_deprecated do + person.errors.add_on_empty [:name, :age] + end end test "add_on_empty generates message with custom default message" do person = Person.new person.errors.expects(:generate_message).with(:name, :empty, { message: 'custom' }) - person.errors.add_on_empty :name, message: 'custom' + assert_deprecated do + person.errors.add_on_empty :name, message: 'custom' + end end test "add_on_empty generates message with empty string value" do person = Person.new person.name = '' person.errors.expects(:generate_message).with(:name, :empty, {}) - person.errors.add_on_empty :name + assert_deprecated do + person.errors.add_on_empty :name + end end test "add_on_blank generates message" do person = Person.new person.errors.expects(:generate_message).with(:name, :blank, {}) - person.errors.add_on_blank :name + assert_deprecated do + person.errors.add_on_blank :name + end end test "add_on_blank generates message for multiple attributes" do person = Person.new person.errors.expects(:generate_message).with(:name, :blank, {}) person.errors.expects(:generate_message).with(:age, :blank, {}) - person.errors.add_on_blank [:name, :age] + assert_deprecated do + person.errors.add_on_blank [:name, :age] + end end test "add_on_blank generates message with custom default message" do person = Person.new person.errors.expects(:generate_message).with(:name, :blank, { message: 'custom' }) - person.errors.add_on_blank :name, message: 'custom' + assert_deprecated do + person.errors.add_on_blank :name, message: 'custom' + end end test "details returns added error detail" do diff --git a/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb b/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb index 3eeb80a48b..da63df9152 100644 --- a/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb +++ b/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb @@ -62,7 +62,7 @@ class I18nGenerateMessageValidationTest < ActiveModel::TestCase assert_equal 'custom message', @person.errors.generate_message(:title, :empty, message: 'custom message') end - # add_on_blank: generate_message(attr, :blank, message: custom_message) + # validates_presence_of: generate_message(attr, :blank, message: custom_message) def test_generate_message_blank_with_default_message assert_equal "can't be blank", @person.errors.generate_message(:title, :blank) end |