-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add system tests for moderation (#7268)
* add system tests for moderation * consistency * remove unfinished test
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require "application_system_test_case" | ||
|
||
class ModerationTest < 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 "banning and unbanning a user" do | ||
visit "/profile/#{users(:bob).username}" | ||
|
||
find("a#info-ellipsis").click | ||
accept_confirm "Are you sure? The user will no longer be able to log in or publish, and their content will be hidden." do | ||
find("a[href='/ban/#{users(:bob).id}'").click() | ||
end | ||
assert find("div.alert", text: "That user has been banned.") | ||
|
||
find("a#info-ellipsis").click | ||
find("a[href='/unban/#{users(:bob).id}'").click() | ||
assert find("div.alert", text: "The user has been unbanned.") | ||
end | ||
|
||
test "moderating and unmoderating a user" do | ||
visit "/profile/#{users(:bob).username}" | ||
|
||
find("a#info-ellipsis").click() | ||
accept_confirm "Are you sure? The user will no longer be able to log in or publish." do | ||
find("a[href='/admin/moderate/#{users(:bob).id}'").click() | ||
end | ||
assert find("div.alert", text: "That user has been placed in moderation.") | ||
|
||
find("a#info-ellipsis").click() | ||
find("a[href='/admin/unmoderate/#{users(:bob).id}'").click() | ||
assert find("div.alert", text: "The user has been unmoderated.") | ||
end | ||
|
||
test "batch-spamming users" do | ||
banned_page = nodes(:spam_targeted_page) | ||
banned_page2 = nodes(:wiki_page) | ||
visit "/spam/batch/#{banned_page.id},#{banned_page2.id}" | ||
page.assert_selector "div.alert-success" | ||
|
||
# verify pages are spammed | ||
visit banned_page.path | ||
assert find("div.alert", text: "That page has been moderated as spam. Please contact web@publiclab.org if you believe there is a problem.") | ||
|
||
visit banned_page2.path | ||
assert find("div.alert", text: "That page has been moderated as spam. Please contact web@publiclab.org if you believe there is a problem.") | ||
|
||
# verify note authors are banned | ||
visit "/" | ||
visit "/profile/#{banned_page.author.username}" | ||
assert find("div.alert", text: "That user has been banned.") | ||
find("a#info-ellipsis").click() | ||
page.assert_selector "a[href='/unban/#{banned_page.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 | ||
end |