Browse Source

Change dates format

pull/1402/head
Kat 3 years ago
parent
commit
b86a2798b6
  1. 4
      app/helpers/locations_helper.rb
  2. 4
      spec/helpers/locations_helper_spec.rb

4
app/helpers/locations_helper.rb

@ -113,9 +113,9 @@ private
return sorted_linked_authorities.first[field] if sorted_linked_authorities.count == 1 return sorted_linked_authorities.first[field] if sorted_linked_authorities.count == 1
sorted_linked_authorities.map { |linked_local_authority| sorted_linked_authorities.map { |linked_local_authority|
formatted_start_date = linked_local_authority.start_date&.to_formatted_s(:govuk_date) formatted_start_date = linked_local_authority.start_date.year == 2021 ? "until" : "#{linked_local_authority.start_date&.to_formatted_s(:govuk_date)} -"
formatted_end_date = linked_local_authority.end_date&.to_formatted_s(:govuk_date) || "present" formatted_end_date = linked_local_authority.end_date&.to_formatted_s(:govuk_date) || "present"
"#{linked_local_authority[field]} (#{formatted_start_date} - #{formatted_end_date})" "#{linked_local_authority[field]} (#{formatted_start_date} #{formatted_end_date})"
}.join("\n") }.join("\n")
end end
end end

4
spec/helpers/locations_helper_spec.rb

@ -162,11 +162,11 @@ RSpec.describe LocationsHelper do
attributes = [ attributes = [
{ attribute: "postcode", name: "Postcode", value: location.postcode }, { attribute: "postcode", name: "Postcode", value: location.postcode },
{ attribute: "name", name: "Location name", value: location.name }, { attribute: "name", name: "Location name", value: location.name },
{ attribute: "local_authority", name: "Local authority", value: "Eden (1 April 2021 - 31 March 2023)\nCumberland (1 April 2023 - present)" }, { attribute: "local_authority", name: "Local authority", value: "Eden (until 31 March 2023)\nCumberland (1 April 2023 - present)" },
{ attribute: "units", name: "Number of units", value: location.units }, { attribute: "units", name: "Number of units", value: location.units },
{ attribute: "type_of_unit", name: "Most common unit", value: location.type_of_unit }, { attribute: "type_of_unit", name: "Most common unit", value: location.type_of_unit },
{ attribute: "mobility_standards", name: "Mobility standards", value: location.mobility_type }, { attribute: "mobility_standards", name: "Mobility standards", value: location.mobility_type },
{ attribute: "location_code", name: "Location code", value: "E07000030 (1 April 2021 - 31 March 2023)\nE06000063 (1 April 2023 - present)" }, { attribute: "location_code", name: "Location code", value: "E07000030 (until 31 March 2023)\nE06000063 (1 April 2023 - present)" },
{ attribute: "availability", name: "Availability", value: "Active from 1 April 2022" }, { attribute: "availability", name: "Availability", value: "Active from 1 April 2022" },
{ attribute: "status", name: "Status", value: :active }, { attribute: "status", name: "Status", value: :active },
] ]

Loading…
Cancel
Save