Add controls to revoke all blocks page
This commit is contained in:
parent
3443533ce3
commit
1ff7b6217a
3 changed files with 55 additions and 1 deletions
|
@ -6,3 +6,22 @@
|
||||||
:block_on => link_to(@user.display_name,
|
:block_on => link_to(@user.display_name,
|
||||||
user_path(@user)) %></h1>
|
user_path(@user)) %></h1>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% unless @user.blocks.active.empty? %>
|
||||||
|
|
||||||
|
<%= bootstrap_form_for :revoke_all, :url => { :action => "revoke_all" } do |f| %>
|
||||||
|
<div class="mb-3">
|
||||||
|
<div class="form-check">
|
||||||
|
<%= check_box_tag "confirm", "yes", false, { :class => "form-check-input" } %>
|
||||||
|
<%= label_tag "confirm", t(".confirm",
|
||||||
|
:active_blocks => t(".active_blocks",
|
||||||
|
:count => @user.blocks.active.count)), { :class => "form-check-label" } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= f.primary t(".revoke") %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% else %>
|
||||||
|
<p><%= t ".empty", :name => @user.display_name %></p>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -2896,6 +2896,12 @@ en:
|
||||||
revoke_all:
|
revoke_all:
|
||||||
title: "Revoking all blocks on %{block_on}"
|
title: "Revoking all blocks on %{block_on}"
|
||||||
heading_html: "Revoking all blocks on %{block_on}"
|
heading_html: "Revoking all blocks on %{block_on}"
|
||||||
|
empty: "%{name} has no active blocks."
|
||||||
|
confirm: "Are you sure you wish to revoke %{active_blocks}?"
|
||||||
|
active_blocks:
|
||||||
|
one: "%{count} active block"
|
||||||
|
other: "%{count} active blocks"
|
||||||
|
revoke: "Revoke!"
|
||||||
helper:
|
helper:
|
||||||
time_future_html: "Ends in %{time}."
|
time_future_html: "Ends in %{time}."
|
||||||
until_login: "Active until the user logs in."
|
until_login: "Active until the user logs in."
|
||||||
|
|
|
@ -27,7 +27,17 @@ class ReportNoteTest < ApplicationSystemTestCase
|
||||||
assert_no_link "Revoke all blocks"
|
assert_no_link "Revoke all blocks"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "revoke all link is present and working for moderators when viewed user has active blocks" do
|
test "revoke all page has no controls when viewed user has no active blocks" do
|
||||||
|
blocked_user = create(:user)
|
||||||
|
sign_in_as(create(:moderator_user))
|
||||||
|
|
||||||
|
visit revoke_all_user_blocks_path(blocked_user)
|
||||||
|
assert_title "Revoking all blocks on #{blocked_user.display_name}"
|
||||||
|
assert_text "Revoking all blocks on #{blocked_user.display_name}"
|
||||||
|
assert_no_button "Revoke!"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "revoke all link is present and working for moderators when viewed user has one active block" do
|
||||||
blocked_user = create(:user)
|
blocked_user = create(:user)
|
||||||
create(:user_block, :user => blocked_user)
|
create(:user_block, :user => blocked_user)
|
||||||
sign_in_as(create(:moderator_user))
|
sign_in_as(create(:moderator_user))
|
||||||
|
@ -38,5 +48,24 @@ class ReportNoteTest < ApplicationSystemTestCase
|
||||||
click_link "Revoke all blocks"
|
click_link "Revoke all blocks"
|
||||||
assert_title "Revoking all blocks on #{blocked_user.display_name}"
|
assert_title "Revoking all blocks on #{blocked_user.display_name}"
|
||||||
assert_text "Revoking all blocks on #{blocked_user.display_name}"
|
assert_text "Revoking all blocks on #{blocked_user.display_name}"
|
||||||
|
assert_unchecked_field "Are you sure you wish to revoke 1 active block?"
|
||||||
|
assert_button "Revoke!"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "revoke all link is present and working for moderators when viewed user has multiple active blocks" do
|
||||||
|
blocked_user = create(:user)
|
||||||
|
create(:user_block, :user => blocked_user)
|
||||||
|
create(:user_block, :user => blocked_user)
|
||||||
|
create(:user_block, :expired, :user => blocked_user)
|
||||||
|
sign_in_as(create(:moderator_user))
|
||||||
|
|
||||||
|
visit user_path(blocked_user)
|
||||||
|
assert_link "Revoke all blocks"
|
||||||
|
|
||||||
|
click_link "Revoke all blocks"
|
||||||
|
assert_title "Revoking all blocks on #{blocked_user.display_name}"
|
||||||
|
assert_text "Revoking all blocks on #{blocked_user.display_name}"
|
||||||
|
assert_unchecked_field "Are you sure you wish to revoke 2 active blocks?"
|
||||||
|
assert_button "Revoke!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue