Add revoke all blocks link
This commit is contained in:
parent
f73b7205f4
commit
8682b58154
6 changed files with 55 additions and 1 deletions
|
@ -61,7 +61,7 @@ class Ability
|
|||
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?
|
||||
|
|
|
@ -101,6 +101,12 @@
|
|||
</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) %>
|
||||
|
|
|
@ -2790,6 +2790,7 @@ en:
|
|||
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"
|
||||
|
|
|
@ -321,6 +321,7 @@ OpenStreetMap::Application.routes.draw do
|
|||
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
|
||||
|
|
|
@ -54,6 +54,14 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
|
|||
{ :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
|
||||
|
||||
##
|
||||
|
|
38
test/system/user_blocks_test.rb
Normal file
38
test/system/user_blocks_test.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
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
|
Loading…
Add table
Reference in a new issue