]> git.openstreetmap.org Git - rails.git/blob - test/controllers/notifications/changeset_comment_view_test.rb
Merge remote-tracking branch 'upstream/pull/7289'
[rails.git] / test / controllers / notifications / changeset_comment_view_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 module Notifications
6   class ChangesetCommentViewTest < ActionView::TestCase
7     def test_render_without_summary
8       changeset_comment = build_stubbed(
9         :changeset_comment,
10         :body => "Insightful comment"
11       )
12
13       notification = build_stubbed(:notification, :record => changeset_comment)
14
15       render(
16         "notifications/notification",
17         :notification => notification
18       )
19
20       assert_dom ".web-notification" do
21         assert_dom "h2", "Changeset comment"
22         assert_not_dom "p", /\("/
23         assert_dom "time", "less than 1 minute ago"
24         assert_dom "blockquote", "Insightful comment"
25       end
26     end
27
28     def test_render_with_summary
29       summary_tag = build_stubbed(
30         :changeset_tag,
31         :k => "comment",
32         :v => "This is a summary"
33       )
34       changeset = build_stubbed(:changeset, :changeset_tags => [summary_tag])
35       changeset_comment = build_stubbed(
36         :changeset_comment,
37         :changeset => changeset,
38         :body => "Insightful comment"
39       )
40       notification = build_stubbed(:notification, :record => changeset_comment)
41
42       render(
43         "notifications/notification",
44         :notification => notification
45       )
46
47       assert_dom ".web-notification" do
48         assert_dom "h2", "Changeset comment"
49         assert_dom "time", "less than 1 minute ago"
50         assert_dom ".event-description", /\("This is a summary"\)/
51         assert_dom "blockquote", "Insightful comment"
52       end
53     end
54   end
55 end