1 # frozen_string_literal: true
5 class NoteCommentTest < ActiveSupport::TestCase
7 ok = %w[opened closed reopened commented hidden]
8 bad = %w[expropriated fubared]
11 note_comment = create(:note_comment)
12 note_comment.event = event
13 assert_predicate note_comment, :valid?, "#{event} is invalid, when it should be"
17 note_comment = create(:note_comment)
18 note_comment.event = event
19 assert_not_predicate note_comment, :valid?, "#{event} is valid when it shouldn't be"
24 ok = %W[Name vergrößern foo\nbar
26 bad = ["foo\x00bar", "foo\x08bar", "foo\x1fbar", "foo\x7fbar",
27 "foo\ufffebar", "foo\uffffbar"]
30 note_comment = create(:note_comment)
31 note_comment.body = body
32 assert_predicate note_comment, :valid?, "#{body} is invalid, when it should be"
36 note_comment = create(:note_comment)
37 note_comment.body = body
38 assert_not_predicate note_comment, :valid?, "#{body} is valid when it shouldn't be"
42 def test_notifiable_subscribers
43 commenter1 = create(:user)
44 commenter2 = create(:user, :suspended)
45 commenter3 = create(:user)
46 commenter4 = create(:user)
48 create(:note_subscription, :note => note, :user => commenter1)
49 create(:note_subscription, :note => note, :user => commenter2)
50 create(:note_subscription, :note => note, :user => commenter3)
51 create(:note_subscription, :note => note, :user => commenter4)
52 comment = create(:note_comment, :note => note, :author => commenter4)
54 assert_equal comment.notifiable_subscribers.sort, [commenter1, commenter3].sort