diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb
index c0b57556d..8bfa1c216 100644
--- a/app/controllers/locations_controller.rb
+++ b/app/controllers/locations_controller.rb
@@ -51,7 +51,7 @@ private
def location_params
required_params = params.require(:location).permit(:postcode, :name, :total_units, :type_of_unit, :wheelchair_adaptation, :add_another_location).merge(scheme_id: @scheme.id)
- required_params[:postcode] = required_params[:postcode].gsub(" ", "").upcase.encode("ASCII", "UTF-8", invalid: :replace, undef: :replace, replace: "") if required_params[:postcode]
+ required_params[:postcode] = required_params[:postcode].delete(" ").upcase.encode("ASCII", "UTF-8", invalid: :replace, undef: :replace, replace: "") if required_params[:postcode]
required_params
end
end
diff --git a/app/models/location.rb b/app/models/location.rb
index e93703a6c..7c012e442 100644
--- a/app/models/location.rb
+++ b/app/models/location.rb
@@ -31,7 +31,7 @@ class Location < ApplicationRecord
{ name: "Type of building", value: type_of_building, suffix: false },
{ name: "Wheelchair adaptation", value: wheelchair_adaptation, suffix: false },
]
- end
+ end
private
diff --git a/app/views/locations/details.html.erb b/app/views/locations/details.html.erb
index d132a0bfa..10f72e4f2 100644
--- a/app/views/locations/details.html.erb
+++ b/app/views/locations/details.html.erb
@@ -3,8 +3,8 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
- href: "/schemes/#{@scheme.id}/support"
- ) %>
+ href: "/schemes/#{@scheme.id}/support",
+ ) %>
<% end %>
<%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %>
diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb
index 7c970fe7a..782ceb0d3 100644
--- a/app/views/locations/new.html.erb
+++ b/app/views/locations/new.html.erb
@@ -3,8 +3,8 @@
<% content_for :before_content do %>
<%= govuk_back_link(
text: "Back",
- href: "/schemes/#{@scheme.id}/support"
- ) %>
+ href: "/schemes/#{@scheme.id}/support",
+ ) %>
<% end %>
<%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %>
diff --git a/app/views/schemes/check_answers.html.erb b/app/views/schemes/check_answers.html.erb
index ded5c9166..a198b703a 100644
--- a/app/views/schemes/check_answers.html.erb
+++ b/app/views/schemes/check_answers.html.erb
@@ -17,7 +17,7 @@
<% row.action(
text: "Change",
href: scheme_details_path(scheme_id: @scheme.id, check_answers: true),
- ) %>
+ ) %>
<% end %>
<% end %>
<% @scheme.check_primary_client_attributes.each do |attr| %>
@@ -27,7 +27,7 @@
<% row.action(
text: "Change",
href: scheme_primary_client_group_path(scheme_id: @scheme.id, check_answers: true),
- ) %>
+ ) %>
<% end %>
<% end %>
<% @scheme.check_secondary_client_confirmation_attributes.each do |attr| %>
@@ -37,7 +37,7 @@
<% row.action(
text: "Change",
href: scheme_confirm_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
- ) %>
+ ) %>
<% end %>
<% end %>
<% if @scheme.has_other_client_group == "Yes" %>
@@ -48,7 +48,7 @@
<% row.action(
text: "Change",
href: scheme_secondary_client_group_path(scheme_id: @scheme.id, check_answers: true),
- ) %>
+ ) %>
<% end %>
<% end %>
<% end %>
@@ -59,7 +59,7 @@
<% row.action(
text: "Change",
href: scheme_support_path(scheme_id: @scheme.id, check_answers: true),
- ) %>
+ ) %>
<% end %>
<% end %>
<% end %>
@@ -94,7 +94,7 @@
<% row.cell(text: location.id) %>
<% row.cell(text: simple_format(location_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" : ""}")) %>
+ <% row.cell(text: simple_format("#{location.type_of_unit}#{location.wheelchair_adaptation == 'Yes' ? "\nWith wheelchair adaptations" : ''}")) %>
<% row.cell(text: "Delete") %>
<% end %>
<% end %>
diff --git a/app/views/schemes/locations.html.erb b/app/views/schemes/locations.html.erb
index 485b49031..9b66e5f3d 100644
--- a/app/views/schemes/locations.html.erb
+++ b/app/views/schemes/locations.html.erb
@@ -4,7 +4,7 @@
<%= govuk_back_link(
text: "Back",
href: "/schemes/#{@scheme.id}",
- ) %>
+ ) %>
<% end %>
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %>
@@ -41,7 +41,7 @@
<% row.cell(text: location.id) %>
<% row.cell(text: location.postcode) %>
<% row.cell(text: location.total_units) %>
- <% row.cell(text: simple_format("#{location.type_of_unit}#{location.wheelchair_adaptation == "Yes" ? "\nWith wheelchair adaptations" : ""}")) %>
+ <% row.cell(text: simple_format("#{location.type_of_unit}#{location.wheelchair_adaptation == 'Yes' ? "\nWith wheelchair adaptations" : ''}")) %>
<% row.cell(text: "Delete") %>
<% end %>
<% end %>
diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb
index 1a627efd4..7c518d1a0 100644
--- a/spec/features/schemes_spec.rb
+++ b/spec/features/schemes_spec.rb
@@ -461,7 +461,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "Self-contained house"
end
- context "changing location details" do
+ context "when changing location details" do
before do
click_link "XX11XX"
fill_in "Postcode", with: "ZZ1 1ZZ"
diff --git a/spec/helpers/tab_nav_helper_spec.rb b/spec/helpers/tab_nav_helper_spec.rb
index a4b5c3306..6aacd657f 100644
--- a/spec/helpers/tab_nav_helper_spec.rb
+++ b/spec/helpers/tab_nav_helper_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe TabNavHelper do
let(:organisation) { FactoryBot.create(:organisation) }
let(:user) { FactoryBot.build(:user, organisation:) }
let(:scheme) { FactoryBot.create(:scheme, service_name: "Some name") }
- let(:location) { FactoryBot.create(:location, scheme: scheme) }
+ let(:location) { FactoryBot.create(:location, scheme:) }
describe "#user_cell" do
it "returns user link and email separated by a newline character" do
diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb
index 2e57e9d66..45d731eb7 100644
--- a/spec/models/location_spec.rb
+++ b/spec/models/location_spec.rb
@@ -14,13 +14,13 @@ RSpec.describe Location, type: :model do
it "does not add an error if postcode is valid" do
location.postcode = "M1 1AE"
- location.save
+ location.save!
expect(location.errors).to be_empty
end
it "does add an error when the postcode is invalid" do
location.postcode = "invalid"
- location.save
+ location.save!
expect(location.errors).not_to be_empty
expect(location.errors["postcode"]).to include(match I18n.t("validations.postcode"))
end
diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb
index dd7cb73b9..7b36d0d28 100644
--- a/spec/requests/locations_controller_spec.rb
+++ b/spec/requests/locations_controller_spec.rb
@@ -324,7 +324,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a data coordinator" 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
@@ -349,7 +349,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a support user" do
let(:user) { FactoryBot.create(:user, :support) }
let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
- let!(:location) { FactoryBot.create(:location, scheme: scheme) }
+ let!(:location) { FactoryBot.create(:location, scheme:) }
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
@@ -389,7 +389,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a data coordinator" 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:) }
let(:params) { { location: { name: "Test", total_units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No", postcode: "ZZ1 1ZZ" } } }
before do
@@ -502,7 +502,7 @@ RSpec.describe LocationsController, type: :request do
context "when signed in as a support 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:) }
let(:params) { { location: { name: "Test", total_units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No", postcode: "ZZ1 1ZZ" } } }
before do