From 60a071db883d5d38e01e61d2a965879f193deab0 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 18 Sep 2024 10:40:50 +0100 Subject: [PATCH] Add banner to the schemes page --- .../organisations/duplicate_schemes.html.erb | 0 app/views/organisations/schemes.html.erb | 10 ++++++++++ config/routes.rb | 1 + spec/requests/organisations_controller_spec.rb | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 app/views/organisations/duplicate_schemes.html.erb diff --git a/app/views/organisations/duplicate_schemes.html.erb b/app/views/organisations/duplicate_schemes.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/organisations/schemes.html.erb b/app/views/organisations/schemes.html.erb index 58b16243a..b9706d4db 100644 --- a/app/views/organisations/schemes.html.erb +++ b/app/views/organisations/schemes.html.erb @@ -11,6 +11,16 @@ ) %>

Supported housing schemes

<% end %> + +<% if display_duplicate_schemes_banner?(@organisation, current_user) %> + <%= govuk_notification_banner(title_text: "Important") do %> +

+ Some schemes and locations might be duplicates. +

+ <%= govuk_link_to "Review possible duplicates", href: schemes_duplicates_organisation_path(@organisation) %> + <% end %> +<% end %> +

<% if SchemePolicy.new(current_user, nil).create? %> <%= govuk_button_link_to "Create a new supported housing scheme", new_scheme_path, html: { method: :post } %> diff --git a/config/routes.rb b/config/routes.rb index 77b862e5a..c0182175d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -178,6 +178,7 @@ Rails.application.routes.draw do get "schemes/csv-download", to: "organisations#download_schemes_csv" post "schemes/email-csv", to: "organisations#email_schemes_csv" get "schemes/csv-confirmation", to: "schemes#csv_confirmation" + get "schemes/duplicates", to: "organisations#duplicate_schemes" get "stock-owners", to: "organisation_relationships#stock_owners" get "stock-owners/add", to: "organisation_relationships#add_stock_owner" get "stock-owners/remove", to: "organisation_relationships#remove_stock_owner" diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index 91dc07094..50ec7fab5 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -207,6 +207,24 @@ RSpec.describe OrganisationsController, type: :request do expect(page).to have_title("#{user.organisation.name} (1 scheme matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") end end + + context "when organisation has absorbed other organisations" do + before do + create(:organisation, merge_date: Time.zone.today, absorbing_organisation: organisation) + end + + context "and it has duplicate schemes or locations" do + before do + create_list(:scheme, 2, :duplicate, owning_organisation: organisation) + get "/organisations/#{organisation.id}/schemes", headers:, params: {} + end + + it "displays a banner with correct content" do + expect(page).to have_content("Some schemes and locations might be duplicates.") + expect(page).to have_link("Review possible duplicates", href: "/organisations/#{organisation.id}/schemes/duplicates") + end + end + end end context "when data coordinator user" do