Browse Source

Add location "available from" column (#782)

pull/783/head
Stéphane Meny 2 years ago committed by GitHub
parent
commit
38a700721e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/views/locations/index.html.erb
  2. 10
      app/views/schemes/check_answers.html.erb
  3. 2
      app/views/schemes/show.html.erb
  4. 1
      spec/factories/location.rb
  5. 5
      spec/features/schemes_helpers.rb
  6. 11
      spec/features/schemes_spec.rb
  7. 4
      spec/requests/locations_controller_spec.rb

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

@ -35,10 +35,7 @@
<% 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: { <% row.cell(header: true, text: "Available from", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Local authority", html_attributes: {
scope: "col", scope: "col",
}) %> }) %>
<% end %> <% end %>
@ -50,8 +47,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>")) %> <% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>")) %>
<% row.cell(text: location.mobility_type) %> <% row.cell(text: location.startdate&.to_formatted_s(:govuk_date)) %>
<% row.cell(text: location.location_admin_district) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

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

@ -3,7 +3,6 @@
<%= form_for(@scheme, as: :scheme, method: :patch) do |f| %> <%= form_for(@scheme, as: :scheme, method: :patch) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters-from-desktop">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %> <%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %>
<% component.tab(label: "Scheme") do %> <% component.tab(label: "Scheme") do %>
@ -52,10 +51,7 @@
<% 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: { <% row.cell(header: true, text: "Available from", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Local authority", html_attributes: {
scope: "col", scope: "col",
}) %> }) %>
<% end %> <% end %>
@ -67,8 +63,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>")) %> <% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>")) %>
<% row.cell(text: location.mobility_type) %> <% row.cell(text: location.startdate&.to_formatted_s(:govuk_date)) %>
<% row.cell(text: location.location_admin_district) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
@ -77,7 +72,6 @@
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
</div>
<%= f.hidden_field :page, value: "check-answers" %> <%= f.hidden_field :page, value: "check-answers" %>
<%= f.hidden_field :confirmed, value: "true" %> <%= f.hidden_field :confirmed, value: "true" %>
<% button_label = @scheme.confirmed? ? "Save" : "Create scheme" %> <% button_label = @scheme.confirmed? ? "Save" : "Create scheme" %>

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

@ -13,7 +13,6 @@
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters-from-desktop">
<%= govuk_summary_list do |summary_list| %> <%= govuk_summary_list do |summary_list| %>
<% @scheme.display_attributes.each do |attr| %> <% @scheme.display_attributes.each do |attr| %>
<% next if current_user.data_coordinator? && attr[:name] == ("Housing stock owned by") %> <% next if current_user.data_coordinator? && attr[:name] == ("Housing stock owned by") %>
@ -25,4 +24,3 @@
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
</div>

1
spec/factories/location.rb

@ -8,6 +8,7 @@ FactoryBot.define do
mobility_type { %w[A M N W X].sample } mobility_type { %w[A M N W X].sample }
location_code { "E09000033" } location_code { "E09000033" }
location_admin_district { "Westminster" } location_admin_district { "Westminster" }
startdate { Faker::Date.between(from: 6.months.ago, to: Time.zone.today) }
scheme scheme
trait :export do trait :export do
postcode { "SW1A 2AA" } postcode { "SW1A 2AA" }

5
spec/features/schemes_helpers.rb

@ -57,7 +57,10 @@ module SchemesHelpers
def fill_in_and_save_location def fill_in_and_save_location
fill_in "Postcode", with: "AA1 1AA" fill_in "Postcode", with: "AA1 1AA"
fill_in "Location name (optional)", with: "Some name" fill_in "Location name (optional)", with: "Some name"
fill_in "Total number of units at this location", with: 1 fill_in "Total number of units at this location", with: 5
fill_in "Day", with: 2
fill_in "Month", with: 2
fill_in "Year", with: 2022
choose "Self-contained house" choose "Self-contained house"
choose "location-add-another-location-no-field" choose "location-add-another-location-no-field"
choose "location-mobility-type-none-field" choose "location-mobility-type-none-field"

11
spec/features/schemes_spec.rb

@ -175,7 +175,7 @@ RSpec.describe "Schemes scheme Features" do
context "when there are locations that belong to the selected scheme" do context "when there are locations that belong to the selected scheme" do
let!(:schemes) { FactoryBot.create_list(:scheme, 5) } let!(:schemes) { FactoryBot.create_list(:scheme, 5) }
let(:scheme) { schemes.first } let(:scheme) { schemes.first }
let!(:locations) { FactoryBot.create_list(:location, 3, scheme:, postcode: "AA11AA") } let!(:locations) { FactoryBot.create_list(:location, 3, scheme:, postcode: "AA11AA", startdate: Time.utc(2022, 1, 1)) }
before do before do
visit("schemes") visit("schemes")
@ -198,8 +198,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content(location.postcode) expect(page).to have_content(location.postcode)
expect(page).to have_content(location.units) expect(page).to have_content(location.units)
expect(page).to have_content(location.type_of_unit) expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type) expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
expect(page).to have_content(location.location_admin_district)
end end
end end
end end
@ -471,10 +470,9 @@ RSpec.describe "Schemes scheme Features" do
it "displays information about the first created location" do it "displays information about the first created location" do
expect(page).to have_content "AA11AA" expect(page).to have_content "AA11AA"
expect(page).to have_content "Some name" expect(page).to have_content "Some name"
expect(page).to have_content "5"
expect(page).to have_content "Self-contained house" expect(page).to have_content "Self-contained house"
expect(page).to have_content "None" expect(page).to have_content "2 February 2022"
expect(page).to have_content "Local authority"
expect(page).to have_content "Westminster"
end end
it "displays information about another location" do it "displays information about another location" do
@ -508,7 +506,6 @@ 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

4
spec/requests/locations_controller_spec.rb

@ -804,7 +804,7 @@ RSpec.describe LocationsController, type: :request do
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.postcode)
expect(page).to have_content(location.type_of_unit) expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type) expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end end
end end
@ -906,7 +906,7 @@ RSpec.describe LocationsController, type: :request do
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.postcode)
expect(page).to have_content(location.type_of_unit) expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type) expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end end
end end

Loading…
Cancel
Save