From 13b77fa1cb49495f1da79fec6f06475d5dd29af7 Mon Sep 17 00:00:00 2001 From: Ronan Limon Duparcmeur Date: Fri, 9 Nov 2018 16:45:18 +0100 Subject: Fix ignored options in the `#added?` method Fixes #34416 --- activemodel/test/cases/errors_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activemodel/test/cases') diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index 41ff6443fe..185b5a24ae 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -228,6 +228,16 @@ class ErrorsTest < ActiveModel::TestCase assert_not person.errors.added?(:name) end + test "added? returns false when checking for an error with an incorrect or missing option" do + person = Person.new + person.errors.add :name, :too_long, count: 25 + + assert person.errors.added? :name, :too_long, count: 25 + assert_not person.errors.added? :name, :too_long, count: 24 + assert_not person.errors.added? :name, :too_long + assert_not person.errors.added? :name, "is too long" + end + test "added? returns false when checking for an error by symbol and a different error with same message is present" do I18n.backend.store_translations("en", errors: { attributes: { name: { wrong: "is wrong", used: "is wrong" } } }) person = Person.new -- cgit v1.2.3