show info of hidden users in admin/organizations

This commit is contained in:
Juanjo Bazán
2015-09-08 18:06:23 +02:00
parent 541563a3eb
commit 6bf8af3526
5 changed files with 28 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ class Admin::OrganizationsController < Admin::BaseController
end end
def search def search
@organizations = Organization.search(params[:term]).page(params[:page]) @organizations = Organization.includes(:user).search(params[:term]).page(params[:page])
end end
def verify def verify

View File

@@ -18,7 +18,9 @@
<h3><%= page_entries_info @organizations %></h3> <h3><%= page_entries_info @organizations %></h3>
<table> <table>
<% hidden = 0 %>
<% @organizations.each do |organization| %> <% @organizations.each do |organization| %>
<% hidden += 1 and next if organization.user.nil? || organization.user.hidden? %>
<tr id="<%= dom_id(organization) %>"> <tr id="<%= dom_id(organization) %>">
<td><%= organization.name %></td> <td><%= organization.name %></td>
<td><%= organization.email %></td> <td><%= organization.email %></td>
@@ -54,4 +56,6 @@
<% end %> <% end %>
</table> </table>
<%= t("admin.organizations.index.hidden_count", count: hidden) if hidden > 0 %>
<%= paginate @organizations %> <%= paginate @organizations %>

View File

@@ -34,6 +34,9 @@ en:
pending: Pending pending: Pending
verified: Verified verified: Verified
rejected: Rejected rejected: Rejected
hidden_count:
one: "There is %{count} organization without user or with the user banned"
other: "There is %{count} organizations without user or with the user banned"
search: search:
title: "Search Organizations" title: "Search Organizations"
actions: actions:

View File

@@ -34,6 +34,9 @@ es:
pending: Pendientes pending: Pendientes
verified: Verificadas verified: Verificadas
rejected: Rechazadas rejected: Rechazadas
hidden_count:
one: "Hay además una organización sin usuario o con el usuario bloqueado"
other: "Hay %{count} organizaciones sin usuario o con el usuario bloqueado"
search: search:
title: "Buscar Organizaciones" title: "Buscar Organizaciones"
actions: actions:

View File

@@ -9,6 +9,23 @@ feature 'Admin::Organizations' do
login_as(administrator) login_as(administrator)
end end
context "Index" do
scenario "shows info on organizations with hidden users" do
troll = create(:user, email: "trol@troller.com")
create(:organization, user: troll, name: "Greentroll")
org = create(:organization, name: "Human Rights")
troll.hide
visit admin_organizations_path
expect(page).to have_content("Human Rights")
expect(page).to have_content(org.user.email)
expect(page).to_not have_content("Greentroll")
expect(page).to_not have_content("trol@troller.com")
expect(page).to have_content("There is 1 organization without user or with the user banned")
end
end
context "Search" do context "Search" do
background do background do