forked from publiclab/plots2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspam2_test.rb
160 lines (148 loc) · 5 KB
/
spam2_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
require "application_system_test_case"
class SpamTest < ApplicationSystemTestCase
def setup
visit "/"
click_on "Login"
fill_in 'user_session[username]', with: 'palpatine'
fill_in 'user_session[password]', with: 'secretive'
click_on "Log in"
end
test "Delete node in spam2" do
spam_page = nodes(:first_timer_note)
visit "/spam2"
accept_confirm "Are you sure you want to delete #{spam_page.path}?" do
find("a[href='/notes/delete/#{spam_page.id}'").click()
end
assert_selector('div.alert', text: 'Node Deleted')
end
test "publish node in spam2" do
publish_page = nodes(:first_timer_note)
visit "/spam2"
find("a[href='/moderate/publish/#{publish_page.id}'").click()
page.assert_selector("div.alert", text: "Content published.")
end
test "spam post in spam2" do
spam_page = nodes(:first_timer_note)
visit "/spam2"
find("a[href='/moderate/spam/#{spam_page.id}'").click()
page.assert_selector("div.alert", text: "Content spammed.")
end
test "ban and unban authors in spam2" do
ban_page = nodes(:first_timer_note)
visit "/spam2"
within "#n#{ban_page.id}" do
find("a[href='/ban/#{ban_page.author.id}'").click()
end
visit "/profile/#{ban_page.author.username}"
find("a#info-ellipsis").click()
page.assert_selector "a[href='/unban/#{ban_page.author.id}'"
visit "/spam2"
within "#n#{ban_page.id}" do
find("a[href='/unban/#{ban_page.author.id}'").click()
end
visit "/profile/#{ban_page.author.username}"
find("a#info-ellipsis").click()
page.assert_selector "a[href='/ban/#{ban_page.author.id}'"
end
test "batch spam nodes" do
banned_page1 = nodes(:first_timer_note)
banned_page2 = nodes(:first_timer_question)
visit "/spam2"
# Click on the checkboxes of unmoderated nodes
within "#n#{banned_page1.id}" do
find(".selectedId").click()
end
within "#n#{banned_page2.id}" do
find(".selectedId").click()
end
find("#batch-spam").click()
page.assert_selector "div.alert-success"
#check if author is banned
visit "/profile/#{banned_page1.author.username}"
assert find("div.alert", text: "That user has been banned.")
find("a#info-ellipsis").click()
page.assert_selector "a[href='/unban/#{banned_page1.author.id}'"
visit "/profile/#{banned_page2.author.username}"
assert find("div.alert", text: "That user has been banned.")
find("a#info-ellipsis").click()
page.assert_selector "a[href='/unban/#{banned_page2.author.id}']"
end
test "Batch publish nodes" do
page1 = nodes(:first_timer_note)
page2 = nodes(:first_timer_question)
visit "/spam2"
within "#n#{page1.id}" do
find(".selectedId").click()
end
within "#n#{page2.id}" do
find(".selectedId").click()
end
find("#batch-publish").click()
page.assert_selector "div.alert-success"
visit "/profile/#{page1.author.username}"
find("a#info-ellipsis").click()
page.assert_selector "a[href='/ban/#{page1.author.id}'"
visit "/profile/#{page2.author.username}"
find("a#info-ellipsis").click()
page.assert_selector "a[href='/ban/#{page2.author.id}'"
end
test "batch delete nodes" do
page1 = nodes(:first_timer_note)
page2 = nodes(:first_timer_question)
visit "/spam2"
within "#n#{page1.id}" do
find(".selectedId").click()
end
within "#n#{page2.id}" do
find(".selectedId").click()
end
find("#delete-batch").click()
assert_selector('div.alert', text: '2 nodes deleted')
end
test "Batch ban and batch unban" do
page1 = nodes(:first_timer_note)
page2 = nodes(:first_timer_question)
visit "/spam2"
within "#n#{page1.id}" do
find(".selectedId").click()
end
within "#n#{page2.id}" do
find(".selectedId").click()
end
find("#batch-ban").click()
assert_selector('div.alert', text: '2 users banned.')
visit "/profile/#{page1.author.username}"
find("a#info-ellipsis").click()
page.assert_selector "a[href='/unban/#{page1.author.id}'"
visit "/profile/#{page2.author.username}"
find("a#info-ellipsis").click()
page.assert_selector "a[href='/unban/#{page2.author.id}'"
visit "/spam2"
within "#n#{page1.id}" do
find(".selectedId").click()
end
within "#n#{page2.id}" do
find(".selectedId").click()
end
find("#batch-unban").click()
assert_selector('div.alert', text: '2 users unbanned.')
visit "/profile/#{page1.author.username}"
find("a#info-ellipsis").click()
page.assert_selector "a[href='/ban/#{page1.author.id}'"
visit "/profile/#{page2.author.username}"
find("a#info-ellipsis").click()
page.assert_selector "a[href='/ban/#{page2.author.id}'"
end
test "select count" do
page1 = nodes(:first_timer_note)
page2 = nodes(:first_timer_question)
visit "/spam2"
within "#n#{page1.id}" do
find(".selectedId").click()
end
within "#n#{page2.id}" do
find(".selectedId").click()
end
assert_selector('#select-count', text: '2')
end
end