From 5edd52d6838661aa9f0be7f2f8e1a61919c67525 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 18 May 2022 16:33:54 +0100 Subject: [PATCH] add pagination test for organisations page 2, remove second before block --- spec/requests/organisations_controller_spec.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index 790d83684..67d3359dd 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -317,15 +317,12 @@ RSpec.describe OrganisationsController, type: :request do end context "when there are more than 20 organisations" do - before do - FactoryBot.create_list(:organisation, 25) - end - let(:support_user) { FactoryBot.create(:user, :support) } let(:total_organisations_count) { Organisation.all.count } before do + FactoryBot.create_list(:organisation, 25) allow(support_user).to receive(:need_two_factor_authentication?).and_return(false) sign_in support_user get "/organisations" @@ -347,6 +344,16 @@ RSpec.describe OrganisationsController, type: :request do expect(page).to have_title("Organisations (page 1 of 2)") end end + + context "when on the second page" do + before do + get "/organisations?page=2", headers:, params: {} + end + + it "shows the total organisations count" do + expect(CGI.unescape_html(response.body)).to match("#{total_organisations_count} total organisations") + end + end end end end