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/controllers/admin/debates_controller.rb b/app/controllers/admin/debates_controller.rb index da1acc7fe..544c3f23d 100644 --- a/app/controllers/admin/debates_controller.rb +++ b/app/controllers/admin/debates_controller.rb @@ -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 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/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/app/views/admin/debates/index.html.erb b/app/views/admin/debates/index.html.erb index 7caa8ecc3..118a0ae66 100644 --- a/app/views/admin/debates/index.html.erb +++ b/app/views/admin/debates/index.html.erb @@ -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 %> <% end %> 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/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index c39973da7..2618305a4 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -10,7 +10,7 @@ <%= f.submit comment_button_text(parent_id), class: "button radius small inline-block" %> - <% if can? :comment_as_moderator, commentable %>º + <% if can? :comment_as_moderator, commentable %>
<%= f.check_box :as_moderator, id: "comment-as-moderator-#{css_id}", label: false %> <%= label_tag "comment-as-moderator-#{css_id}", t("comments.form.comment_as_moderator"), class: "checkbox" %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index fae6a38c6..48072ab3b 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 @@ -66,6 +67,7 @@ en: filters: all: All with_confirmed_hide: Confirmed + without_confirmed_hide: Pending users: index: title: Banned users @@ -73,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 13984ab39..1bd9364a5 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 @@ -66,6 +67,7 @@ es: filters: all: Todos with_confirmed_hide: Confirmados + without_confirmed_hide: Pendientes users: index: title: Usuarios bloqueados @@ -73,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/lib/acts_as_paranoid_aliases.rb b/lib/acts_as_paranoid_aliases.rb index 1d7dbf6d9..e8abab530 100644 --- a/lib/acts_as_paranoid_aliases.rb +++ b/lib/acts_as_paranoid_aliases.rb @@ -34,6 +34,10 @@ module ActsAsParanoidAliases where("confirmed_hide_at IS NOT NULL") end + def without_confirmed_hide + where("confirmed_hide_at IS NULL") + end + def with_hidden with_deleted end 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 diff --git a/spec/features/admin/debates_spec.rb b/spec/features/admin/debates_spec.rb index 9d956582e..bccd3429c 100644 --- a/spec/features/admin/debates_spec.rb +++ b/spec/features/admin/debates_spec.rb @@ -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') 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 diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 86903960f..07d055ed2 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -296,20 +296,13 @@ feature 'Debates' do end describe 'Limiting tags shown' do - tags = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"] - let(:all_tags) { tags } - let(:debate) { create :debate, tag_list: all_tags } - scenario 'Index page shows up to 5 tags per debate' do - debate - visible_tags = ["Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"] + tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"] + create :debate, tag_list: tag_list visit debates_path within('.debate .tags') do - visible_tags.each do |tag| - expect(page).to have_content tag - end expect(page).to have_content '2+' end end