]> git.openstreetmap.org Git - rails.git/blob - test/controllers/notifications/diary_comment_view_test.rb
Merge remote-tracking branch 'upstream/pull/7294'
[rails.git] / test / controllers / notifications / diary_comment_view_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 module Notifications
6   class DiaryCommentViewTest < ActionView::TestCase
7     def test_render
8       diary_comment = build_stubbed(:diary_comment)
9       notification = build_stubbed(:notification, :record => diary_comment)
10
11       render(
12         "notifications/notification",
13         :notification => notification
14       )
15
16       assert_dom ".web-notification" do
17         assert_dom "h2", "Diary comment"
18         assert_dom "time", "less than 1 minute ago"
19         assert_dom "blockquote", diary_comment.body
20       end
21     end
22
23     def test_render_with_long_text
24       comment_user = build_stubbed(
25         :user,
26         :display_name => "Helpful Commenter"
27       )
28       diary_entry = build_stubbed(:diary_entry)
29       diary_comment = build_stubbed(
30         :diary_comment,
31         :user => comment_user,
32         :diary_entry => diary_entry,
33         :body => read_fixture_file("lorem_ipsum.txt")
34       )
35       notification = build_stubbed(:notification, :record => diary_comment)
36
37       render(
38         "notifications/notification",
39         :notification => notification
40       )
41
42       assert_dom ".web-notification blockquote p", :count => 3
43     end
44   end
45 end