1 # -*- coding: utf-8 -*-
4 class ChangesetCommentTest < ActiveSupport::TestCase
6 def test_does_not_accept_invalid_author
7 comment = create(:changeset_comment)
10 assert !comment.valid?
12 comment.author_id = 999111
13 assert !comment.valid?
16 def test_does_not_accept_invalid_changeset
17 comment = create(:changeset_comment)
19 comment.changeset = nil
20 assert !comment.valid?
22 comment.changeset_id = 999111
23 assert !comment.valid?
26 def test_does_not_accept_empty_visible
27 comment = create(:changeset_comment)
30 assert !comment.valid?
33 def test_comments_of_changeset_count
34 changeset = create(:changeset)
35 create_list(:changeset_comment, 3, :changeset_id => changeset.id)
36 assert_equal 3, Changeset.find(changeset.id).comments.count
40 ok = %W[Name vergrößern foo\nbar
42 bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
43 "foo\ufffebar", "foo\uffffbar"]
46 changeset_comment = create(:changeset_comment)
47 changeset_comment.body = body
48 assert changeset_comment.valid?, "#{body} is invalid, when it should be"
52 changeset_comment = create(:changeset_comment)
53 changeset_comment.body = body
54 assert !changeset_comment.valid?, "#{body} is valid when it shouldn't be"