diff --git a/app/views/comments/_actions.html.erb b/app/views/comments/_actions.html.erb index 27574e2fc..5454179f0 100644 --- a/app/views/comments/_actions.html.erb +++ b/app/views/comments/_actions.html.erb @@ -1,10 +1,13 @@ -  |  - <%= link_to t("admin.actions.hide").capitalize, hide_moderation_comment_path(comment), - method: :put, remote: true, data: { confirm: t('admin.actions.confirm') } %> - <% unless comment.user.hidden? %> + <% if can? :hide, comment %> +  |  + <%= link_to t("admin.actions.hide").capitalize, hide_moderation_comment_path(comment), + method: :put, remote: true, data: { confirm: t('admin.actions.confirm') } %> + <% end %> + + <% if can? :hide, comment.user %>  |  <%= link_to t("admin.actions.hide_author").capitalize, hide_moderation_user_path(comment.user_id, debate_id: @debate.id), method: :put, data: { confirm: t('admin.actions.confirm') } %> <% end %> - \ No newline at end of file + diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 0d922be04..75cc9e6dd 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -69,9 +69,7 @@ <%= link_to(comment_link_text(comment), "", class: "js-add-comment-link", data: {'id': dom_id(comment)}) %> - <% if moderator? %> - <%= render 'comments/actions', comment: comment %> - <% end %> + <%= render 'comments/actions', comment: comment %> <%= render 'comments/form', {parent: comment, toggeable: true} %> <% end %> diff --git a/spec/features/moderation/comments_spec.rb b/spec/features/moderation/comments_spec.rb index e52a87c17..5a4100f77 100644 --- a/spec/features/moderation/comments_spec.rb +++ b/spec/features/moderation/comments_spec.rb @@ -59,17 +59,38 @@ feature 'Moderate Comments' do moderator = create(:moderator) debate = create(:debate) - create(:comment, commentable: debate) + comment = create(:comment, commentable: debate) login_as(moderator.user) visit debate_path(debate) - expect(page).to have_css("#moderator-comment-actions") + within "#comment_#{comment.id}" do + expect(page).to have_link("Hide") + expect(page).to have_link("Ban author") + end login_as(citizen) visit debate_path(debate) - expect(page).to_not have_css("#moderator-comment-actions") + within "#comment_#{comment.id}" do + expect(page).to_not have_link("Hide") + expect(page).to_not have_link("Ban author") + end + end + + scenario 'Moderator actions do not appear in own comments' do + moderator = create(:moderator) + + debate = create(:debate) + comment = create(:comment, commentable: debate, user: moderator.user) + + login_as(moderator.user) + visit debate_path(debate) + + within "#comment_#{comment.id}" do + expect(page).to_not have_link("Hide") + expect(page).to_not have_link("Ban author") + end end feature '/moderation/ menu' do