]> git.openstreetmap.org Git - rails.git/blob - test/controllers/notifications/changeset_comment_view_test.rb
Localisation updates from https://translatewiki.net.
[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       notification = build_stubbed(:notification, :record => changeset_comment)
13       notification_wrapper = UserNotifications::ChangesetCommentNotification.new(notification)
14
15       render "notifications/changeset_comment", :notification => notification_wrapper
16
17       assert_dom ".user-notification" do
18         assert_dom "h2", "Changeset comment"
19         assert_not_dom "p", /\("/
20         assert_dom "time", "less than 1 minute ago"
21         assert_dom "blockquote", "Insightful comment"
22       end
23     end
24
25     def test_render_with_summary
26       summary_tag = build_stubbed(
27         :changeset_tag,
28         :k => "comment",
29         :v => "This is a summary"
30       )
31       changeset = build_stubbed(:changeset, :changeset_tags => [summary_tag])
32       changeset_comment = build_stubbed(
33         :changeset_comment,
34         :changeset => changeset,
35         :body => "Insightful comment"
36       )
37       notification = build_stubbed(:notification, :record => changeset_comment)
38       notification_wrapper = UserNotifications::ChangesetCommentNotification.new(notification)
39
40       render "notifications/changeset_comment", :notification => notification_wrapper
41
42       assert_dom ".user-notification" do
43         assert_dom "h2", "Changeset comment"
44         assert_dom "time", "less than 1 minute ago"
45         assert_dom ".event-description", /\("This is a summary"\)/
46         assert_dom "blockquote", "Insightful comment"
47       end
48     end
49   end
50 end