From 45addee279cfeb915f9f27a4a43bef1cbc8e30a4 Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Mon, 17 Apr 2023 12:07:30 +0100
Subject: [PATCH] CLDC-2054 Add request a merge page (#1519)
* Move and rename some tests
* Add a merge organisation link
* Add merge page
* Don't display a second nav bar for support
* Fix spacing
* fix spacing and typos
---
app/helpers/navigation_items_helper.rb | 2 +-
app/views/organisations/merge.html.erb | 48 +++++++++++++++++++
app/views/organisations/show.html.erb | 3 ++
config/initializers/feature_toggle.rb | 4 ++
config/routes.rb | 1 +
spec/features/organisation_spec.rb | 27 +++++------
.../requests/organisations_controller_spec.rb | 35 ++++++++++++++
7 files changed, 105 insertions(+), 15 deletions(-)
create mode 100644 app/views/organisations/merge.html.erb
diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb
index 8db369d59..3def5547f 100644
--- a/app/helpers/navigation_items_helper.rb
+++ b/app/helpers/navigation_items_helper.rb
@@ -101,7 +101,7 @@ private
end
def subnav_details_path?(path)
- path.include?("/organisations") && path.include?("/details")
+ path.include?("/organisations") && (path.include?("/details") || path.include?("/merge"))
end
def stock_owners_path?(path)
diff --git a/app/views/organisations/merge.html.erb b/app/views/organisations/merge.html.erb
new file mode 100644
index 000000000..7d72d08b7
--- /dev/null
+++ b/app/views/organisations/merge.html.erb
@@ -0,0 +1,48 @@
+<% content_for :before_content do %>
+ <% title = "Tell us if your organisation is merging" %>
+ <% content_for :title, title %>
+
+ <%= govuk_back_link href: organisation_path %>
+<% end %>
+
Tell us if your organisation is merging
+
+
+
+
+ Use this service to tell us if your organisation is merging with one or more other organisations. You can also use it to tell us about past merges that have not yet been reported to CORE.
+
+
+
Before you start
+
Regardless of the merge type, you’ll be asked for:
+
+ - the organisations merging in CORE
+ - the merge type: for example one organisation absorbing the rest, or them all creating a new organisation
+ - to confirm or update the telephone number
+ - the merge date
+ - if user email addresses will change with this merge
+
+
+
If email addresses are changing
+ <%= govuk_inset_text(text: "Update all user email addresses on CORE as soon as they change, so that everyone can still access their CORE account. ") %>
+
+ Users must have access to their old email address, so they can confirm their new one.
+
+
+
If merging into a new organisation
+
You'll also be asked for the new organisation’s:
+
+ - name
+ - address
+ - telephone number
+ - housing provider type
+ - Regulator of Social Housing registration number
+ - held stock details
+
+
+ <%= govuk_warning_text text: "You will not be able to submit your request without the above information. Do not start the form until you have obtained all of the information. " %>
+ <%= govuk_start_button(
+ text: "Start now",
+ href: "#",
+ ) %>
+
+
diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb
index bbe9ae67a..4561e985b 100644
--- a/app/views/organisations/show.html.erb
+++ b/app/views/organisations/show.html.erb
@@ -35,6 +35,9 @@
<% end %>
<% end %>
+ <% if FeatureToggle.merge_organisations_enabled? %>
+ Is your organisation merging with another? <%= govuk_link_to "Let us know using this form", merge_organisation_path %>
+ <% end %>
diff --git a/config/initializers/feature_toggle.rb b/config/initializers/feature_toggle.rb
index 125aa6770..9986af543 100644
--- a/config/initializers/feature_toggle.rb
+++ b/config/initializers/feature_toggle.rb
@@ -53,4 +53,8 @@ class FeatureToggle
def self.collection_2023_2024_year_enabled?
true
end
+
+ def self.merge_organisations_enabled?
+ !Rails.env.production?
+ end
end
diff --git a/config/routes.rb b/config/routes.rb
index c01f38027..f6e00083b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -119,6 +119,7 @@ Rails.application.routes.draw do
get "managing-agents/remove", to: "organisation_relationships#remove_managing_agent"
post "managing-agents", to: "organisation_relationships#create_managing_agent"
delete "managing-agents", to: "organisation_relationships#delete_managing_agent"
+ get "merge", to: "organisations#merge"
end
end
diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb
index bc6aa243a..7e25fe933 100644
--- a/spec/features/organisation_spec.rb
+++ b/spec/features/organisation_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe "User Features" do
expect(page).to have_current_path("/organisations/#{org_id}/details")
end
- context "when the user is a coordinator and the organisation does not hold housing stock" do
+ context "and the organisation does not hold housing stock" do
before do
organisation.update(holds_own_stock: false)
end
@@ -51,7 +51,7 @@ RSpec.describe "User Features" do
end
end
- context "when the user is a coordinator and the organisation holds housing stock" do
+ context "and the organisation holds housing stock" do
before do
organisation.update(holds_own_stock: true)
end
@@ -61,18 +61,6 @@ RSpec.describe "User Features" do
expect(page).to have_link("Schemes", href: "/schemes")
end
end
-
- context "when the user is support and the organisation does not hold housing stock" do
- before do
- organisation.update!(holds_own_stock: false)
- user.update!(role: "support")
- end
-
- it "does not show schemes in the primary or secondary navigation bar on the organisations page" do
- visit("/organisations")
- expect(page).not_to have_link("Schemes", href: "/schemes", count: 2)
- end
- end
end
context "when users are part of organisation" do
@@ -321,5 +309,16 @@ RSpec.describe "User Features" do
end
end
end
+
+ context "and the organisation does not hold housing stock" do
+ before do
+ organisation.update!(holds_own_stock: false)
+ end
+
+ it "does not show schemes in the primary or secondary navigation bar on the organisations page" do
+ visit("/organisations")
+ expect(page).not_to have_link("Schemes", href: "/schemes", count: 2)
+ end
+ end
end
end
diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb
index 15cfba390..459987fdc 100644
--- a/spec/requests/organisations_controller_spec.rb
+++ b/spec/requests/organisations_controller_spec.rb
@@ -227,6 +227,11 @@ RSpec.describe OrganisationsController, type: :request do
expected_html = "data-qa=\"change-name\" href=\"/organisations/#{organisation.id}/edit\""
expect(response.body).to include(expected_html)
end
+
+ it "displays a link to merge organisations" do
+ expect(page).to have_content("Is your organisation merging with another?")
+ expect(page).to have_link("Let us know using this form", href: "/organisations/#{organisation.id}/merge")
+ end
end
context "with organisation that are not in scope for the user, i.e. that they do not belong to" do
@@ -435,6 +440,36 @@ RSpec.describe OrganisationsController, type: :request do
expect { request }.not_to change(Organisation, :count)
end
end
+
+ describe "#merge" do
+ context "with an organisation that the user belongs to" do
+ before do
+ get "/organisations/#{organisation.id}/merge", headers:, params: {}
+ end
+
+ it "shows the correct content" do
+ expect(page).to have_content("Tell us if your organisation is merging")
+ end
+
+ it "has a correct back link" do
+ expect(page).to have_link("Back", href: "/organisations/#{organisation.id}")
+ end
+
+ it "has a correct start no button" do
+ expect(page).to have_link("Start now", href: "#")
+ end
+ end
+
+ context "with organisation that are not in scope for the user, i.e. that they do not belong to" do
+ before do
+ get "/organisations/#{unauthorised_organisation.id}/merge", headers:, params: {}
+ end
+
+ it "returns not found 404 from org details route" do
+ expect(response).to have_http_status(:not_found)
+ end
+ end
+ end
end
context "with a data provider user" do