diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 382ed583c..c818b0c32 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -568,7 +568,7 @@ private def format_postcode(value) value = value.upcase.gsub(/\s+/, "") - value.length == 5 ? value= value.insert(2, ' ') : value= value.insert(3, ' ') + value = value.length == 5 ? value.insert(2, " ") : value.insert(3, " ") value.strip end diff --git a/app/models/form.rb b/app/models/form.rb index 7ea8ff47e..57b529f10 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -178,6 +178,5 @@ class Form end end end - end end diff --git a/spec/features/form/postcode_format_spec.rb b/spec/features/form/postcode_format_spec.rb index b9ff03f8a..eca14ae40 100644 --- a/spec/features/form/postcode_format_spec.rb +++ b/spec/features/form/postcode_format_spec.rb @@ -2,26 +2,23 @@ require "rails_helper" require_relative "helpers" RSpec.describe "Postcode formatting" do - include Helpers - include Form::Setup - let(:user) { FactoryBot.create(:user) } - let(:case_log) do - FactoryBot.create( - :case_log, - :in_progress, - owning_organisation: user.organisation, - managing_organisation: user.organisation, - ) - end - let(:id) { case_log.id } - let(:validator) { case_log._validators[nil].first } - - before do - sign_in user - end + include Helpers + let(:user) { FactoryBot.create(:user) } + let(:case_log) do + FactoryBot.create( + :case_log, + :in_progress, + owning_organisation: user.organisation, + managing_organisation: user.organisation, + ) + end + let(:id) { case_log.id } + before do + sign_in user + end -context "when a postcode is input" do + context "when a postcode is input" do # it "for a 6 character postcode a space will be after the third character" do # visit("/logs/#{id}/property-postcode") # fill_in("case-log-postcode-full-field", with: "aa11aa") @@ -30,13 +27,12 @@ context "when a postcode is input" do # expect(page).to have_text("AA1 1AA") # end - it "for a 5 character postcode a space will be after the second character" do visit("/logs/#{id}/property-postcode") - fill_in("case-log-postcode-full-field", with: "a99aa") + fill_in("case-log-postcode-full-field", with: "a9 9aa") click_button("Save and continue") visit("/logs/#{id}/property-information/check-answers") expect(page).to have_text("A9 9AA") end end -end \ No newline at end of file +end