1 # frozen_string_literal: true
 
   5 class DiaryCommentTest < ActiveSupport::TestCase
 
   7     # Create the default language for diary entries
 
   8     create(:language, :code => "en")
 
  11   test "body must be present" do
 
  12     comment = build(:diary_comment, :body => "")
 
  13     assert_not comment.valid?
 
  14     assert_not_nil comment.errors[:body], "no validation error for missing body"
 
  17   test "body must not be too long" do
 
  18     comment = build(:diary_comment, :body => "x" * 65536)
 
  19     assert_predicate comment, :valid?
 
  21     comment = build(:diary_comment, :body => "x" * 65537)
 
  22     assert_not_predicate comment, :valid?
 
  23     assert_not_nil comment.errors[:body], "no validation error for body too long"