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 changeset = create(:changeset)
37 create_list(:changeset_comment, 3, :changeset_id => changeset.id)
38 assert_equal 3, Changeset.find(changeset.id).comments.count
42 ok = %W(Name vergrößern foo\nbar
44 bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
45 "foo\ufffebar", "foo\uffffbar"]
48 changeset_comment = create(:changeset_comment)
49 changeset_comment.body = body
50 assert changeset_comment.valid?, "#{body} is invalid, when it should be"
54 changeset_comment = create(:changeset_comment)
55 changeset_comment.body = body
56 assert !changeset_comment.valid?, "#{body} is valid when it shouldn't be"