@ -25,11 +25,24 @@ class AnswerFormatValidatorTest < ActiveSupport::TestCase
|
||||
assert_match(/enter.*answer/, obj.errors.messages[:answer][0])
|
||||
end
|
||||
|
||||
test "text should FAIL with more than 1000 charactures" do
|
||||
test "text should PASS with 999 character" do
|
||||
obj = AnswerValidatable.new('text')
|
||||
obj.answer = SecureRandom.urlsafe_base64(1001)
|
||||
obj.answer = long_string_with_returns
|
||||
|
||||
assert obj.valid?
|
||||
assert obj.errors.messages.empty?
|
||||
end
|
||||
|
||||
test "text should FAIL with more than 1000 character" do
|
||||
obj = AnswerValidatable.new('text')
|
||||
obj.answer = long_string_with_returns + " - to long now "
|
||||
|
||||
refute obj.valid?
|
||||
assert_match(/char.*limit.*1000.$/, obj.errors.messages[:answer][0])
|
||||
end
|
||||
|
||||
def long_string_with_returns
|
||||
# returns 999 chars, after \r is stripped.
|
||||
"Some rando input\r\n\rYo. Making this up.\r\n" * 27
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user