From 0e7473be6660ea0241fbd6b3fe2ae9597d4b9982 Mon Sep 17 00:00:00 2001 From: JG Date: Wed, 15 Jun 2022 11:50:51 +0100 Subject: [PATCH] testing pagination --- spec/requests/schemes_controller_spec.rb | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index ae081e9b4..4ac816bd8 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -301,6 +301,35 @@ RSpec.describe SchemesController, type: :request do it "has correct title" do expect(page).to have_title("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") end + + context "when paginating over 20 results" do + let!(:locations) { FactoryBot.create_list(:location, 25, scheme:) } + + context "when on the first page" do + before do + get "/schemes/#{scheme.id}/locations" + end + + it "shows the total locations count" do + expect(CGI.unescape_html(response.body)).to match("25 total schemes.") + end + + it "shows which schemes are being shown on the current page" do + expect(CGI.unescape_html(response.body)).to match("Showing 1 to 20 of 25 schemes") + end + + it "has correct page 1 of 2 title" do + expect(page).to have_title("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + end + + it "has pagination links" do + expect(page).to have_content("Previous") + expect(page).not_to have_link("Previous") + expect(page).to have_content("Next") + expect(page).to have_link("Next") + end + end + end end end end