3 class ChangesetCommentTest < ActiveSupport::TestCase
5 def test_does_not_accept_invalid_author
6 comment = create(:changeset_comment)
9 assert_not comment.valid?
11 comment.author_id = 999111
12 assert_not comment.valid?
15 def test_does_not_accept_invalid_changeset
16 comment = create(:changeset_comment)
18 comment.changeset = nil
19 assert_not comment.valid?
21 comment.changeset_id = 999111
22 assert_not comment.valid?
25 def test_does_not_accept_empty_visible
26 comment = create(:changeset_comment)
29 assert_not comment.valid?
32 def test_comments_of_changeset_count
33 changeset = create(:changeset)
34 create_list(:changeset_comment, 3, :changeset_id => changeset.id)
35 assert_equal 3, Changeset.find(changeset.id).comments.count
39 ok = %W[Name vergrößern foo\nbar
41 bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
42 "foo\ufffebar", "foo\uffffbar"]
45 changeset_comment = create(:changeset_comment)
46 changeset_comment.body = body
47 assert changeset_comment.valid?, "#{body} is invalid, when it should be"
51 changeset_comment = create(:changeset_comment)
52 changeset_comment.body = body
53 assert !changeset_comment.valid?, "#{body} is valid when it shouldn't be"