Skip to content

Commit

Permalink
AO3-5977 Hide "Approve All Unreviewed Comments" button from admins on…
Browse files Browse the repository at this point in the history
… works

Also hides "Approve All Unreviewed Comments" when there are no unreviewed comments.
  • Loading branch information
WelpThatWorked committed Nov 23, 2024
1 parent 5ea268b commit c96ba24
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
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 @comments[0] && can_review_comment?(@comments[0]) %>
<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 button "Approve All Unreviewed Comments"
And I should not see button "Approve"

Scenario: Admin can edit language on works when posting without previewing
Given basic languages
And I am logged in as "regular_user"
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ def with_scope(locator)
end
end

Then /^(?:|I )should not see button "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|

Check warning on line 260 in features/step_definitions/web_steps.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Prefer Cucumber expressions (https://github.com/cucumber/cucumber-expressions) over regex for step names; refer to https://github.com/otwcode/otwarchive/wiki/Reviewdog-and-RuboCop if regex is still required Raw Output: features/step_definitions/web_steps.rb:260:6: R: Cucumber/RegexStepName: Prefer Cucumber expressions (https://github.com/cucumber/cucumber-expressions) over regex for step names; refer to https://github.com/otwcode/otwarchive/wiki/Reviewdog-and-RuboCop if regex is still required
with_scope(selector) do
page.body.should_not have_button(text)
end
end

Then /^(?:|I )should be on (.+)$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
Expand Down

0 comments on commit c96ba24

Please sign in to comment.