diff --git a/app/helpers/tab_nav_helper.rb b/app/helpers/tab_nav_helper.rb index e8802d86c..0cba9f8e4 100644 --- a/app/helpers/tab_nav_helper.rb +++ b/app/helpers/tab_nav_helper.rb @@ -11,7 +11,7 @@ module TabNavHelper [govuk_link_to(link_text, "/schemes/#{location.scheme.id}/locations/#{location.id}/edit", method: :patch), "Location #{location.name}"].join("\n") end - def edit_location_cell(location) + def edit_location_name_cell(location) link_text = location.postcode [govuk_link_to(link_text, "/schemes/#{location.scheme.id}/locations/#{location.id}/edit-name", method: :patch), "Location #{location.name}"].join("\n") end diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index 9c7793fea..88bff9ca4 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -36,7 +36,7 @@ <%= table.body do |body| %> <%= body.row do |row| %> <% row.cell(text: location.id) %> - <% row.cell(text: simple_format(edit_location_cell(location), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> + <% row.cell(text: simple_format(edit_location_name_cell(location), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: location.total_units) %> <% row.cell(text: simple_format("#{location.type_of_unit}#{location.wheelchair_adaptation == 'Yes' ? "\nWith wheelchair adaptations" : ''}")) %> <% end %> diff --git a/db/seeds.rb b/db/seeds.rb index 54ba854b3..be13a937c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -112,7 +112,7 @@ unless Rails.env.test? Location.create!( scheme: scheme1, location_code: "S254-CU193AA", - postcode: "CU19 3AA", + postcode: "CU193AA", name: "Rectory Road", type_of_unit: 4, type_of_building: "Purpose-built", @@ -123,7 +123,7 @@ unless Rails.env.test? Location.create!( scheme: scheme1, location_code: "S254-DM250DC", - postcode: "DM25 0DC", + postcode: "DM250DC", name: "Smithy Lane", type_of_unit: 1, type_of_building: "Converted from previous residential or non-residential property", @@ -134,7 +134,7 @@ unless Rails.env.test? Location.create!( scheme: scheme2, location_code: "S254-YX130WP", - postcode: "YX13 0WP", + postcode: "YX130WP", name: "Smithy Lane", type_of_unit: 2, type_of_building: "Converted from previous residential or non-residential property", diff --git a/spec/helpers/tab_nav_helper_spec.rb b/spec/helpers/tab_nav_helper_spec.rb index 3403ce490..8afc45193 100644 --- a/spec/helpers/tab_nav_helper_spec.rb +++ b/spec/helpers/tab_nav_helper_spec.rb @@ -20,6 +20,13 @@ RSpec.describe TabNavHelper do end end + describe "#edit_location_name_cell" do + it "returns the location link to the postcode with optional name" do + expected_html = "#{location.postcode}\nLocation #{location.name}" + expect(edit_location_name_cell(location)).to match(expected_html) + end + end + describe "#location_cell" do it "returns the location link to the postcode with optional name" do expected_html = "#{location.postcode}\nLocation #{location.name}"