From 9d49c67b5963ce2beefce63284aa11de8c8ad2f7 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 4 Dec 2023 10:48:43 +0000 Subject: [PATCH] Add test --- spec/requests/schemes_controller_spec.rb | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index f5535ce28..3016c3f4b 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -2229,12 +2229,14 @@ RSpec.describe SchemesController, type: :request do get "/schemes/#{scheme.id}/edit-name" end - it "does not include the owning organisation question" do - expect(response).to have_http_status(:ok) - expect(page).not_to have_content("Which organisation owns the housing stock for this scheme?") + context "and there are no absorbed organisations" do + it "does not include the owning organisation question" do + expect(response).to have_http_status(:ok) + expect(page).not_to have_content("Which organisation owns the housing stock for this scheme?") + end end - context "and there are absorbed organisations" do + context "and there are organisations absorbed during an open collection period" do let(:merged_organisation) { create(:organisation) } before do @@ -2247,6 +2249,20 @@ RSpec.describe SchemesController, type: :request do expect(page).to have_content("Which organisation owns the housing stock for this scheme?") end end + + context "and there are no recently absorbed organisations" do + let(:merged_organisation) { create(:organisation) } + + before do + merged_organisation.update!(absorbing_organisation: user.organisation, merge_date: Time.zone.today - 2.years) + get "/schemes/#{scheme.id}/edit-name" + end + + it "does not include the owning organisation question" do + expect(response).to have_http_status(:ok) + expect(page).not_to have_content("Which organisation owns the housing stock for this scheme?") + end + end end context "when attempting to access secondary-client-group scheme page for another organisation" do