diff --git a/app/assets/stylesheets/admin/search.css b/app/assets/stylesheets/admin/search.css new file mode 100644 index 000000000..f4e818abd --- /dev/null +++ b/app/assets/stylesheets/admin/search.css @@ -0,0 +1,17 @@ +.admin [role=search] { + display: flex; + + [type="submit"] { + @include button($background: $link); + border-radius: 0; + font-size: 1rem; + + &[disabled] { + @include button-disabled; + } + } + + @include breakpoint(medium) { + width: 50%; + } +} diff --git a/app/components/admin/search_component.html.erb b/app/components/admin/search_component.html.erb new file mode 100644 index 000000000..0caf05d0e --- /dev/null +++ b/app/components/admin/search_component.html.erb @@ -0,0 +1,4 @@ +<%= form_tag(url, options) do |f| %> + <%= text_field_tag :search, search_terms.to_s, placeholder: label, "aria-label": label %> + <%= submit_tag t("admin.shared.search.search") %> +<% end %> diff --git a/app/components/admin/search_component.rb b/app/components/admin/search_component.rb new file mode 100644 index 000000000..e7c4a3e45 --- /dev/null +++ b/app/components/admin/search_component.rb @@ -0,0 +1,23 @@ +class Admin::SearchComponent < ApplicationComponent + attr_reader :label, :form_options + + def initialize(label:, url: nil, **form_options) + @label = label + @url = url + @form_options = form_options + end + + def url + @url || request.path + end + + private + + def search_terms + params[:search] + end + + def options + { method: :get, role: "search" }.merge(form_options) + end +end diff --git a/app/controllers/admin/administrators_controller.rb b/app/controllers/admin/administrators_controller.rb index 8e77a93e6..8d8a5c741 100644 --- a/app/controllers/admin/administrators_controller.rb +++ b/app/controllers/admin/administrators_controller.rb @@ -6,7 +6,7 @@ class Admin::AdministratorsController < Admin::BaseController end def search - @users = User.search(params[:name_or_email]) + @users = User.search(params[:search]) .includes(:administrator) .page(params[:page]) .for_render diff --git a/app/controllers/admin/managers_controller.rb b/app/controllers/admin/managers_controller.rb index e001d5b72..4161a9a97 100644 --- a/app/controllers/admin/managers_controller.rb +++ b/app/controllers/admin/managers_controller.rb @@ -6,7 +6,7 @@ class Admin::ManagersController < Admin::BaseController end def search - @users = User.search(params[:name_or_email]) + @users = User.search(params[:search]) .includes(:manager) .page(params[:page]) .for_render diff --git a/app/controllers/admin/moderators_controller.rb b/app/controllers/admin/moderators_controller.rb index 8d7508a12..ece34b1fb 100644 --- a/app/controllers/admin/moderators_controller.rb +++ b/app/controllers/admin/moderators_controller.rb @@ -6,7 +6,7 @@ class Admin::ModeratorsController < Admin::BaseController end def search - @users = User.search(params[:name_or_email]) + @users = User.search(params[:search]) .includes(:moderator) .page(params[:page]) .for_render diff --git a/app/controllers/admin/officials_controller.rb b/app/controllers/admin/officials_controller.rb index 1b96a9365..1fd3adaa9 100644 --- a/app/controllers/admin/officials_controller.rb +++ b/app/controllers/admin/officials_controller.rb @@ -4,7 +4,7 @@ class Admin::OfficialsController < Admin::BaseController end def search - @users = User.search(params[:name_or_email]).page(params[:page]).for_render + @users = User.search(params[:search]).page(params[:page]).for_render end def edit diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb index 1a5367286..695cf0996 100644 --- a/app/controllers/admin/organizations_controller.rb +++ b/app/controllers/admin/organizations_controller.rb @@ -12,7 +12,7 @@ class Admin::OrganizationsController < Admin::BaseController def search @organizations = Organization.includes(:user) - .search(params[:term]) + .search(params[:search]) .order("users.created_at", :name, "users.email") .page(params[:page]) end diff --git a/app/controllers/admin/poll/officers_controller.rb b/app/controllers/admin/poll/officers_controller.rb index 9cf752126..3b926622d 100644 --- a/app/controllers/admin/poll/officers_controller.rb +++ b/app/controllers/admin/poll/officers_controller.rb @@ -6,7 +6,7 @@ class Admin::Poll::OfficersController < Admin::Poll::BaseController end def search - @user = User.find_by(email: params[:email]) + @user = User.find_by(email: params[:search]) respond_to do |format| if @user diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index c6d147af0..f17ac5c9c 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -7,8 +7,6 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController def index @polls = Poll.not_budget - @search = search_params[:search] - @questions = @questions.search(search_params).page(params[:page]).order("created_at DESC") @proposals = Proposal.successful.sort_by_confidence_score diff --git a/app/controllers/admin/valuators_controller.rb b/app/controllers/admin/valuators_controller.rb index fdfaab799..067090426 100644 --- a/app/controllers/admin/valuators_controller.rb +++ b/app/controllers/admin/valuators_controller.rb @@ -10,7 +10,7 @@ class Admin::ValuatorsController < Admin::BaseController end def search - @users = User.search(params[:name_or_email]) + @users = User.search(params[:search]) .includes(:valuator) .page(params[:page]) .for_render diff --git a/app/controllers/admin/verifications_controller.rb b/app/controllers/admin/verifications_controller.rb index 939add888..3e3671ec3 100644 --- a/app/controllers/admin/verifications_controller.rb +++ b/app/controllers/admin/verifications_controller.rb @@ -4,7 +4,7 @@ class Admin::VerificationsController < Admin::BaseController end def search - @users = User.incomplete_verification.search(params[:name_or_email]) + @users = User.incomplete_verification.search(params[:search]) .page(params[:page]) .for_render render :index diff --git a/app/controllers/moderation/users_controller.rb b/app/controllers/moderation/users_controller.rb index f07268348..2c958eda8 100644 --- a/app/controllers/moderation/users_controller.rb +++ b/app/controllers/moderation/users_controller.rb @@ -21,7 +21,7 @@ class Moderation::UsersController < Moderation::BaseController private def load_users - @users = User.with_hidden.search(params[:name_or_email]).page(params[:page]).for_render + @users = User.with_hidden.search(params[:search]).page(params[:page]).for_render end def block_user diff --git a/app/views/admin/debates/index.html.erb b/app/views/admin/debates/index.html.erb index 117c9f9f8..7a743aea1 100644 --- a/app/views/admin/debates/index.html.erb +++ b/app/views/admin/debates/index.html.erb @@ -5,7 +5,7 @@

