Skip to content

Commit 50ec25b

Browse files
committed
Remove duplicated tests
1 parent 7c788e9 commit 50ec25b

File tree

1 file changed

+8
-54
lines changed

1 file changed

+8
-54
lines changed

activemodel/test/cases/errors_test.rb

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,8 @@ def test_each_when_arity_is_negative
5555
def test_any?
5656
errors = ActiveModel::Errors.new(Person.new)
5757
errors.add(:name)
58-
assert_not_deprecated {
59-
assert errors.any?, "any? should return true"
60-
}
61-
assert_not_deprecated {
62-
assert errors.any? { |_| true }, "any? should return true"
63-
}
58+
assert errors.any?, "any? should return true"
59+
assert errors.any? { |_| true }, "any? should return true"
6460
end
6561

6662
def test_first
@@ -169,32 +165,6 @@ def test_no_key
169165
assert_equal ["cannot be nil"], person.errors[:name]
170166
end
171167

172-
test "add an error message on a specific attribute (deprecated)" do
173-
person = Person.new
174-
person.errors.add(:name, "cannot be blank")
175-
assert_equal ["cannot be blank"], person.errors[:name]
176-
end
177-
178-
test "add an error message on a specific attribute with a defined type (deprecated)" do
179-
person = Person.new
180-
person.errors.add(:name, :blank, message: "cannot be blank")
181-
assert_equal ["cannot be blank"], person.errors[:name]
182-
end
183-
184-
test "add an error with a symbol (deprecated)" do
185-
person = Person.new
186-
person.errors.add(:name, :blank)
187-
message = person.errors.generate_message(:name, :blank)
188-
assert_equal [message], person.errors[:name]
189-
end
190-
191-
test "add an error with a proc (deprecated)" do
192-
person = Person.new
193-
message = Proc.new { "cannot be blank" }
194-
person.errors.add(:name, message)
195-
assert_equal ["cannot be blank"], person.errors[:name]
196-
end
197-
198168
test "add creates an error object and returns it" do
199169
person = Person.new
200170
error = person.errors.add(:name, :blank)
@@ -249,6 +219,12 @@ def test_no_key
249219
assert_equal ["can't be blank"], person.errors[:name]
250220
end
251221

222+
test "add an error message on a specific attribute with a defined type" do
223+
person = Person.new
224+
person.errors.add(:name, :blank, message: "cannot be blank")
225+
assert_equal ["cannot be blank"], person.errors[:name]
226+
end
227+
252228
test "initialize options[:message] as Proc, which evaluates to String" do
253229
msg = "custom msg"
254230
type = Proc.new { msg }
@@ -641,16 +617,6 @@ def call
641617
assert_empty person.errors.details
642618
end
643619

644-
test "copy errors (deprecated)" do
645-
errors = ActiveModel::Errors.new(Person.new)
646-
errors.add(:name, :invalid)
647-
person = Person.new
648-
person.errors.copy!(errors)
649-
650-
assert_equal [:name], person.errors.messages.keys
651-
assert_equal [:name], person.errors.details.keys
652-
end
653-
654620
test "details returns empty array when accessed with non-existent attribute" do
655621
errors = ActiveModel::Errors.new(Person.new)
656622

@@ -669,18 +635,6 @@ def call
669635
end
670636
end
671637

672-
test "merge errors (deprecated)" do
673-
errors = ActiveModel::Errors.new(Person.new)
674-
errors.add(:name, :invalid)
675-
676-
person = Person.new
677-
person.errors.add(:name, :blank)
678-
person.errors.merge!(errors)
679-
680-
assert_equal({ name: ["can't be blank", "is invalid"] }, person.errors.messages)
681-
assert_equal({ name: [{ error: :blank }, { error: :invalid }] }, person.errors.details)
682-
end
683-
684638
test "merge errors" do
685639
errors = ActiveModel::Errors.new(Person.new)
686640
errors.add(:name, :invalid)

0 commit comments

Comments
 (0)