Include the searched term in the search input form

This commit is contained in:
taitus
2020-12-03 09:02:51 +01:00
committed by Javi Martín
parent 427dec8cbd
commit 7b6294199c
5 changed files with 9 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
<div class="small-12 medium-6">
<%= form_for(User.new, url: url, as: :user, method: :get) do |f| %>
<div class="input-group">
<%= text_field_tag :name_or_email, "", placeholder: t("admin.shared.user_search.placeholder") %>
<%= text_field_tag :name_or_email, params[:name_or_email].to_s, placeholder: t("admin.shared.user_search.placeholder") %>
<div class="input-group-button">
<%= f.submit t("admin.shared.user_search.button"), class: "button" %>
</div>

View File

@@ -83,6 +83,7 @@ describe "Admin administrators" do
click_button "Search"
expect(page).to have_content("Administrators: User search")
expect(page).to have_field "name_or_email", with: "Sumn"
expect(page).to have_content(administrator1.name)
expect(page).not_to have_content(administrator2.name)
end
@@ -95,6 +96,7 @@ describe "Admin administrators" do
click_button "Search"
expect(page).to have_content("Administrators: User search")
expect(page).to have_field "name_or_email", with: administrator2.email
expect(page).to have_content(administrator2.email)
expect(page).not_to have_content(administrator1.email)
end

View File

@@ -64,6 +64,7 @@ describe "Admin managers", :admin do
click_button "Search"
expect(page).to have_content("Managers: User search")
expect(page).to have_field "name_or_email", with: "Taylor"
expect(page).to have_content(manager1.name)
expect(page).not_to have_content(manager2.name)
end
@@ -76,6 +77,7 @@ describe "Admin managers", :admin do
click_button "Search"
expect(page).to have_content("Managers: User search")
expect(page).to have_field "name_or_email", with: manager2.email
expect(page).to have_content(manager2.email)
expect(page).not_to have_content(manager1.email)
end

View File

@@ -64,6 +64,7 @@ describe "Admin moderators", :admin do
click_button "Search"
expect(page).to have_content("Moderators: User search")
expect(page).to have_field "name_or_email", with: "Eliz"
expect(page).to have_content(moderator1.name)
expect(page).not_to have_content(moderator2.name)
end
@@ -76,6 +77,7 @@ describe "Admin moderators", :admin do
click_button "Search"
expect(page).to have_content("Moderators: User search")
expect(page).to have_field "name_or_email", with: moderator2.email
expect(page).to have_content(moderator2.email)
expect(page).not_to have_content(moderator1.email)
end

View File

@@ -89,6 +89,7 @@ describe "Admin valuators", :admin do
click_button "Search"
expect(page).to have_content("Valuators: User search")
expect(page).to have_field "name_or_email", with: "Foster"
expect(page).to have_content(valuator1.name)
expect(page).not_to have_content(valuator2.name)
end
@@ -101,6 +102,7 @@ describe "Admin valuators", :admin do
click_button "Search"
expect(page).to have_content("Valuators: User search")
expect(page).to have_field "name_or_email", with: valuator2.email
expect(page).to have_content(valuator2.email)
expect(page).not_to have_content(valuator1.email)
end