<%= t("admin.debates.index.title") %>

<% if @debates.any? %> - <%= render "/admin/shared/debate_search", url: admin_debates_path %> + <%= render Admin::SearchComponent.new(label: t("admin.shared.debate_search.placeholder")) %>

<%= page_entries_info @debates %>

diff --git a/app/views/admin/local_census_records/index.html.erb b/app/views/admin/local_census_records/index.html.erb index 0278f8275..5de47ed85 100644 --- a/app/views/admin/local_census_records/index.html.erb +++ b/app/views/admin/local_census_records/index.html.erb @@ -8,16 +8,10 @@ new_admin_local_census_records_import_path, class: "button float-right hollow" %> -
- <%= form_tag admin_local_census_records_path, method: :get, remote: true do %> -
- <%= text_field_tag :search, "", placeholder: t("admin.local_census_records.index.search.placeholder") %> -
- <%= submit_tag t("admin.local_census_records.index.search.search"), class: "button" %> -
-
- <% end %> -
+<%= render Admin::SearchComponent.new( + label: t("admin.local_census_records.index.search.placeholder"), + remote: true +) %>
<%= render "local_census_records" %> diff --git a/app/views/admin/organizations/index.html.erb b/app/views/admin/organizations/index.html.erb index b1110488a..d28ffc42f 100644 --- a/app/views/admin/organizations/index.html.erb +++ b/app/views/admin/organizations/index.html.erb @@ -1,16 +1,9 @@

<%= t("admin.organizations.index.title") %>

-
- <%= form_for(Organization.new, url: search_admin_organizations_path, method: :get) do |f| %> -
- <%= text_field_tag :term, "", placeholder: t("admin.organizations.index.search_placeholder") %> - -
- <%= f.submit t("admin.organizations.index.search"), class: "button" %> -
-
- <% end %> -
+<%= render Admin::SearchComponent.new( + url: search_admin_organizations_path, + label: t("admin.organizations.index.search_placeholder") +) %> <%= render "shared/filter_subnav", i18n_namespace: "admin.organizations.index" %> diff --git a/app/views/admin/organizations/search.html.erb b/app/views/admin/organizations/search.html.erb index 2e534d052..40a08a7c9 100644 --- a/app/views/admin/organizations/search.html.erb +++ b/app/views/admin/organizations/search.html.erb @@ -1,15 +1,6 @@

