From 6fed53b694dcb2f510a93ef10b275bc13534b97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 16 Nov 2021 00:06:05 +0000 Subject: [PATCH] Remove deprecated `ActiveModel::Errors#values` --- activemodel/CHANGELOG.md | 4 ++++ activemodel/lib/active_model/errors.rb | 9 --------- activemodel/test/cases/errors_test.rb | 20 -------------------- guides/source/7_0_release_notes.md | 2 ++ 4 files changed, 6 insertions(+), 29 deletions(-) diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 661971ab32..f741d46b08 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,3 +1,7 @@ +* Remove deprecated `ActiveModel::Errors#values`. + + *Rafael Mendonça França* + * Remove deprecated `ActiveModel::Errors#slice!`. *Rafael Mendonça França* diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index a3081a97a8..8fa1c37ec8 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -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"]} diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index 1bb68f732a..a2a892bce5 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -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" } diff --git a/guides/source/7_0_release_notes.md b/guides/source/7_0_release_notes.md index 8e20dc9e1d..a0e8269b9a 100644 --- a/guides/source/7_0_release_notes.md +++ b/guides/source/7_0_release_notes.md @@ -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