From aec8774726473ef807cbb1d7149338cdcd6b5bf6 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 8 Oct 2024 08:41:07 +0100 Subject: [PATCH] Make title dynamic --- app/views/organisations/duplicate_schemes.html.erb | 11 ++++++++++- spec/requests/organisations_controller_spec.rb | 12 ++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/views/organisations/duplicate_schemes.html.erb b/app/views/organisations/duplicate_schemes.html.erb index ecbea184e..427cf427c 100644 --- a/app/views/organisations/duplicate_schemes.html.erb +++ b/app/views/organisations/duplicate_schemes.html.erb @@ -4,7 +4,16 @@ <%= form_with model: @organisation, url: schemes_duplicates_organisation_path(@organisation), method: "post" do |f| %> <%= f.govuk_error_summary %> - <% title = "Review these sets of schemes and locations" %> + <% if @duplicate_schemes.any? %> + <% if @duplicate_locations.any? %> + <% title = "Review these sets of schemes and locations" %> + <% else %> + <% title = "Review these sets of schemes" %> + <% end %> + <% else %> + <% title = "Review these sets of locations" %> + <% end %> + <% content_for :title, title %> <% if current_user.support? %> diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index a8d686635..223cc9e00 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -376,10 +376,6 @@ RSpec.describe OrganisationsController, type: :request do get "/organisations/#{organisation.id}/schemes/duplicates", headers: end - it "has page heading" do - expect(page).to have_content("Review these sets of schemes and locations") - end - context "with duplicate schemes and locations" do let(:schemes) { create_list(:scheme, 5, :duplicate, owning_organisation: organisation) } @@ -396,6 +392,10 @@ RSpec.describe OrganisationsController, type: :request do it "displays the duplicate locations" do expect(page).to have_content("These 2 sets of locations might have duplicates") end + + it "has page heading" do + expect(page).to have_content("Review these sets of schemes and locations") + end end context "without duplicate schemes and locations" do @@ -414,12 +414,12 @@ RSpec.describe OrganisationsController, type: :request do before do sign_in user - create_list(:scheme, 5, :duplicate) + create_list(:scheme, 5, :duplicate, owning_organisation: organisation) get "/organisations/#{organisation.id}/schemes/duplicates", headers: end it "has page heading" do - expect(page).to have_content("Review these sets of schemes and locations") + expect(page).to have_content("Review these sets of schemes") end end