In the moderation section there's no clear indicator as to what the "Hide" and "Block" buttons do and the difference between them. Since we're using confirmation dialogs in all moderation actions except these ones, we're adding them here as well, so the difference will appear in the dialog. This isn't a very good solution, though, since the confirmation dialog comes after clicking the button and users have already been wondering whether clicking that button will be the right choice. A better solution would be making the purpose clear before the button is clicked, although that's something we don't do anywhere in the admin/moderation sections.
79 lines
2.1 KiB
Ruby
79 lines
2.1 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Moderate users" do
|
|
scenario "Hide" do
|
|
citizen = create(:user)
|
|
moderator = create(:moderator)
|
|
|
|
debate1 = create(:debate, author: citizen)
|
|
debate2 = create(:debate, author: citizen)
|
|
debate3 = create(:debate)
|
|
comment3 = create(:comment, user: citizen, commentable: debate3, body: "SPAMMER")
|
|
|
|
login_as(moderator.user)
|
|
visit debates_path
|
|
|
|
expect(page).to have_content(debate1.title)
|
|
expect(page).to have_content(debate2.title)
|
|
expect(page).to have_content(debate3.title)
|
|
|
|
visit debate_path(debate3)
|
|
|
|
expect(page).to have_content(comment3.body)
|
|
|
|
visit debate_path(debate1)
|
|
|
|
within("#debate_#{debate1.id}") do
|
|
accept_confirm("Are you sure? This will hide the user \"#{debate1.author.name}\" and all their contents.") do
|
|
click_button "Block author"
|
|
end
|
|
end
|
|
|
|
expect(page).to have_current_path(debates_path)
|
|
expect(page).not_to have_content(debate1.title)
|
|
expect(page).not_to have_content(debate2.title)
|
|
expect(page).to have_content(debate3.title)
|
|
|
|
visit debate_path(debate3)
|
|
|
|
expect(page).not_to have_content(comment3.body)
|
|
|
|
click_link("Sign out")
|
|
|
|
visit root_path
|
|
|
|
click_link "Sign in"
|
|
fill_in "user_login", with: citizen.email
|
|
fill_in "user_password", with: citizen.password
|
|
click_button "Enter"
|
|
|
|
expect(page).to have_content "Invalid Email or username or password"
|
|
expect(page).to have_current_path(new_user_session_path)
|
|
end
|
|
|
|
scenario "Search and ban users" do
|
|
citizen = create(:user, username: "Wanda Maximoff")
|
|
moderator = create(:moderator)
|
|
|
|
login_as(moderator.user)
|
|
|
|
visit moderation_users_path
|
|
|
|
expect(page).not_to have_content citizen.name
|
|
fill_in "search", with: "Wanda"
|
|
click_button "Search"
|
|
|
|
within("#moderation_users") do
|
|
expect(page).to have_content citizen.name
|
|
expect(page).not_to have_content "Blocked"
|
|
|
|
accept_confirm { click_button "Block" }
|
|
end
|
|
|
|
within("#moderation_users") do
|
|
expect(page).to have_content citizen.name
|
|
expect(page).to have_content "Blocked"
|
|
end
|
|
end
|
|
end
|