<%= t("admin.organizations.search.title") %>

-
- <%= form_for(Organization.new, url: search_admin_organizations_path, method: :get) do |f| %> -
- <%= text_field_tag :term, "", placeholder: t("admin.organizations.index.search_placeholder") %> -
- <%= f.submit t("admin.organizations.index.search"), class: "button" %> -
-
- <% end %> -
+<%= render Admin::SearchComponent.new(label: t("admin.organizations.index.search_placeholder")) %>
<% if @organizations.any? %> diff --git a/app/views/admin/poll/booth_assignments/_search_booths.html.erb b/app/views/admin/poll/booth_assignments/_search_booths.html.erb index b8f5d7c80..adf7ed00d 100644 --- a/app/views/admin/poll/booth_assignments/_search_booths.html.erb +++ b/app/views/admin/poll/booth_assignments/_search_booths.html.erb @@ -5,7 +5,7 @@ @search, placeholder: t("admin.shared.booths_search.placeholder"), id: "search-booths" %>
- <%= submit_tag t("admin.shared.booths_search.button"), class: "button" %> + <%= submit_tag t("admin.shared.search.search"), class: "button" %>
<% end %> diff --git a/app/views/admin/poll/booths/index.html.erb b/app/views/admin/poll/booths/index.html.erb index 415515653..4954801a2 100644 --- a/app/views/admin/poll/booths/index.html.erb +++ b/app/views/admin/poll/booths/index.html.erb @@ -4,7 +4,7 @@ <%= link_to t("admin.booths.index.add_booth"), new_admin_booth_path, class: "button float-right" %> <% end %> -<%= render "/admin/shared/booth_search", url: admin_booths_path %> +<%= render Admin::SearchComponent.new(label: t("admin.shared.booths_search.placeholder")) %> <% if @booths.empty? %>
diff --git a/app/views/admin/poll/officer_assignments/_search_officers.html.erb b/app/views/admin/poll/officer_assignments/_search_officers.html.erb index 2e994fe8a..b1602dc7e 100644 --- a/app/views/admin/poll/officer_assignments/_search_officers.html.erb +++ b/app/views/admin/poll/officer_assignments/_search_officers.html.erb @@ -5,7 +5,7 @@ @search, placeholder: t("admin.shared.poll_officers_search.placeholder"), id: "search-officers" %>
- <%= submit_tag t("admin.shared.poll_officers_search.button"), class: "button" %> + <%= submit_tag t("admin.shared.search.search"), class: "button" %>
<% end %> diff --git a/app/views/admin/poll/officers/_search.html.erb b/app/views/admin/poll/officers/_search.html.erb index 4e5574d07..715a15237 100644 --- a/app/views/admin/poll/officers/_search.html.erb +++ b/app/views/admin/poll/officers/_search.html.erb @@ -1,11 +1,7 @@

<%= t("admin.poll_officers.search.help") %>

-<%= form_tag search_admin_officers_path, method: :get, remote: true do %> -
- <%= text_field_tag :email, "", - placeholder: t("admin.poll_officers.search.email_placeholder") %> -
- <%= submit_tag t("admin.poll_officers.search.search"), class: "button" %> -
-
-<% end %> +<%= render Admin::SearchComponent.new( + url: search_admin_officers_path, + label: t("admin.poll_officers.search.email_placeholder"), + remote: true +) %> diff --git a/app/views/admin/poll/officers/index.html.erb b/app/views/admin/poll/officers/index.html.erb index c6b5caf74..1f84a46ee 100644 --- a/app/views/admin/poll/officers/index.html.erb +++ b/app/views/admin/poll/officers/index.html.erb @@ -1,8 +1,6 @@

<%= t("admin.poll_officers.index.title") %>

