From de758b4413c426be8bd0aa34cdf463566bb5165b Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 31 Mar 2022 12:53:30 +0100 Subject: [PATCH] Add pagination to title --- app/views/case_logs/index.html.erb | 7 +++---- spec/requests/case_logs_controller_spec.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/views/case_logs/index.html.erb b/app/views/case_logs/index.html.erb index b1d40c173..f9d4e3766 100644 --- a/app/views/case_logs/index.html.erb +++ b/app/views/case_logs/index.html.erb @@ -1,8 +1,7 @@ -<% content_for :title, "Logs" %> +<% title = @pagy.pages > 1 ? "Logs (page #{@pagy.page} of #{@pagy.pages})" : "Logs" %> +<% content_for :title, title %> -

- <%= content_for(:title) %> -

+

Logs

<%= govuk_button_to "Create a new lettings log", case_logs_path %> diff --git a/spec/requests/case_logs_controller_spec.rb b/spec/requests/case_logs_controller_spec.rb index 4e2937cbe..6c93d86a5 100644 --- a/spec/requests/case_logs_controller_spec.rb +++ b/spec/requests/case_logs_controller_spec.rb @@ -309,6 +309,10 @@ RSpec.describe CaseLogsController, type: :request do it "shows which logs are being shown on the current page" do expect(CGI.unescape_html(response.body)).to match("Showing 1 to 20 of 26 logs") end + + it "has pagination in the title" do + expect(page).to have_title("Logs (page 1 of 2)") + end end context "when on the second page" do @@ -330,6 +334,10 @@ RSpec.describe CaseLogsController, type: :request do it "shows which logs are being shown on the current page" do expect(CGI.unescape_html(response.body)).to match("Showing 21 to 26 of 26 logs") end + + it "has pagination in the title" do + expect(page).to have_title("Logs (page 2 of 2)") + end end end end