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