adds pending filter to admin/debates

This commit is contained in:
Juanjo Bazán
2015-09-06 21:32:54 +02:00
committed by Juanjo Bazán
parent 29ebff615c
commit 1a7806150a
6 changed files with 26 additions and 9 deletions

View File

@@ -1,10 +1,10 @@
class Admin::DebatesController < Admin::BaseController
has_filters %w{all with_confirmed_hide}, only: :index
has_filters %w{without_confirmed_hide all with_confirmed_hide}, only: :index
before_action :load_debate, only: [:confirm_hide, :restore]
def index
@debates = Debate.only_hidden.send(@current_filter).page(params[:page])
@debates = Debate.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
end
def confirm_hide

View File

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

View File

@@ -66,6 +66,7 @@ en:
filters:
all: All
with_confirmed_hide: Confirmed
without_confirmed_hide: Pending
users:
index:
title: Banned users

View File

@@ -66,6 +66,7 @@ es:
filters:
all: Todos
with_confirmed_hide: Confirmados
without_confirmed_hide: Pendientes
users:
index:
title: Usuarios bloqueados

View File

@@ -24,23 +24,32 @@ feature 'Admin debates' do
click_link 'Confirm'
expect(page).to_not have_content(debate.title)
click_link('Confirmed')
expect(page).to have_content(debate.title)
expect(page).to have_content('Confirmed')
expect(debate.reload).to be_confirmed_hide
end
scenario "Current filter is properly highlighted" do
visit admin_debates_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_debates_path(filter: 'Pending')
expect(page).to_not have_link('Pending')
expect(page).to have_link('All')
expect(page).to have_link('Confirmed')
visit admin_debates_path(filter: 'all')
expect(page).to have_link('Pending')
expect(page).to_not have_link('All')
expect(page).to have_link('Confirmed')
visit admin_debates_path(filter: 'with_confirmed_hide')
expect(page).to have_link('All')
expect(page).to have_link('Pending')
expect(page).to_not have_link('Confirmed')
end
@@ -48,6 +57,10 @@ feature 'Admin debates' do
create(:debate, :hidden, title: "Unconfirmed debate")
create(:debate, :hidden, :with_confirmed_hide, title: "Confirmed debate")
visit admin_debates_path(filter: 'pending')
expect(page).to have_content('Unconfirmed debate')
expect(page).to_not have_content('Confirmed debate')
visit admin_debates_path(filter: 'all')
expect(page).to have_content('Unconfirmed debate')
expect(page).to have_content('Confirmed debate')

View File

@@ -302,7 +302,7 @@ feature 'Debates' do
scenario 'Index page shows up to 5 tags per debate' do
debate
visible_tags = ["Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
visible_tags = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares"]
visit debates_path