diff --git a/app/components/search_result_caption_component.html.erb b/app/components/search_result_caption_component.html.erb index b8a9382b7..b2a28a505 100644 --- a/app/components/search_result_caption_component.html.erb +++ b/app/components/search_result_caption_component.html.erb @@ -7,7 +7,7 @@ <%= count %> <%= item_label.pluralize(count) %> matching filters
<% else %> - <%= count %> total <%= item %> + <%= count %> total <%= item.pluralize(count) %> <% end %> diff --git a/app/views/bulk_upload_shared/uploads.html.erb b/app/views/bulk_upload_shared/uploads.html.erb index 958887453..a9d134c60 100644 --- a/app/views/bulk_upload_shared/uploads.html.erb +++ b/app/views/bulk_upload_shared/uploads.html.erb @@ -1,4 +1,4 @@ -<% item_label = format_label(@pagy.count, "uploads") %> +<% item_label = format_label(@pagy.count, "upload") %> <% title = format_title(@searched, bulk_upload_title(controller.controller_name), current_user, item_label, @pagy.count, nil) %> <% content_for :title, title %> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index 23550f894..8ef5bcb56 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -32,7 +32,7 @@ count: @pagy.count, item_label:, total_count: @total_count, - item: "locations", + item: "location", filters_count: applied_filters_count(@filter_type), )) %> <% end %> diff --git a/app/views/logs/_log_list.html.erb b/app/views/logs/_log_list.html.erb index b5290c117..24714f247 100644 --- a/app/views/logs/_log_list.html.erb +++ b/app/views/logs/_log_list.html.erb @@ -1,7 +1,7 @@

