diff --git a/app/models/location.rb b/app/models/location.rb index e58f6dec6..a4dedd6ae 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,3 +1,22 @@ class Location < ApplicationRecord belongs_to :scheme + + WHEELCHAIR_ADAPTATION = { + 0 => "No", + 1 => "Yes", + }.freeze + + def display_attributes + [ + { name: "Location code ", value: location_code, suffix: false }, + { name: "Postcode", value: postcode, suffix: county }, + { name: "Type of unit", value: type_of_unit, suffix: false }, + { name: "Type of building", value: type_of_building, suffix: false }, + { name: "Wheelchair adaptation", value: wheelchair_adaptation_display, suffix: false }, + ] + end + + def wheelchair_adaptation_display + WHEELCHAIR_ADAPTATION[wheelchair_adaptation] + end end diff --git a/app/views/schemes/locations.html.erb b/app/views/schemes/locations.html.erb index 938286066..b08beb2f9 100644 --- a/app/views/schemes/locations.html.erb +++ b/app/views/schemes/locations.html.erb @@ -5,15 +5,14 @@ <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> - <%= render SubNavigationComponent.new( items: scheme_items(request.path, @scheme.id, @scheme.locations.count), ) %>
-
- <% @scheme.locations.each do |location| %> + <% @scheme.locations.each do |location| %> +

<%= "#{location.address_line1}, #{location.address_line2}" %> @@ -21,49 +20,22 @@

-
-
- Location code -
-
- <%= location.location_code %> -
-
-
-
- Postcode -
-
- <%= location.postcode %> -
-
-
-
- Type of unit -
-
- <%= location.type_of_unit %> -
-
-
-
- Type of building -
-
- <%= location.type_of_building %> -
-
-
-
- Wheelchair adaptation -
-
- <%= location.wheelchair_adaptation %> -
-
+ <% location.display_attributes.each do |attribute| %> +
+
+ <%= attribute[:name] %> +
+
+ <%= attribute[:value] %> + <% if attribute[:suffix] %> + <%= attribute[:suffix] %> + <% end %> +
+
+ <% end %>
- <% end %> -
+
+ <% end %>
diff --git a/db/seeds.rb b/db/seeds.rb index f90628229..fdf9d6172 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -70,7 +70,7 @@ unless Rails.env.test? end if Rails.env.development? && Scheme.count.zero? - Scheme.create!( + scheme1 = Scheme.create!( code: "S878", service_name: "Beulahside Care", sensitive: 0, @@ -85,7 +85,7 @@ unless Rails.env.test? created_at: Time.zone.now, ) - Scheme.create!( + scheme2 = Scheme.create!( code: "S312", service_name: "Abdullahview Point", sensitive: 0, @@ -100,7 +100,7 @@ unless Rails.env.test? created_at: Time.zone.now, ) - scheme = Scheme.create!( + Scheme.create!( code: "7XYZ", service_name: "Caspermouth Center", sensitive: 1, @@ -115,16 +115,41 @@ unless Rails.env.test? created_at: Time.zone.now, ) - Location.create( - scheme: scheme, - location_code: "7XYZ", - postcode: "ZX1 177", - address_line1: "1 High street", - address_line2: "London", - type_of_unit: "unit", - type_of_building: "building", + Location.create!( + scheme: scheme1, + location_code: "S254-CU193AA", + postcode: "CU19 3AA", + address_line1: "Rectory Road", + address_line2: "North Chaim", + type_of_unit: "Self-contained flat or bedsit", + type_of_building: "Purpose-built", + county: "Mid Sussex", wheelchair_adaptation: 0, ) + + Location.create!( + scheme: scheme1, + location_code: "S254-DM250DC", + postcode: "DM25 0DC", + address_line1: "Smithy Lane", + address_line2: "North Kellieworth", + type_of_unit: "Self-contained flat or bedsit with common facilities", + type_of_building: "Converted from previous residential or non-residential property", + county: "Fife", + wheelchair_adaptation: 1, + ) + + Location.create!( + scheme: scheme2, + location_code: "S254-YX130WP", + postcode: "YX13 0WP", + address_line1: "Smithy Lane", + address_line2: "East Darwin", + type_of_unit: "Shared house or hostel", + type_of_building: "Converted from previous residential or non-residential property", + county: "Rochford", + wheelchair_adaptation: 1, + ) end pp "Seeded 3 dummy schemes" diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 66040ed52..b2d96ff8e 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -112,7 +112,7 @@ RSpec.describe "Schemes scheme Features" do end context "when I click to see individual scheme" do - let(:scheme) { schemes.first } + let(:scheme) { schemes.first } before do click_link(scheme.service_name) @@ -134,7 +134,7 @@ RSpec.describe "Schemes scheme Features" do context "when there are locations that belong to the selected scheme" do let!(:schemes) { FactoryBot.create_list(:scheme, 5) } let(:scheme) { schemes.first } - let!(:locations) { FactoryBot.create_list(:location, 3, scheme: scheme) } + let!(:locations) { FactoryBot.create_list(:location, 3, scheme:) } before do visit("schemes") diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index a8a705dd4..53ba369ba 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -274,7 +274,7 @@ RSpec.describe SchemesController, type: :request do context "when signed in as a data coordinator user" do let(:user) { FactoryBot.create(:user, :data_coordinator) } let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) } - let!(:location) { FactoryBot.create(:location, scheme: scheme) } + let!(:location) { FactoryBot.create(:location, scheme:) } before do sign_in user