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-5977 Hide "Approve All Unreviewed Comments" button from admins on works #4966

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions app/helpers/comments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ def can_review_comment?(comment)
is_author_of?(comment.ultimate_parent) || policy(comment).can_review_comment?
end

def can_review_all_comments?(commentable)
commentable.is_a?(AdminPost) || is_author_of?(commentable)
end

#### HELPERS FOR REPLYING TO COMMENTS #####

# return link to add new reply to a comment
Expand Down
10 changes: 6 additions & 4 deletions app/views/comments/unreviewed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<!--/descriptions-->

<!--Subnavigation, sorting and actions-->
<ul class="navigation actions">
<% path = @commentable.is_a?(AdminPost) ? review_all_admin_post_comments_path(@commentable) : review_all_work_comments_path(@commentable) %>
<li><%= button_to(t(".approve_all"), path, method: :put) %></li>
</ul>
<% if can_review_all_comments?(@commentable) %>
<ul class="navigation actions">
<% path = @commentable.is_a?(AdminPost) ? review_all_admin_post_comments_path(@commentable) : review_all_work_comments_path(@commentable) %>
<li><%= button_to(t(".approve_all"), path, method: :put) %></li>
</ul>
<% end %>
<!--/subnav-->

<!--main content-->
Expand Down
13 changes: 13 additions & 0 deletions features/admins/admin_works.feature
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,19 @@ Feature: Admin Actions for Works, Comments, Series, Bookmarks
Then I should see "rolex"
And I should not see "This comment has been marked as spam."

Scenario: Moderated comments cannot be approved by admin
Given the moderated work "Moderation" by "author"
And I am logged in as "commenter"
And I post the comment "Test comment" on the work "Moderation"
When I am logged in as a "superadmin" admin
And I view the work "Moderation"
Then I should see "Unreviewed Comments (1)"
And the comment on "Moderation" should be marked as unreviewed
When I follow "Unreviewed Comments (1)"
Then I should see "Test comment"
And I should not see an "Approve All Unreviewed Comments" button
And I should not see an "Approve" button

Scenario: Admin can edit language on works when posting without previewing
Given basic languages
And I am logged in as "regular_user"
Expand Down
Loading