diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb
index 1615a1e33..300731e22 100644
--- a/app/controllers/schemes_controller.rb
+++ b/app/controllers/schemes_controller.rb
@@ -6,7 +6,7 @@ class SchemesController < ApplicationController
before_action :authenticate_scope!
def index
- redirect_to supported_housing_organisation_path(current_user.organisation) unless current_user.support?
+ redirect_to schemes_organisation_path(current_user.organisation) unless current_user.support?
all_schemes = Scheme.all
@pagy, @schemes = pagy(filtered_collection(all_schemes, search_term))
diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb
index af1416286..7cf01c9cf 100644
--- a/app/helpers/navigation_items_helper.rb
+++ b/app/helpers/navigation_items_helper.rb
@@ -7,12 +7,12 @@ module NavigationItemsHelper
NavigationItem.new("Organisations", organisations_path, organisations_current?(path)),
NavigationItem.new("Users", "/users", users_current?(path)),
NavigationItem.new("Logs", case_logs_path, logs_current?(path)),
- NavigationItem.new("Supported housing", "/supported-housing", supported_housing_current?(path)),
+ NavigationItem.new("Supported housing", "/schemes", supported_housing_current?(path)),
]
elsif current_user.data_coordinator?
[
NavigationItem.new("Logs", case_logs_path, logs_current?(path)),
- NavigationItem.new("Supported housing", "/supported-housing", subnav_supported_housing_path?(path)),
+ NavigationItem.new("Supported housing", "/schemes", subnav_supported_housing_path?(path)),
NavigationItem.new("Users", users_organisation_path(current_user.organisation), subnav_users_path?(path)),
NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", subnav_details_path?(path)),
]
@@ -28,7 +28,7 @@ module NavigationItemsHelper
def secondary_items(path, current_organisation_id)
[
NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)),
- NavigationItem.new("Supported housing", "/organisations/#{current_organisation_id}/supported-housing", subnav_supported_housing_path?(path)),
+ NavigationItem.new("Supported housing", "/organisations/#{current_organisation_id}/schemes", subnav_supported_housing_path?(path)),
NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)),
NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)),
]
@@ -36,8 +36,8 @@ module NavigationItemsHelper
def scheme_items(_path, current_scheme_id, count)
[
- NavigationItem.new("Scheme", "/supported-housing/#{current_scheme_id}", true),
- NavigationItem.new("#{count} locations", "/supported-housing/#{current_scheme_id}/locations", false),
+ NavigationItem.new("Scheme", "/schemes/#{current_scheme_id}", true),
+ NavigationItem.new("#{count} locations", "/schemes/#{current_scheme_id}/locations", false),
]
end
@@ -52,7 +52,7 @@ private
end
def supported_housing_current?(path)
- path == "/supported-housing" || path.include?("/supported-housing/")
+ path == "/schemes" || path.include?("/schemes/")
end
def organisations_current?(path)
@@ -60,7 +60,7 @@ private
end
def subnav_supported_housing_path?(path)
- path.include?("/organisations") && path.include?("/supported-housing") || path.include?("/supported-housing/")
+ path.include?("/organisations") && path.include?("/schemes") || path.include?("/schemes/")
end
def subnav_users_path?(path)
diff --git a/app/views/schemes/_scheme_list.html.erb b/app/views/schemes/_scheme_list.html.erb
index 8d6ef7a72..4e3413f9d 100644
--- a/app/views/schemes/_scheme_list.html.erb
+++ b/app/views/schemes/_scheme_list.html.erb
@@ -17,7 +17,7 @@
<% row.cell(header: true, text: "Service", html_attributes: {
scope: "col",
}) %>
- <% row.cell(header: true, text: "Managing agent", html_attributes: {
+ <% row.cell(header: true, text: "Managed by", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Created", html_attributes: {
diff --git a/config/routes.rb b/config/routes.rb
index 10ca9b9c2..01efc2623 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -35,7 +35,7 @@ Rails.application.routes.draw do
get "edit/password", to: "users#edit_password"
end
- resources :schemes, path: "/supported-housing", only: %i[index show] do
+ resources :schemes, only: %i[index show] do
member do
get "locations", to: "schemes#locations"
end
@@ -54,7 +54,7 @@ Rails.application.routes.draw do
get "users", to: "organisations#users"
get "users/invite", to: "users/account#new"
get "logs", to: "organisations#logs"
- get "supported-housing", to: "organisations#schemes"
+ get "schemes", to: "organisations#schemes"
end
end
diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb
index d46c14e49..60b174bef 100644
--- a/spec/features/schemes_spec.rb
+++ b/spec/features/schemes_spec.rb
@@ -26,12 +26,12 @@ RSpec.describe "Supported housing scheme Features" do
end
it "displays the link to the supported housing" do
- expect(page).to have_link("Supported housing", href: "/supported-housing")
+ expect(page).to have_link("Supported housing", href: "/schemes")
end
context "when I click Supported housing" do
before do
- click_link "Supported housing", href: "/supported-housing"
+ click_link "Supported housing", href: "/schemes"
end
it "shows list of schemes" do
@@ -101,7 +101,7 @@ RSpec.describe "Supported housing scheme Features" do
context "when I visit supported housing page" do
before do
- visit("supported-housing")
+ visit("schemes")
end
it "shows list of links to schemes" do
@@ -137,7 +137,7 @@ RSpec.describe "Supported housing scheme Features" do
let(:scheme) { schemes.first }
before do
- visit("supported-housing")
+ visit("schemes")
click_link(scheme.service_name)
end
diff --git a/spec/helpers/navigation_items_helper_spec.rb b/spec/helpers/navigation_items_helper_spec.rb
index 52ad582c5..c90ee318d 100644
--- a/spec/helpers/navigation_items_helper_spec.rb
+++ b/spec/helpers/navigation_items_helper_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", true),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", users_path, false),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
]
@@ -27,7 +27,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", users_path, true),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
]
@@ -42,7 +42,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", users_path, false),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, true),
]
@@ -57,7 +57,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
]
@@ -72,7 +72,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", true),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
]
@@ -87,14 +87,14 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", true),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", true),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
]
end
it "returns navigation items with supported housing item set as current" do
- expect(primary_items("/supported-housing/1", current_user)).to eq(expected_navigation_items)
+ expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items)
end
end
end
@@ -108,7 +108,7 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", true),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
]
end
@@ -123,7 +123,7 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", true),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
]
end
@@ -138,7 +138,7 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
]
end
@@ -153,12 +153,12 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", true),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", true),
]
end
it "returns navigation items with the users item set as current" do
- expect(primary_items("/supported-housing", current_user)).to eq(expected_navigation_items)
+ expect(primary_items("/schemes", current_user)).to eq(expected_navigation_items)
end
end
@@ -168,7 +168,7 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", true),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
]
end
@@ -183,12 +183,12 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", true),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", true),
]
end
it "returns navigation items with supported housing item set as current" do
- expect(primary_items("/supported-housing/1", current_user)).to eq(expected_navigation_items)
+ expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items)
end
end
@@ -200,14 +200,14 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
]
end
let(:expected_secondary_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/organisations/#{current_user.organisation.id}/logs", true),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/organisations/#{current_user.organisation.id}/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/organisations/#{current_user.organisation.id}/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", false),
]
@@ -226,14 +226,14 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
]
end
let(:expected_secondary_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/organisations/#{current_user.organisation.id}/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/organisations/#{current_user.organisation.id}/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/organisations/#{current_user.organisation.id}/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", true),
NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", false),
]
@@ -246,20 +246,20 @@ RSpec.describe NavigationItemsHelper do
end
context "when the user is on organisation schemes page" do
- let(:required_sub_path) { "supported-housing" }
+ let(:required_sub_path) { "schemes" }
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
]
end
let(:expected_secondary_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/organisations/#{current_user.organisation.id}/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/organisations/#{current_user.organisation.id}/supported-housing", true),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/organisations/#{current_user.organisation.id}/schemes", true),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", false),
]
@@ -278,14 +278,14 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
]
end
let(:expected_secondary_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/organisations/#{current_user.organisation.id}/logs", false),
- NavigationItemsHelper::NavigationItem.new("Supported housing", "/organisations/#{current_user.organisation.id}/supported-housing", false),
+ NavigationItemsHelper::NavigationItem.new("Supported housing", "/organisations/#{current_user.organisation.id}/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", true),
]
diff --git a/spec/helpers/tab_nav_helper_spec.rb b/spec/helpers/tab_nav_helper_spec.rb
index 59d4170b7..7ec36f974 100644
--- a/spec/helpers/tab_nav_helper_spec.rb
+++ b/spec/helpers/tab_nav_helper_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe TabNavHelper do
describe "#scheme_cell" do
it "returns the scheme link service name and primary user group separated by a newline character" do
- expected_html = "#{scheme.service_name}\nScheme #{scheme.primary_client_group_display}"
+ expected_html = "#{scheme.service_name}\nScheme #{scheme.primary_client_group_display}"
expect(scheme_cell(scheme)).to match(expected_html)
end
end
diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb
index 4d5c248d5..2718d6f97 100644
--- a/spec/requests/schemes_controller_spec.rb
+++ b/spec/requests/schemes_controller_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe SchemesController, type: :request do
describe "#index" do
context "when not signed in" do
it "redirects to the sign in page" do
- get "/supported-housing"
+ get "/schemes"
expect(response).to redirect_to("/account/sign-in")
end
end
@@ -20,7 +20,7 @@ RSpec.describe SchemesController, type: :request do
before do
sign_in user
- get "/supported-housing"
+ get "/schemes"
end
it "returns 401 unauthorized" do
@@ -34,12 +34,12 @@ RSpec.describe SchemesController, type: :request do
before do
sign_in user
- get "/supported-housing"
+ get "/schemes"
end
it "redirects to the organisation schemes path" do
follow_redirect!
- expect(path).to match("/organisations/#{user.organisation.id}/supported-housing")
+ expect(path).to match("/organisations/#{user.organisation.id}/schemes")
end
end
@@ -47,7 +47,7 @@ RSpec.describe SchemesController, type: :request do
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
- get "/supported-housing"
+ get "/schemes"
end
it "has page heading" do
@@ -86,7 +86,7 @@ RSpec.describe SchemesController, type: :request do
context "when on the first page" do
before do
- get "/supported-housing"
+ get "/schemes"
end
it "shows the total schemes count" do
@@ -111,7 +111,7 @@ RSpec.describe SchemesController, type: :request do
context "when on the second page" do
before do
- get "/supported-housing?page=2"
+ get "/schemes?page=2"
end
it "shows the total schemes count" do
@@ -140,7 +140,7 @@ RSpec.describe SchemesController, type: :request do
let(:search_param) { "CODE321" }
before do
- get "/supported-housing?search=#{search_param}"
+ get "/schemes?search=#{search_param}"
end
it "returns matching results" do
@@ -166,7 +166,7 @@ RSpec.describe SchemesController, type: :request do
context "when not signed in" do
it "redirects to the sign in page" do
- get "/supported-housing/#{specific_scheme.id}"
+ get "/schemes/#{specific_scheme.id}"
expect(response).to redirect_to("/account/sign-in")
end
end
@@ -176,7 +176,7 @@ RSpec.describe SchemesController, type: :request do
before do
sign_in user
- get "/supported-housing/#{specific_scheme.id}"
+ get "/schemes/#{specific_scheme.id}"
end
it "returns 401 unauthorized" do
@@ -194,7 +194,7 @@ RSpec.describe SchemesController, type: :request do
end
it "has page heading" do
- get "/supported-housing/#{specific_scheme.id}"
+ get "/schemes/#{specific_scheme.id}"
expect(page).to have_content(specific_scheme.code)
expect(page).to have_content(specific_scheme.service_name)
expect(page).to have_content(specific_scheme.organisation.name)
@@ -211,11 +211,11 @@ RSpec.describe SchemesController, type: :request do
expect(page).to have_content(specific_scheme.intended_stay_display)
end
- context "when coordinator attempts to see scheme belogning to a different organisation" do
+ context "when coordinator attempts to see scheme belonging to a different organisation" do
let!(:specific_scheme) { FactoryBot.create(:scheme) }
it "returns 404 not found" do
- get "/supported-housing/#{specific_scheme.id}"
+ get "/schemes/#{specific_scheme.id}"
expect(response).to have_http_status(:not_found)
end
end
@@ -225,7 +225,7 @@ RSpec.describe SchemesController, type: :request do
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
- get "/supported-housing/#{specific_scheme.id}"
+ get "/schemes/#{specific_scheme.id}"
end
it "has page heading" do
@@ -246,4 +246,29 @@ RSpec.describe SchemesController, type: :request do
end
end
end
+
+ describe "#locations" do
+ let(:specific_scheme) { schemes.first }
+
+ context "when not signed in" do
+ it "redirects to the sign in page" do
+ get "/schemes/#{specific_scheme.id}"
+ expect(response).to redirect_to("/account/sign-in")
+ end
+ end
+
+ context "when signed in as a data provider user" do
+ let(:user) { FactoryBot.create(:user) }
+
+ before do
+ sign_in user
+ get "/schemes/#{specific_scheme.id}"
+ end
+
+ it "returns 401 unauthorized" do
+ request
+ expect(response).to have_http_status(:unauthorized)
+ end
+ end
+ end
end