1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove deprecated ActiveModel::Errors#values

This commit is contained in:
Rafael Mendonça França 2021-11-16 00:06:05 +00:00
parent 362e17e899
commit 6fed53b694
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
4 changed files with 6 additions and 29 deletions

View file

@ -1,3 +1,7 @@
* Remove deprecated `ActiveModel::Errors#values`.
*Rafael Mendonça França*
* Remove deprecated `ActiveModel::Errors#slice!`.
*Rafael Mendonça França*

View file

@ -200,15 +200,6 @@ module ActiveModel
@errors.each(&block)
end
# Returns all message values.
#
# person.errors.messages # => {:name=>["cannot be nil", "must be specified"]}
# person.errors.values # => [["cannot be nil", "must be specified"]]
def values
deprecation_removal_warning(:values, "errors.map { |error| error.message }")
@errors.map(&:message).freeze
end
# Returns all message keys.
#
# person.errors.messages # => {:name=>["cannot be nil", "must be specified"]}

View file

@ -127,16 +127,6 @@ class ErrorsTest < ActiveModel::TestCase
assert_equal ["omg"], errors["name"]
end
test "values returns an array of messages" do
errors = ActiveModel::Errors.new(Person.new)
assert_deprecated { errors.messages[:foo] = "omg" }
assert_deprecated { errors.messages[:baz] = "zomg" }
assert_deprecated do
assert_equal ["omg", "zomg"], errors.values
end
end
test "[]= overrides values" do
errors = ActiveModel::Errors.new(self)
assert_deprecated { errors.messages[:foo] = "omg" }
@ -145,16 +135,6 @@ class ErrorsTest < ActiveModel::TestCase
assert_equal ["zomg"], errors[:foo]
end
test "values returns an empty array after try to get a message only" do
errors = ActiveModel::Errors.new(Person.new)
errors.messages[:foo]
errors.messages[:baz]
assert_deprecated do
assert_equal [], errors.values
end
end
test "keys returns the error keys" do
errors = ActiveModel::Errors.new(Person.new)
assert_deprecated { errors.messages[:foo] << "omg" }

View file

@ -128,6 +128,8 @@ Please refer to the [Changelog][active-model] for detailed changes.
* Remove deprecated `ActiveModel::Errors#slice!`.
* Remove deprecated `ActiveModel::Errors#values`.
### Deprecations
### Notable changes