can [:index, :show, :resolve, :ignore, :reopen], Issue
can :create, IssueComment
can [:new, :create, :edit, :update, :destroy], Redaction
- can [:new, :edit, :create, :update, :revoke], UserBlock
+ can [:new, :edit, :create, :update, :revoke, :revoke_all], UserBlock
end
if user.administrator?
</li>
<% end %>
+ <% if can?(:revoke_all, UserBlock) and @user.blocks.active.exists? %>
+ <li>
+ <%= link_to t(".revoke_all_blocks"), revoke_all_user_blocks_path(@user) %>
+ </li>
+ <% end %>
+
<% if can?(:create, UserBlock) %>
<li>
<%= link_to t(".create_block"), new_user_block_path(@user) %>
importer: "Revoke importer access"
block_history: "Active Blocks"
moderator_history: "Blocks Given"
+ revoke_all_blocks: "Revoke all blocks"
comments: "Comments"
create_block: "Block this User"
activate_user: "Activate this User"
get "/blocks/new/:display_name" => "user_blocks#new", :as => "new_user_block"
resources :user_blocks
match "/blocks/:id/revoke" => "user_blocks#revoke", :via => [:get, :post], :as => "revoke_user_block"
+ match "/user/:display_name/blocks/revoke_all" => "user_blocks#revoke_all", :via => [:get, :post], :as => "revoke_all_user_blocks"
# issues and reports
resources :issues do
{ :path => "/user/username/blocks_by", :method => :get },
{ :controller => "user_blocks", :action => "blocks_by", :display_name => "username" }
)
+ assert_routing(
+ { :path => "/user/username/blocks/revoke_all", :method => :get },
+ { :controller => "user_blocks", :action => "revoke_all", :display_name => "username" }
+ )
+ assert_routing(
+ { :path => "/user/username/blocks/revoke_all", :method => :post },
+ { :controller => "user_blocks", :action => "revoke_all", :display_name => "username" }
+ )
end
##
--- /dev/null
+require "application_system_test_case"
+
+class ReportNoteTest < ApplicationSystemTestCase
+ test "revoke all link is absent for anonymous users when viewed user has active blocks" do
+ blocked_user = create(:user)
+ create(:user_block, :user => blocked_user)
+
+ visit user_path(blocked_user)
+ assert_no_link "Revoke all blocks"
+ end
+
+ test "revoke all link is absent for regular users when viewed user has active blocks" do
+ blocked_user = create(:user)
+ create(:user_block, :user => blocked_user)
+ sign_in_as(create(:user))
+
+ visit user_path(blocked_user)
+ assert_no_link "Revoke all blocks"
+ end
+
+ test "revoke all link is absent for moderators when viewed user has no active blocks" do
+ blocked_user = create(:user)
+ create(:user_block, :expired, :user => blocked_user)
+ sign_in_as(create(:moderator_user))
+
+ visit user_path(blocked_user)
+ assert_no_link "Revoke all blocks"
+ end
+
+ test "revoke all link is present for moderators when viewed user has active blocks" do
+ blocked_user = create(:user)
+ create(:user_block, :user => blocked_user)
+ sign_in_as(create(:moderator_user))
+
+ visit user_path(blocked_user)
+ assert_link "Revoke all blocks"
+ end
+end