Merge pull request #2105 from wairbut-m2c/aperez-admin-search
Enable search by name/email on several Admin sections
This commit is contained in:
@@ -6,16 +6,10 @@ class Admin::AdministratorsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@user = User.find_by(email: params[:email])
|
||||
|
||||
respond_to do |format|
|
||||
if @user
|
||||
@administrator = Administrator.find_or_initialize_by(user: @user)
|
||||
format.js
|
||||
else
|
||||
format.js { render "user_not_found" }
|
||||
end
|
||||
end
|
||||
@users = User.search(params[:name_or_email])
|
||||
.includes(:administrator)
|
||||
.page(params[:page])
|
||||
.for_render
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -6,16 +6,10 @@ class Admin::ManagersController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@user = User.find_by(email: params[:email])
|
||||
|
||||
respond_to do |format|
|
||||
if @user
|
||||
@manager = Manager.find_or_initialize_by(user: @user)
|
||||
format.js
|
||||
else
|
||||
format.js { render "user_not_found" }
|
||||
end
|
||||
end
|
||||
@users = User.search(params[:name_or_email])
|
||||
.includes(:manager)
|
||||
.page(params[:page])
|
||||
.for_render
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -6,16 +6,10 @@ class Admin::ModeratorsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@user = User.find_by(email: params[:email])
|
||||
|
||||
respond_to do |format|
|
||||
if @user
|
||||
@moderator = Moderator.find_or_initialize_by(user: @user)
|
||||
format.js
|
||||
else
|
||||
format.js { render "user_not_found" }
|
||||
end
|
||||
end
|
||||
@users = User.search(params[:name_or_email])
|
||||
.includes(:moderator)
|
||||
.page(params[:page])
|
||||
.for_render
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -6,16 +6,10 @@ class Admin::ValuatorsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@user = User.find_by(email: params[:email])
|
||||
|
||||
respond_to do |format|
|
||||
if @user
|
||||
@valuator = Valuator.find_or_initialize_by(user: @user)
|
||||
format.js
|
||||
else
|
||||
format.js { render "user_not_found" }
|
||||
end
|
||||
end
|
||||
@users = User.search(params[:name_or_email])
|
||||
.includes(:valuator)
|
||||
.page(params[:page])
|
||||
.for_render
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -36,4 +30,4 @@ class Admin::ValuatorsController < Admin::BaseController
|
||||
params.require(:valuator).permit(:user_id, :description)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<div class="small-12 column">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<%= administrator.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= administrator.email %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<% if administrator.persisted? %>
|
||||
<%= link_to t('admin.administrators.administrator.delete'),
|
||||
admin_administrator_path(administrator),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
<% else %>
|
||||
<%= link_to t('admin.administrators.administrator.add'),{ controller: "admin/administrators", action: :create, user_id: administrator.user_id },
|
||||
method: :post,
|
||||
class: "button success" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -1,39 +1,24 @@
|
||||
<h2 class="inline-block"><%= t("admin.administrators.index.title") %></h2>
|
||||
|
||||
<div class="row">
|
||||
<%= form_tag search_admin_administrators_path, method: :get, remote: true do %>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= text_field_tag :email, '', placeholder: t('admin.administrators.search.email_placeholder') %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= submit_tag t('admin.administrators.search.search'), class: 'button' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="search-result" class="row"></div>
|
||||
<%= render 'admin/shared/user_search', url: search_admin_administrators_path %>
|
||||
|
||||
<h3><%= page_entries_info @administrators %></h3>
|
||||
|
||||
<table id="administrators">
|
||||
<% @administrators.each do |administrator| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= administrator.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= administrator.email %>
|
||||
</td>
|
||||
<td><%= administrator.name %></td>
|
||||
<td><%= administrator.email %></td>
|
||||
<td class="text-right">
|
||||
<% if administrator.persisted? %>
|
||||
<%= link_to t('admin.administrators.administrator.delete'),
|
||||
admin_administrator_path(administrator),
|
||||
method: :delete,
|
||||
class: "button hollow alert"
|
||||
%>
|
||||
class: "button hollow alert" %>
|
||||
<% else %>
|
||||
<%= link_to t('admin.administrators.administrator.add'),
|
||||
{ controller: "admin/administrators", action: :create,
|
||||
{ controller: "admin/administrators",
|
||||
action: :create,
|
||||
user_id: administrator.user_id },
|
||||
method: :post,
|
||||
class: "button success" %>
|
||||
|
||||
29
app/views/admin/administrators/search.html.erb
Normal file
29
app/views/admin/administrators/search.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<h2><%= t("admin.administrators.search.title") %></h2>
|
||||
|
||||
<%= render 'admin/shared/user_search', url: search_admin_administrators_path %>
|
||||
|
||||
<h3><%= page_entries_info @users %></h3>
|
||||
|
||||
<table id="administrators">
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.email %></td>
|
||||
<td class="text-right">
|
||||
<% if user.administrator? && user.administrator.persisted? %>
|
||||
<%= link_to t('admin.administrators.administrator.delete'),
|
||||
admin_administrator_path(user),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
<% else %>
|
||||
<%= link_to t('admin.administrators.administrator.add'),
|
||||
{ controller: "admin/administrators",
|
||||
action: :create,
|
||||
user_id: user },
|
||||
method: :post,
|
||||
class: "button success" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
@@ -1 +0,0 @@
|
||||
$("#search-result").html("<%= j render 'administrator', administrator: @administrator %>");
|
||||
@@ -1 +0,0 @@
|
||||
$("#search-result").html("<div class=\"small-12 column\"><div class=\"callout alert\"><%= j t('admin.administrators.search.user_not_found') %></div></div>");
|
||||
@@ -1,24 +0,0 @@
|
||||
<div class="small-12 column">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<%= manager.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= manager.email %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<% if manager.persisted? %>
|
||||
<%= link_to t('admin.managers.manager.delete'),
|
||||
admin_manager_path(manager),
|
||||
method: :delete,
|
||||
class: "button hollow alert"
|
||||
%>
|
||||
<% else %>
|
||||
<%= link_to t('admin.managers.manager.add'),{ controller: "admin/managers", action: :create, user_id: manager.user_id },
|
||||
method: :post, class: "button success" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -1,39 +1,27 @@
|
||||
<h2><%= t("admin.managers.index.title") %></h2>
|
||||
|
||||
<div class="row">
|
||||
<%= form_tag search_admin_managers_path, method: :get, remote: true do %>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= text_field_tag :email, '', placeholder: t('admin.managers.search.email_placeholder') %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= submit_tag t('admin.managers.search.search'), class: 'button' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="search-result" class="row"></div>
|
||||
<%= render 'admin/shared/user_search', url: search_admin_managers_path %>
|
||||
|
||||
<h3><%= page_entries_info @managers %></h3>
|
||||
|
||||
<table id="managers">
|
||||
<% @managers.each do |manager| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= manager.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= manager.email %>
|
||||
</td>
|
||||
<td><%= manager.name %></td>
|
||||
<td><%= manager.email %></td>
|
||||
<td class="text-right">
|
||||
<% if manager.persisted? %>
|
||||
<%= link_to t('admin.managers.manager.delete'),
|
||||
admin_manager_path(manager),
|
||||
method: :delete,
|
||||
class: "button hollow alert"
|
||||
%>
|
||||
admin_manager_path(manager),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
<% else %>
|
||||
<%= link_to t('admin.managers.manager.add'),{ controller: "admin/managers", action: :create, user_id: manager.user_id },
|
||||
method: :post, class: "button success" %>
|
||||
<%= link_to t('admin.managers.manager.add'),
|
||||
{ controller: "admin/managers",
|
||||
action: :create,
|
||||
user_id: manager.user_id },
|
||||
method: :post,
|
||||
class: "button success" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
29
app/views/admin/managers/search.html.erb
Normal file
29
app/views/admin/managers/search.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<h2><%= t("admin.managers.search.title") %></h2>
|
||||
|
||||
<%= render 'admin/shared/user_search', url: search_admin_managers_path %>
|
||||
|
||||
<h3><%= page_entries_info @users %></h3>
|
||||
|
||||
<table id="managers">
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.email %></td>
|
||||
<td class="text-right">
|
||||
<% if user.manager? && user.manager.persisted? %>
|
||||
<%= link_to t('admin.managers.manager.delete'),
|
||||
admin_manager_path(user),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
<% else %>
|
||||
<%= link_to t('admin.managers.manager.add'),
|
||||
{ controller: "admin/managers",
|
||||
action: :create,
|
||||
user_id: user },
|
||||
method: :post,
|
||||
class: "button success" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
@@ -1 +0,0 @@
|
||||
$("#search-result").html("<%= j render 'manager', manager: @manager %>");
|
||||
@@ -1 +0,0 @@
|
||||
$("#search-result").html("<div class=\"small-12 column\"><div class=\"callout alert\"><%= j t('admin.managers.search.user_not_found') %></div></div>");
|
||||
@@ -1,26 +0,0 @@
|
||||
<div class="small-12 column">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<%= moderator.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= moderator.email %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<% if moderator.persisted? %>
|
||||
<%= link_to t('admin.moderators.moderator.delete'),
|
||||
admin_moderator_path(moderator),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
<% else %>
|
||||
<%= link_to t('admin.moderators.moderator.add'),{ controller: "admin/moderators", action: :create, user_id: moderator.user_id },
|
||||
method: :post,
|
||||
class: "button success" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -2,30 +2,15 @@
|
||||
|
||||
<h2 class="inline-block"><%= t("admin.moderators.index.title") %></h2>
|
||||
|
||||
<div class="row">
|
||||
<%= form_tag search_admin_moderators_path, method: :get, remote: true do %>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= text_field_tag :email, '', placeholder: t('admin.moderators.search.email_placeholder') %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= submit_tag t('admin.moderators.search.search'), class: 'button' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="search-result" class="row"></div>
|
||||
<%= render 'admin/shared/user_search', url: search_admin_moderators_path %>
|
||||
|
||||
<h3><%= page_entries_info @moderators %></h3>
|
||||
|
||||
<table id="moderators">
|
||||
<% @moderators.each do |moderator| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= moderator.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= moderator.email %>
|
||||
</td>
|
||||
<td><%= moderator.name %></td>
|
||||
<td><%= moderator.email %></td>
|
||||
<td class="text-right">
|
||||
<% if moderator.persisted? %>
|
||||
<%= link_to t('admin.moderators.moderator.delete'),
|
||||
@@ -35,7 +20,8 @@
|
||||
%>
|
||||
<% else %>
|
||||
<%= link_to t('admin.moderators.moderator.add'),
|
||||
{ controller: "admin/moderators", action: :create,
|
||||
{ controller: "admin/moderators",
|
||||
action: :create,
|
||||
user_id: moderator.user_id },
|
||||
method: :post,
|
||||
class: "button success" %>
|
||||
|
||||
29
app/views/admin/moderators/search.html.erb
Normal file
29
app/views/admin/moderators/search.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<h2><%= t("admin.moderators.search.title") %></h2>
|
||||
|
||||
<%= render 'admin/shared/user_search', url: search_admin_moderators_path %>
|
||||
|
||||
<h3><%= page_entries_info @users %></h3>
|
||||
|
||||
<table id="moderators">
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.email %></td>
|
||||
<td class="text-right">
|
||||
<% if user.moderator? && user.moderator.persisted? %>
|
||||
<%= link_to t('admin.moderators.moderator.delete'),
|
||||
admin_moderator_path(user),
|
||||
method: :delete,
|
||||
class: "button hollow alert" %>
|
||||
<% else %>
|
||||
<%= link_to t('admin.moderators.moderator.add'),
|
||||
{ controller: "admin/moderators",
|
||||
action: :create,
|
||||
user_id: user },
|
||||
method: :post,
|
||||
class: "button success" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
@@ -1 +0,0 @@
|
||||
$("#search-result").html("<%= j render 'moderator', moderator: @moderator %>");
|
||||
@@ -1 +0,0 @@
|
||||
$("#search-result").html("<div class=\"small-12 column\"><div class=\"callout alert\"><%= j t('admin.moderators.search.user_not_found') %></div></div>");
|
||||
@@ -1,28 +0,0 @@
|
||||
<div class="small-12 column">
|
||||
<h3><%= t('admin.valuators.valuator.user_found') %></h3>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<%= valuator.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= valuator.email %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<% unless @valuator.persisted? %>
|
||||
<%= form_for @valuator, url: admin_valuators_path do |f| %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column ">
|
||||
<%= f.text_field :description, label: false, placeholder: t('admin.valuators.valuator.description_placeholder') %>
|
||||
<%= f.hidden_field :user_id %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column end" style="border:ddotted 10px red;">
|
||||
<%= f.submit t('admin.valuators.valuator.add'), class: "button success float-left" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,34 +1,15 @@
|
||||
<h2><%= t("admin.valuators.index.title") %></h2>
|
||||
|
||||
<div class="row">
|
||||
<%= form_tag search_admin_valuators_path, method: :get, remote: true do %>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= text_field_tag :email, '', placeholder: t('admin.valuators.search.email_placeholder') %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= submit_tag t('admin.valuators.search.search'), class: 'button radius' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="search-result" class="row"></div>
|
||||
<%= render 'admin/shared/user_search', url: search_admin_valuators_path %>
|
||||
|
||||
<h3><%= page_entries_info @valuators %></h3>
|
||||
|
||||
<table id="valuators">
|
||||
<% @valuators.each do |valuator| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= valuator.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= valuator.email %>
|
||||
</td>
|
||||
<td>
|
||||
<% if valuator.description.present? %>
|
||||
<%= valuator.description %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= valuator.name %></td>
|
||||
<td><%= valuator.email %></td>
|
||||
<td><%= valuator.description if valuator.description.present? %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
27
app/views/admin/valuators/search.html.erb
Normal file
27
app/views/admin/valuators/search.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<h2><%= t("admin.valuators.search.title") %></h2>
|
||||
|
||||
<%= render 'admin/shared/user_search', url: search_admin_valuators_path %>
|
||||
|
||||
<h3><%= page_entries_info @users %></h3>
|
||||
|
||||
<table id="valuators">
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.email %></td>
|
||||
<td class="float-right">
|
||||
<% if user.valuator? && user.valuator.description.present? %>
|
||||
<%= user.valuator.description %>
|
||||
<% else %>
|
||||
<%= form_for Valuator.new(user: user), url: admin_valuators_path do |f| %>
|
||||
<%= f.text_field :description,
|
||||
label: false,
|
||||
placeholder: t("admin.valuators.valuator.description_placeholder") %>
|
||||
<%= f.hidden_field :user_id %>
|
||||
<%= f.submit t("admin.valuators.valuator.add"), class: "button success float-left" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
@@ -1 +0,0 @@
|
||||
$("#search-result").html("<%= j render 'valuator', valuator: @valuator %>");
|
||||
@@ -1 +0,0 @@
|
||||
$("#search-result").html("<div class=\"small-12 column\"><div class=\"callout alert\"><%= j t('admin.valuators.search.user_not_found') %></div></div>");
|
||||
@@ -386,9 +386,7 @@ en:
|
||||
add: Add
|
||||
delete: Delete
|
||||
search:
|
||||
email_placeholder: Search user by email
|
||||
search: Search
|
||||
user_not_found: User not found
|
||||
title: 'Managers: User search'
|
||||
menu:
|
||||
activity: Moderator activity
|
||||
admin: Admin menu
|
||||
@@ -438,9 +436,7 @@ en:
|
||||
delete: Delete
|
||||
restricted_removal: "Sorry, you can't remove yourself from the administrators"
|
||||
search:
|
||||
email_placeholder: Search user by email
|
||||
search: Search
|
||||
user_not_found: User not found
|
||||
title: 'Administrators: User search'
|
||||
moderators:
|
||||
index:
|
||||
title: Moderators
|
||||
@@ -448,9 +444,7 @@ en:
|
||||
add: Add
|
||||
delete: Delete
|
||||
search:
|
||||
email_placeholder: Search user by email
|
||||
search: Search
|
||||
user_not_found: User not found
|
||||
title: 'Moderators: User search'
|
||||
newsletters:
|
||||
index:
|
||||
title: Newsletters
|
||||
@@ -460,12 +454,9 @@ en:
|
||||
title: Valuators
|
||||
valuator:
|
||||
description_placeholder: 'Description (optional)'
|
||||
user_found: User found
|
||||
add: Add to valuators
|
||||
search:
|
||||
email_placeholder: Search user by email
|
||||
search: Search
|
||||
user_not_found: User not found
|
||||
title: 'Valuators: User search'
|
||||
summary:
|
||||
title: Valuator summary for investment projects
|
||||
valuator_name: Valuator
|
||||
|
||||
@@ -387,9 +387,7 @@ es:
|
||||
delete: Borrar
|
||||
restricted_removal: "Lo sentimos, no puedes eliminarte a ti mismo de la lista"
|
||||
search:
|
||||
email_placeholder: Buscar usuario por email
|
||||
search: Buscar
|
||||
user_not_found: Usuario no encontrado
|
||||
title: 'Administradores: Búsqueda de usuarios'
|
||||
managers:
|
||||
index:
|
||||
title: Gestores
|
||||
@@ -397,9 +395,7 @@ es:
|
||||
add: Añadir como Gestor
|
||||
delete: Borrar
|
||||
search:
|
||||
email_placeholder: Buscar usuario por email
|
||||
search: Buscar
|
||||
user_not_found: Usuario no encontrado
|
||||
title: 'Gestores: Búsqueda de usuarios'
|
||||
menu:
|
||||
activity: Actividad de moderadores
|
||||
admin: Menú de administración
|
||||
@@ -448,9 +444,7 @@ es:
|
||||
add: Añadir como Moderador
|
||||
delete: Borrar
|
||||
search:
|
||||
email_placeholder: Buscar usuario por email
|
||||
search: Buscar
|
||||
user_not_found: Usuario no encontrado
|
||||
title: 'Moderadores: Búsqueda de usuarios'
|
||||
newsletters:
|
||||
index:
|
||||
title: Envío de newsletters
|
||||
@@ -460,12 +454,9 @@ es:
|
||||
title: Evaluadores
|
||||
valuator:
|
||||
description_placeholder: "Descripción (opcional)"
|
||||
user_found: Usuario encontrado
|
||||
add: Añadir como evaluador
|
||||
search:
|
||||
email_placeholder: Buscar usuario por email
|
||||
search: Buscar
|
||||
user_not_found: Usuario no encontrado
|
||||
title: 'Evaluadores: Búsqueda de usuarios'
|
||||
summary:
|
||||
title: Resumen de evaluación de propuestas de inversión
|
||||
valuator_name: Evaluador
|
||||
|
||||
@@ -16,7 +16,7 @@ feature 'Admin administrators' do
|
||||
end
|
||||
|
||||
scenario 'Create Administrator', :js do
|
||||
fill_in 'email', with: @user.email
|
||||
fill_in 'name_or_email', with: @user.email
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
@@ -41,5 +41,53 @@ feature 'Admin administrators' do
|
||||
expect(page).to have_content I18n.t("admin.administrators.administrator.restricted_removal")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Search' do
|
||||
|
||||
background do
|
||||
user = create(:user, username: 'Bernard Sumner', email: 'bernard@sumner.com')
|
||||
user2 = create(:user, username: 'Tony Soprano', email: 'tony@soprano.com')
|
||||
@administrator1 = create(:administrator, user: user)
|
||||
@administrator2 = create(:administrator, user: user2)
|
||||
visit admin_administrators_path
|
||||
end
|
||||
|
||||
scenario 'returns no results if search term is empty' do
|
||||
expect(page).to have_content(@administrator1.name)
|
||||
expect(page).to have_content(@administrator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: ' '
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Administrators: User search')
|
||||
expect(page).to have_content('users cannot be found')
|
||||
expect(page).to_not have_content(@administrator1.name)
|
||||
expect(page).to_not have_content(@administrator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by name' do
|
||||
expect(page).to have_content(@administrator1.name)
|
||||
expect(page).to have_content(@administrator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: 'Sumn'
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Administrators: User search')
|
||||
expect(page).to have_content(@administrator1.name)
|
||||
expect(page).to_not have_content(@administrator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by email' do
|
||||
expect(page).to have_content(@administrator1.email)
|
||||
expect(page).to have_content(@administrator2.email)
|
||||
|
||||
fill_in 'name_or_email', with: @administrator2.email
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Administrators: User search')
|
||||
expect(page).to have_content(@administrator2.email)
|
||||
expect(page).to_not have_content(@administrator1.email)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ feature 'Admin managers' do
|
||||
end
|
||||
|
||||
scenario 'Create Manager', :js do
|
||||
fill_in 'email', with: @user.email
|
||||
fill_in 'name_or_email', with: @user.email
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
@@ -34,4 +34,52 @@ feature 'Admin managers' do
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
context 'Search' do
|
||||
|
||||
background do
|
||||
user = create(:user, username: 'Taylor Swift', email: 'taylor@swift.com')
|
||||
user2 = create(:user, username: 'Stephanie Corneliussen', email: 'steph@mrrobot.com')
|
||||
@manager1 = create(:manager, user: user)
|
||||
@manager2 = create(:manager, user: user2)
|
||||
visit admin_managers_path
|
||||
end
|
||||
|
||||
scenario 'returns no results if search term is empty' do
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).to have_content(@manager2.name)
|
||||
|
||||
fill_in 'name_or_email', with: ' '
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Managers: User search')
|
||||
expect(page).to have_content('users cannot be found')
|
||||
expect(page).to_not have_content(@manager1.name)
|
||||
expect(page).to_not have_content(@manager2.name)
|
||||
end
|
||||
|
||||
scenario 'search by name' do
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).to have_content(@manager2.name)
|
||||
|
||||
fill_in 'name_or_email', with: 'Taylor'
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Managers: User search')
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).to_not have_content(@manager2.name)
|
||||
end
|
||||
|
||||
scenario 'search by email' do
|
||||
expect(page).to have_content(@manager1.email)
|
||||
expect(page).to have_content(@manager2.email)
|
||||
|
||||
fill_in 'name_or_email', with: @manager2.email
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Managers: User search')
|
||||
expect(page).to have_content(@manager2.email)
|
||||
expect(page).to_not have_content(@manager1.email)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ feature 'Admin moderators' do
|
||||
end
|
||||
|
||||
scenario 'Create Moderator', :js do
|
||||
fill_in 'email', with: @user.email
|
||||
fill_in 'name_or_email', with: @user.email
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
@@ -33,5 +33,53 @@ feature 'Admin moderators' do
|
||||
expect(page).to_not have_content @moderator.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Search' do
|
||||
|
||||
background do
|
||||
user = create(:user, username: 'Elizabeth Bathory', email: 'elizabeth@bathory.com')
|
||||
user2 = create(:user, username: 'Ada Lovelace', email: 'ada@lovelace.com')
|
||||
@moderator1 = create(:moderator, user: user)
|
||||
@moderator2 = create(:moderator, user: user2)
|
||||
visit admin_moderators_path
|
||||
end
|
||||
|
||||
scenario 'returns no results if search term is empty' do
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).to have_content(@moderator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: ' '
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Moderators: User search')
|
||||
expect(page).to have_content('users cannot be found')
|
||||
expect(page).to_not have_content(@moderator1.name)
|
||||
expect(page).to_not have_content(@moderator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by name' do
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).to have_content(@moderator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: 'Eliz'
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Moderators: User search')
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).to_not have_content(@moderator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by email' do
|
||||
expect(page).to have_content(@moderator1.email)
|
||||
expect(page).to have_content(@moderator2.email)
|
||||
|
||||
fill_in 'name_or_email', with: @moderator2.email
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Moderators: User search')
|
||||
expect(page).to have_content(@moderator2.email)
|
||||
expect(page).to_not have_content(@moderator1.email)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,32 +2,79 @@ require 'rails_helper'
|
||||
|
||||
feature 'Admin valuators' do
|
||||
background do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: 'Jose Luis Balbin')
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: 'Jose Luis Balbin')
|
||||
@valuator = create(:valuator)
|
||||
login_as(@admin.user)
|
||||
visit admin_valuators_path
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
expect(page).to have_content @valuator.name
|
||||
expect(page).to have_content @valuator.email
|
||||
expect(page).to_not have_content @user.name
|
||||
expect(page).to have_content(@valuator.name)
|
||||
expect(page).to have_content(@valuator.email)
|
||||
expect(page).to_not have_content(@user.name)
|
||||
end
|
||||
|
||||
scenario 'Create Valuator', :js do
|
||||
fill_in 'email', with: @user.email
|
||||
fill_in 'name_or_email', with: @user.email
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content(@user.name)
|
||||
fill_in 'valuator_description', with: 'environmental expert'
|
||||
click_button 'Add to valuators'
|
||||
|
||||
within("#valuators") do
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content 'environmental expert'
|
||||
within('#valuators') do
|
||||
expect(page).to have_content(@user.name)
|
||||
expect(page).to have_content('environmental expert')
|
||||
end
|
||||
end
|
||||
|
||||
context 'Search' do
|
||||
|
||||
background do
|
||||
user = create(:user, username: 'David Foster Wallace', email: 'david@wallace.com')
|
||||
user2 = create(:user, username: 'Steven Erikson', email: 'steven@erikson.com')
|
||||
@valuator1 = create(:valuator, user: user)
|
||||
@valuator2 = create(:valuator, user: user2)
|
||||
visit admin_valuators_path
|
||||
end
|
||||
|
||||
scenario 'returns no results if search term is empty' do
|
||||
expect(page).to have_content(@valuator1.name)
|
||||
expect(page).to have_content(@valuator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: ' '
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Valuators: User search')
|
||||
expect(page).to have_content('users cannot be found')
|
||||
expect(page).to_not have_content(@valuator1.name)
|
||||
expect(page).to_not have_content(@valuator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by name' do
|
||||
expect(page).to have_content(@valuator1.name)
|
||||
expect(page).to have_content(@valuator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: 'Foster'
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Valuators: User search')
|
||||
expect(page).to have_content(@valuator1.name)
|
||||
expect(page).to_not have_content(@valuator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by email' do
|
||||
expect(page).to have_content(@valuator1.email)
|
||||
expect(page).to have_content(@valuator2.email)
|
||||
|
||||
fill_in 'name_or_email', with: @valuator2.email
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content('Valuators: User search')
|
||||
expect(page).to have_content(@valuator2.email)
|
||||
expect(page).to_not have_content(@valuator1.email)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user