]> git.openstreetmap.org Git - rails.git/blob - test/system/note_comments_test.rb
Add frozen_string_literal comments to ruby files
[rails.git] / test / system / note_comments_test.rb
1 # frozen_string_literal: true
2
3 require "application_system_test_case"
4
5 class NoteCommentsTest < ApplicationSystemTestCase
6   test "open note has login notice" do
7     note = create(:note_with_comments)
8     visit note_path(note)
9
10     within_sidebar do
11       assert_no_button "Resolve"
12       assert_no_button "Comment"
13       assert_link "Log in to comment on this note", :href => login_path(:referer => note_path(note))
14     end
15   end
16
17   test "closed note has no login notice" do
18     note = create(:note_with_comments, :closed)
19     visit note_path(note)
20
21     within_sidebar do
22       assert_no_button "Reactivate"
23       assert_no_link "Log in to comment on this note"
24     end
25   end
26
27   test "can add comment" do
28     note = create(:note_with_comments)
29     user = create(:user)
30     sign_in_as(user)
31     visit note_path(note)
32
33     within_sidebar do
34       assert_no_content "Comment from #{user.display_name}"
35       assert_no_content "Some newly added note comment"
36       assert_button "Resolve"
37       assert_button "Comment", :disabled => true
38
39       fill_in "text", :with => "Some newly added note comment"
40
41       assert_button "Comment & Resolve"
42       assert_button "Comment", :disabled => false
43
44       click_on "Comment"
45
46       assert_content "Comment from #{user.display_name}"
47       assert_content "Some newly added note comment"
48     end
49   end
50
51   test "can't add a comment when blocked" do
52     note = create(:note_with_comments)
53     user = create(:user)
54     sign_in_as(user)
55     visit note_path(note)
56     block = create(:user_block, :user => user)
57
58     within_sidebar do
59       fill_in "text", :with => "Comment that won't be added while blocked"
60
61       assert_no_text "Comment from #{user.display_name}"
62       assert_no_text "Comment that won't be added while blocked"
63       assert_no_text "Your access to the API has been blocked"
64       assert_button "Comment & Resolve", :disabled => false
65       assert_button "Comment", :disabled => false
66
67       click_on "Comment"
68
69       assert_no_text "Comment from #{user.display_name}"
70       assert_no_text "Comment that won't be added while blocked"
71       assert_text "Your access to the API has been blocked"
72       assert_button "Comment & Resolve", :disabled => false
73       assert_button "Comment", :disabled => false
74
75       block.revoke! block.creator
76
77       click_on "Comment"
78
79       assert_text "Comment from #{user.display_name}"
80       assert_text "Comment that won't be added while blocked"
81       assert_no_text "Your access to the API has been blocked"
82     end
83   end
84
85   test "no subscribe button when not logged in" do
86     note = create(:note_with_comments)
87     visit note_path(note)
88
89     within_sidebar do
90       assert_no_button "Subscribe"
91       assert_no_button "Unsubscribe"
92     end
93   end
94
95   test "can subscribe" do
96     note = create(:note_with_comments)
97     user = create(:user)
98     sign_in_as(user)
99     visit note_path(note)
100
101     within_sidebar do
102       assert_button "Subscribe"
103       assert_no_button "Unsubscribe"
104
105       click_on "Subscribe"
106
107       assert_no_button "Subscribe"
108       assert_button "Unsubscribe"
109     end
110   end
111
112   test "can unsubscribe" do
113     note = create(:note_with_comments)
114     user = create(:user)
115     create(:note_subscription, :note => note, :user => user)
116     sign_in_as(user)
117     visit note_path(note)
118
119     within_sidebar do
120       assert_no_button "Subscribe"
121       assert_button "Unsubscribe"
122
123       click_on "Unsubscribe"
124
125       assert_button "Subscribe"
126       assert_no_button "Unsubscribe"
127     end
128   end
129 end