Browse Source

Add pagination to title

pull/438/head
baarkerlounger 3 years ago
parent
commit
597fb70151
  1. 7
      app/views/case_logs/index.html.erb
  2. 12
      spec/requests/case_logs_controller_spec.rb

7
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 %>
<h1 class="govuk-heading-l"> <h1 class="govuk-heading-l">Logs</h1>
<%= content_for(:title) %>
</h1>
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= govuk_button_to "Create a new lettings log", case_logs_path %> <%= govuk_button_to "Create a new lettings log", case_logs_path %>

12
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 it "does not show the pagination result line" do
expect(CGI.unescape_html(response.body)).not_to match("Showing <b>1</b> to <b>20</b> of <b>26</b> logs") expect(CGI.unescape_html(response.body)).not_to match("Showing <b>1</b> to <b>20</b> of <b>26</b> logs")
end end
it "does not have pagination in the title" do
expect(page).to have_title("Logs")
end
end end
context "when there are more than 20 logs" do 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 it "shows which logs are being shown on the current page" do
expect(CGI.unescape_html(response.body)).to match("Showing <b>1</b> to <b>20</b> of <b>26</b> logs") expect(CGI.unescape_html(response.body)).to match("Showing <b>1</b> to <b>20</b> of <b>26</b> logs")
end end
it "has pagination in the title" do
expect(page).to have_title("Logs (page 1 of 2)")
end
end end
context "when on the second page" do 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 it "shows which logs are being shown on the current page" do
expect(CGI.unescape_html(response.body)).to match("Showing <b>21</b> to <b>26</b> of <b>26</b> logs") expect(CGI.unescape_html(response.body)).to match("Showing <b>21</b> to <b>26</b> of <b>26</b> logs")
end end
it "has pagination in the title" do
expect(page).to have_title("Logs (page 2 of 2)")
end
end end
end end
end end

Loading…
Cancel
Save