1 # -*- coding: utf-8 -*-
4 class ChangesetCommentTest < ActiveSupport::TestCase
5 fixtures :changesets, :changeset_comments
7 def test_changeset_comment_count
8 assert_equal 4, ChangesetComment.count
12 def test_does_not_accept_invalid_author
13 comment = changeset_comments(:normal_comment_1)
16 assert !comment.valid?
18 comment.author_id = 999111
19 assert !comment.valid?
22 def test_does_not_accept_invalid_changeset
23 comment = changeset_comments(:normal_comment_1)
25 comment.changeset = nil
26 assert !comment.valid?
28 comment.changeset_id = 999111
29 assert !comment.valid?
32 def test_does_not_accept_empty_visible
33 comment = changeset_comments(:normal_comment_1)
36 assert !comment.valid?
39 def test_comments_of_changeset_count
40 assert_equal 3, Changeset.find(changesets(:normal_user_closed_change).id).comments.count
44 ok = %W(Name vergrößern foo\nbar
46 bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
47 "foo\ufffebar", "foo\uffffbar"]
50 changeset_comment = changeset_comments(:normal_comment_1)
51 changeset_comment.body = body
52 assert changeset_comment.valid?, "#{body} is invalid, when it should be"
56 changeset_comment = changeset_comments(:normal_comment_1)
57 changeset_comment.body = body
58 assert !changeset_comment.valid?, "#{body} is valid when it shouldn't be"