1 # -*- coding: utf-8 -*-
4 class ChangesetCommentTest < ActiveSupport::TestCase
5 fixtures :changesets, :users
8 def test_does_not_accept_invalid_author
9 comment = create(:changeset_comment)
12 assert !comment.valid?
14 comment.author_id = 999111
15 assert !comment.valid?
18 def test_does_not_accept_invalid_changeset
19 comment = create(:changeset_comment)
21 comment.changeset = nil
22 assert !comment.valid?
24 comment.changeset_id = 999111
25 assert !comment.valid?
28 def test_does_not_accept_empty_visible
29 comment = create(:changeset_comment)
32 assert !comment.valid?
35 def test_comments_of_changeset_count
36 create_list(:changeset_comment, 3, :changeset_id => changesets(:normal_user_closed_change).id)
37 assert_equal 3, Changeset.find(changesets(:normal_user_closed_change).id).comments.count
41 ok = %W(Name vergrößern foo\nbar
43 bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
44 "foo\ufffebar", "foo\uffffbar"]
47 changeset_comment = create(:changeset_comment)
48 changeset_comment.body = body
49 assert changeset_comment.valid?, "#{body} is invalid, when it should be"
53 changeset_comment = create(:changeset_comment)
54 changeset_comment.body = body
55 assert !changeset_comment.valid?, "#{body} is valid when it shouldn't be"