- <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", filters_count: applied_filters_count(@filter_type))) %> + <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "log", filters_count: applied_filters_count(@filter_type))) %> <% if logs&.any? %> <%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv", class: "govuk-!-margin-right-4", style: "white-space: nowrap" %> <% if @current_user.support? %> diff --git a/app/views/logs/index.html.erb b/app/views/logs/index.html.erb index f142a2580..c51466097 100644 --- a/app/views/logs/index.html.erb +++ b/app/views/logs/index.html.erb @@ -1,4 +1,4 @@ -<% item_label = format_label(@pagy.count, "logs") %> +<% item_label = format_label(@pagy.count, "log") %> <% title = format_title(@searched, "#{log_type_for_controller(controller).capitalize} logs", current_user, item_label, @pagy.count, nil) %> <% content_for :title, title %> diff --git a/app/views/logs/update_logs.html.erb b/app/views/logs/update_logs.html.erb index 1ab1fa31c..985adecf3 100644 --- a/app/views/logs/update_logs.html.erb +++ b/app/views/logs/update_logs.html.erb @@ -1,4 +1,4 @@ -<% item_label = format_label(@pagy.count, "logs") %> +<% item_label = format_label(@pagy.count, "log") %> <% title = "Update logs" %> <% content_for :title, title %> diff --git a/app/views/organisation_relationships/managing_agents.html.erb b/app/views/organisation_relationships/managing_agents.html.erb index 726533e53..d09056d86 100644 --- a/app/views/organisation_relationships/managing_agents.html.erb +++ b/app/views/organisation_relationships/managing_agents.html.erb @@ -1,4 +1,4 @@ -<% item_label = format_label(@pagy.count, "managing agents") %> +<% item_label = format_label(@pagy.count, "managing agent") %> <% if current_user.support? %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> @@ -44,7 +44,7 @@ pagy: @pagy, searched: @searched, item_label:, - search_item: "managing agents", + search_item: "managing agent", total_count: @total_count, remove_path: ->(org_id) { managing_agents_remove_organisation_path(target_organisation_id: org_id) }, } %> diff --git a/app/views/organisation_relationships/stock_owners.html.erb b/app/views/organisation_relationships/stock_owners.html.erb index 41b7af06d..3bbba6bf8 100644 --- a/app/views/organisation_relationships/stock_owners.html.erb +++ b/app/views/organisation_relationships/stock_owners.html.erb @@ -1,4 +1,4 @@ -<% item_label = format_label(@pagy.count, "stock owners") %> +<% item_label = format_label(@pagy.count, "stock owner") %> <% if current_user.support? %> <%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> <%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %> @@ -41,7 +41,7 @@ pagy: @pagy, searched: @searched, item_label:, - search_item: "stock owners", + search_item: "stock owner", total_count: @total_count, remove_path: ->(org_id) { stock_owners_remove_organisation_path(target_organisation_id: org_id) }, } %> diff --git a/app/views/organisations/_organisation_list.html.erb b/app/views/organisations/_organisation_list.html.erb index 67cc9c7a3..16309a5eb 100644 --- a/app/views/organisations/_organisation_list.html.erb +++ b/app/views/organisations/_organisation_list.html.erb @@ -1,7 +1,7 @@
<%= govuk_table do |table| %> <%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> - <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "organisations", filters_count: applied_filters_count(@filter_type))) %> + <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "organisation", filters_count: applied_filters_count(@filter_type))) %> <% end %> <%= table.with_head do |head| %> <%= head.with_row do |row| %> diff --git a/app/views/organisations/index.html.erb b/app/views/organisations/index.html.erb index 411d792c1..1de12ab77 100644 --- a/app/views/organisations/index.html.erb +++ b/app/views/organisations/index.html.erb @@ -1,4 +1,4 @@ -<% item_label = format_label(@pagy.count, "organisations") %> +<% item_label = format_label(@pagy.count, "organisation") %> <% title = format_title(@searched, "Organisations", current_user, item_label, @pagy.count, nil) %> <% content_for :title, title %> diff --git a/app/views/organisations/logs.html.erb b/app/views/organisations/logs.html.erb index e172a76a9..e318ff6ee 100644 --- a/app/views/organisations/logs.html.erb +++ b/app/views/organisations/logs.html.erb @@ -1,4 +1,4 @@ -<% item_label = format_label(@pagy.count, "logs") %> +<% item_label = format_label(@pagy.count, "log") %> <% title = format_title(@searched, action_name.humanize, current_user, item_label, @pagy.count, @organisation.name) %> <% content_for :title, title %> diff --git a/app/views/schemes/_scheme_list.html.erb b/app/views/schemes/_scheme_list.html.erb index 967295236..1c11e86d1 100644 --- a/app/views/schemes/_scheme_list.html.erb +++ b/app/views/schemes/_scheme_list.html.erb @@ -2,7 +2,7 @@ <%= govuk_table do |table| %> <%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> - <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "schemes", filters_count: applied_filters_count(@filter_type))) %> + <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "scheme", filters_count: applied_filters_count(@filter_type))) %> <% if @schemes&.any? %> <%= govuk_link_to "Download schemes (CSV)", schemes_csv_download_url, type: "text/csv", class: "govuk-!-margin-right-4", style: "white-space: nowrap" %> <%= govuk_link_to "Download locations (CSV)", locations_csv_download_url, type: "text/csv", class: "govuk-!-margin-right-4", style: "white-space: nowrap" %> diff --git a/app/views/users/_user_list.html.erb b/app/views/users/_user_list.html.erb index 436c0def2..82a82b33b 100644 --- a/app/views/users/_user_list.html.erb +++ b/app/views/users/_user_list.html.erb @@ -1,7 +1,7 @@
<%= govuk_table do |table| %> <%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> - <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "users", filters_count: applied_filters_count(@filter_type))) %> + <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "user", filters_count: applied_filters_count(@filter_type))) %> <% if current_user.support? %> <% query = searched.present? ? "?search=#{searched}" : nil %> <%= govuk_link_to "Download (CSV)", "#{request.path}.csv#{query}", type: "text/csv", style: "white-space: nowrap" %> diff --git a/spec/components/search_result_caption_component_spec.rb b/spec/components/search_result_caption_component_spec.rb index 25cbc1bdd..05ac09630 100644 --- a/spec/components/search_result_caption_component_spec.rb +++ b/spec/components/search_result_caption_component_spec.rb @@ -5,7 +5,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do let(:count) { 2 } let(:item_label) { "user" } let(:total_count) { 3 } - let(:item) { "schemes" } + let(:item) { "scheme" } let(:filters_count) { 1 } let(:result) { render_inline(described_class.new(searched:, count:, item_label:, total_count:, item:, filters_count:)) } @@ -21,6 +21,14 @@ RSpec.describe SearchResultCaptionComponent, type: :component do it "renders table caption including the search results and total" do expect(result.to_html).to eq("\n 2 users matching search
\n
\n") end + + context "with 1 result" do + let(:count) { 1 } + + it "renders table caption including the search results and total" do + expect(result.to_html).to eq("\n 1 user matching search
\n
\n") + end + end end context "when filter results are found" do @@ -29,6 +37,14 @@ RSpec.describe SearchResultCaptionComponent, type: :component do it "renders table caption including the search results and total" do expect(result.to_html).to eq("\n 2 users matching filters
\n
\n") end + + context "with 1 result" do + let(:count) { 1 } + + it "renders table caption including the search results and total" do + expect(result.to_html).to eq("\n 1 user matching filters
\n
\n") + end + end end context "when no search/filter is applied" do @@ -38,6 +54,14 @@ RSpec.describe SearchResultCaptionComponent, type: :component do it "renders table caption with total count only" do expect(result.to_html).to eq("\n \n 2 total schemes\n \n\n") end + + context "with 1 result" do + let(:count) { 1 } + + it "renders table caption with total count only" do + expect(result.to_html).to eq("\n \n 1 total scheme\n \n\n") + end + end end context "when nothing is found" do diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index e795b76ea..d84a6d714 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -759,7 +759,7 @@ RSpec.describe LettingsLogsController, type: :request do it "has search results in the title" do get "/lettings-logs?search=#{log_to_search.id}", headers:, params: {} - expect(page).to have_title("Lettings logs (1 logs matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expect(page).to have_title("Lettings logs (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") end it "shows lettings logs matching the id" do @@ -895,7 +895,7 @@ RSpec.describe LettingsLogsController, type: :request do end it "shows the total log count" do - expect(CGI.unescape_html(response.body)).to match("1 total logs") + expect(CGI.unescape_html(response.body)).to match("1 total log") end it "does not show the pagination links" do diff --git a/spec/requests/organisation_relationships_controller_spec.rb b/spec/requests/organisation_relationships_controller_spec.rb index 79706fff9..8e8dc4f2d 100644 --- a/spec/requests/organisation_relationships_controller_spec.rb +++ b/spec/requests/organisation_relationships_controller_spec.rb @@ -53,7 +53,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do end it "shows the pagination count" do - expect(page).to have_content("1 total stock owners") + expect(page).to have_content("1 total stock owner") end context "when adding a stock owner" do @@ -149,7 +149,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do end it "shows the pagination count" do - expect(page).to have_content("1 total managing agents") + expect(page).to have_content("1 total managing agent") end context "and current organisation is deactivated" do @@ -345,7 +345,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do end it "shows the pagination count" do - expect(page).to have_content("1 total stock owners") + expect(page).to have_content("1 total stock owner") end end @@ -481,7 +481,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do end it "shows the pagination count" do - expect(page).to have_content("1 total managing agents") + expect(page).to have_content("1 total managing agent") end end @@ -647,7 +647,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do end it "shows the pagination count" do - expect(page).to have_content("1 total stock owners") + expect(page).to have_content("1 total stock owner") end context "when adding a stock owner" do @@ -697,7 +697,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do end it "shows the pagination count" do - expect(page).to have_content("1 total managing agents") + expect(page).to have_content("1 total managing agent") end it "shows remove link(s)" do diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index ae3297d59..26723a563 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -1203,7 +1203,7 @@ RSpec.describe OrganisationsController, type: :request do it "has search results in the title" do get "/organisations/#{organisation.id}/lettings-logs?search=#{log_to_search.id}", headers: headers, params: {} - expect(page).to have_title("#{organisation.name} (1 logs matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expect(page).to have_title("#{organisation.name} (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") end it "has search term in the search box" do @@ -1352,7 +1352,7 @@ RSpec.describe OrganisationsController, type: :request do it "has search results in the title" do get "/organisations/#{organisation.id}/sales-logs?search=#{log_to_search.id}", headers: headers, params: {} - expect(page).to have_title("#{organisation.name} (1 logs matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expect(page).to have_title("#{organisation.name} (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") end it "shows sales logs matching the id" do @@ -1616,11 +1616,11 @@ RSpec.describe OrganisationsController, type: :request do end it "updates the table caption" do - expect(page).to have_content("1 organisations matching search") + expect(page).to have_content("1 organisation matching search") end it "has search in the title" do - expect(page).to have_title("Organisations (1 organisations matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expect(page).to have_title("Organisations (1 organisation matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") end context "when the search term matches more than 1 result" do diff --git a/spec/requests/sales_logs_controller_spec.rb b/spec/requests/sales_logs_controller_spec.rb index dc056c1ed..6c882cc87 100644 --- a/spec/requests/sales_logs_controller_spec.rb +++ b/spec/requests/sales_logs_controller_spec.rb @@ -610,7 +610,7 @@ RSpec.describe SalesLogsController, type: :request do it "has search results in the title" do get "/sales-logs?search=#{log_to_search.id}", headers: headers, params: {} - expect(page).to have_title("Sales logs (1 logs matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expect(page).to have_title("Sales logs (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") end it "shows sales logs matching the id" do @@ -692,7 +692,7 @@ RSpec.describe SalesLogsController, type: :request do end it "shows the total log count" do - expect(CGI.unescape_html(response.body)).to match("1 total logs") + expect(CGI.unescape_html(response.body)).to match("1 total log") end it "does not show the pagination links" do