-
- <%= render "search" %> -
+<%= render "search" %>
diff --git a/app/views/admin/poll/questions/_search.html.erb b/app/views/admin/poll/questions/_search.html.erb index e8a2c52c5..73730dcd6 100644 --- a/app/views/admin/poll/questions/_search.html.erb +++ b/app/views/admin/poll/questions/_search.html.erb @@ -1,10 +1 @@ -<%= form_tag(admin_questions_path, method: :get) do |f| %> -
- <%= text_field_tag :search, - @search, - placeholder: t("admin.shared.poll_questions_search.placeholder") %> -
- <%= submit_tag t("admin.shared.poll_questions_search.button"), class: "button" %> -
-
-<% end %> +<%= render Admin::SearchComponent.new(label: t("admin.shared.poll_questions_search.placeholder")) %> diff --git a/app/views/admin/poll/questions/index.html.erb b/app/views/admin/poll/questions/index.html.erb index d5fac81e4..6f704e489 100644 --- a/app/views/admin/poll/questions/index.html.erb +++ b/app/views/admin/poll/questions/index.html.erb @@ -3,9 +3,7 @@ <%= link_to t("admin.questions.index.create"), new_admin_question_path, class: "button float-right" %> -
- <%= render "search" %> -
+<%= render "search" %>
<%= render "filter_subnav" %> diff --git a/app/views/admin/proposals/index.html.erb b/app/views/admin/proposals/index.html.erb index bc59de812..075e70278 100644 --- a/app/views/admin/proposals/index.html.erb +++ b/app/views/admin/proposals/index.html.erb @@ -5,7 +5,7 @@

<%= t("admin.proposals.index.title") %>

<% if @proposals.any? %> - <%= render "/admin/shared/proposal_search", url: admin_proposals_path %> + <%= render Admin::SearchComponent.new(label: t("admin.shared.proposal_search.placeholder")) %>

<%= page_entries_info @proposals %>

diff --git a/app/views/admin/shared/_booth_search.html.erb b/app/views/admin/shared/_booth_search.html.erb deleted file mode 100644 index eb22940db..000000000 --- a/app/views/admin/shared/_booth_search.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<%= form_for(Poll::Booth.new, url: url, as: :booth, method: :get) do |f| %> -
-
- <%= text_field_tag :search, params[:search], placeholder: t("admin.shared.booths_search.placeholder") %> -
- <%= f.submit t("admin.shared.booths_search.button"), class: "button" %> -
-
-
-<% end %> diff --git a/app/views/admin/shared/_debate_search.html.erb b/app/views/admin/shared/_debate_search.html.erb deleted file mode 100644 index 42c9938d0..000000000 --- a/app/views/admin/shared/_debate_search.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<%= form_for(Debate.new, url: url, as: :debate, method: :get) do |f| %> -
-
- <%= text_field_tag :search, "", placeholder: t("admin.shared.debate_search.placeholder") %> -
- <%= f.submit t("admin.shared.debate_search.button"), class: "button" %> -
-
-
-<% end %> diff --git a/app/views/admin/shared/_proposal_search.html.erb b/app/views/admin/shared/_proposal_search.html.erb deleted file mode 100644 index 5a6207d4c..000000000 --- a/app/views/admin/shared/_proposal_search.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<%= form_for(Proposal.new, url: url, as: :proposal, method: :get) do |f| %> -
-
- <%= text_field_tag :search, "", placeholder: t("admin.shared.proposal_search.placeholder") %> -
- <%= f.submit t("admin.shared.proposal_search.button"), class: "button" %> -
-
-
-<% end %> diff --git a/app/views/admin/shared/_user_search.html.erb b/app/views/admin/shared/_user_search.html.erb index c553052c2..2023fd0ed 100644 --- a/app/views/admin/shared/_user_search.html.erb +++ b/app/views/admin/shared/_user_search.html.erb @@ -1,10 +1 @@ -
- <%= form_for(User.new, url: url, as: :user, method: :get) do |f| %> -
- <%= text_field_tag :name_or_email, "", placeholder: t("admin.shared.user_search.placeholder") %> -
- <%= f.submit t("admin.shared.user_search.button"), class: "button" %> -
-
- <% end %> -
+<%= render Admin::SearchComponent.new(url: url, label: t("admin.shared.user_search.placeholder")) %> diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index 612f5d81d..96ece4ae5 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,15 +1,9 @@

<%= t("admin.users.index.title") %>

