diff --git a/app/assets/stylesheets/moderation/users/index.scss b/app/assets/stylesheets/moderation/users/index.scss index 47471d2d5..849153b24 100644 --- a/app/assets/stylesheets/moderation/users/index.scss +++ b/app/assets/stylesheets/moderation/users/index.scss @@ -8,11 +8,11 @@ justify-content: flex-end; } - .soft-block-link { + .hide-link { @include hollow-button($color-warning); } - .hide-link { + .block-link { @include hollow-button($alert-color); } } diff --git a/app/components/shared/moderation_actions_component.html.erb b/app/components/shared/moderation_actions_component.html.erb index c0d05d560..5d37fed88 100644 --- a/app/components/shared/moderation_actions_component.html.erb +++ b/app/components/shared/moderation_actions_component.html.erb @@ -6,7 +6,7 @@ <% if can? :hide, record.author %> <%= raw separator %> - <%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(record.author_id), - method: :put, data: { confirm: confirm_hide_author_text } %> + <%= link_to t("admin.actions.block_author").capitalize, block_moderation_user_path(record.author_id), + method: :put, data: { confirm: confirm_block_author_text } %> <% end %> diff --git a/app/components/shared/moderation_actions_component.rb b/app/components/shared/moderation_actions_component.rb index 43e4fd217..94f3212b6 100644 --- a/app/components/shared/moderation_actions_component.rb +++ b/app/components/shared/moderation_actions_component.rb @@ -20,8 +20,8 @@ class Shared::ModerationActionsComponent < ApplicationComponent t("admin.actions.confirm_action", action: t("admin.actions.hide"), name: record.human_name) end - def confirm_hide_author_text - t("admin.actions.confirm_action", action: t("admin.actions.hide_author"), name: record.author.name) + def confirm_block_author_text + t("admin.actions.confirm_action", action: t("admin.actions.block_author"), name: record.author.name) end def separator diff --git a/app/controllers/moderation/users_controller.rb b/app/controllers/moderation/users_controller.rb index 3466e695c..b3a043d96 100644 --- a/app/controllers/moderation/users_controller.rb +++ b/app/controllers/moderation/users_controller.rb @@ -6,16 +6,16 @@ class Moderation::UsersController < Moderation::BaseController def index end - def soft_block - soft_block_user + def hide + hide_user - redirect_with_query_params_to({ action: :index }, { notice: I18n.t("moderation.users.notice_soft_hide") }) + redirect_with_query_params_to({ action: :index }, { notice: I18n.t("moderation.users.notice_hide") }) end - def hide + def block block_user - redirect_with_query_params_to index_path_options, { notice: I18n.t("moderation.users.notice_hide") } + redirect_with_query_params_to index_path_options, { notice: I18n.t("moderation.users.notice_block") } end private @@ -24,9 +24,9 @@ class Moderation::UsersController < Moderation::BaseController @users = User.with_hidden.search(params[:search]).page(params[:page]).for_render end - def soft_block_user + def hide_user @user.hide - Activity.log(current_user, :soft_block, @user) + Activity.log(current_user, :hide, @user) end def block_user diff --git a/app/models/abilities/moderation.rb b/app/models/abilities/moderation.rb index 9c6cd3857..bda41b203 100644 --- a/app/models/abilities/moderation.rb +++ b/app/models/abilities/moderation.rb @@ -47,9 +47,6 @@ module Abilities can :hide, User cannot :hide, User, id: user.id - can :soft_block, User - cannot :soft_block, User, id: user.id - can :block, User cannot :block, User, id: user.id diff --git a/app/models/activity.rb b/app/models/activity.rb index 864ef0e5b..3accc495b 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -2,7 +2,7 @@ class Activity < ApplicationRecord belongs_to :actionable, -> { with_hidden }, polymorphic: true belongs_to :user, -> { with_hidden }, inverse_of: :activities - VALID_ACTIONS = %w[hide soft_block block restore valuate email].freeze + VALID_ACTIONS = %w[hide block restore valuate email].freeze validates :action, inclusion: { in: VALID_ACTIONS } diff --git a/app/views/moderation/users/index.html.erb b/app/views/moderation/users/index.html.erb index 56d15acd0..c2617282a 100644 --- a/app/views/moderation/users/index.html.erb +++ b/app/views/moderation/users/index.html.erb @@ -22,8 +22,8 @@ <%= t("moderation.users.index.hidden") %> <% else %> <%= render Admin::TableActionsComponent.new(user, actions: []) do |actions| %> - <%= actions.action(:soft_block, text: t("moderation.users.index.soft_hide"), method: :put) %> <%= actions.action(:hide, text: t("moderation.users.index.hide"), method: :put) %> + <%= actions.action(:block, text: t("moderation.users.index.block"), method: :put) %> <% end %> <% end %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index ea4897c6a..a740a897a 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -4,12 +4,12 @@ en: title: Administration actions: actions: Actions + block_author: "Block author" confirm_action: "Are you sure? %{action} \"%{name}\"" confirm_delete: "Are you sure? This action will delete \"%{name}\" and can't be undone." confirm_hide: Confirm moderation delete: "Delete" hide: Hide - hide_author: Hide author label: "%{action} %{name}" restore: Restore mark_featured: Featured diff --git a/config/locales/en/moderation.yml b/config/locales/en/moderation.yml index 63c834fcd..6fc1e98c4 100644 --- a/config/locales/en/moderation.yml +++ b/config/locales/en/moderation.yml @@ -101,10 +101,10 @@ en: title: Proposal notifications users: index: + block: Block hidden: Blocked - hide: Block + hide: Hide search_placeholder: email or name of user - soft_hide: Soft Block title: Block users - notice_hide: User blocked. All of this user's debates and comments have been hidden. - notice_soft_hide: User blocked. All ot this user's debates and comments are still available. + notice_block: User blocked. All of this user's debates and comments have been hidden. + notice_hide: User blocked. All ot this user's debates and comments are still available. diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 82a55c334..9ff38ec50 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -4,12 +4,12 @@ es: title: Administración actions: actions: Acciones + block_author: "Bloquear al autor" confirm_action: "¿Estás seguro? %{action} \"%{name}\"" confirm_delete: "¿Estás seguro? Esta acción borrará \"%{name}\" y no se puede deshacer." confirm_hide: Confirmar moderación delete: Borrar hide: Ocultar - hide_author: Bloquear al autor label: "%{action} %{name}" restore: Volver a mostrar mark_featured: Destacar diff --git a/config/locales/es/moderation.yml b/config/locales/es/moderation.yml index 2fff7b996..445dca9f9 100644 --- a/config/locales/es/moderation.yml +++ b/config/locales/es/moderation.yml @@ -101,10 +101,10 @@ es: title: Notificaciones de propuestas users: index: + block: Bloquear hidden: Bloqueado - hide: Bloquear + hide: Ocultar search_placeholder: email o nombre de usuario - soft_hide: Ocultar title: Bloquear usuarios - notice_hide: Usuario bloqueado. Se han ocultado todos sus debates y comentarios. - notice_soft_hide: Usuario bloqueado. Todos sus debates y comentarios siguen disponibles. + notice_block: Usuario bloqueado. Se han ocultado todos sus debates y comentarios. + notice_hide: Usuario bloqueado. Todos sus debates y comentarios siguen disponibles. diff --git a/config/routes/moderation.rb b/config/routes/moderation.rb index 009d9484a..2bf1f41e7 100644 --- a/config/routes/moderation.rb +++ b/config/routes/moderation.rb @@ -4,7 +4,7 @@ namespace :moderation do resources :users, only: :index do member do put :hide - put :soft_block + put :block end end diff --git a/spec/controllers/moderation/users_controller_spec.rb b/spec/controllers/moderation/users_controller_spec.rb index 59d2e7f41..4f9fdea6d 100644 --- a/spec/controllers/moderation/users_controller_spec.rb +++ b/spec/controllers/moderation/users_controller_spec.rb @@ -6,7 +6,19 @@ describe Moderation::UsersController do describe "PUT hide" do it "keeps query parameters while using protected redirects" do - get :hide, params: { id: user, search: "user@consul.dev", host: "evil.dev" } + user = create(:user, email: "user@consul.dev") + + get :hide, params: { id: user, name_or_email: "user@consul.dev", host: "evil.dev" } + + expect(response).to redirect_to "/moderation/users?name_or_email=user%40consul.dev" + end + end + + describe "PUT block" do + it "keeps query parameters while using protected redirects" do + user = create(:user, email: "user@consul.dev") + + get :block, params: { id: user, search: "user@consul.dev", host: "evil.dev" } expect(response).to redirect_to "/moderation/users?search=user%40consul.dev" end @@ -15,7 +27,7 @@ describe Moderation::UsersController do proposal = create(:proposal, author: user) request.env["HTTP_REFERER"] = proposal_path(proposal) - put :hide, params: { id: user } + put :block, params: { id: user } expect(response).to redirect_to proposals_path expect(flash[:notice]).to eq "User blocked. All of this user's debates and comments have been hidden." @@ -25,19 +37,9 @@ describe Moderation::UsersController do investment = create(:budget_investment, author: user) request.env["HTTP_REFERER"] = budget_investment_path(investment.budget, investment) - put :hide, params: { id: user } + put :block, params: { id: user } expect(response).to redirect_to budget_investments_path(investment.budget) end end - - describe "PUT soft_block" do - it "keeps query parameters while using protected redirects" do - user = create(:user, email: "user@consul.dev") - - get :soft_block, params: { id: user, name_or_email: "user@consul.dev", host: "evil.dev" } - - expect(response).to redirect_to "/moderation/users?name_or_email=user%40consul.dev" - end - end end diff --git a/spec/models/abilities/moderator_spec.rb b/spec/models/abilities/moderator_spec.rb index 508d268f0..9f3cb14dc 100644 --- a/spec/models/abilities/moderator_spec.rb +++ b/spec/models/abilities/moderator_spec.rb @@ -90,9 +90,6 @@ describe Abilities::Moderator do it { should_not be_able_to(:hide, user) } it { should be_able_to(:hide, other_user) } - it { should_not be_able_to(:soft_block, user) } - it { should be_able_to(:soft_block, other_user) } - it { should_not be_able_to(:block, user) } it { should be_able_to(:block, other_user) } diff --git a/spec/system/admin/activity_spec.rb b/spec/system/admin/activity_spec.rb index 09236ac67..e501de72f 100644 --- a/spec/system/admin/activity_spec.rb +++ b/spec/system/admin/activity_spec.rb @@ -217,7 +217,7 @@ describe "Admin activity" do visit proposal_path(proposal) within("#proposal_#{proposal.id}") do - accept_confirm("Are you sure? Hide author \"#{proposal.author.name}\"") { click_link "Hide author" } + accept_confirm("Are you sure? Block author \"#{proposal.author.name}\"") { click_link "Block author" } expect(page).to have_current_path(proposals_path) end diff --git a/spec/system/admin/hidden_comments_spec.rb b/spec/system/admin/hidden_comments_spec.rb index 407207fa9..b73651257 100644 --- a/spec/system/admin/hidden_comments_spec.rb +++ b/spec/system/admin/hidden_comments_spec.rb @@ -13,7 +13,7 @@ describe "Admin hidden comments", :admin do visit proposal_path(proposal) within("#proposal_#{proposal.id}") do - accept_confirm("Are you sure? Hide author \"#{proposal.author.name}\"") { click_link "Hide author" } + accept_confirm("Are you sure? Block author \"#{proposal.author.name}\"") { click_link "Block author" } end expect(page).to have_current_path proposals_path diff --git a/spec/system/moderation/budget_investments_spec.rb b/spec/system/moderation/budget_investments_spec.rb index 9cfaf7849..aafd765f9 100644 --- a/spec/system/moderation/budget_investments_spec.rb +++ b/spec/system/moderation/budget_investments_spec.rb @@ -23,7 +23,7 @@ describe "Moderate budget investments" do login_as(mod.user) visit budget_investment_path(budget, investment) - accept_confirm("Are you sure? Hide author \"#{investment.author.name}\"") { click_link "Hide author" } + accept_confirm("Are you sure? Block author \"#{investment.author.name}\"") { click_link "Block author" } expect(page).to have_current_path(budget_investments_path(budget)) expect(page).not_to have_content(investment.title) @@ -37,7 +37,7 @@ describe "Moderate budget investments" do within "#budget_investment_#{investment.id}" do expect(page).not_to have_link("Hide") - expect(page).not_to have_link("Hide author") + expect(page).not_to have_link("Block author") end end diff --git a/spec/system/moderation/users_spec.rb b/spec/system/moderation/users_spec.rb index 3e54731bf..cd4c83ef2 100644 --- a/spec/system/moderation/users_spec.rb +++ b/spec/system/moderation/users_spec.rb @@ -24,7 +24,7 @@ describe "Moderate users" do visit debate_path(debate1) within("#debate_#{debate1.id}") do - accept_confirm("Are you sure? Hide author \"#{debate1.author.name}\"") { click_link "Hide author" } + accept_confirm("Are you sure? Block author \"#{debate1.author.name}\"") { click_link "Block author" } end expect(page).to have_current_path(debates_path)