Browse Source

Add mobility type question

pull/763/head
Kat 3 years ago
parent
commit
d55e7a8731
  1. 2
      app/controllers/locations_controller.rb
  2. 4
      app/models/location.rb
  3. 11
      app/views/locations/edit.html.erb
  4. 4
      app/views/locations/index.html.erb
  5. 11
      app/views/locations/new.html.erb
  6. 4
      app/views/schemes/check_answers.html.erb
  7. 7
      config/locales/en.yml
  8. 8
      spec/features/schemes_spec.rb
  9. 9
      spec/requests/locations_controller_spec.rb
  10. 2
      spec/services/imports/scheme_location_import_service_spec.rb

2
app/controllers/locations_controller.rb

@ -88,7 +88,7 @@ private
end end
def location_params def location_params
required_params = params.require(:location).permit(:postcode, :name, :units, :type_of_unit, :wheelchair_adaptation, :add_another_location, :startdate).merge(scheme_id: @scheme.id) required_params = params.require(:location).permit(:postcode, :name, :units, :type_of_unit, :wheelchair_adaptation, :add_another_location, :startdate, :mobility_type).merge(scheme_id: @scheme.id)
required_params[:postcode] = PostcodeService.clean(required_params[:postcode]) if required_params[:postcode] required_params[:postcode] = PostcodeService.clean(required_params[:postcode]) if required_params[:postcode]
required_params required_params
end end

4
app/models/location.rb

@ -15,10 +15,10 @@ class Location < ApplicationRecord
enum wheelchair_adaptation: WHEELCHAIR_ADAPTATIONS enum wheelchair_adaptation: WHEELCHAIR_ADAPTATIONS
MOBILITY_TYPE = { MOBILITY_TYPE = {
"Property fitted with equipment and adaptations (if not designed to above standards)": "A", "Wheelchair-user standard": "W",
"Fitted with equipment and adaptations": "A",
"Property designed to accessible general standard": "M", "Property designed to accessible general standard": "M",
"None": "N", "None": "N",
"Property designed to wheelchair user standard": "W",
"Missing": "X", "Missing": "X",
}.freeze }.freeze

11
app/views/locations/edit.html.erb

@ -36,6 +36,17 @@
:name, :name,
legend: { text: I18n.t("questions.location.type_of_unit"), size: "m" } %> legend: { text: I18n.t("questions.location.type_of_unit"), size: "m" } %>
<% mobility_types_to_display = Location.mobility_types.excluding("Property designed to accessible general standard", "Missing") %>
<% mobility_type_selection = mobility_types_to_display.map { |key, value| OpenStruct.new(id: key, name: key.to_s.humanize, description: I18n.t("questions.descriptions.location.mobility_type.#{value}")) } %>
<%= f.govuk_collection_radio_buttons :mobility_type,
mobility_type_selection,
:id,
:name,
:description,
legend: { text: I18n.t("questions.location.mobility_type"), size: "m" } %>
<% wheelchair_user_selection = Location.wheelchair_adaptations.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% wheelchair_user_selection = Location.wheelchair_adaptations.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :wheelchair_adaptation, <%= f.govuk_collection_radio_buttons :wheelchair_adaptation,
wheelchair_user_selection, wheelchair_user_selection,

4
app/views/locations/index.html.erb