-
- <%= form_tag admin_users_path, method: :get, remote: true do %> -
- <%= text_field_tag :search, "", placeholder: t("admin.users.search.placeholder") %> -
- <%= submit_tag t("admin.users.search.search"), class: "button" %> -
-
- <% end %> -
+<%= render Admin::SearchComponent.new( + label: t("admin.users.search.placeholder"), + remote: true +) %>
<%= render "users" %> diff --git a/app/views/management/proposals/index.html.erb b/app/views/management/proposals/index.html.erb index 6ec7bd712..a5862961e 100644 --- a/app/views/management/proposals/index.html.erb +++ b/app/views/management/proposals/index.html.erb @@ -1,7 +1,7 @@

<%= t("management.proposals.index.title") %>

- <%= render "admin/shared/proposal_search", url: management_proposals_path %> + <%= render Admin::SearchComponent.new(label: t("admin.shared.proposal_search.placeholder")) %>
diff --git a/app/views/moderation/users/index.html.erb b/app/views/moderation/users/index.html.erb index c7fcf502b..9008f8fec 100644 --- a/app/views/moderation/users/index.html.erb +++ b/app/views/moderation/users/index.html.erb @@ -1,15 +1,6 @@

<%= t("moderation.users.index.title") %>

-<%= form_for(User.new, url: moderation_users_path, as: :user, method: :get) do |f| %> -
-
- <%= text_field_tag :name_or_email, "", placeholder: t("moderation.users.index.search_placeholder") %> -
-
- <%= f.submit t("moderation.users.index.search"), class: "button success" %> -
-
-<% end %> +<%= render Admin::SearchComponent.new(label: t("moderation.users.index.search_placeholder")) %> <% if @users.present? %>

<%= page_entries_info @users %>

diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index cf330ae41..6c05bf15c 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -907,7 +907,6 @@ en: entry_name: officer search: email_placeholder: Search user by email - search: Search user_not_found: User not found help: "To add or remove Poll officers use the search form below." poll_officer_assignments: @@ -1170,7 +1169,6 @@ en: no_organizations: There are no organizations. reject: Reject rejected: Rejected - search: Search search_placeholder: Name, email or phone number title: Organisations verified: Verified @@ -1255,23 +1253,19 @@ en: shared: true_value: "Yes" false_value: "No" + search: + search: "Search" booths_search: - button: Search placeholder: Search booth by name or location poll_officers_search: - button: Search placeholder: Search poll officers poll_questions_search: - button: Search placeholder: Search poll questions proposal_search: - button: Search placeholder: Search proposals by title, code, description or question debate_search: - button: Search placeholder: Search debates by title or description user_search: - button: Search placeholder: Search user by name or email search_results: "Search results" no_search_results: "No results found." @@ -1440,7 +1434,6 @@ en: erased: Erased search: placeholder: Search user by email, name or document number - search: Search verifications: index: phone_not_given: Phone not given @@ -1581,7 +1574,6 @@ en: postal_code: Postal code search: placeholder: Search by document number - search: Search import: Import CSV new: creating: Creating new local census record diff --git a/config/locales/en/moderation.yml b/config/locales/en/moderation.yml index 01be3e57d..53b2ea64d 100644 --- a/config/locales/en/moderation.yml +++ b/config/locales/en/moderation.yml @@ -111,7 +111,6 @@ en: index: hidden: Blocked hide: Block - search: Search search_placeholder: email or name of user title: Block users notice_hide: User blocked. All of this user's debates and comments have been hidden. diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 18c87db4b..f970c74f4 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -906,7 +906,6 @@ es: entry_name: presidente de mesa search: email_placeholder: Buscar usuario por email - search: Buscar user_not_found: Usuario no encontrado help: "Para añadir o eliminar Presidentes de mesa utiliza el buscador a continuación." poll_officer_assignments: @@ -1169,7 +1168,6 @@ es: no_organizations: No hay organizaciones. reject: Rechazar rejected: Rechazada - search: Buscar search_placeholder: Nombre, email o teléfono title: Organizaciones verified: Verificada @@ -1254,23 +1252,19 @@ es: shared: true_value: "Sí" false_value: "No" + search: + search: "Buscar" booths_search: - button: Buscar placeholder: Buscar urna por nombre poll_officers_search: - button: Buscar placeholder: Buscar presidentes de mesa poll_questions_search: - button: Buscar placeholder: Buscar preguntas proposal_search: - button: Buscar placeholder: Buscar propuestas por título, código, descripción o pregunta debate_search: - button: Buscar placeholder: Buscar debates por título o descripción user_search: - button: Buscar placeholder: Buscar usuario por nombre o email search_results: "Resultados de la búsqueda" no_search_results: "No se han encontrado resultados." @@ -1439,7 +1433,6 @@ es: erased: Borrados search: placeholder: Buscar usuario por email, nombre o DNI - search: Buscar verifications: index: phone_not_given: No ha dado su teléfono @@ -1580,7 +1573,6 @@ es: postal_code: Código postal search: placeholder: Búsqueda por número de documento - search: Buscar import: Importar CSV new: creating: Creando nuevo registro de censo local @@ -1605,4 +1597,4 @@ es: errored: Filas erróneas created: Registros creados local_census_records: - no_records_found: No se han encontrado registros. \ No newline at end of file + no_records_found: No se han encontrado registros. diff --git a/config/locales/es/moderation.yml b/config/locales/es/moderation.yml index a31d7b6c5..968c7bfd0 100644 --- a/config/locales/es/moderation.yml +++ b/config/locales/es/moderation.yml @@ -111,7 +111,6 @@ es: index: hidden: Bloqueado hide: Bloquear - search: Buscar search_placeholder: email o nombre de usuario title: Bloquear usuarios notice_hide: Usuario bloqueado. Se han ocultado todos sus debates y comentarios. diff --git a/spec/controllers/moderation/users_controller_spec.rb b/spec/controllers/moderation/users_controller_spec.rb index 424e41c8b..1699c9c4e 100644 --- a/spec/controllers/moderation/users_controller_spec.rb +++ b/spec/controllers/moderation/users_controller_spec.rb @@ -7,9 +7,9 @@ describe Moderation::UsersController do it "keeps query parameters while using protected redirects" do user = create(:user, email: "user@consul.dev") - get :hide_in_moderation_screen, params: { id: user, name_or_email: "user@consul.dev", host: "evil.dev" } + get :hide_in_moderation_screen, params: { id: user, search: "user@consul.dev", host: "evil.dev" } - expect(response).to redirect_to "/moderation/users?name_or_email=user%40consul.dev" + expect(response).to redirect_to "/moderation/users?search=user%40consul.dev" end end end diff --git a/spec/system/admin/activity_spec.rb b/spec/system/admin/activity_spec.rb index d83c29d9f..0accba34a 100644 --- a/spec/system/admin/activity_spec.rb +++ b/spec/system/admin/activity_spec.rb @@ -223,7 +223,7 @@ describe "Admin activity" do scenario "Shows moderation activity from moderation screen" do user = create(:user) - visit moderation_users_path(name_or_email: user.username) + visit moderation_users_path(search: user.username) within("#moderation_users") do click_link "Block" diff --git a/spec/system/admin/administrators_spec.rb b/spec/system/admin/administrators_spec.rb index a97f5d389..c8da6fc80 100644 --- a/spec/system/admin/administrators_spec.rb +++ b/spec/system/admin/administrators_spec.rb @@ -19,7 +19,7 @@ describe "Admin administrators" do end scenario "Create Administrator", :js do - fill_in "name_or_email", with: user.email + fill_in "search", with: user.email click_button "Search" expect(page).to have_content user.name @@ -66,7 +66,7 @@ describe "Admin administrators" do expect(page).to have_content(administrator1.name) expect(page).to have_content(administrator2.name) - fill_in "name_or_email", with: " " + fill_in "search", with: " " click_button "Search" expect(page).to have_content("Administrators: User search") @@ -79,10 +79,11 @@ describe "Admin administrators" do expect(page).to have_content(administrator1.name) expect(page).to have_content(administrator2.name) - fill_in "name_or_email", with: "Sumn" + fill_in "search", with: "Sumn" click_button "Search" expect(page).to have_content("Administrators: User search") + expect(page).to have_field "search", with: "Sumn" expect(page).to have_content(administrator1.name) expect(page).not_to have_content(administrator2.name) end @@ -91,10 +92,11 @@ describe "Admin administrators" do expect(page).to have_content(administrator1.email) expect(page).to have_content(administrator2.email) - fill_in "name_or_email", with: administrator2.email + fill_in "search", with: administrator2.email click_button "Search" expect(page).to have_content("Administrators: User search") + expect(page).to have_field "search", with: administrator2.email expect(page).to have_content(administrator2.email) expect(page).not_to have_content(administrator1.email) end diff --git a/spec/system/admin/managers_spec.rb b/spec/system/admin/managers_spec.rb index 081152a46..6b46fa15e 100644 --- a/spec/system/admin/managers_spec.rb +++ b/spec/system/admin/managers_spec.rb @@ -15,7 +15,7 @@ describe "Admin managers", :admin do end scenario "Create Manager", :js do - fill_in "name_or_email", with: user.email + fill_in "search", with: user.email click_button "Search" expect(page).to have_content user.name @@ -47,7 +47,7 @@ describe "Admin managers", :admin do expect(page).to have_content(manager1.name) expect(page).to have_content(manager2.name) - fill_in "name_or_email", with: " " + fill_in "search", with: " " click_button "Search" expect(page).to have_content("Managers: User search") @@ -60,10 +60,11 @@ describe "Admin managers", :admin do expect(page).to have_content(manager1.name) expect(page).to have_content(manager2.name) - fill_in "name_or_email", with: "Taylor" + fill_in "search", with: "Taylor" click_button "Search" expect(page).to have_content("Managers: User search") + expect(page).to have_field "search", with: "Taylor" expect(page).to have_content(manager1.name) expect(page).not_to have_content(manager2.name) end @@ -72,10 +73,11 @@ describe "Admin managers", :admin do expect(page).to have_content(manager1.email) expect(page).to have_content(manager2.email) - fill_in "name_or_email", with: manager2.email + fill_in "search", with: manager2.email click_button "Search" expect(page).to have_content("Managers: User search") + expect(page).to have_field "search", with: manager2.email expect(page).to have_content(manager2.email) expect(page).not_to have_content(manager1.email) end diff --git a/spec/system/admin/moderators_spec.rb b/spec/system/admin/moderators_spec.rb index 8ae8c8e58..df1af19b4 100644 --- a/spec/system/admin/moderators_spec.rb +++ b/spec/system/admin/moderators_spec.rb @@ -15,7 +15,7 @@ describe "Admin moderators", :admin do end scenario "Create Moderator", :js do - fill_in "name_or_email", with: user.email + fill_in "search", with: user.email click_button "Search" expect(page).to have_content user.name @@ -47,7 +47,7 @@ describe "Admin moderators", :admin do expect(page).to have_content(moderator1.name) expect(page).to have_content(moderator2.name) - fill_in "name_or_email", with: " " + fill_in "search", with: " " click_button "Search" expect(page).to have_content("Moderators: User search") @@ -60,10 +60,11 @@ describe "Admin moderators", :admin do expect(page).to have_content(moderator1.name) expect(page).to have_content(moderator2.name) - fill_in "name_or_email", with: "Eliz" + fill_in "search", with: "Eliz" click_button "Search" expect(page).to have_content("Moderators: User search") + expect(page).to have_field "search", with: "Eliz" expect(page).to have_content(moderator1.name) expect(page).not_to have_content(moderator2.name) end @@ -72,10 +73,11 @@ describe "Admin moderators", :admin do expect(page).to have_content(moderator1.email) expect(page).to have_content(moderator2.email) - fill_in "name_or_email", with: moderator2.email + fill_in "search", with: moderator2.email click_button "Search" expect(page).to have_content("Moderators: User search") + expect(page).to have_field "search", with: moderator2.email expect(page).to have_content(moderator2.email) expect(page).not_to have_content(moderator1.email) end diff --git a/spec/system/admin/officials_spec.rb b/spec/system/admin/officials_spec.rb index 2b1e18331..2cd86c085 100644 --- a/spec/system/admin/officials_spec.rb +++ b/spec/system/admin/officials_spec.rb @@ -38,7 +38,7 @@ describe "Admin officials", :admin do scenario "Create an official" do visit admin_officials_path - fill_in "name_or_email", with: citizen.email + fill_in "search", with: citizen.email click_button "Search" expect(page).to have_current_path(search_admin_officials_path, ignore_query: true) diff --git a/spec/system/admin/organizations_spec.rb b/spec/system/admin/organizations_spec.rb index 86548e846..7f2d400df 100644 --- a/spec/system/admin/organizations_spec.rb +++ b/spec/system/admin/organizations_spec.rb @@ -36,7 +36,7 @@ describe "Admin::Organizations" do visit admin_organizations_path expect(page).to have_content("Get up, Stand up") - fill_in "term", with: " " + fill_in "search", with: " " click_button "Search" expect(page).to have_current_path(search_admin_organizations_path, ignore_query: true) @@ -49,7 +49,7 @@ describe "Admin::Organizations" do visit search_admin_organizations_path expect(page).not_to have_content("Get up, Stand up") - fill_in "term", with: "Up, sta" + fill_in "search", with: "Up, sta" click_button "Search" within("#search-results") do @@ -61,7 +61,7 @@ describe "Admin::Organizations" do visit search_admin_organizations_path expect(page).not_to have_content("Get up, Stand up") - fill_in "term", with: user.email + fill_in "search", with: user.email click_button "Search" within("#search-results") do @@ -73,7 +73,7 @@ describe "Admin::Organizations" do visit search_admin_organizations_path expect(page).not_to have_content("Get up, Stand up") - fill_in "term", with: user.phone_number + fill_in "search", with: user.phone_number click_button "Search" within("#search-results") do diff --git a/spec/system/admin/poll/officers_spec.rb b/spec/system/admin/poll/officers_spec.rb index 51d2fd506..cf08b95a0 100644 --- a/spec/system/admin/poll/officers_spec.rb +++ b/spec/system/admin/poll/officers_spec.rb @@ -15,7 +15,7 @@ describe "Admin poll officers", :admin do end scenario "Create", :js do - fill_in "email", with: user.email + fill_in "search", with: user.email click_button "Search" expect(page).to have_content user.name diff --git a/spec/system/admin/valuators_spec.rb b/spec/system/admin/valuators_spec.rb index 388da65bd..f5108dd63 100644 --- a/spec/system/admin/valuators_spec.rb +++ b/spec/system/admin/valuators_spec.rb @@ -22,7 +22,7 @@ describe "Admin valuators", :admin do end scenario "Create", :js do - fill_in "name_or_email", with: user.email + fill_in "search", with: user.email click_button "Search" expect(page).to have_content(user.name) @@ -72,7 +72,7 @@ describe "Admin valuators", :admin do expect(page).to have_content(valuator1.name) expect(page).to have_content(valuator2.name) - fill_in "name_or_email", with: " " + fill_in "search", with: " " click_button "Search" expect(page).to have_content("Valuators: User search") @@ -85,10 +85,11 @@ describe "Admin valuators", :admin do expect(page).to have_content(valuator1.name) expect(page).to have_content(valuator2.name) - fill_in "name_or_email", with: "Foster" + fill_in "search", with: "Foster" click_button "Search" expect(page).to have_content("Valuators: User search") + expect(page).to have_field "search", with: "Foster" expect(page).to have_content(valuator1.name) expect(page).not_to have_content(valuator2.name) end @@ -97,10 +98,11 @@ describe "Admin valuators", :admin do expect(page).to have_content(valuator1.email) expect(page).to have_content(valuator2.email) - fill_in "name_or_email", with: valuator2.email + fill_in "search", with: valuator2.email click_button "Search" expect(page).to have_content("Valuators: User search") + expect(page).to have_field "search", with: valuator2.email expect(page).to have_content(valuator2.email) expect(page).not_to have_content(valuator1.email) end diff --git a/spec/system/admin/verifications_spec.rb b/spec/system/admin/verifications_spec.rb index 69bb37fb2..98961a571 100644 --- a/spec/system/admin/verifications_spec.rb +++ b/spec/system/admin/verifications_spec.rb @@ -22,7 +22,7 @@ describe "Incomplete verifications", :admin do visit admin_verifications_path - fill_in "name_or_email", with: "juan" + fill_in "search", with: "juan" click_button "Search" expect(page).to have_content("Juan_anonymous") diff --git a/spec/system/moderation/users_spec.rb b/spec/system/moderation/users_spec.rb index d05951eae..62a72d59a 100644 --- a/spec/system/moderation/users_spec.rb +++ b/spec/system/moderation/users_spec.rb @@ -58,7 +58,7 @@ describe "Moderate users" do visit moderation_users_path expect(page).not_to have_content citizen.name - fill_in "name_or_email", with: "Wanda" + fill_in "search", with: "Wanda" click_button "Search" within("#moderation_users") do