Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6572 Show admins when blocks and mutes were created #4662

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/blocked/users/_blocked_user_blurb.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% pseud = block.blocked.default_pseud %>
<li class="user pseud picture blurb group" role="article">
<%= render "pseuds/pseud_module", pseud: pseud %>
<%= render "pseuds/pseud_module", pseud: pseud, date: block.created_at %>

<h6 class="landmark heading">User Actions</h6>
<ul class="actions" role="navigation">
Expand Down
2 changes: 1 addition & 1 deletion app/views/muted/users/_muted_user_blurb.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% pseud = mute.muted.default_pseud %>
<li class="user pseud picture blurb group" role="article">
<%= render "pseuds/pseud_module", pseud: pseud %>
<%= render "pseuds/pseud_module", pseud: pseud, date: mute.created_at %>

<h6 class="landmark heading">User Actions</h6>
<ul class="actions" role="navigation">
Expand Down
4 changes: 4 additions & 0 deletions app/views/pseuds/_pseud_module.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<div class="icon">
<%= icon_display(pseud.user, pseud) %>
</div>
<%# created_at date to display to admins for mutes and blocks %>
<% if local_assigns[:date] && logged_in_as_admin? %>
<p class="datetime"><%= date %></p>
<% end %>
</div>
<% unless pseud.description.blank? %>
<blockquote class="userstuff">
Expand Down
16 changes: 16 additions & 0 deletions features/step_definitions/block_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@
blocked = User.find_by(login: blocked)
expect(Block.find_by(blocker: blocker, blocked: blocked)).to be_blank
end

Then "the blurb should say when {string} blocked {string}" do |blocker, blocked|
blocker = User.find_by(login: blocker)
blocked = User.find_by(login: blocked)
block = Block.where(blocker: blocker, blocked: blocked).first
# Find the blurb for the specified block using the h4 with the blocked user's name, navigate back up to div, and then down to the datetime p
expect(page).to have_xpath("//li/div/h4/a[text()[contains(., '#{blocked.login}')]]/parent::h4/parent::div/p[text()[contains(., '#{block.created_at}')]]")
end

Then "the blurb should not say when {string} blocked {string}" do |blocker, blocked|
blocker = User.find_by(login: blocker)
blocked = User.find_by(login: blocked)
block = Block.where(blocker: blocker, blocked: blocked).first
# Find the blurb for the specified block using the h4 with the blocked user's name, navigate back up to div, and then down to where the datetime p would be
expect(page).not_to have_xpath("//li/div/h4/a[text()[contains(., '#{blocked.login}')]]/parent::h4/parent::div/p[text()[contains(., '#{block.created_at}')]]")
end
16 changes: 16 additions & 0 deletions features/step_definitions/mute_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@
muted = User.find_by(login: muted)
expect(Mute.find_by(muter: muter, muted: muted)).to be_blank
end

Then "the blurb should say when {string} muted {string}" do |muter, muted|
muter = User.find_by(login: muter)
muted = User.find_by(login: muted)
mute = Mute.where(muter: muter, muted: muted).first
# Find the blurb for the specified mute using the h4 with the muted user's name, navigate back up to div, and then down to the datetime p
expect(page).to have_xpath("//li/div/h4/a[text()[contains(., '#{muted.login}')]]/parent::h4/parent::div/p[text()[contains(., '#{mute.created_at}')]]")
end

Then "the blurb should not say when {string} muted {string}" do |muter, muted|
muter = User.find_by(login: muter)
muted = User.find_by(login: muted)
mute = Mute.where(muter: muter, muted: muted).first
# Find the blurb for the specified mute using the h4 with the muted user's name, navigate back up to div, and then down to where the datetime p would be
expect(page).not_to have_xpath("//li/div/h4/a[text()[contains(., '#{muted.login}')]]/parent::h4/parent::div/p[text()[contains(., '#{mute.created_at}')]]")
end
2 changes: 2 additions & 0 deletions features/users/blocking.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Feature: Blocking
And I press "Yes, Block User"
Then I should see "You have blocked the user pest."
And the user "blocker" should have a block for "pest"
And the blurb should not say when "blocker" blocked "pest"

Examples:
| page |
Expand Down Expand Up @@ -109,6 +110,7 @@ Feature: Blocking
When I am logged in as a "<role>" admin
And I go to the blocked users page for "blocker"
Then I should see "pest"
And the blurb should say when "blocker" blocked "pest"
And I should see a link "Unblock"
When I follow "Unblock"
Then I should see "Sorry, you don't have permission to access the page you were trying to reach."
Expand Down
2 changes: 2 additions & 0 deletions features/users/muting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Feature: Muting
And I press "Yes, Mute User"
Then I should see "You have muted the user pest."
And the user "muter" should have a mute for "pest"
And the blurb should not say when "muter" muted "pest"

Scenario Outline: Users can mute from various user-related pages
Given the user "pest" exists and is activated
Expand Down Expand Up @@ -88,6 +89,7 @@ Feature: Muting
When I am logged in as a "<role>" admin
And I go to the muted users page for "muter"
Then I should see "pest"
And the blurb should say when "muter" muted "pest"
And I should see a link "Unmute"
When I follow "Unmute"
Then I should see "Sorry, you don't have permission to access the page you were trying to reach."
Expand Down
Loading