logs activity: hiding comments

This commit is contained in:
Juanjo Bazán
2015-09-22 16:42:24 +02:00
parent 7ca3f574d8
commit 064ff631b2
2 changed files with 52 additions and 2 deletions

View File

@@ -14,14 +14,14 @@ class Moderation::CommentsController < Moderation::BaseController
end end
def hide def hide
@comment.hide hide_comment @comment
end end
def moderate def moderate
@comments = @comments.where(id: params[:comment_ids]) @comments = @comments.where(id: params[:comment_ids])
if params[:hide_comments].present? if params[:hide_comments].present?
@comments.accessible_by(current_ability, :hide).each(&:hide) @comments.accessible_by(current_ability, :hide).each {|comment| hide_comment comment}
elsif params[:ignore_flags].present? elsif params[:ignore_flags].present?
@comments.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag) @comments.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag)
@@ -40,4 +40,9 @@ class Moderation::CommentsController < Moderation::BaseController
@comments = Comment.accessible_by(current_ability, :moderate) @comments = Comment.accessible_by(current_ability, :moderate)
end end
def hide_comment(comment)
comment.hide
Activity.log(current_user, :hide, comment)
end
end end

View File

@@ -95,4 +95,49 @@ feature 'Admin activity' do
end end
end end
context "Comments" do
scenario "Shows moderation activity on comments", :js do
debate = create(:debate)
comment = create(:comment, commentable: debate)
visit debate_path(debate)
within("#comment_#{comment.id}") do
click_link 'Hide'
end
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
expect(page).to have_content(comment.body)
expect(page).to have_content(@admin.user.username)
end
end
scenario "Shows moderation activity from moderation screen" do
comment1 = create(:comment, body: "SPAM")
comment2 = create(:comment)
comment3 = create(:comment, body: "Offensive!")
visit moderation_comments_path(filter: 'all')
within("#comment_#{comment1.id}") do
check "comment_#{comment1.id}_check"
end
within("#comment_#{comment3.id}") do
check "comment_#{comment3.id}_check"
end
click_on "Hide comments"
visit admin_activity_path
expect(page).to have_content(comment1.body)
expect(page).to_not have_content(comment2.body)
expect(page).to have_content(comment3.body)
end
end
end end