Browse Source

supported housing to schemes - part 2

pull/662/head
JG 3 years ago
parent
commit
f0c2b24ec1
  1. 2
      app/components/primary_navigation_component.rb
  2. 6
      app/helpers/navigation_items_helper.rb
  3. 6
      app/views/organisations/schemes.html.erb
  4. 6
      app/views/schemes/index.html.erb
  5. 8
      spec/components/primary_navigation_component_spec.rb
  6. 12
      spec/features/schemes_spec.rb
  7. 46
      spec/helpers/navigation_items_helper_spec.rb
  8. 26
      spec/requests/organisations_controller_spec.rb
  9. 12
      spec/requests/schemes_controller_spec.rb

2
app/components/primary_navigation_component.rb

@ -3,7 +3,7 @@ class PrimaryNavigationComponent < ViewComponent::Base
def initialize(items:)
@items = items
FeatureToggle.supported_housing_schemes_enabled? ? @items : @items.reject! { |nav_item| nav_item.text.include?("Supported housing") }
FeatureToggle.supported_housing_schemes_enabled? ? @items : @items.reject! { |nav_item| nav_item.text.include?("Schemes") }
super
end

6
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", "/schemes", supported_housing_current?(path)),
NavigationItem.new("Schemes", "/schemes", supported_housing_current?(path)),
]
elsif current_user.data_coordinator?
[
NavigationItem.new("Logs", case_logs_path, logs_current?(path)),
NavigationItem.new("Supported housing", "/schemes", subnav_supported_housing_path?(path)),
NavigationItem.new("Schemes", "/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}/schemes", subnav_supported_housing_path?(path)),
NavigationItem.new("Schemes", "/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)),
]

6
app/views/organisations/schemes.html.erb

@ -1,9 +1,9 @@
<% item_label = format_label(@pagy.count, "scheme") %>
<% title = format_title(@searched, "Supported housing services", current_user, item_label, @pagy.count, @organisation.name) %>
<% title = format_title(@searched, "Schemes", current_user, item_label, @pagy.count, @organisation.name) %>
<% content_for :title, title %>
<%= render partial: "organisations/headings", locals: current_user.support? ? { main: @organisation.name, sub: nil } : { main: "Supported housing services", sub: current_user.organisation.name } %>
<%= render partial: "organisations/headings", locals: current_user.support? ? { main: @organisation.name, sub: nil } : { main: "Schemes", sub: current_user.organisation.name } %>
<% if current_user.support? %>
<%= render SubNavigationComponent.new(
@ -11,7 +11,7 @@
) %>
<% end %>
<h2 class="govuk-visually-hidden">Supported housing services</h2>
<h2 class="govuk-visually-hidden">Schemes</h2>
<%= render SearchComponent.new(current_user:, search_label: "Search by service name or code", value: @searched) %>

6
app/views/schemes/index.html.erb

@ -1,11 +1,11 @@
<% item_label = format_label(@pagy.count, "scheme") %>
<% title = format_title(@searched, "Supported housing services", current_user, item_label, @pagy.count, nil) %>
<% title = format_title(@searched, "Schemes", current_user, item_label, @pagy.count, nil) %>
<% content_for :title, title %>
<%= render partial: "organisations/headings", locals: current_user.support? ? { main: "Supported housing services", sub: nil } : { main: "Supported housing services", sub: current_user.organisation.name } %>
<%= render partial: "organisations/headings", locals: current_user.support? ? { main: "Schemes", sub: nil } : { main: "Schemes", sub: current_user.organisation.name } %>
<h2 class="govuk-visually-hidden">Supported housing services</h2>
<h2 class="govuk-visually-hidden">Schemes</h2>
<%= render SearchComponent.new(current_user:, search_label: "Search by service name or code", value: @searched) %>

8
spec/components/primary_navigation_component_spec.rb

@ -6,7 +6,7 @@ RSpec.describe PrimaryNavigationComponent, type: :component 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("Schemes", "/schemes", false),
]
end
@ -36,7 +36,7 @@ RSpec.describe PrimaryNavigationComponent, type: :component do
expect(result.text).to include("Organisations")
expect(result.text).to include("Users")
expect(result.text).to include("Logs")
expect(result.text).to include("Supported housing")
expect(result.text).to include("Schemes")
end
end
@ -45,9 +45,9 @@ RSpec.describe PrimaryNavigationComponent, type: :component do
allow(Rails.env).to receive(:production?).and_return(true)
end
it "doesn't render supported housing" do
it "doesn't render schemes" do
result = render_inline(described_class.new(items:))
expect(result.text).not_to include("Supported housing")
expect(result.text).not_to include("Schemes")
end
end
end

12
spec/features/schemes_spec.rb

@ -1,6 +1,6 @@
require "rails_helper"
RSpec.describe "Supported housing scheme Features" do
RSpec.describe "Schemes scheme Features" do
context "when viewing list of schemes" do
context "when I am signed as a support user and there are schemes in the database" do
let(:user) { FactoryBot.create(:user, :support, last_sign_in_at: Time.zone.now) }
@ -25,13 +25,13 @@ RSpec.describe "Supported housing scheme Features" do
click_button("Submit")
end
it "displays the link to the supported housing" do
expect(page).to have_link("Supported housing", href: "/schemes")
it "displays the link to the schemes" do
expect(page).to have_link("Schemes", href: "/schemes")
end
context "when I click Supported housing" do
context "when I click schemes" do
before do
click_link "Supported housing", href: "/schemes"
click_link "Schemes", href: "/schemes"
end
it "shows list of schemes" do
@ -99,7 +99,7 @@ RSpec.describe "Supported housing scheme Features" do
click_button("Submit")
end
context "when I visit supported housing page" do
context "when I visit schemes page" do
before do
visit("schemes")
end

