[admin/comments] remove comments of blocked users
This commit is contained in:
@@ -4,7 +4,7 @@ class Admin::CommentsController < Admin::BaseController
|
|||||||
before_action :load_comment, only: [:confirm_hide, :restore]
|
before_action :load_comment, only: [:confirm_hide, :restore]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@comments = Comment.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
|
@comments = Comment.only_hidden.with_visible_author.send(@current_filter).order(hidden_at: :desc).page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm_hide
|
def confirm_hide
|
||||||
|
|||||||
@@ -18,10 +18,9 @@ class Comment < ActiveRecord::Base
|
|||||||
belongs_to :user, -> { with_hidden }
|
belongs_to :user, -> { with_hidden }
|
||||||
|
|
||||||
scope :recent, -> { order(id: :desc) }
|
scope :recent, -> { order(id: :desc) }
|
||||||
|
|
||||||
scope :sort_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
|
scope :sort_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||||
|
|
||||||
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
scope :for_render, -> { with_hidden.includes(user: :organization) }
|
||||||
|
scope :with_visible_author, -> { joins(:user).where("users.hidden_at IS NULL") }
|
||||||
|
|
||||||
after_create :call_after_commented
|
after_create :call_after_commented
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,26 @@ feature 'Admin comments' do
|
|||||||
login_as(admin.user)
|
login_as(admin.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Restore', :js do
|
scenario "Do not show comments from blocked users" do
|
||||||
|
comment = create(:comment, :hidden, body: "SPAM from SPAMMER")
|
||||||
|
proposal = create(:proposal, author: comment.author)
|
||||||
|
create(:comment, commentable: proposal, user: comment.author, body: "Good Proposal!")
|
||||||
|
|
||||||
|
visit admin_comments_path
|
||||||
|
expect(page).to have_content("SPAM from SPAMMER")
|
||||||
|
expect(page).not_to have_content("Good Proposal!")
|
||||||
|
|
||||||
|
visit proposal_path(proposal)
|
||||||
|
within("#proposal_#{proposal.id}") do
|
||||||
|
click_link 'Ban author'
|
||||||
|
end
|
||||||
|
|
||||||
|
visit admin_comments_path
|
||||||
|
expect(page).to_not have_content("SPAM from SPAMMER")
|
||||||
|
expect(page).not_to have_content("Good Proposal!")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Restore" do
|
||||||
comment = create(:comment, :hidden, body: 'Not really SPAM')
|
comment = create(:comment, :hidden, body: 'Not really SPAM')
|
||||||
visit admin_comments_path
|
visit admin_comments_path
|
||||||
|
|
||||||
@@ -18,7 +37,7 @@ feature 'Admin comments' do
|
|||||||
expect(comment.reload).to_not be_hidden
|
expect(comment.reload).to_not be_hidden
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Confirm hide' do
|
scenario "Confirm hide" do
|
||||||
comment = create(:comment, :hidden, body: 'SPAM')
|
comment = create(:comment, :hidden, body: 'SPAM')
|
||||||
visit admin_comments_path
|
visit admin_comments_path
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user