diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 3ca25b23a..98283ffed 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -1,10 +1,10 @@ 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] 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 def confirm_hide diff --git a/app/views/admin/comments/index.html.erb b/app/views/admin/comments/index.html.erb index f0639047f..ec0fddc1a 100644 --- a/app/views/admin/comments/index.html.erb +++ b/app/views/admin/comments/index.html.erb @@ -18,11 +18,12 @@ method: :put, data: { confirm: t("admin.actions.confirm") }, class: "button radius tiny success right" %> - - <%= link_to t("admin.actions.confirm_hide"), - confirm_hide_admin_comment_path(comment, request.query_parameters), - method: :put, - class: "button radius tiny warning right" %> + <% unless comment.confirmed_hide? %> + <%= link_to t("admin.actions.confirm_hide"), + confirm_hide_admin_comment_path(comment, request.query_parameters), + method: :put, + class: "button radius tiny warning right" %> + <% end %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 4aecba1b0..1e6bfda91 100644 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -59,6 +59,7 @@ en: filters: all: All with_confirmed_hide: Confirmed + without_confirmed_hide: Pending debates: index: title: Hidden debates diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index fae43bfc1..1dbc9a340 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -59,6 +59,7 @@ es: filters: all: Todos with_confirmed_hide: Confirmados + without_confirmed_hide: Pendientes debates: index: title: Debates ocultos diff --git a/spec/features/admin/comments_spec.rb b/spec/features/admin/comments_spec.rb index 92d010cac..833e01717 100644 --- a/spec/features/admin/comments_spec.rb +++ b/spec/features/admin/comments_spec.rb @@ -24,22 +24,31 @@ feature 'Admin comments' do 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('Confirmed') expect(comment.reload).to be_confirmed_hide end scenario "Current filter is properly highlighted" do 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') visit admin_comments_path(filter: 'all') + expect(page).to have_link('Pending') expect(page).to_not have_link('All') expect(page).to have_link('Confirmed') visit admin_comments_path(filter: 'with_confirmed_hide') + expect(page).to have_link('Pending') expect(page).to have_link('All') expect(page).to_not have_link('Confirmed') end