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:
@@ -19,7 +19,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<% if user.hidden? %>
|
||||
<%= t("moderation.users.index.hidden") %>
|
||||
<%= status(user) %>
|
||||
<% else %>
|
||||
<%= render Admin::TableActionsComponent.new(user, actions: []) do |actions| %>
|
||||
<%= actions.action(
|
||||
|
||||
@@ -4,4 +4,14 @@ class Moderation::Users::IndexComponent < ApplicationComponent
|
||||
def initialize(users)
|
||||
@users = users
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def status(user)
|
||||
t("admin.activity.show.actions.#{activity_action(user)}")
|
||||
end
|
||||
|
||||
def activity_action(user)
|
||||
Activity.where(actionable: user, action: [:hide, :block]).last&.action || "block"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -104,7 +104,6 @@ en:
|
||||
block: Block
|
||||
confirm_block: "Are you sure? This will hide the user \"%{name}\" and all their contents."
|
||||
confirm_hide: "Are you sure? This will hide the user \"%{name}\" without hiding their contents."
|
||||
hidden: Blocked
|
||||
hide: Hide
|
||||
search_placeholder: email or name of user
|
||||
title: Block users
|
||||
|
||||
@@ -104,7 +104,6 @@ es:
|
||||
block: Bloquear
|
||||
confirm_block: "¿Seguro? Esto ocultará a \"%{name}\" así como todos sus contenidos."
|
||||
confirm_hide: "¿Seguro? Esto ocultará a \"%{name}\" sin ocultar sus contenidos."
|
||||
hidden: Bloqueado
|
||||
hide: Ocultar
|
||||
search_placeholder: email o nombre de usuario
|
||||
title: Bloquear usuarios
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user