Differentiate between blocked and hidden users

It was a bit confusing to press the "hide" button and then see the user
listed as "blocked". Some moderators might think they accidentally
pressed the wrong button.
This commit is contained in:
Javi Martín
2021-12-30 14:29:03 +01:00
parent e9d9789c25
commit efb7ad9e42
6 changed files with 109 additions and 9 deletions

View File

@@ -13,17 +13,90 @@ describe Moderation::Users::IndexComponent, controller: Moderation::UsersControl
expect(table).to have_button "Hide"
expect(table).to have_button "Block"
expect(table).not_to have_content "Blocked"
expect(table).not_to have_content "Hidden"
end
end
it "shows 'blocked' for hidden users" do
create(:user, :hidden)
context "for hidden users" do
it "shows 'blocked' when the user has been blocked" do
user = create(:user, :hidden)
Activity.log(nil, :block, user)
render_inline component
render_inline component
page.find("table") do |table|
expect(table).to have_content "Blocked"
expect(table).not_to have_button
page.find("table") do |table|
expect(table).to have_content "Blocked"
expect(table).not_to have_content "Hidden"
expect(table).not_to have_button
end
end
it "shows 'hidden' when the user has been hidden" do
user = create(:user, :hidden)
Activity.log(nil, :hide, user)
render_inline component
page.find("table") do |table|
expect(table).to have_content "Hidden"
expect(table).not_to have_content "Blocked"
expect(table).not_to have_button
end
end
it "shows 'blocked' when there are no activities to hide the user" do
create(:user, :hidden)
render_inline component
page.find("table") do |table|
expect(table).to have_content "Blocked"
end
end
it "is not affected by activities for other users" do
blocked = create(:user, :hidden, username: "Very bad user")
hidden = create(:user, :hidden, username: "Slightly bad user")
Activity.log(nil, :block, blocked)
Activity.log(nil, :hide, hidden)
render_inline component
page.find("tr", text: "Very bad user") do |row|
expect(row).to have_content "Blocked"
end
page.find("tr", text: "Slightly bad user") do |row|
expect(row).to have_content "Hidden"
end
end
it "doesn't consider activities other than block or hide" do
user = create(:user, :hidden)
Activity.log(nil, :block, user)
Activity.log(nil, :restore, user)
render_inline component
page.find("table") do |table|
expect(table).to have_content "Blocked"
end
end
it "shows actions after the user has been restored" do
user = create(:user, :hidden)
Activity.log(nil, :block, user)
user.restore
render_inline component
page.find("table") do |table|
expect(table).to have_button "Hide"
expect(table).to have_button "Block"
expect(table).not_to have_content "Blocked"
expect(table).not_to have_content "Hidden"
end
end
end
end

View File

@@ -75,4 +75,23 @@ describe "Moderate users" do
expect(page).to have_content "Blocked"
end
end
scenario "Hide users in the moderation section" do
create(:user, username: "Rick")
login_as(create(:moderator).user)
visit moderation_users_path(search: "Rick")
within("#moderation_users") do
accept_confirm('This will hide the user "Rick" without hiding their contents') do
click_button "Hide"
end
end
expect(page).to have_content "The user has been hidden"
within("#moderation_users") do
expect(page).to have_content "Hidden"
end
end
end