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)
16 "notifications/notification",
17 :notification => notification
20 assert_dom ".web-notification" do
21 assert_dom "h2", "Note comment"
22 assert_dom "time", "less than 1 minute ago"
23 assert_dom "blockquote", note_comment.body
27 def test_render_commented_with_long_text
28 comment_author = build_stubbed(
30 :display_name => "Helpful Commenter"
32 note = build_stubbed(:note)
33 note_comment = build_stubbed(
35 :author => comment_author,
37 :body => read_fixture_file("lorem_ipsum.txt")
39 notification = build_stubbed(:notification, :record => note_comment)
42 "notifications/notification",
43 :notification => notification
46 assert_dom ".web-notification blockquote p", :count => 3
49 def test_render_closed_with_comment
50 comment_author = build_stubbed(
52 :display_name => "Helpful Commenter"
54 note = build_stubbed(:note)
55 note_comment = build_stubbed(
57 :author => comment_author,
61 notification = build_stubbed(:notification, :record => note_comment)
64 "notifications/notification",
65 :notification => notification
68 assert_dom ".web-notification" do
69 assert_dom "h2", "Note resolved"
70 assert_dom "time", "less than 1 minute ago"
71 assert_dom "blockquote", note_comment.body
75 def test_render_closed_without_comment
76 comment_author = build_stubbed(
78 :display_name => "Helpful Commenter"
80 note = build_stubbed(:note)
81 note_comment = build_stubbed(
83 :author => comment_author,
88 notification = build_stubbed(:notification, :record => note_comment)
91 "notifications/notification",
92 :notification => notification
95 assert_dom ".web-notification" do
96 assert_dom "h2", "Note resolved"
97 assert_dom "time", "less than 1 minute ago"
98 assert_not_dom "blockquote"
102 def test_render_reopened
103 comment_author = build_stubbed(
105 :display_name => "Helpful Commenter"
107 note = build_stubbed(:note)
108 note_comment = build_stubbed(
110 :author => comment_author,
112 :event => "reopened",
115 notification = build_stubbed(:notification, :record => note_comment)
118 "notifications/notification",
119 :notification => notification
122 assert_dom ".web-notification" do
123 assert_dom "h2", "Note reopened"
124 assert_dom "time", "less than 1 minute ago"
125 assert_not_dom "blockquote"