46
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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Users", "/organisations/#{current_user.organisation.id}/users", true),
NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false),
]
@ -87,13 +87,13 @@ RSpec.describe NavigationItemsHelper do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", true),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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
it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items)
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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
]
end
@ -147,13 +147,13 @@ RSpec.describe NavigationItemsHelper do
end
end
context "when the user is on the supported housing page" do
context "when the user is on the Schemes page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Supported housing", "/schemes", true),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", true),
]
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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", false),
]
end
@ -183,11 +183,11 @@ 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", "/schemes", true),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", true),
]
end
it "returns navigation items with supported housing item set as current" do
it "returns navigation items with Schemes item set as current" do
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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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}/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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}/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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),
]
@ -252,14 +252,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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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}/schemes", true),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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", "/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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}/schemes", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/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),
]

26
spec/requests/organisations_controller_spec.rb

@ -31,8 +31,8 @@ RSpec.describe OrganisationsController, type: :request do
expect(response).to redirect_to("/account/sign-in")
end
it "does not let you see supported housing list" do
get "/organisations/#{organisation.id}/supported-housing", headers: headers, params: {}
it "does not let you see schemes list" do
get "/organisations/#{organisation.id}/schemes", headers: headers, params: {}
expect(response).to redirect_to("/account/sign-in")
end
end
@ -48,11 +48,11 @@ RSpec.describe OrganisationsController, type: :request do
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
get "/organisations/#{organisation.id}/supported-housing", headers:, params: {}
get "/organisations/#{organisation.id}/schemes", headers:, params: {}
end
it "has page heading" do
expect(page).to have_content("Supported housing services")
expect(page).to have_content("Schemes")
end
it "shows a search bar" do
@ -60,7 +60,7 @@ RSpec.describe OrganisationsController, type: :request do
end
it "has hidden accebility field with description" do
expected_field = "<h2 class=\"govuk-visually-hidden\">Supported housing services</h2>"
expected_field = "<h2 class=\"govuk-visually-hidden\">Schemes</h2>"
expect(CGI.unescape_html(response.body)).to include(expected_field)
end
@ -77,7 +77,7 @@ RSpec.describe OrganisationsController, type: :request do
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
get "/organisations/#{organisation.id}/supported-housing?search=#{search_param}"
get "/organisations/#{organisation.id}/schemes?search=#{search_param}"
end
it "returns matching results" do
@ -104,19 +104,19 @@ RSpec.describe OrganisationsController, type: :request do
before do
sign_in user
get "/organisations/#{organisation.id}/supported-housing", headers:, params: {}
get "/organisations/#{organisation.id}/schemes", headers:, params: {}
end
it "has page heading" do
expect(page).to have_content("Supported housing services")
expect(page).to have_content("Schemes")
end
it "shows a search bar" do
expect(page).to have_field("search", type: "search")
end
it "has hidden accebility field with description" do
expected_field = "<h2 class=\"govuk-visually-hidden\">Supported housing services</h2>"
it "has hidden accessibility field with description" do
expected_field = "<h2 class=\"govuk-visually-hidden\">Schemes</h2>"
expect(CGI.unescape_html(response.body)).to include(expected_field)
end
@ -131,7 +131,7 @@ RSpec.describe OrganisationsController, type: :request do
let!(:unauthorised_organisation) { FactoryBot.create(:organisation) }
before do
get "/organisations/#{unauthorised_organisation.id}/supported-housing", headers:, params: {}
get "/organisations/#{unauthorised_organisation.id}/schemes", headers:, params: {}
end
it "returns not found 404 from org details route" do
@ -144,7 +144,7 @@ RSpec.describe OrganisationsController, type: :request do
let(:search_param) { "CODE321" }
before do
get "/organisations/#{organisation.id}/supported-housing?search=#{search_param}"
get "/organisations/#{organisation.id}/schemes?search=#{search_param}"
end
it "returns matching results" do
@ -159,7 +159,7 @@ RSpec.describe OrganisationsController, type: :request do
end
it "has search in the title" do
expect(page).to have_title("Supported housing services (1 scheme matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title("Schemes (1 scheme matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
end
end

12
spec/requests/schemes_controller_spec.rb

@ -51,7 +51,7 @@ RSpec.describe SchemesController, type: :request do
end
it "has page heading" do
expect(page).to have_content("Supported housing services")
expect(page).to have_content("Schemes")
end
it "shows all schemes" do
@ -65,7 +65,7 @@ RSpec.describe SchemesController, type: :request do
end
it "has correct title" do
expect(page).to have_title("Supported housing services - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title("Schemes - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
it "shows the total organisations count" do
@ -73,7 +73,7 @@ RSpec.describe SchemesController, type: :request do
end
it "has hidden accebility field with description" do
expected_field = "<h2 class=\"govuk-visually-hidden\">Supported housing services</h2>"
expected_field = "<h2 class=\"govuk-visually-hidden\">Schemes</h2>"
expect(CGI.unescape_html(response.body)).to include(expected_field)
end
@ -98,7 +98,7 @@ RSpec.describe SchemesController, type: :request do
end
it "has correct page 1 of 2 title" do
expect(page).to have_title("Supported housing services (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title("Schemes (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
it "has pagination links" do
@ -130,7 +130,7 @@ RSpec.describe SchemesController, type: :request do
end
it "has correct page 1 of 2 title" do
expect(page).to have_title("Supported housing services (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title("Schemes (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
end
end
@ -155,7 +155,7 @@ RSpec.describe SchemesController, type: :request do
end
it "has search in the title" do
expect(page).to have_title("Supported housing services (1 scheme matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
expect(page).to have_title("Schemes (1 scheme matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
end
end

Loading…
Cancel
Save