Adds test for not using moderation links in my own comments

This commit is contained in:
kikito
2015-08-24 18:36:56 +02:00
parent 36fb9b60b2
commit c6976b0905
3 changed files with 33 additions and 11 deletions

View File

@@ -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? %>
<span class='js-moderation-actions'>
<% if can? :hide, comment %>
&nbsp;|&nbsp;
<%= 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 %>
&nbsp;|&nbsp;
<%= 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 %>
</span>
</span>

View File

@@ -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 %>

View File

@@ -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