Browse Source

supported housing to schemes

pull/662/head
JG 3 years ago
parent
commit
ed9882b5da
  1. 2
      app/controllers/schemes_controller.rb
  2. 14
      app/helpers/navigation_items_helper.rb
  3. 2
      app/views/schemes/_scheme_list.html.erb
  4. 4
      config/routes.rb
  5. 8
      spec/features/schemes_spec.rb
  6. 48
      spec/helpers/navigation_items_helper_spec.rb
  7. 2
      spec/helpers/tab_nav_helper_spec.rb
  8. 53
      spec/requests/schemes_controller_spec.rb

2
app/controllers/schemes_controller.rb

@ -6,7 +6,7 @@ class SchemesController < ApplicationController
before_action :authenticate_scope! before_action :authenticate_scope!
def index 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 all_schemes = Scheme.all
@pagy, @schemes = pagy(filtered_collection(all_schemes, search_term)) @pagy, @schemes = pagy(filtered_collection(all_schemes, search_term))

14
app/helpers/navigation_items_helper.rb

@ -7,12 +7,12 @@ module NavigationItemsHelper
NavigationItem.new("Organisations", organisations_path, organisations_current?(path)), NavigationItem.new("Organisations", organisations_path, organisations_current?(path)),
NavigationItem.new("Users", "/users", users_current?(path)), NavigationItem.new("Users", "/users", users_current?(path)),
NavigationItem.new("Logs", case_logs_path, logs_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? elsif current_user.data_coordinator?
[ [
NavigationItem.new("Logs", case_logs_path, logs_current?(path)), 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("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)), 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) def secondary_items(path, current_organisation_id)
[ [
NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)), 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("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)),
NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_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) def scheme_items(_path, current_scheme_id, count)
[ [
NavigationItem.new("Scheme", "/supported-housing/#{current_scheme_id}", true), NavigationItem.new("Scheme", "/schemes/#{current_scheme_id}", true),
NavigationItem.new("#{count} locations", "/supported-housing/#{current_scheme_id}/locations", false), NavigationItem.new("#{count} locations", "/schemes/#{current_scheme_id}/locations", false),
] ]
end end
@ -52,7 +52,7 @@ private
end end
def supported_housing_current?(path) def supported_housing_current?(path)
path == "/supported-housing" || path.include?("/supported-housing/") path == "/schemes" || path.include?("/schemes/")
end end
def organisations_current?(path) def organisations_current?(path)
@ -60,7 +60,7 @@ private
end end
def subnav_supported_housing_path?(path) 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 end
def subnav_users_path?(path) def subnav_users_path?(path)

2
app/views/schemes/_scheme_list.html.erb

@ -17,7 +17,7 @@
<% row.cell(header: true, text: "Service", html_attributes: { <% row.cell(header: true, text: "Service", html_attributes: {
scope: "col", scope: "col",
}) %> }) %>
<% row.cell(header: true, text: "Managing agent", html_attributes: { <% row.cell(header: true, text: "Managed by", html_attributes: {
scope: "col", scope: "col",
}) %> }) %>
<% row.cell(header: true, text: "Created", html_attributes: { <% row.cell(header: true, text: "Created", html_attributes: {

4
config/routes.rb

@ -35,7 +35,7 @@ Rails.application.routes.draw do
get "edit/password", to: "users#edit_password" get "edit/password", to: "users#edit_password"
end end
resources :schemes, path: "/supported-housing", only: %i[index show] do resources :schemes, only: %i[index show] do
member do member do
get "locations", to: "schemes#locations" get "locations", to: "schemes#locations"
end end
@ -54,7 +54,7 @@ Rails.application.routes.draw do
get "users", to: "organisations#users" get "users", to: "organisations#users"
get "users/invite", to: "users/account#new" get "users/invite", to: "users/account#new"
get "logs", to: "organisations#logs" get "logs", to: "organisations#logs"
get "supported-housing", to: "organisations#schemes" get "schemes", to: "organisations#schemes"
end end
end end

8
spec/features/schemes_spec.rb

@ -26,12 +26,12 @@ RSpec.describe "Supported housing scheme Features" do
end end
it "displays the link to the supported housing" do 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 end
context "when I click Supported housing" do context "when I click Supported housing" do
before do before do
click_link "Supported housing", href: "/supported-housing" click_link "Supported housing", href: "/schemes"
end end
it "shows list of schemes" do 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 context "when I visit supported housing page" do
before do before do
visit("supported-housing") visit("schemes")
end end
it "shows list of links to schemes" do it "shows list of links to schemes" do
@ -137,7 +137,7 @@ RSpec.describe "Supported housing scheme Features" do
let(:scheme) { schemes.first } let(:scheme) { schemes.first }
before do before do
visit("supported-housing") visit("schemes")
click_link(scheme.service_name) click_link(scheme.service_name)
end end

48
spec/helpers/navigation_items_helper_spec.rb

@ -12,7 +12,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do let(:expected_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", true), 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("Users", users_path, false),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false), NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
] ]
@ -27,7 +27,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do let(:expected_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), 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("Users", users_path, true),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false), NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
] ]
@ -42,7 +42,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do let(:expected_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), 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("Users", users_path, false),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, true), NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, true),
] ]
@ -57,7 +57,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do let(:expected_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), 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("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false), NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
] ]
@ -72,7 +72,7 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do let(:expected_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), 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("Users", "/organisations/#{current_user.organisation.id}/users", true),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false), NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
] ]
@ -87,14 +87,14 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do let(:expected_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), 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("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false), NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
] ]
end end
it "returns navigation items with supported housing item set as current" do 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 end
end end
@ -108,7 +108,7 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false), NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", true), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", true),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
] ]
end end
@ -123,7 +123,7 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false), NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", true), NavigationItemsHelper::NavigationItem.new("Users", "/users", true),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
] ]
end end
@ -138,7 +138,7 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false), NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
] ]
end end
@ -153,12 +153,12 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false), NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", true), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", true),
] ]
end end
it "returns navigation items with the users item set as current" do 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
end end
@ -168,7 +168,7 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false), NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", true), NavigationItemsHelper::NavigationItem.new("Users", "/users", true),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
] ]
end end
@ -183,12 +183,12 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false), NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", true), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", true),
] ]
end end
it "returns navigation items with supported housing item set as current" do 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 end
@ -200,14 +200,14 @@ RSpec.describe NavigationItemsHelper do
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true), NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
] ]
end end
let(:expected_secondary_navigation_items) do let(:expected_secondary_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/organisations/#{current_user.organisation.id}/logs", true), 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("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", 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("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
] ]
end end
let(:expected_secondary_navigation_items) do let(:expected_secondary_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/organisations/#{current_user.organisation.id}/logs", false), 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("Users", "/organisations/#{current_user.organisation.id}/users", true),
NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", false), NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", false),
] ]
@ -246,20 +246,20 @@ RSpec.describe NavigationItemsHelper do
end end
context "when the user is on organisation schemes page" do 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 let(:expected_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true), NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
] ]
end end
let(:expected_secondary_navigation_items) do let(:expected_secondary_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/organisations/#{current_user.organisation.id}/logs", false), 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("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", 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("Organisations", "/organisations", true),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false), NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", false),
] ]
end end
let(:expected_secondary_navigation_items) do let(:expected_secondary_navigation_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Logs", "/organisations/#{current_user.organisation.id}/logs", false), 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("Users", "/organisations/#{current_user.organisation.id}/users", false),
NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", true), NavigationItemsHelper::NavigationItem.new("About this organisation", "/organisations/#{current_user.organisation.id}", true),
] ]