@ -30,6 +30,9 @@
<% row.cell(header: true, text: "Common unit type", html_attributes: { <% row.cell(header: true, text: "Common unit type", html_attributes: {
scope: "col", scope: "col",
}) %> }) %>
<% row.cell(header: true, text: "Mobility type", html_attributes: {
scope: "col",
}) %>
<% end %> <% end %>
<% end %> <% end %>
<% @locations.each do |location| %> <% @locations.each do |location| %>
@ -39,6 +42,7 @@
<% row.cell(text: simple_format(location_cell(location, "/schemes/#{@scheme.id}/locations/#{location.id}/edit-name"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: simple_format(location_cell(location, "/schemes/#{@scheme.id}/locations/#{location.id}/edit-name"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.units) %> <% row.cell(text: location.units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == 'Yes' ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ''}")) %> <% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == 'Yes' ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ''}")) %>
<% row.cell(text: location.mobility_type) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

11
app/views/locations/new.html.erb

@ -46,6 +46,17 @@
hint: { text: I18n.t("hints.location.wheelchair_adaptation") }, hint: { text: I18n.t("hints.location.wheelchair_adaptation") },
legend: { text: I18n.t("questions.location.wheelchair_adaptation"), size: "m" } %> legend: { text: I18n.t("questions.location.wheelchair_adaptation"), size: "m" } %>
<% mobility_types_to_display = Location.mobility_types.excluding("Property designed to accessible general standard", "Missing") %>
<% mobility_type_selection = mobility_types_to_display.map { |key, value| OpenStruct.new(id: key, name: key.to_s.humanize, description: I18n.t("questions.descriptions.location.mobility_type.#{value}")) } %>
<%= f.govuk_collection_radio_buttons :mobility_type,
mobility_type_selection,
:id,
:name,
:description,
legend: { text: I18n.t("questions.location.mobility_type"), size: "m" } %>
<%= f.govuk_date_field :startdate, <%= f.govuk_date_field :startdate,
legend: { text: I18n.t("questions.location.startdate"), size: "m" }, legend: { text: I18n.t("questions.location.startdate"), size: "m" },
width: 20 %> width: 20 %>

4
app/views/schemes/check_answers.html.erb

@ -90,6 +90,9 @@
<% row.cell(header: true, text: "Common unit type", html_attributes: { <% row.cell(header: true, text: "Common unit type", html_attributes: {
scope: "col", scope: "col",
}) %> }) %>
<% row.cell(header: true, text: "Mobility type", html_attributes: {
scope: "col",
}) %>
<% end %> <% end %>
<% end %> <% end %>
<% @scheme.locations.each do |location| %> <% @scheme.locations.each do |location| %>
@ -99,6 +102,7 @@
<% row.cell(text: simple_format(location_cell(location, "/schemes/#{@scheme.id}/locations/#{location.id}/edit"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: simple_format(location_cell(location, "/schemes/#{@scheme.id}/locations/#{location.id}/edit"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.units) %> <% row.cell(text: location.units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == 'Yes' ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ''}")) %> <% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>#{location.wheelchair_adaptation == 'Yes' ? "\n<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">With wheelchair adaptations</span>" : ''}")) %>
<% row.cell(text: location.mobility_type) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

7
config/locales/en.yml

@ -326,6 +326,13 @@ en:
wheelchair_adaptation: "Are the majority of units in this location built or adapted to wheelchair-user standards?" wheelchair_adaptation: "Are the majority of units in this location built or adapted to wheelchair-user standards?"
startdate: "When did the first property in this location become available under this scheme?" startdate: "When did the first property in this location become available under this scheme?"
add_another_location: "Do you want to add another location?" add_another_location: "Do you want to add another location?"
mobility_type: "What are the mobility standards for the majority of units in this location?"
descriptions:
location:
mobility_type:
W: "The majority of units are suitable for someone who uses a wheelchair and offer the full use of all rooms and facilities."
A: "For example, the majority of units have been fitted with stairlifts, ramps, level access showers or grab rails."
N: "The majority of units are not designed to wheelchair-user standards or fitted with any equipment and adaptations."
hints: hints:
location: location:

8
spec/features/schemes_spec.rb

@ -209,6 +209,10 @@ RSpec.describe "Schemes scheme Features" do
it "shows details of those locations" do it "shows details of those locations" do
locations.each do |location| locations.each do |location|
expect(page).to have_content(location.id) expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
expect(page).to have_content(location.units)
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type)
end end
end end
end end
@ -405,6 +409,7 @@ RSpec.describe "Schemes scheme Features" do
choose "Self-contained house" choose "Self-contained house"
choose "location-wheelchair-adaptation-no-field" choose "location-wheelchair-adaptation-no-field"
choose "location-add-another-location-no-field" choose "location-add-another-location-no-field"
choose "location-mobility-type-none-field"
click_button "Save and continue" click_button "Save and continue"
end end
@ -426,6 +431,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "SW1P4DF" expect(page).to have_content "SW1P4DF"
expect(page).to have_content "Some name" expect(page).to have_content "Some name"
expect(page).to have_content "Self-contained house" expect(page).to have_content "Self-contained house"
expect(page).to have_content "None"
end end
end end
@ -465,6 +471,7 @@ RSpec.describe "Schemes scheme Features" do
before do before do
click_link "XX11XX" click_link "XX11XX"
fill_in "Postcode", with: "ZZ1 1ZZ" fill_in "Postcode", with: "ZZ1 1ZZ"
choose "location-mobility-type-wheelchair-user-standard-field"
click_button "Save and continue" click_button "Save and continue"
end end
@ -472,6 +479,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "Locations" expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location" expect(page).to have_content "#{scheme.locations.count} location"
expect(page).to have_content "ZZ11ZZ" expect(page).to have_content "ZZ11ZZ"
expect(page).to have_content("Wheelchair-user standard")
end end
end end
end end

9
spec/requests/locations_controller_spec.rb

@ -91,7 +91,7 @@ RSpec.describe LocationsController, type: :request do
let(:user) { FactoryBot.create(:user, :data_coordinator) } let(:user) { FactoryBot.create(:user, :data_coordinator) }
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) }
let(:startdate) { Time.utc(2022, 2, 2) } let(:startdate) { Time.utc(2022, 2, 2) }
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No", postcode: "ZZ1 1ZZ", startdate: } } } let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No", postcode: "ZZ1 1ZZ", startdate:, mobility_type: "A" } } }
before do before do
sign_in user sign_in user
@ -113,6 +113,7 @@ RSpec.describe LocationsController, type: :request do
expect(Location.last.type_of_unit).to eq("Bungalow") expect(Location.last.type_of_unit).to eq("Bungalow")
expect(Location.last.wheelchair_adaptation).to eq("No") expect(Location.last.wheelchair_adaptation).to eq("No")
expect(Location.last.startdate).to eq(startdate) expect(Location.last.startdate).to eq(startdate)
expect(Location.last.mobility_type).to eq("Fitted with equipment and adaptations")
end end
context "when postcode is submitted with lower case" do context "when postcode is submitted with lower case" do
@ -134,7 +135,7 @@ RSpec.describe LocationsController, type: :request do
end end
context "when do you want to add another location is selected as yes" do context "when do you want to add another location is selected as yes" do
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "Yes", postcode: "ZZ1 1ZZ" } } } let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "Yes", postcode: "ZZ1 1ZZ", mobility_type: "N" } } }
it "creates a new location for scheme with valid params and redirects to correct page" do it "creates a new location for scheme with valid params and redirects to correct page" do
expect { post "/schemes/#{scheme.id}/locations", params: }.to change(Location, :count).by(1) expect { post "/schemes/#{scheme.id}/locations", params: }.to change(Location, :count).by(1)
@ -149,6 +150,7 @@ RSpec.describe LocationsController, type: :request do
expect(Location.last.units).to eq(5) expect(Location.last.units).to eq(5)
expect(Location.last.type_of_unit).to eq("Bungalow") expect(Location.last.type_of_unit).to eq("Bungalow")
expect(Location.last.wheelchair_adaptation).to eq("No") expect(Location.last.wheelchair_adaptation).to eq("No")
expect(Location.last.mobility_type).to eq("None")
end end
end end
@ -172,7 +174,7 @@ RSpec.describe LocationsController, type: :request do
end end
context "when do you want to add another location is not selected" do context "when do you want to add another location is not selected" do
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", postcode: "ZZ1 1ZZ" } } } let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", postcode: "ZZ1 1ZZ", mobility_type: "W" } } }
it "creates a new location for scheme with valid params and redirects to correct page" do it "creates a new location for scheme with valid params and redirects to correct page" do
expect { post "/schemes/#{scheme.id}/locations", params: }.to change(Location, :count).by(1) expect { post "/schemes/#{scheme.id}/locations", params: }.to change(Location, :count).by(1)
@ -187,6 +189,7 @@ RSpec.describe LocationsController, type: :request do
expect(Location.last.units).to eq(5) expect(Location.last.units).to eq(5)
expect(Location.last.type_of_unit).to eq("Bungalow") expect(Location.last.type_of_unit).to eq("Bungalow")
expect(Location.last.wheelchair_adaptation).to eq("No") expect(Location.last.wheelchair_adaptation).to eq("No")
expect(Location.last.mobility_type).to eq("Wheelchair-user standard")
end end
end end

2
spec/services/imports/scheme_location_import_service_spec.rb

@ -134,7 +134,7 @@ RSpec.describe Imports::SchemeLocationImportService do
expect(location.name).to eq("Location 1") expect(location.name).to eq("Location 1")
expect(location.postcode).to eq("S44 6EJ") expect(location.postcode).to eq("S44 6EJ")
expect(location.units).to eq(5) expect(location.units).to eq(5)
expect(location.mobility_type).to eq("Property fitted with equipment and adaptations (if not designed to above standards)") expect(location.mobility_type).to eq("Fitted with equipment and adaptations")
expect(location.type_of_unit).to eq("Bungalow") expect(location.type_of_unit).to eq("Bungalow")
expect(location.old_id).to eq(first_location_id) expect(location.old_id).to eq(first_location_id)
expect(location.old_visible_id).to eq(10) expect(location.old_visible_id).to eq(10)

Loading…
Cancel
Save