From 597fb70151e6627477bb2e6ca04e469ff4ff6769 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 | 12 ++++++++++++ 2 files changed, 15 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 1ca8cb9b7..ab0282576 100644 --- a/spec/requests/case_logs_controller_spec.rb +++ b/spec/requests/case_logs_controller_spec.rb @@ -201,6 +201,10 @@ RSpec.describe CaseLogsController, type: :request do it "does not show the pagination result line" do expect(CGI.unescape_html(response.body)).not_to match("Showing 1 to 20 of 26 logs") end + + it "does not have pagination in the title" do + expect(page).to have_title("Logs") + end end context "when there are more than 20 logs" do @@ -223,6 +227,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 @@ -244,6 +252,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