]> git.openstreetmap.org Git - rails.git/blob - test/controllers/notifications/note_comment_view_test.rb
Localisation updates from https://translatewiki.net.
[rails.git] / test / controllers / notifications / note_comment_view_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 module Notifications
6   class NoteCommentViewTest < ActionView::TestCase
7     def test_render_commented
8       note_comment = build_stubbed(
9         :note_comment,
10         :author => build_stubbed(:user),
11         :event => "commented"
12       )
13       notification = build_stubbed(:notification, :record => note_comment)
14       notification_wrapper = UserNotifications::NoteCommentNotification.new(notification)
15
16       render "notifications/note_comment", :notification => notification_wrapper
17
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
21     end
22
23     def test_render_closed_with_comment
24       comment_author = build_stubbed(
25         :user,
26         :display_name => "Helpful Commenter"
27       )
28       note = build_stubbed(:note)
29       note_comment = build_stubbed(
30         :note_comment,
31         :author => comment_author,
32         :note => note,
33         :event => "closed"
34       )
35       notification = build_stubbed(:notification, :record => note_comment)
36       notification_wrapper = UserNotifications::NoteCommentNotification.new(notification)
37
38       render "notifications/note_comment", :notification => notification_wrapper
39
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
43     end
44
45     def test_render_closed_without_comment
46       comment_author = build_stubbed(
47         :user,
48         :display_name => "Helpful Commenter"
49       )
50       note = build_stubbed(:note)
51       note_comment = build_stubbed(
52         :note_comment,
53         :author => comment_author,
54         :note => note,
55         :event => "closed",
56         :body => ""
57       )
58       notification = Struct.new(:record).new(note_comment)
59       notification_wrapper = UserNotifications::NoteCommentNotification.new(notification)
60
61       render "notifications/note_comment", :notification => notification_wrapper
62
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"
66     end
67
68     def test_render_reopened
69       comment_author = build_stubbed(
70         :user,
71         :display_name => "Helpful Commenter"
72       )
73       note = build_stubbed(:note)
74       note_comment = build_stubbed(
75         :note_comment,
76         :author => comment_author,
77         :note => note,
78         :event => "reopened",
79         :body => ""
80       )
81       notification = Struct.new(:record).new(note_comment)
82       notification_wrapper = UserNotifications::NoteCommentNotification.new(notification)
83
84       render "notifications/note_comment", :notification => notification_wrapper
85
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"
89     end
90   end
91 end