2
spec/helpers/tab_nav_helper_spec.rb

@ -21,7 +21,7 @@ RSpec.describe TabNavHelper do
describe "#scheme_cell" do describe "#scheme_cell" do
it "returns the scheme link service name and primary user group separated by a newline character" do it "returns the scheme link service name and primary user group separated by a newline character" do
expected_html = "<a class=\"govuk-link\" href=\"/supported-housing\">#{scheme.service_name}</a>\n<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group_display}</span>" expected_html = "<a class=\"govuk-link\" href=\"/schemes\">#{scheme.service_name}</a>\n<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group_display}</span>"
expect(scheme_cell(scheme)).to match(expected_html) expect(scheme_cell(scheme)).to match(expected_html)
end end
end end

53
spec/requests/schemes_controller_spec.rb

@ -10,7 +10,7 @@ RSpec.describe SchemesController, type: :request do
describe "#index" do describe "#index" do
context "when not signed in" do context "when not signed in" do
it "redirects to the sign in page" do it "redirects to the sign in page" do
get "/supported-housing" get "/schemes"
expect(response).to redirect_to("/account/sign-in") expect(response).to redirect_to("/account/sign-in")
end end
end end
@ -20,7 +20,7 @@ RSpec.describe SchemesController, type: :request do
before do before do
sign_in user sign_in user
get "/supported-housing" get "/schemes"
end end
it "returns 401 unauthorized" do it "returns 401 unauthorized" do
@ -34,12 +34,12 @@ RSpec.describe SchemesController, type: :request do
before do before do
sign_in user sign_in user
get "/supported-housing" get "/schemes"
end end
it "redirects to the organisation schemes path" do it "redirects to the organisation schemes path" do
follow_redirect! follow_redirect!
expect(path).to match("/organisations/#{user.organisation.id}/supported-housing") expect(path).to match("/organisations/#{user.organisation.id}/schemes")
end end
end end
@ -47,7 +47,7 @@ RSpec.describe SchemesController, type: :request do
before do before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user sign_in user
get "/supported-housing" get "/schemes"
end end
it "has page heading" do it "has page heading" do
@ -86,7 +86,7 @@ RSpec.describe SchemesController, type: :request do
context "when on the first page" do context "when on the first page" do
before do before do
get "/supported-housing" get "/schemes"
end end
it "shows the total schemes count" do it "shows the total schemes count" do
@ -111,7 +111,7 @@ RSpec.describe SchemesController, type: :request do
context "when on the second page" do context "when on the second page" do
before do before do
get "/supported-housing?page=2" get "/schemes?page=2"
end end
it "shows the total schemes count" do it "shows the total schemes count" do
@ -140,7 +140,7 @@ RSpec.describe SchemesController, type: :request do
let(:search_param) { "CODE321" } let(:search_param) { "CODE321" }
before do before do
get "/supported-housing?search=#{search_param}" get "/schemes?search=#{search_param}"
end end
it "returns matching results" do it "returns matching results" do
@ -166,7 +166,7 @@ RSpec.describe SchemesController, type: :request do
context "when not signed in" do context "when not signed in" do
it "redirects to the sign in page" 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") expect(response).to redirect_to("/account/sign-in")
end end
end end
@ -176,7 +176,7 @@ RSpec.describe SchemesController, type: :request do
before do before do
sign_in user sign_in user
get "/supported-housing/#{specific_scheme.id}" get "/schemes/#{specific_scheme.id}"
end end
it "returns 401 unauthorized" do it "returns 401 unauthorized" do
@ -194,7 +194,7 @@ RSpec.describe SchemesController, type: :request do
end end
it "has page heading" do 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.code)
expect(page).to have_content(specific_scheme.service_name) expect(page).to have_content(specific_scheme.service_name)
expect(page).to have_content(specific_scheme.organisation.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) expect(page).to have_content(specific_scheme.intended_stay_display)
end 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) } let!(:specific_scheme) { FactoryBot.create(:scheme) }
it "returns 404 not found" do 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) expect(response).to have_http_status(:not_found)
end end
end end
@ -225,7 +225,7 @@ RSpec.describe SchemesController, type: :request do
before do before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user sign_in user
get "/supported-housing/#{specific_scheme.id}" get "/schemes/#{specific_scheme.id}"
end end
it "has page heading" do it "has page heading" do
@ -246,4 +246,29 @@ RSpec.describe SchemesController, type: :request do
end end
end 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 end

Loading…
Cancel
Save