adds pending filter to admin/comments

This commit is contained in:
Juanjo Bazán
2015-09-06 21:45:41 +02:00
parent 1a7806150a
commit bc90812d37
5 changed files with 21 additions and 9 deletions

View File

@@ -1,10 +1,10 @@
class Admin::CommentsController < Admin::BaseController class Admin::CommentsController < Admin::BaseController
has_filters %w{all with_confirmed_hide} has_filters %w{without_confirmed_hide all with_confirmed_hide}
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).page(params[:page]) @comments = Comment.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
end end
def confirm_hide def confirm_hide

View File

@@ -18,11 +18,12 @@
method: :put, method: :put,
data: { confirm: t("admin.actions.confirm") }, data: { confirm: t("admin.actions.confirm") },
class: "button radius tiny success right" %> class: "button radius tiny success right" %>
<% unless comment.confirmed_hide? %>
<%= link_to t("admin.actions.confirm_hide"), <%= link_to t("admin.actions.confirm_hide"),
confirm_hide_admin_comment_path(comment, request.query_parameters), confirm_hide_admin_comment_path(comment, request.query_parameters),
method: :put, method: :put,
class: "button radius tiny warning right" %> class: "button radius tiny warning right" %>
<% end %>
</div> </div>
</div> </div>
</li> </li>

View File

@@ -59,6 +59,7 @@ en:
filters: filters:
all: All all: All
with_confirmed_hide: Confirmed with_confirmed_hide: Confirmed
without_confirmed_hide: Pending
debates: debates:
index: index:
title: Hidden debates title: Hidden debates

View File

@@ -59,6 +59,7 @@ es:
filters: filters:
all: Todos all: Todos
with_confirmed_hide: Confirmados with_confirmed_hide: Confirmados
without_confirmed_hide: Pendientes
debates: debates:
index: index:
title: Debates ocultos title: Debates ocultos

View File

@@ -24,22 +24,31 @@ feature 'Admin comments' do
click_link 'Confirm' click_link 'Confirm'
expect(page).to_not have_content(comment.body)
click_link('Confirmed')
expect(page).to have_content(comment.body) expect(page).to have_content(comment.body)
expect(page).to have_content('Confirmed')
expect(comment.reload).to be_confirmed_hide expect(comment.reload).to be_confirmed_hide
end end
scenario "Current filter is properly highlighted" do scenario "Current filter is properly highlighted" do
visit admin_comments_path visit admin_comments_path
expect(page).to_not have_link('All') expect(page).to_not have_link('Pending')
expect(page).to have_link('All')
expect(page).to have_link('Confirmed')
visit admin_comments_path(filter: 'Pending')
expect(page).to_not have_link('Pending')
expect(page).to have_link('All')
expect(page).to have_link('Confirmed') expect(page).to have_link('Confirmed')
visit admin_comments_path(filter: 'all') visit admin_comments_path(filter: 'all')
expect(page).to have_link('Pending')
expect(page).to_not have_link('All') expect(page).to_not have_link('All')
expect(page).to have_link('Confirmed') expect(page).to have_link('Confirmed')
visit admin_comments_path(filter: 'with_confirmed_hide') visit admin_comments_path(filter: 'with_confirmed_hide')
expect(page).to have_link('Pending')
expect(page).to have_link('All') expect(page).to have_link('All')
expect(page).to_not have_link('Confirmed') expect(page).to_not have_link('Confirmed')
end end