1 # frozen_string_literal: true
6 class NoteCommentViewTest < ActionView::TestCase
7 def test_render_commented
8 note_comment = build_stubbed(
10 :author => build_stubbed(:user),
13 notification = build_stubbed(:notification, :record => note_comment)
14 notification_wrapper = UserNotifications::NoteCommentNotification.new(notification)
16 render "notifications/note_comment", :notification => notification_wrapper
18 assert_dom ".user-notification h2", "Note comment"
19 assert_dom ".user-notification time", "less than 1 minute ago"
20 assert_dom ".user-notification blockquote", note_comment.body
23 def test_render_closed_with_comment
24 comment_author = build_stubbed(
26 :display_name => "Helpful Commenter"
28 note = build_stubbed(:note)
29 note_comment = build_stubbed(
31 :author => comment_author,
35 notification = build_stubbed(:notification, :record => note_comment)
36 notification_wrapper = UserNotifications::NoteCommentNotification.new(notification)
38 render "notifications/note_comment", :notification => notification_wrapper
40 assert_dom ".user-notification h2", "Note resolved"
41 assert_dom ".user-notification time", "less than 1 minute ago"
42 assert_dom ".user-notification blockquote", note_comment.body
45 def test_render_closed_without_comment
46 comment_author = build_stubbed(
48 :display_name => "Helpful Commenter"
50 note = build_stubbed(:note)
51 note_comment = build_stubbed(
53 :author => comment_author,
58 notification = Struct.new(:record).new(note_comment)
59 notification_wrapper = UserNotifications::NoteCommentNotification.new(notification)
61 render "notifications/note_comment", :notification => notification_wrapper
63 assert_dom ".user-notification h2", "Note resolved"
64 assert_dom ".user-notification time", "less than 1 minute ago"
65 assert_not_dom ".user-notification blockquote"
68 def test_render_reopened
69 comment_author = build_stubbed(
71 :display_name => "Helpful Commenter"
73 note = build_stubbed(:note)
74 note_comment = build_stubbed(
76 :author => comment_author,
81 notification = Struct.new(:record).new(note_comment)
82 notification_wrapper = UserNotifications::NoteCommentNotification.new(notification)
84 render "notifications/note_comment", :notification => notification_wrapper
86 assert_dom ".user-notification h2", "Note reopened"
87 assert_dom ".user-notification time", "less than 1 minute ago"
88 assert_not_dom ".user-notification blockquote"