Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display search metadata on search results pages #298

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def show
if @search_form.valid?
result_returned = record.present?

SearchLog.create!(
@search = SearchLog.create!(
dsi_user: current_dsi_user,
last_name: @search_form.last_name,
date_of_birth: @search_form.date_of_birth.to_fs(:db),
result_returned:
result_returned:,
)

render :no_record and return unless result_returned
Expand Down
2 changes: 1 addition & 1 deletion app/forms/search_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SearchForm
include ActiveModel::Model
include ActiveModel::Validations::Callbacks

attr_accessor :last_name, :day, :month, :year
attr_accessor :last_name, :day, :month, :year, :searched_at

validates :last_name, presence: true
validates :date_of_birth, presence: true
Expand Down
16 changes: 7 additions & 9 deletions app/views/searches/no_record.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<% content_for :page_title, "No record found" %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { "Home" => root_path, "Search results" => nil }) %>
<% content_for :breadcrumbs do %>
<%= govuk_breadcrumbs(breadcrumbs: { "Home" => root_path, "Search results" => nil }) %>
<span class="govuk-caption-m">
Searched at <%= @search.created_at.to_fs(:time_on_date_long) %>
</span>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">No record found on the Children’s Barred List</h1>

<%= govuk_summary_list(
rows: [
{ key: { text: "Last name" }, value: { text: @search_form.last_name } },
{ key: { text: "Date of birth" }, value: { text: @search_form.date_of_birth.to_fs(:long_uk) } }
])
%>

<p class="govuk_body">
There is no record on the children’s barred list with this last name and date of birth.
No record found for <%= @search.last_name %> born on <%= Date.parse(@search.date_of_birth).to_fs(:long_uk) %>
</p>

<p class="govuk_body">
Expand Down
8 changes: 6 additions & 2 deletions app/views/searches/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<% content_for :page_title, "Possible match with the children’s barred list" %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: { "Home" => root_path, "Search results" => nil }) %>
<% content_for :breadcrumbs do %>
<%= govuk_breadcrumbs(breadcrumbs: { "Home" => root_path, "Search results" => nil }) %>
<span class="govuk-caption-m">
Searched at <%= @search.created_at.to_fs(:time_on_date_long) %>
</span>
<% end %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
Expand All @@ -21,4 +26,3 @@
</p>
</div>
</div>

1 change: 1 addition & 0 deletions config/initializers/date_formats.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Date::DATE_FORMATS[:long_uk] = "%e %B %Y"
Time::DATE_FORMATS[:time_on_date_long] = "%-I:%M%P on %-d %B %Y"
2 changes: 2 additions & 0 deletions spec/system/user_searches_with_matching_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def and_i_click_search
end

def then_i_see_a_result
expect(page).to have_content "Searched at #{SearchLog.last.created_at.to_fs(:time_on_date_long)}"
expect(page).to have_content "Possible match with the children’s barred list"
expect(page).to have_content @record.last_name
expect(page).to have_content Date.parse(@record.date_of_birth).to_fs(:long_uk)
end

def and_my_search_is_logged
Expand Down
4 changes: 3 additions & 1 deletion spec/system/user_searches_with_no_matching_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def and_i_click_search
end

def then_i_see_the_no_record_page
expect(page).to have_content "Searched at #{SearchLog.last.created_at.to_fs(:time_on_date_long)}"
expect(page).to have_content "No record found"
expect(page).to have_content "Random name"
expect(page).to have_content(
"No record found for Random name born on #{Date.parse(@record.date_of_birth).to_fs(:long_uk)}")
end

def and_my_search_is_logged
Expand Down
Loading