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. 6
      app/views/locations/index.html.erb
  5. 11
      app/views/locations/new.html.erb
  6. 6
      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
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
end

4
app/models/location.rb

@ -15,10 +15,10 @@ class Location < ApplicationRecord
enum wheelchair_adaptation: WHEELCHAIR_ADAPTATIONS
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",
"None": "N",
"Property designed to wheelchair user standard": "W",
"Missing": "X",
}.freeze

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

@ -36,6 +36,17 @@
:name,
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) } %>
<%= f.govuk_collection_radio_buttons :wheelchair_adaptation,
wheelchair_user_selection,

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

@ -30,6 +30,9 @@
<% row.cell(header: true, text: "Common unit type", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Mobility type", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% @locations.each do |location| %>
@ -39,7 +42,8 @@
<% 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: 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>" : ''}")) %>
<% end %>
<% row.cell(text: location.mobility_type) %>
<% end %>
<% end %>
<% end %>
<% end %>

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

@ -46,6 +46,17 @@
hint: { text: I18n.t("hints.location.wheelchair_adaptation") },
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,
legend: { text: I18n.t("questions.location.startdate"), size: "m" },
width: 20 %>

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

@ -90,6 +90,9 @@
<% row.cell(header: true, text: "Common unit type", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Mobility type", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% @scheme.locations.each do |location| %>
@ -99,7 +102,8 @@
<% 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: 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>" : ''}")) %>
<% end %>
<% row.cell(text: location.mobility_type) %>
<% 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?"
startdate: "When did the first property in this location become available under this scheme?"
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:
location:

8
spec/features/schemes_spec.rb

@ -209,6 +209,10 @@ RSpec.describe "Schemes scheme Features" do
it "shows details of those locations" do
locations.each do |location|
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
@ -405,6 +409,7 @@ RSpec.describe "Schemes scheme Features" do
choose "Self-contained house"
choose "location-wheelchair-adaptation-no-field"
choose "location-add-another-location-no-field"
choose "location-mobility-type-none-field"
click_button "Save and continue"
end
@ -426,6 +431,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "SW1P4DF"
expect(page).to have_content "Some name"
expect(page).to have_content "Self-contained house"
expect(page).to have_content "None"
end
end
@ -465,6 +471,7 @@ RSpec.describe "Schemes scheme Features" do
before do
click_link "XX11XX"
fill_in "Postcode", with: "ZZ1 1ZZ"
choose "location-mobility-type-wheelchair-user-standard-field"
click_button "Save and continue"
end
@ -472,6 +479,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
expect(page).to have_content "ZZ11ZZ"
expect(page).to have_content("Wheelchair-user standard")
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!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) }
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
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.wheelchair_adaptation).to eq("No")
expect(Location.last.startdate).to eq(startdate)
expect(Location.last.mobility_type).to eq("Fitted with equipment and adaptations")
end
context "when postcode is submitted with lower case" do
@ -134,7 +135,7 @@ RSpec.describe LocationsController, type: :request do
end
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
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.type_of_unit).to eq("Bungalow")
expect(Location.last.wheelchair_adaptation).to eq("No")
expect(Location.last.mobility_type).to eq("None")
end
end
@ -172,7 +174,7 @@ RSpec.describe LocationsController, type: :request do
end
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
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.type_of_unit).to eq("Bungalow")
expect(Location.last.wheelchair_adaptation).to eq("No")
expect(Location.last.mobility_type).to eq("Wheelchair-user standard")
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.postcode).to eq("S44 6EJ")
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.old_id).to eq(first_location_id)
expect(location.old_visible_id).to eq(10)

Loading…
Cancel
Save