diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 8bbbcdc8c..013fe4e90 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,5 +1,5 @@ class Admin::UsersController < 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_user, only: [:confirm_hide, :restore] diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index 0d18c8b61..b3c0ad40b 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -14,11 +14,12 @@ method: :put, data: { confirm: t("admin.actions.confirm") }, class: "button radius tiny success right" %> - - <%= link_to t("admin.actions.confirm_hide"), + <% unless user.confirmed_hide? %> + <%= link_to t("admin.actions.confirm_hide"), confirm_hide_admin_user_path(user, request.query_parameters), method: :put, class: "button radius tiny warning right" %> + <% end %> <% end %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 1e6bfda91..48072ab3b 100644 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -75,6 +75,7 @@ en: filters: all: All with_confirmed_hide: Confirmed + without_confirmed_hide: Pending show: title: "User activity from %{user}" back: Back diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 1dbc9a340..1bd9364a5 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -75,6 +75,7 @@ es: filters: all: Todos with_confirmed_hide: Confirmados + without_confirmed_hide: Pendientes show: title: "Actividad del usuario %{user}" back: Volver diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb index 84dbccf50..0bd999ff1 100644 --- a/spec/features/admin/users_spec.rb +++ b/spec/features/admin/users_spec.rb @@ -40,23 +40,32 @@ feature 'Admin users' do click_link 'Confirm' + expect(page).to_not have_content(user.username) + click_link('Confirmed') expect(page).to have_content(user.username) - expect(page).to have_content('Confirmed') expect(user.reload).to be_confirmed_hide end scenario "Current filter is properly highlighted" do visit admin_users_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_users_path(filter: 'Pending') + expect(page).to_not have_link('Pending') + expect(page).to have_link('All') expect(page).to have_link('Confirmed') visit admin_users_path(filter: 'all') + expect(page).to have_link('Pending') expect(page).to_not have_link('All') expect(page).to have_link('Confirmed') visit admin_users_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