Merge pull request #537 from AyuntamientoMadrid/debates-moderation-530
refactors Debates&Comments moderation
This commit is contained in:
@@ -203,7 +203,7 @@ body.admin {
|
|||||||
margin-left: rem-calc(12);
|
margin-left: rem-calc(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
.proposal-description {
|
.moderation-description {
|
||||||
max-height: rem-calc(65);
|
max-height: rem-calc(65);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
max-width: rem-calc(750);
|
max-width: rem-calc(750);
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
class Moderation::BulkController < Moderation::BaseController
|
|
||||||
|
|
||||||
def index
|
|
||||||
@debates = Debate.sort_for_moderation.page(params[:page]).per(100).includes(:author)
|
|
||||||
end
|
|
||||||
|
|
||||||
def hide
|
|
||||||
debates = Debate.where(id: params[:debate_ids])
|
|
||||||
if params[:commit] == t('moderation.bulk.index.hide_debates')
|
|
||||||
debates.each(&:hide)
|
|
||||||
elsif params[:commit] == t('moderation.bulk.index.block_authors')
|
|
||||||
debates.includes(:author).map(&:author).uniq.each(&:block)
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to action: :index
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,33 +1,43 @@
|
|||||||
class Moderation::CommentsController < Moderation::BaseController
|
class Moderation::CommentsController < Moderation::BaseController
|
||||||
has_filters %w{pending_flag_review all with_ignored_flag}, only: :index
|
has_filters %w{pending_flag_review all with_ignored_flag}, only: :index
|
||||||
|
has_orders %w{flags created_at}, only: :index
|
||||||
|
|
||||||
before_action :load_comments, only: :index
|
before_action :load_comments, only: [:index, :moderate]
|
||||||
|
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@comments = @comments.send(@current_filter)
|
@comments = @comments.send(@current_filter)
|
||||||
@comments = @comments.page(params[:page])
|
.send("sort_by_#{@current_order}")
|
||||||
|
.page(params[:page])
|
||||||
|
.per(50)
|
||||||
end
|
end
|
||||||
|
|
||||||
def hide
|
def hide
|
||||||
@comment.hide
|
@comment.hide
|
||||||
end
|
end
|
||||||
|
|
||||||
def hide_in_moderation_screen
|
def moderate
|
||||||
@comment.hide
|
@comments = @comments.where(id: params[:comment_ids])
|
||||||
redirect_to request.query_parameters.merge(action: :index)
|
|
||||||
|
if params[:hide_comments].present?
|
||||||
|
@comments.accessible_by(current_ability, :hide).each(&:hide)
|
||||||
|
|
||||||
|
elsif params[:ignore_flags].present?
|
||||||
|
@comments.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag)
|
||||||
|
|
||||||
|
elsif params[:block_authors].present?
|
||||||
|
author_ids = @comments.pluck(:user_id).uniq
|
||||||
|
User.where(id: author_ids).accessible_by(current_ability, :block).each(&:block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ignore_flag
|
|
||||||
@comment.ignore_flag
|
|
||||||
redirect_to request.query_parameters.merge(action: :index)
|
redirect_to request.query_parameters.merge(action: :index)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_comments
|
def load_comments
|
||||||
@comments = Comment.accessible_by(current_ability, :hide).flagged.sort_for_moderation.includes(:commentable)
|
@comments = Comment.accessible_by(current_ability, :moderate)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,32 +1,43 @@
|
|||||||
class Moderation::DebatesController < Moderation::BaseController
|
class Moderation::DebatesController < Moderation::BaseController
|
||||||
has_filters %w{pending_flag_review all with_ignored_flag}, only: :index
|
has_filters %w{pending_flag_review all with_ignored_flag}, only: :index
|
||||||
|
has_orders %w{flags created_at}, only: :index
|
||||||
|
|
||||||
before_action :load_debates, only: :index
|
before_action :load_debates, only: [:index, :moderate]
|
||||||
|
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@debates = @debates.send(@current_filter).page(params[:page])
|
@debates = @debates.send(@current_filter)
|
||||||
|
.send("sort_by_#{@current_order}")
|
||||||
|
.page(params[:page])
|
||||||
|
.per(50)
|
||||||
end
|
end
|
||||||
|
|
||||||
def hide
|
def hide
|
||||||
@debate.hide
|
@debate.hide
|
||||||
end
|
end
|
||||||
|
|
||||||
def hide_in_moderation_screen
|
def moderate
|
||||||
@debate.hide
|
@debates = @debates.where(id: params[:debate_ids])
|
||||||
redirect_to request.query_parameters.merge(action: :index)
|
|
||||||
|
if params[:hide_debates].present?
|
||||||
|
@debates.accessible_by(current_ability, :hide).each(&:hide)
|
||||||
|
|
||||||
|
elsif params[:ignore_flags].present?
|
||||||
|
@debates.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag)
|
||||||
|
|
||||||
|
elsif params[:block_authors].present?
|
||||||
|
author_ids = @debates.pluck(:author_id).uniq
|
||||||
|
User.where(id: author_ids).accessible_by(current_ability, :block).each(&:block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ignore_flag
|
|
||||||
@debate.ignore_flag
|
|
||||||
redirect_to request.query_parameters.merge(action: :index)
|
redirect_to request.query_parameters.merge(action: :index)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_debates
|
def load_debates
|
||||||
@debates = Debate.accessible_by(current_ability, :hide).flagged.sort_for_moderation
|
@debates = Debate.accessible_by(current_ability, :moderate)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -59,12 +59,18 @@ class Ability
|
|||||||
can :ignore_flag, Comment, ignored_flag_at: nil, hidden_at: nil
|
can :ignore_flag, Comment, ignored_flag_at: nil, hidden_at: nil
|
||||||
cannot :ignore_flag, Comment, user_id: user.id
|
cannot :ignore_flag, Comment, user_id: user.id
|
||||||
|
|
||||||
|
can :moderate, Comment
|
||||||
|
cannot :moderate, Comment, user_id: user.id
|
||||||
|
|
||||||
can :hide, Debate, hidden_at: nil
|
can :hide, Debate, hidden_at: nil
|
||||||
cannot :hide, Debate, author_id: user.id
|
cannot :hide, Debate, author_id: user.id
|
||||||
|
|
||||||
can :ignore_flag, Debate, ignored_flag_at: nil, hidden_at: nil
|
can :ignore_flag, Debate, ignored_flag_at: nil, hidden_at: nil
|
||||||
cannot :ignore_flag, Debate, author_id: user.id
|
cannot :ignore_flag, Debate, author_id: user.id
|
||||||
|
|
||||||
|
can :moderate, Debate
|
||||||
|
cannot :moderate, Debate, author_id: user.id
|
||||||
|
|
||||||
can :hide, Proposal, hidden_at: nil
|
can :hide, Proposal, hidden_at: nil
|
||||||
cannot :hide, Proposal, author_id: user.id
|
cannot :hide, Proposal, author_id: user.id
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ 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 :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") }
|
scope :with_visible_author, -> { joins(:user).where("users.hidden_at IS NULL") }
|
||||||
|
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||||
|
scope :sort_by_created_at, -> { order(created_at: :desc) }
|
||||||
|
|
||||||
after_create :call_after_commented
|
after_create :call_after_commented
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ class Debate < ActiveRecord::Base
|
|||||||
|
|
||||||
before_save :calculate_hot_score, :calculate_confidence_score
|
before_save :calculate_hot_score, :calculate_confidence_score
|
||||||
|
|
||||||
scope :sort_for_moderation, -> { order(flags_count: :desc, updated_at: :desc) }
|
|
||||||
scope :for_render, -> { includes(:tags) }
|
scope :for_render, -> { includes(:tags) }
|
||||||
scope :sort_by_hot_score , -> { order(hot_score: :desc) }
|
scope :sort_by_hot_score , -> { order(hot_score: :desc) }
|
||||||
scope :sort_by_confidence_score , -> { order(confidence_score: :desc) }
|
scope :sort_by_confidence_score , -> { order(confidence_score: :desc) }
|
||||||
scope :sort_by_created_at, -> { order(created_at: :desc) }
|
scope :sort_by_created_at, -> { order(created_at: :desc) }
|
||||||
scope :sort_by_most_commented, -> { order(comments_count: :desc) }
|
scope :sort_by_most_commented, -> { order(comments_count: :desc) }
|
||||||
scope :sort_by_random, -> { order("RANDOM()") }
|
scope :sort_by_random, -> { order("RANDOM()") }
|
||||||
|
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||||
|
|
||||||
# Ahoy setup
|
# Ahoy setup
|
||||||
visitable # Ahoy will automatically assign visit_id on create
|
visitable # Ahoy will automatically assign visit_id on create
|
||||||
|
|||||||
@@ -31,12 +31,5 @@
|
|||||||
<%= t("moderation.menu.users") %>
|
<%= t("moderation.menu.users") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li <%= "class=active" if controller_name == "bulk" %>>
|
|
||||||
<%= link_to moderation_bulk_path do %>
|
|
||||||
<i class="icon-debates"></i>
|
|
||||||
<%= t("moderation.menu.bulk") %>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
<h2><%= t("moderation.bulk.index.title") %></h2>
|
|
||||||
|
|
||||||
<h3><%= page_entries_info @debates %></h3>
|
|
||||||
|
|
||||||
<%= form_tag moderation_bulk_hide_path, method: :put do %>
|
|
||||||
<p class="right">
|
|
||||||
<%= t('moderation.bulk.index.check') %>:
|
|
||||||
<%= link_to t('moderation.bulk.index.check_all'), '#', data: {check_all: "debate_ids[]"} %>
|
|
||||||
|
|
|
||||||
<%= link_to t('moderation.bulk.index.check_none'), '#', data: {check_none: "debate_ids[]"} %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<%= t("moderation.bulk.index.headers.debate") %>
|
|
||||||
</th>
|
|
||||||
<th class="text-center"><%= t("moderation.bulk.index.headers.flags") %></th>
|
|
||||||
<th>
|
|
||||||
<%= t("moderation.bulk.index.headers.moderate") %>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
<% @debates.each do |debate| %>
|
|
||||||
<tr id="debate_<%= debate.id %>">
|
|
||||||
<td>
|
|
||||||
<%= link_to debate.title, debate, target: "_blank" %>
|
|
||||||
<span class="bullet"> • </span>
|
|
||||||
<%= debate.author.username %>
|
|
||||||
<span class="bullet"> • </span>
|
|
||||||
<span class="date"><%= l debate.updated_at.to_date %></span>
|
|
||||||
<br>
|
|
||||||
<%= debate.description %>
|
|
||||||
</td>
|
|
||||||
<td class="text-center"><%= debate.flags_count %></td>
|
|
||||||
<td class="text-center">
|
|
||||||
<%= check_box_tag "debate_ids[]", debate.id, nil, id: "#{dom_id(debate)}_check" %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<%= submit_tag t('moderation.bulk.index.hide_debates'), class: "button radius", data: {confirm: t('moderation.bulk.index.confirm')} %>
|
|
||||||
<%= submit_tag t('moderation.bulk.index.block_authors'), class: "button radius", data: {confirm: t('moderation.bulk.index.confirm')} %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= paginate @debates %>
|
|
||||||
@@ -2,44 +2,76 @@
|
|||||||
|
|
||||||
<%= render 'shared/filter_subnav', i18n_namespace: "moderation.comments.index" %>
|
<%= render 'shared/filter_subnav', i18n_namespace: "moderation.comments.index" %>
|
||||||
|
|
||||||
<h3><%= page_entries_info @comments %></h3>
|
<div class="row">
|
||||||
|
<h3 class="small-8 large-8 columns"><%= page_entries_info @comments %></h3>
|
||||||
|
<div class="small-4 large-4 columns">
|
||||||
|
<div class="right">
|
||||||
|
<%= t("moderation.comments.index.order") %>
|
||||||
|
<%= render 'shared/order_selector', i18n_namespace: "moderation.comments.index" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= form_tag moderate_moderation_comments_path(request.query_parameters), method: :put do %>
|
||||||
|
<p class="right js-check">
|
||||||
|
<%= t('shared.check') %>:
|
||||||
|
<%= link_to t('shared.check_all'), '#', data: {check_all: "comment_ids[]"} %>
|
||||||
|
|
|
||||||
|
<%= link_to t('shared.check_none'), '#', data: {check_none: "comment_ids[]"} %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<%= t("moderation.comments.index.headers.commentable") %> |
|
<%= t("moderation.comments.index.headers.comment") %>
|
||||||
<%= t("moderation.comments.index.headers.commentable_type") %> |
|
</th>
|
||||||
<%= t("moderation.comments.index.headers.updated_at") %>
|
<th>
|
||||||
|
<%= t("moderation.comments.index.headers.moderate") %>
|
||||||
</th>
|
</th>
|
||||||
<th><%= t("moderation.comments.index.headers.comment") %></th>
|
|
||||||
<th class="text-center"><%= t("moderation.comments.index.headers.flags") %></th>
|
|
||||||
<th class="text-center" colspan="2"><%= t("moderation.debates.index.headers.actions") %></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% @comments.each do |comment| %>
|
<% @comments.each do |comment| %>
|
||||||
<tr id="comment_<%= comment.id %>">
|
<tr id="comment_<%= comment.id %>">
|
||||||
<td>
|
<td>
|
||||||
|
<%= comment.commentable_type.constantize.model_name.human %> -
|
||||||
<%= link_to comment.commentable.title, comment.commentable %>
|
<%= link_to comment.commentable.title, comment.commentable %>
|
||||||
<br>
|
<br>
|
||||||
<%= comment.commentable_type.constantize.model_name.human %>
|
|
||||||
<span class="date"><%= l comment.updated_at.to_date %></span>
|
<span class="date"><%= l comment.updated_at.to_date %></span>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= comment.flags_count %><i class="icon-flag flag-disable"></i>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= comment.author.username %>
|
||||||
|
<br>
|
||||||
|
<p>
|
||||||
|
<%= comment.body %>
|
||||||
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td><%= text_with_links comment.body %></td>
|
<td class="text-center">
|
||||||
<td class="text-center"><%= comment.flags_count %></td>
|
<%= check_box_tag "comment_ids[]", comment.id, nil, id: "#{dom_id(comment)}_check" %>
|
||||||
<td>
|
|
||||||
<%= link_to t("moderation.comments.index.hide"), hide_in_moderation_screen_moderation_comment_path(comment, request.query_parameters), method: :put, class: "delete" %>
|
|
||||||
</td>
|
</td>
|
||||||
<% if can? :ignore_flag, comment %>
|
|
||||||
<td>
|
|
||||||
<%= link_to t("moderation.comments.index.ignore_flag"), ignore_flag_moderation_comment_path(comment, request.query_parameters), method: :put, class: "button radius tiny warning" %>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
<% if comment.ignored_flag? %>
|
|
||||||
<td class="ignored">
|
|
||||||
<%= t("moderation.comments.index.ignored_flag") %>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<%= submit_tag t('moderation.comments.index.block_authors'),
|
||||||
|
name: "block_authors",
|
||||||
|
class: "button radius alert",
|
||||||
|
data: {confirm: t('moderation.comments.index.confirm')}
|
||||||
|
%>
|
||||||
|
|
||||||
|
<div class="right">
|
||||||
|
<%= submit_tag t('moderation.comments.index.hide_comments'),
|
||||||
|
name: "hide_comments",
|
||||||
|
class: "button radius alert",
|
||||||
|
data: {confirm: t('moderation.comments.index.confirm')}
|
||||||
|
%>
|
||||||
|
<%= submit_tag t('moderation.comments.index.ignore_flags'),
|
||||||
|
name: "ignore_flags",
|
||||||
|
class: "button radius success",
|
||||||
|
data: {confirm: t('moderation.comments.index.confirm')}
|
||||||
|
%>
|
||||||
|
</div>
|
||||||
|
|
||||||
<%= paginate @comments %>
|
<%= paginate @comments %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -2,17 +2,32 @@
|
|||||||
|
|
||||||
<%= render 'shared/filter_subnav', i18n_namespace: "moderation.debates.index" %>
|
<%= render 'shared/filter_subnav', i18n_namespace: "moderation.debates.index" %>
|
||||||
|
|
||||||
<h3><%= page_entries_info @debates %></h3>
|
<div class="row">
|
||||||
|
<h3 class="small-8 large-8 columns"><%= page_entries_info @debates %></h3>
|
||||||
|
<div class="small-4 large-4 columns">
|
||||||
|
<div class="right">
|
||||||
|
<%= t("moderation.debates.index.order") %>
|
||||||
|
<%= render 'shared/order_selector', i18n_namespace: "moderation.debates.index" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= form_tag moderate_moderation_debates_path(request.query_parameters), method: :put do %>
|
||||||
|
<p class="right js-check">
|
||||||
|
<%= t('shared.check') %>:
|
||||||
|
<%= link_to t('shared.check_all'), '#', data: {check_all: "debate_ids[]"} %>
|
||||||
|
|
|
||||||
|
<%= link_to t('shared.check_none'), '#', data: {check_none: "debate_ids[]"} %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<%= t("moderation.debates.index.headers.title") %> |
|
<%= t("moderation.debates.index.headers.debate") %>
|
||||||
<%= t("moderation.debates.index.headers.updated_at") %> |
|
</th>
|
||||||
<%= t("moderation.debates.index.headers.description") %>
|
<th>
|
||||||
|
<%= t("moderation.debates.index.headers.moderate") %>
|
||||||
</th>
|
</th>
|
||||||
<th class="text-center"><%= t("moderation.debates.index.headers.flags") %></th>
|
|
||||||
<th class="text-center" colspan="2"><%= t("moderation.debates.index.headers.actions") %></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% @debates.each do |debate| %>
|
<% @debates.each do |debate| %>
|
||||||
<tr id="debate_<%= debate.id %>">
|
<tr id="debate_<%= debate.id %>">
|
||||||
@@ -20,25 +35,41 @@
|
|||||||
<%= link_to debate.title, debate, target: "_blank" %>
|
<%= link_to debate.title, debate, target: "_blank" %>
|
||||||
<br>
|
<br>
|
||||||
<span class="date"><%= l debate.updated_at.to_date %></span>
|
<span class="date"><%= l debate.updated_at.to_date %></span>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= debate.flags_count %><i class="icon-flag flag-disable"></i>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= debate.author.username %>
|
||||||
<br>
|
<br>
|
||||||
|
<div class="moderation-description">
|
||||||
<%= debate.description %>
|
<%= debate.description %>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center"><%= debate.flags_count %></td>
|
<td class="text-center">
|
||||||
<td>
|
<%= check_box_tag "debate_ids[]", debate.id, nil, id: "#{dom_id(debate)}_check" %>
|
||||||
<%= link_to t("moderation.debates.index.hide"), hide_in_moderation_screen_moderation_debate_path(debate, request.query_parameters), method: :put, class: "delete" %>
|
|
||||||
</td>
|
</td>
|
||||||
<% if can? :ignore_flag, debate %>
|
|
||||||
<td>
|
|
||||||
<%= link_to t("moderation.debates.index.ignore_flag"), ignore_flag_moderation_debate_path(debate, request.query_parameters), method: :put, class: "button radius tiny warning" %>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
<% if debate.ignored_flag? %>
|
|
||||||
<td class="ignored">
|
|
||||||
<%= t("moderation.debates.index.ignored_flag") %>
|
|
||||||
</td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<%= submit_tag t('moderation.debates.index.block_authors'),
|
||||||
|
name: "block_authors",
|
||||||
|
class: "button radius alert",
|
||||||
|
data: {confirm: t('moderation.debates.index.confirm')}
|
||||||
|
%>
|
||||||
|
|
||||||
|
<div class="right">
|
||||||
|
<%= submit_tag t('moderation.debates.index.hide_debates'),
|
||||||
|
name: "hide_debates",
|
||||||
|
class: "button radius alert",
|
||||||
|
data: {confirm: t('moderation.debates.index.confirm')}
|
||||||
|
%>
|
||||||
|
<%= submit_tag t('moderation.debates.index.ignore_flags'),
|
||||||
|
name: "ignore_flags",
|
||||||
|
class: "button radius success",
|
||||||
|
data: {confirm: t('moderation.debates.index.confirm')}
|
||||||
|
%>
|
||||||
|
</div>
|
||||||
|
|
||||||
<%= paginate @debates %>
|
<%= paginate @debates %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= proposal.author.username %>
|
<%= proposal.author.username %>
|
||||||
<br>
|
<br>
|
||||||
<div class="proposal-description">
|
<div class="moderation-description">
|
||||||
<%= proposal.description %>
|
<%= proposal.description %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -110,9 +110,12 @@ ignore_unused:
|
|||||||
- 'admin.users.index.filter*'
|
- 'admin.users.index.filter*'
|
||||||
- 'admin.comments.index.hidden_*'
|
- 'admin.comments.index.hidden_*'
|
||||||
- 'moderation.comments.index.filter*'
|
- 'moderation.comments.index.filter*'
|
||||||
|
- 'moderation.comments.index.order*'
|
||||||
- 'moderation.debates.index.filter*'
|
- 'moderation.debates.index.filter*'
|
||||||
- 'moderation.proposals.index.filter*'
|
- 'moderation.proposals.index.filter*'
|
||||||
- 'moderation.proposals.index.order*'
|
- 'moderation.proposals.index.order*'
|
||||||
|
- 'moderation.debates.index.filter*'
|
||||||
|
- 'moderation.debates.index.order*'
|
||||||
- 'debates.index.orders.*'
|
- 'debates.index.orders.*'
|
||||||
- 'debates.index.search_form.*'
|
- 'debates.index.search_form.*'
|
||||||
- 'proposals.index.orders.*'
|
- 'proposals.index.orders.*'
|
||||||
|
|||||||
@@ -5,44 +5,47 @@ en:
|
|||||||
flagged_debates: Debates
|
flagged_debates: Debates
|
||||||
flagged_comments: Comments
|
flagged_comments: Comments
|
||||||
users: Ban users
|
users: Ban users
|
||||||
bulk: Bulk moderation
|
|
||||||
dashboard:
|
dashboard:
|
||||||
index:
|
index:
|
||||||
title: Moderation
|
title: Moderation
|
||||||
comments:
|
comments:
|
||||||
index:
|
index:
|
||||||
title: Comments flagged as inappropriate
|
hide_comments: Hide comments
|
||||||
|
block_authors: Block authors
|
||||||
|
ignore_flags: Ignore flags
|
||||||
|
title: Comments
|
||||||
headers:
|
headers:
|
||||||
flags: Flags
|
|
||||||
updated_at: Date
|
|
||||||
commentable_type: Type
|
|
||||||
commentable: Root
|
|
||||||
comment: Comment
|
comment: Comment
|
||||||
hide: Hide
|
moderate: Moderate
|
||||||
ignore_flag: Ignore
|
|
||||||
ignored_flag: Ignored
|
|
||||||
filter: Filter
|
filter: Filter
|
||||||
filters:
|
filters:
|
||||||
all: All
|
all: All
|
||||||
pending_flag_review: Pending
|
pending_flag_review: Pending
|
||||||
with_ignored_flag: Ignored
|
with_ignored_flag: Ignored
|
||||||
|
order: Order
|
||||||
|
orders:
|
||||||
|
created_at: Newest
|
||||||
|
flags: Most flagged
|
||||||
|
confirm: Are you sure?
|
||||||
debates:
|
debates:
|
||||||
index:
|
index:
|
||||||
title: Debates flagged as inappropriate
|
hide_debates: Hide debates
|
||||||
|
block_authors: Block authors
|
||||||
|
ignore_flags: Ignore flags
|
||||||
|
title: Debates
|
||||||
headers:
|
headers:
|
||||||
flags: Flags
|
debate: Debate
|
||||||
updated_at: Date
|
moderate: Moderate
|
||||||
title: Title
|
|
||||||
description: Description
|
|
||||||
actions: Actions
|
|
||||||
hide: Hide
|
|
||||||
ignore_flag: Ignore
|
|
||||||
ignored_flag: Ignored
|
|
||||||
filter: Filter
|
filter: Filter
|
||||||
filters:
|
filters:
|
||||||
all: All
|
all: All
|
||||||
pending_flag_review: Pending
|
pending_flag_review: Pending
|
||||||
with_ignored_flag: Ignored
|
with_ignored_flag: Ignored
|
||||||
|
order: Order
|
||||||
|
orders:
|
||||||
|
created_at: Newest
|
||||||
|
flags: Most flagged
|
||||||
|
confirm: Are you sure?
|
||||||
proposals:
|
proposals:
|
||||||
index:
|
index:
|
||||||
hide_proposals: Hide proposals
|
hide_proposals: Hide proposals
|
||||||
@@ -62,19 +65,6 @@ en:
|
|||||||
created_at: Newest
|
created_at: Newest
|
||||||
flags: Most flagged
|
flags: Most flagged
|
||||||
confirm: Are you sure?
|
confirm: Are you sure?
|
||||||
bulk:
|
|
||||||
index:
|
|
||||||
title: Bulk moderation
|
|
||||||
headers:
|
|
||||||
debate: Debate
|
|
||||||
flags: Denuncias
|
|
||||||
moderate: Moderar
|
|
||||||
hide_debates: Hide debates
|
|
||||||
block_authors: Block authors
|
|
||||||
confirm: Are you sure?
|
|
||||||
check: Select
|
|
||||||
check_all: All
|
|
||||||
check_none: None
|
|
||||||
users:
|
users:
|
||||||
notice_hide: User banned.
|
notice_hide: User banned.
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -5,44 +5,47 @@ es:
|
|||||||
flagged_debates: Debates
|
flagged_debates: Debates
|
||||||
flagged_comments: Comentarios
|
flagged_comments: Comentarios
|
||||||
users: Bloquear usuarios
|
users: Bloquear usuarios
|
||||||
bulk: Moderar en bloque
|
|
||||||
dashboard:
|
dashboard:
|
||||||
index:
|
index:
|
||||||
title: Moderación
|
title: Moderación
|
||||||
comments:
|
comments:
|
||||||
index:
|
index:
|
||||||
title: Comentarios denunciados como inapropiados
|
hide_comments: Ocultar comentarios
|
||||||
|
block_authors: Bloquear autores
|
||||||
|
ignore_flags: Marcar como revisados
|
||||||
|
title: Comentarios
|
||||||
headers:
|
headers:
|
||||||
flags: Denuncias
|
|
||||||
updated_at: Fecha
|
|
||||||
commentable_type: Tipo
|
|
||||||
commentable: Raíz
|
|
||||||
comment: Comentario
|
comment: Comentario
|
||||||
hide: Ocultar
|
moderate: Moderar
|
||||||
ignore_flag: Ignorar
|
|
||||||
ignored_flag: Ignorado
|
|
||||||
filter: Filtrar
|
|
||||||
filters:
|
|
||||||
all: Todos
|
|
||||||
pending_flag_review: Pendientes
|
|
||||||
with_ignored_flag: Ignorados
|
|
||||||
debates:
|
|
||||||
index:
|
|
||||||
title: Debates denunciados como inapropiados
|
|
||||||
headers:
|
|
||||||
flags: Denuncias
|
|
||||||
updated_at: Fecha
|
|
||||||
title: Título
|
|
||||||
description: Descripción
|
|
||||||
actions: Acciones
|
|
||||||
hide: Ocultar
|
|
||||||
ignore_flag: Ignorar
|
|
||||||
ignored_flag: Ignorado
|
|
||||||
filter: Filtrar
|
filter: Filtrar
|
||||||
filters:
|
filters:
|
||||||
all: Todos
|
all: Todos
|
||||||
pending_flag_review: Pendientes
|
pending_flag_review: Pendientes
|
||||||
with_ignored_flag: Marcados como revisados
|
with_ignored_flag: Marcados como revisados
|
||||||
|
order: Orden
|
||||||
|
orders:
|
||||||
|
created_at: Más nuevos
|
||||||
|
flags: Más denunciados
|
||||||
|
confirm: ¿Estás seguro?
|
||||||
|
debates:
|
||||||
|
index:
|
||||||
|
hide_debates: Ocultar debates
|
||||||
|
block_authors: Bloquear autores
|
||||||
|
ignore_flags: Marcar como revisados
|
||||||
|
title: Debates
|
||||||
|
headers:
|
||||||
|
debate: Debate
|
||||||
|
moderate: Moderar
|
||||||
|
filter: Filtrar
|
||||||
|
filters:
|
||||||
|
all: Todos
|
||||||
|
pending_flag_review: Pendientes
|
||||||
|
with_ignored_flag: Marcados como revisados
|
||||||
|
order: Orden
|
||||||
|
orders:
|
||||||
|
created_at: Más nuevos
|
||||||
|
flags: Más denunciados
|
||||||
|
confirm: ¿Estás seguro?
|
||||||
proposals:
|
proposals:
|
||||||
index:
|
index:
|
||||||
hide_proposals: Ocultar Propuestas
|
hide_proposals: Ocultar Propuestas
|
||||||
@@ -62,19 +65,6 @@ es:
|
|||||||
created_at: Más recientes
|
created_at: Más recientes
|
||||||
flags: Más denunciadas
|
flags: Más denunciadas
|
||||||
confirm: ¿Estás seguro?
|
confirm: ¿Estás seguro?
|
||||||
bulk:
|
|
||||||
index:
|
|
||||||
title: Moderar en bloque
|
|
||||||
headers:
|
|
||||||
debate: Debate
|
|
||||||
flags: Denuncias
|
|
||||||
moderate: Moderar
|
|
||||||
hide_debates: Ocultar debates
|
|
||||||
block_authors: Bloquear usuarios
|
|
||||||
confirm: ¿Estás seguro?
|
|
||||||
check: Seleccionar
|
|
||||||
check_all: Todos
|
|
||||||
check_none: Ninguno
|
|
||||||
users:
|
users:
|
||||||
notice_hide: Usuario bloqueado. Se han ocultado todos sus debates y comentarios.
|
notice_hide: Usuario bloqueado. Se han ocultado todos sus debates y comentarios.
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -127,8 +127,9 @@ Rails.application.routes.draw do
|
|||||||
resources :debates, only: :index do
|
resources :debates, only: :index do
|
||||||
member do
|
member do
|
||||||
put :hide
|
put :hide
|
||||||
put :hide_in_moderation_screen
|
end
|
||||||
put :ignore_flag
|
collection do
|
||||||
|
put :moderate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -144,13 +145,11 @@ Rails.application.routes.draw do
|
|||||||
resources :comments, only: :index do
|
resources :comments, only: :index do
|
||||||
member do
|
member do
|
||||||
put :hide
|
put :hide
|
||||||
put :hide_in_moderation_screen
|
end
|
||||||
put :ignore_flag
|
collection do
|
||||||
|
put :moderate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/bulk', to: "bulk#index"
|
|
||||||
put '/bulk/hide', to: "bulk#hide"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :stats, only: [:show]
|
resource :stats, only: [:show]
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ feature 'Debates' do
|
|||||||
login_as(author)
|
login_as(author)
|
||||||
|
|
||||||
visit new_debate_path
|
visit new_debate_path
|
||||||
fill_in 'debate_title', with: 'End evictions'
|
fill_in 'debate_title', with: 'A title for a debate'
|
||||||
fill_in 'debate_description', with: 'This is very important because...'
|
fill_in 'debate_description', with: 'This is very important because...'
|
||||||
fill_in 'debate_captcha', with: correct_captcha_text
|
fill_in 'debate_captcha', with: correct_captcha_text
|
||||||
check 'debate_terms_of_service'
|
check 'debate_terms_of_service'
|
||||||
|
|
||||||
click_button 'Start a debate'
|
click_button 'Start a debate'
|
||||||
|
|
||||||
|
expect(page).to have_content 'A title for a debate'
|
||||||
expect(page).to have_content 'Debate was successfully created.'
|
expect(page).to have_content 'Debate was successfully created.'
|
||||||
expect(page).to have_content 'End evictions'
|
|
||||||
expect(page).to have_content 'This is very important because...'
|
expect(page).to have_content 'This is very important because...'
|
||||||
expect(page).to have_content author.name
|
expect(page).to have_content author.name
|
||||||
expect(page).to have_content I18n.l(Debate.last.created_at.to_date)
|
expect(page).to have_content I18n.l(Debate.last.created_at.to_date)
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
feature 'Moderate in bulk' do
|
|
||||||
background do
|
|
||||||
moderator = create(:moderator)
|
|
||||||
login_as(moderator.user)
|
|
||||||
end
|
|
||||||
|
|
||||||
feature "When a debate has been selected for moderation" do
|
|
||||||
background do
|
|
||||||
@debate = create(:debate)
|
|
||||||
visit moderation_bulk_path
|
|
||||||
|
|
||||||
within("#debate_#{@debate.id}") do
|
|
||||||
check "debate_#{@debate.id}_check"
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).to_not have_css("debate_#{@debate.id}")
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Hide the debate' do
|
|
||||||
click_on "Hide debates"
|
|
||||||
expect(page).to_not have_css("debate_#{@debate.id}")
|
|
||||||
expect(@debate.reload).to be_hidden
|
|
||||||
expect(@debate.author).to_not be_hidden
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Block the author' do
|
|
||||||
click_on "Block authors"
|
|
||||||
expect(page).to_not have_css("debate_#{@debate.id}")
|
|
||||||
expect(@debate.reload).to be_hidden
|
|
||||||
expect(@debate.author).to be_hidden
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "select all/none", :js do
|
|
||||||
create_list(:debate, 2)
|
|
||||||
|
|
||||||
visit moderation_bulk_path
|
|
||||||
|
|
||||||
click_on 'All'
|
|
||||||
all('input[type=checkbox]').each do |checkbox|
|
|
||||||
expect(checkbox).to be_checked
|
|
||||||
end
|
|
||||||
|
|
||||||
click_on 'None'
|
|
||||||
all('input[type=checkbox]').each do |checkbox|
|
|
||||||
expect(checkbox).to_not be_checked
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,18 +1,15 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature 'Moderate Comments' do
|
feature 'Moderate comments' do
|
||||||
|
|
||||||
feature 'Hiding Comments' do
|
scenario 'Hide', :js do
|
||||||
|
|
||||||
scenario 'Hide without children hides the comment completely', :js do
|
|
||||||
citizen = create(:user)
|
citizen = create(:user)
|
||||||
moderator = create(:moderator)
|
moderator = create(:moderator)
|
||||||
|
|
||||||
debate = create(:debate)
|
comment = create(:comment)
|
||||||
comment = create(:comment, commentable: debate, body: 'SPAM')
|
|
||||||
|
|
||||||
login_as(moderator.user)
|
login_as(moderator.user)
|
||||||
visit debate_path(debate)
|
visit debate_path(comment.commentable)
|
||||||
|
|
||||||
within("#comment_#{comment.id}") do
|
within("#comment_#{comment.id}") do
|
||||||
click_link 'Hide'
|
click_link 'Hide'
|
||||||
@@ -20,86 +17,105 @@ feature 'Moderate Comments' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
login_as(citizen)
|
login_as(citizen)
|
||||||
visit debate_path(debate)
|
visit debate_path(comment.commentable)
|
||||||
|
|
||||||
expect(page).to have_css('.comment', count: 1)
|
expect(page).to have_css('.comment', count: 1)
|
||||||
expect(page).to_not have_content('This comment has been deleted')
|
expect(page).to_not have_content('This comment has been deleted')
|
||||||
expect(page).to_not have_content('SPAM')
|
expect(page).to_not have_content('SPAM')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Children visible', :js do
|
scenario 'Can not hide own comment' do
|
||||||
citizen = create(:user)
|
|
||||||
moderator = create(:moderator)
|
moderator = create(:moderator)
|
||||||
|
comment = create(:comment, user: moderator.user)
|
||||||
debate = create(:debate)
|
|
||||||
comment = create(:comment, commentable: debate, body: 'SPAM')
|
|
||||||
create(:comment, commentable: debate, body: 'Acceptable reply', parent_id: comment.id)
|
|
||||||
|
|
||||||
login_as(moderator.user)
|
login_as(moderator.user)
|
||||||
visit debate_path(debate)
|
visit debate_path(comment.commentable)
|
||||||
|
|
||||||
within("#comment_#{comment.id}") do
|
within("#comment_#{comment.id}") do
|
||||||
first(:link, "Hide").click
|
expect(page).to_not have_link('Hide')
|
||||||
expect(page).to have_css('.comment .faded')
|
expect(page).to_not have_link('Block author')
|
||||||
end
|
|
||||||
|
|
||||||
login_as(citizen)
|
|
||||||
visit debate_path(debate)
|
|
||||||
|
|
||||||
expect(page).to have_css('.comment', count: 2)
|
|
||||||
expect(page).to have_content('This comment has been deleted')
|
|
||||||
expect(page).to_not have_content('SPAM')
|
|
||||||
|
|
||||||
expect(page).to have_content('Acceptable reply')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Moderator actions in the comment' do
|
feature '/moderation/ screen' do
|
||||||
citizen = create(:user)
|
|
||||||
moderator = create(:moderator)
|
|
||||||
|
|
||||||
debate = create(:debate)
|
|
||||||
comment = create(:comment, commentable: debate)
|
|
||||||
|
|
||||||
login_as(moderator.user)
|
|
||||||
visit debate_path(debate)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
background do
|
background do
|
||||||
moderator = create(:moderator)
|
moderator = create(:moderator)
|
||||||
login_as(moderator.user)
|
login_as(moderator.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature 'moderate in bulk' do
|
||||||
|
feature "When a comment has been selected for moderation" do
|
||||||
|
background do
|
||||||
|
@comment = create(:comment)
|
||||||
|
visit moderation_comments_path
|
||||||
|
within('.sub-nav') do
|
||||||
|
click_link "All"
|
||||||
|
end
|
||||||
|
|
||||||
|
within("#comment_#{@comment.id}") do
|
||||||
|
check "comment_#{@comment.id}_check"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to_not have_css("comment_#{@comment.id}")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Hide the comment' do
|
||||||
|
click_on "Hide comments"
|
||||||
|
expect(page).to_not have_css("comment_#{@comment.id}")
|
||||||
|
expect(@comment.reload).to be_hidden
|
||||||
|
expect(@comment.user).to_not be_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Block the user' do
|
||||||
|
click_on "Block authors"
|
||||||
|
expect(page).to_not have_css("comment_#{@comment.id}")
|
||||||
|
expect(@comment.reload).to be_hidden
|
||||||
|
expect(@comment.user).to be_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Ignore the comment' do
|
||||||
|
click_on "Ignore flags"
|
||||||
|
expect(page).to_not have_css("comment_#{@comment.id}")
|
||||||
|
expect(@comment.reload).to be_ignored_flag
|
||||||
|
expect(@comment.reload).to_not be_hidden
|
||||||
|
expect(@comment.user).to_not be_hidden
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "select all/none", :js do
|
||||||
|
create_list(:comment, 2)
|
||||||
|
|
||||||
|
visit moderation_comments_path
|
||||||
|
|
||||||
|
within('.js-check') { click_on 'All' }
|
||||||
|
|
||||||
|
all('input[type=checkbox]').each do |checkbox|
|
||||||
|
expect(checkbox).to be_checked
|
||||||
|
end
|
||||||
|
|
||||||
|
within('.js-check') { click_on 'None' }
|
||||||
|
|
||||||
|
all('input[type=checkbox]').each do |checkbox|
|
||||||
|
expect(checkbox).to_not be_checked
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "remembering page, filter and order" do
|
||||||
|
create_list(:comment, 52)
|
||||||
|
|
||||||
|
visit moderation_comments_path(filter: 'all', page: '2', order: 'created_at')
|
||||||
|
|
||||||
|
click_on "Ignore flags"
|
||||||
|
|
||||||
|
expect(page).to have_selector('.js-order-selector[data-order="created_at"]')
|
||||||
|
|
||||||
|
expect(current_url).to include('filter=all')
|
||||||
|
expect(current_url).to include('page=2')
|
||||||
|
expect(current_url).to include('order=created_at')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Current filter is properly highlighted" do
|
scenario "Current filter is properly highlighted" do
|
||||||
visit moderation_comments_path
|
visit moderation_comments_path
|
||||||
expect(page).to_not have_link('Pending')
|
expect(page).to_not have_link('Pending')
|
||||||
@@ -107,98 +123,74 @@ feature 'Moderate Comments' do
|
|||||||
expect(page).to have_link('Ignored')
|
expect(page).to have_link('Ignored')
|
||||||
|
|
||||||
visit moderation_comments_path(filter: 'all')
|
visit moderation_comments_path(filter: 'all')
|
||||||
|
within('.sub-nav') do
|
||||||
expect(page).to_not have_link('All')
|
expect(page).to_not have_link('All')
|
||||||
expect(page).to have_link('Pending')
|
expect(page).to have_link('Pending')
|
||||||
expect(page).to have_link('Ignored')
|
expect(page).to have_link('Ignored')
|
||||||
|
end
|
||||||
|
|
||||||
visit moderation_comments_path(filter: 'pending_flag_review')
|
visit moderation_comments_path(filter: 'pending_flag_review')
|
||||||
|
within('.sub-nav') do
|
||||||
expect(page).to have_link('All')
|
expect(page).to have_link('All')
|
||||||
expect(page).to_not have_link('Pending')
|
expect(page).to_not have_link('Pending')
|
||||||
expect(page).to have_link('Ignored')
|
expect(page).to have_link('Ignored')
|
||||||
|
end
|
||||||
|
|
||||||
visit moderation_comments_path(filter: 'with_ignored_flag')
|
visit moderation_comments_path(filter: 'with_ignored_flag')
|
||||||
|
within('.sub-nav') do
|
||||||
expect(page).to have_link('All')
|
expect(page).to have_link('All')
|
||||||
expect(page).to have_link('Pending')
|
expect(page).to have_link('Pending')
|
||||||
expect(page).to_not have_link('Ignored')
|
expect(page).to_not have_link('Ignored')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Filtering comments" do
|
scenario "Filtering comments" do
|
||||||
|
create(:comment, body: "Regular comment")
|
||||||
create(:comment, :flagged, body: "Pending comment")
|
create(:comment, :flagged, body: "Pending comment")
|
||||||
create(:comment, :flagged, :hidden, body: "Hidden comment")
|
create(:comment, :hidden, body: "Hidden comment")
|
||||||
create(:comment, :flagged, :with_ignored_flag, body: "Ignored comment")
|
create(:comment, :flagged, :with_ignored_flag, body: "Ignored comment")
|
||||||
|
|
||||||
visit moderation_comments_path(filter: 'all')
|
visit moderation_comments_path(filter: 'all')
|
||||||
|
expect(page).to have_content('Regular comment')
|
||||||
expect(page).to have_content('Pending comment')
|
expect(page).to have_content('Pending comment')
|
||||||
expect(page).to_not have_content('Hidden comment')
|
expect(page).to_not have_content('Hidden comment')
|
||||||
expect(page).to have_content('Ignored comment')
|
expect(page).to have_content('Ignored comment')
|
||||||
|
|
||||||
visit moderation_comments_path(filter: 'pending_flag_review')
|
visit moderation_comments_path(filter: 'pending_flag_review')
|
||||||
|
expect(page).to_not have_content('Regular comment')
|
||||||
expect(page).to have_content('Pending comment')
|
expect(page).to have_content('Pending comment')
|
||||||
expect(page).to_not have_content('Hidden comment')
|
expect(page).to_not have_content('Hidden comment')
|
||||||
expect(page).to_not have_content('Ignored comment')
|
expect(page).to_not have_content('Ignored comment')
|
||||||
|
|
||||||
visit moderation_comments_path(filter: 'with_ignored_flag')
|
visit moderation_comments_path(filter: 'with_ignored_flag')
|
||||||
|
expect(page).to_not have_content('Regular comment')
|
||||||
expect(page).to_not have_content('Pending comment')
|
expect(page).to_not have_content('Pending comment')
|
||||||
expect(page).to_not have_content('Hidden comment')
|
expect(page).to_not have_content('Hidden comment')
|
||||||
expect(page).to have_content('Ignored comment')
|
expect(page).to have_content('Ignored comment')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Reviewing links remember the pagination setting and the filter" do
|
scenario "sorting comments" do
|
||||||
per_page = Kaminari.config.default_per_page
|
create(:comment, body: "Flagged comment", created_at: Time.now - 1.day, flags_count: 5)
|
||||||
(per_page + 2).times { create(:comment, :flagged) }
|
create(:comment, body: "Flagged newer comment", created_at: Time.now - 12.hours, flags_count: 3)
|
||||||
|
create(:comment, body: "Newer comment", created_at: Time.now)
|
||||||
|
|
||||||
visit moderation_comments_path(filter: 'pending_flag_review', page: 2)
|
visit moderation_comments_path(order: 'created_at')
|
||||||
|
|
||||||
click_link('Ignore', match: :first, exact: true)
|
expect("Flagged newer comment").to appear_before("Flagged comment")
|
||||||
|
|
||||||
expect(current_url).to include('filter=pending_flag_review')
|
visit moderation_comments_path(order: 'flags')
|
||||||
expect(current_url).to include('page=2')
|
|
||||||
end
|
|
||||||
|
|
||||||
feature 'A flagged comment exists' do
|
expect("Flagged comment").to appear_before("Flagged newer comment")
|
||||||
|
|
||||||
background do
|
visit moderation_comments_path(filter: 'all', order: 'created_at')
|
||||||
debate = create(:debate, title: 'Democracy')
|
|
||||||
@comment = create(:comment, :flagged, commentable: debate, body: 'spammy spam')
|
|
||||||
visit moderation_comments_path
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'It is displayed with the correct attributes' do
|
expect("Newer comment").to appear_before("Flagged newer comment")
|
||||||
within("#comment_#{@comment.id}") do
|
expect("Flagged newer comment").to appear_before("Flagged comment")
|
||||||
expect(page).to have_link('Democracy')
|
|
||||||
expect(page).to have_content('spammy spam')
|
|
||||||
expect(page).to have_content('1')
|
|
||||||
expect(page).to have_link('Hide')
|
|
||||||
expect(page).to have_link('Ignore')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Hiding the comment' do
|
visit moderation_comments_path(filter: 'all', order: 'flags')
|
||||||
within("#comment_#{@comment.id}") do
|
|
||||||
click_link('Hide')
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(current_path).to eq(moderation_comments_path)
|
expect("Flagged comment").to appear_before("Flagged newer comment")
|
||||||
expect(page).to_not have_selector("#comment_#{@comment.id}")
|
expect("Flagged newer comment").to appear_before("Newer comment")
|
||||||
|
|
||||||
expect(@comment.reload).to be_hidden
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Marking the comment as ignored' do
|
|
||||||
within("#comment_#{@comment.id}") do
|
|
||||||
click_link('Ignore')
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(current_path).to eq(moderation_comments_path)
|
|
||||||
|
|
||||||
click_link('Ignored')
|
|
||||||
|
|
||||||
within("#comment_#{@comment.id}") do
|
|
||||||
expect(page).to have_content('Ignored')
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(@comment.reload).to be_ignored_flag
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,13 +36,85 @@ feature 'Moderate debates' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature '/moderation/ menu' do
|
feature '/moderation/ screen' do
|
||||||
|
|
||||||
background do
|
background do
|
||||||
moderator = create(:moderator)
|
moderator = create(:moderator)
|
||||||
login_as(moderator.user)
|
login_as(moderator.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature 'moderate in bulk' do
|
||||||
|
feature "When a debate has been selected for moderation" do
|
||||||
|
background do
|
||||||
|
@debate = create(:debate)
|
||||||
|
visit moderation_debates_path
|
||||||
|
within('.sub-nav') do
|
||||||
|
click_link "All"
|
||||||
|
end
|
||||||
|
|
||||||
|
within("#debate_#{@debate.id}") do
|
||||||
|
check "debate_#{@debate.id}_check"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to_not have_css("debate_#{@debate.id}")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Hide the debate' do
|
||||||
|
click_on "Hide debates"
|
||||||
|
expect(page).to_not have_css("debate_#{@debate.id}")
|
||||||
|
expect(@debate.reload).to be_hidden
|
||||||
|
expect(@debate.author).to_not be_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Block the author' do
|
||||||
|
click_on "Block authors"
|
||||||
|
expect(page).to_not have_css("debate_#{@debate.id}")
|
||||||
|
expect(@debate.reload).to be_hidden
|
||||||
|
expect(@debate.author).to be_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Ignore the debate' do
|
||||||
|
click_on "Ignore flags"
|
||||||
|
expect(page).to_not have_css("debate_#{@debate.id}")
|
||||||
|
expect(@debate.reload).to be_ignored_flag
|
||||||
|
expect(@debate.reload).to_not be_hidden
|
||||||
|
expect(@debate.author).to_not be_hidden
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "select all/none", :js do
|
||||||
|
create_list(:debate, 2)
|
||||||
|
|
||||||
|
visit moderation_debates_path
|
||||||
|
|
||||||
|
within('.js-check') { click_on 'All' }
|
||||||
|
|
||||||
|
all('input[type=checkbox]').each do |checkbox|
|
||||||
|
expect(checkbox).to be_checked
|
||||||
|
end
|
||||||
|
|
||||||
|
within('.js-check') { click_on 'None' }
|
||||||
|
|
||||||
|
all('input[type=checkbox]').each do |checkbox|
|
||||||
|
expect(checkbox).to_not be_checked
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "remembering page, filter and order" do
|
||||||
|
create_list(:debate, 52)
|
||||||
|
|
||||||
|
visit moderation_debates_path(filter: 'all', page: '2', order: 'created_at')
|
||||||
|
|
||||||
|
click_on "Ignore flags"
|
||||||
|
|
||||||
|
expect(page).to have_selector('.js-order-selector[data-order="created_at"]')
|
||||||
|
|
||||||
|
expect(current_url).to include('filter=all')
|
||||||
|
expect(current_url).to include('page=2')
|
||||||
|
expect(current_url).to include('order=created_at')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Current filter is properly highlighted" do
|
scenario "Current filter is properly highlighted" do
|
||||||
visit moderation_debates_path
|
visit moderation_debates_path
|
||||||
expect(page).to_not have_link('Pending')
|
expect(page).to_not have_link('Pending')
|
||||||
@@ -50,98 +122,74 @@ feature 'Moderate debates' do
|
|||||||
expect(page).to have_link('Ignored')
|
expect(page).to have_link('Ignored')
|
||||||
|
|
||||||
visit moderation_debates_path(filter: 'all')
|
visit moderation_debates_path(filter: 'all')
|
||||||
|
within('.sub-nav') do
|
||||||
expect(page).to_not have_link('All')
|
expect(page).to_not have_link('All')
|
||||||
expect(page).to have_link('Pending')
|
expect(page).to have_link('Pending')
|
||||||
expect(page).to have_link('Ignored')
|
expect(page).to have_link('Ignored')
|
||||||
|
end
|
||||||
|
|
||||||
visit moderation_debates_path(filter: 'pending_flag_review')
|
visit moderation_debates_path(filter: 'pending_flag_review')
|
||||||
|
within('.sub-nav') do
|
||||||
expect(page).to have_link('All')
|
expect(page).to have_link('All')
|
||||||
expect(page).to_not have_link('Pending')
|
expect(page).to_not have_link('Pending')
|
||||||
expect(page).to have_link('Ignored')
|
expect(page).to have_link('Ignored')
|
||||||
|
end
|
||||||
|
|
||||||
visit moderation_debates_path(filter: 'with_ignored_flag')
|
visit moderation_debates_path(filter: 'with_ignored_flag')
|
||||||
|
within('.sub-nav') do
|
||||||
expect(page).to have_link('All')
|
expect(page).to have_link('All')
|
||||||
expect(page).to have_link('Pending')
|
expect(page).to have_link('Pending')
|
||||||
expect(page).to_not have_link('Ignored')
|
expect(page).to_not have_link('Ignored')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Filtering debates" do
|
scenario "Filtering debates" do
|
||||||
|
create(:debate, title: "Regular debate")
|
||||||
create(:debate, :flagged, title: "Pending debate")
|
create(:debate, :flagged, title: "Pending debate")
|
||||||
create(:debate, :flagged, :hidden, title: "Hidden debate")
|
create(:debate, :hidden, title: "Hidden debate")
|
||||||
create(:debate, :flagged, :with_ignored_flag, title: "Ignored debate")
|
create(:debate, :flagged, :with_ignored_flag, title: "Ignored debate")
|
||||||
|
|
||||||
visit moderation_debates_path(filter: 'all')
|
visit moderation_debates_path(filter: 'all')
|
||||||
|
expect(page).to have_content('Regular debate')
|
||||||
expect(page).to have_content('Pending debate')
|
expect(page).to have_content('Pending debate')
|
||||||
expect(page).to_not have_content('Hidden debate')
|
expect(page).to_not have_content('Hidden debate')
|
||||||
expect(page).to have_content('Ignored debate')
|
expect(page).to have_content('Ignored debate')
|
||||||
|
|
||||||
visit moderation_debates_path(filter: 'pending_flag_review')
|
visit moderation_debates_path(filter: 'pending_flag_review')
|
||||||
|
expect(page).to_not have_content('Regular debate')
|
||||||
expect(page).to have_content('Pending debate')
|
expect(page).to have_content('Pending debate')
|
||||||
expect(page).to_not have_content('Hidden debate')
|
expect(page).to_not have_content('Hidden debate')
|
||||||
expect(page).to_not have_content('Ignored debate')
|
expect(page).to_not have_content('Ignored debate')
|
||||||
|
|
||||||
visit moderation_debates_path(filter: 'with_ignored_flag')
|
visit moderation_debates_path(filter: 'with_ignored_flag')
|
||||||
|
expect(page).to_not have_content('Regular debate')
|
||||||
expect(page).to_not have_content('Pending debate')
|
expect(page).to_not have_content('Pending debate')
|
||||||
expect(page).to_not have_content('Hidden debate')
|
expect(page).to_not have_content('Hidden debate')
|
||||||
expect(page).to have_content('Ignored debate')
|
expect(page).to have_content('Ignored debate')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Reviewing links remember the pagination setting and the filter" do
|
scenario "sorting debates" do
|
||||||
per_page = Kaminari.config.default_per_page
|
create(:debate, title: "Flagged debate", created_at: Time.now - 1.day, flags_count: 5)
|
||||||
(per_page + 2).times { create(:debate, :flagged) }
|
create(:debate, title: "Flagged newer debate", created_at: Time.now - 12.hours, flags_count: 3)
|
||||||
|
create(:debate, title: "Newer debate", created_at: Time.now)
|
||||||
|
|
||||||
visit moderation_debates_path(filter: 'pending_flag_review', page: 2)
|
visit moderation_debates_path(order: 'created_at')
|
||||||
|
|
||||||
click_link('Ignore', match: :first, exact: true)
|
expect("Flagged newer debate").to appear_before("Flagged debate")
|
||||||
|
|
||||||
expect(current_url).to include('filter=pending_flag_review')
|
visit moderation_debates_path(order: 'flags')
|
||||||
expect(current_url).to include('page=2')
|
|
||||||
end
|
|
||||||
|
|
||||||
feature 'A flagged debate exists' do
|
expect("Flagged debate").to appear_before("Flagged newer debate")
|
||||||
|
|
||||||
background do
|
visit moderation_debates_path(filter: 'all', order: 'created_at')
|
||||||
@debate = create(:debate, :flagged, title: 'spammy spam', description: 'buy buy buy')
|
|
||||||
visit moderation_debates_path
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'It is displayed with the correct attributes' do
|
expect("Newer debate").to appear_before("Flagged newer debate")
|
||||||
within("#debate_#{@debate.id}") do
|
expect("Flagged newer debate").to appear_before("Flagged debate")
|
||||||
expect(page).to have_link('spammy spam')
|
|
||||||
expect(page).to have_content('buy buy buy')
|
|
||||||
expect(page).to have_content('1')
|
|
||||||
expect(page).to have_link('Hide')
|
|
||||||
expect(page).to have_link('Ignore')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Hiding the debate' do
|
visit moderation_debates_path(filter: 'all', order: 'flags')
|
||||||
within("#debate_#{@debate.id}") do
|
|
||||||
click_link('Hide')
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(current_path).to eq(moderation_debates_path)
|
expect("Flagged debate").to appear_before("Flagged newer debate")
|
||||||
expect(page).to_not have_selector("#debate_#{@debate.id}")
|
expect("Flagged newer debate").to appear_before("Newer debate")
|
||||||
|
|
||||||
expect(@debate.reload).to be_hidden
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Marking the debate as ignored' do
|
|
||||||
within("#debate_#{@debate.id}") do
|
|
||||||
click_link('Ignore')
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(current_path).to eq(moderation_debates_path)
|
|
||||||
|
|
||||||
click_link('All')
|
|
||||||
|
|
||||||
within("#debate_#{@debate.id}") do
|
|
||||||
expect(page).to have_content('Ignored')
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(@debate.reload).to be_ignored_flag
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -173,6 +173,9 @@ describe Ability do
|
|||||||
it { should_not be_able_to(:hide, hidden_comment) }
|
it { should_not be_able_to(:hide, hidden_comment) }
|
||||||
it { should_not be_able_to(:hide, own_comment) }
|
it { should_not be_able_to(:hide, own_comment) }
|
||||||
|
|
||||||
|
it { should be_able_to(:moderate, comment) }
|
||||||
|
it { should_not be_able_to(:moderate, own_comment) }
|
||||||
|
|
||||||
it { should be_able_to(:hide, debate) }
|
it { should be_able_to(:hide, debate) }
|
||||||
it { should be_able_to(:hide_in_moderation_screen, debate) }
|
it { should be_able_to(:hide_in_moderation_screen, debate) }
|
||||||
it { should_not be_able_to(:hide, hidden_debate) }
|
it { should_not be_able_to(:hide, hidden_debate) }
|
||||||
@@ -193,6 +196,9 @@ describe Ability do
|
|||||||
it { should_not be_able_to(:ignore_flag, ignored_debate) }
|
it { should_not be_able_to(:ignore_flag, ignored_debate) }
|
||||||
it { should_not be_able_to(:ignore_flag, own_debate) }
|
it { should_not be_able_to(:ignore_flag, own_debate) }
|
||||||
|
|
||||||
|
it { should be_able_to(:moderate, debate) }
|
||||||
|
it { should_not be_able_to(:moderate, own_debate) }
|
||||||
|
|
||||||
it { should be_able_to(:ignore_flag, proposal) }
|
it { should be_able_to(:ignore_flag, proposal) }
|
||||||
it { should_not be_able_to(:ignore_flag, hidden_proposal) }
|
it { should_not be_able_to(:ignore_flag, hidden_proposal) }
|
||||||
it { should_not be_able_to(:ignore_flag, ignored_proposal) }
|
it { should_not be_able_to(:ignore_flag, ignored_proposal) }
|
||||||
|
|||||||
Reference in New Issue
Block a user