]> git.openstreetmap.org Git - rails.git/blob - test/models/diary_comment_test.rb
Merge pull request #6394 from openstreetmap/dependabot/github_actions/ruby/setup...
[rails.git] / test / models / diary_comment_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 class DiaryCommentTest < ActiveSupport::TestCase
6   def setup
7     # Create the default language for diary entries
8     create(:language, :code => "en")
9   end
10
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"
15   end
16
17   test "body must not be too long" do
18     comment = build(:diary_comment, :body => "x" * 65536)
19     assert_predicate comment, :valid?
20
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"
24   end
25 end