-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/pull/4440'
- Loading branch information
Showing
8 changed files
with
215 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<% @title = t ".title", | ||
:block_on => @user.display_name %> | ||
|
||
<% content_for :heading do %> | ||
<h1><%= t ".heading_html", | ||
:block_on => link_to(@user.display_name, | ||
user_path(@user)) %></h1> | ||
<% 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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
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 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) | ||
create(:user_block, :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 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 |