Browse Source

lint

pull/781/head
Ted-U 3 years ago
parent
commit
b9405c4472
  1. 2
      app/models/case_log.rb
  2. 1
      app/models/form.rb
  3. 4
      spec/features/form/postcode_format_spec.rb

2
app/models/case_log.rb

@ -568,7 +568,7 @@ private
def format_postcode(value) def format_postcode(value)
value = value.upcase.gsub(/\s+/, "") 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 value.strip
end end

1
app/models/form.rb

@ -178,6 +178,5 @@ class Form
end end
end end
end end
end end
end end

4
spec/features/form/postcode_format_spec.rb

@ -3,7 +3,6 @@ require_relative "helpers"
RSpec.describe "Postcode formatting" do RSpec.describe "Postcode formatting" do
include Helpers include Helpers
include Form::Setup
let(:user) { FactoryBot.create(:user) } let(:user) { FactoryBot.create(:user) }
let(:case_log) do let(:case_log) do
FactoryBot.create( FactoryBot.create(
@ -14,13 +13,11 @@ RSpec.describe "Postcode formatting" do
) )
end end
let(:id) { case_log.id } let(:id) { case_log.id }
let(:validator) { case_log._validators[nil].first }
before do before do
sign_in user sign_in user
end 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 # it "for a 6 character postcode a space will be after the third character" do
# visit("/logs/#{id}/property-postcode") # visit("/logs/#{id}/property-postcode")
@ -30,7 +27,6 @@ context "when a postcode is input" do
# expect(page).to have_text("AA1 1AA") # expect(page).to have_text("AA1 1AA")
# end # end
it "for a 5 character postcode a space will be after the second character" do it "for a 5 character postcode a space will be after the second character" do
visit("/logs/#{id}/property-postcode") visit("/logs/#{id}/property-postcode")
fill_in("case-log-postcode-full-field", with: "a9 9aa") fill_in("case-log-postcode-full-field", with: "a9 9aa")

Loading…
Cancel
Save