Browse Source

CLDC-3768: Call process_postcode_changes when setting postcode_full from postcode_full_input (#2803)

pull/2764/head^2
Rachael Booth 2 months ago committed by GitHub
parent
commit
4d14d4bbcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      app/models/log.rb
  2. 12
      spec/models/lettings_log_spec.rb
  3. 12
      spec/models/sales_log_spec.rb

1
app/models/log.rb

@ -111,6 +111,7 @@ class Log < ApplicationRecord
self.town_or_city = nil
self.county = nil
self.postcode_full = postcode_full_input
process_postcode_changes!
else
self.uprn = uprn_selection
self.uprn_confirmed = 1

12
spec/models/lettings_log_spec.rb

@ -2021,5 +2021,17 @@ RSpec.describe LettingsLog do
end
end
end
describe "#process_address_change!" do
context "when uprn_selection is uprn_not_listed" do
let(:log) { build(:lettings_log, uprn_selection: "uprn_not_listed", address_line1_input: "Address line 1", postcode_full_input: "AA1 1AA") }
it "sets log address fields, including postcode known" do
expect { log.process_address_change! }.to change(log, :address_line1).from(nil).to("Address line 1")
.and change(log, :postcode_full).from(nil).to("AA1 1AA")
.and change(log, :postcode_known).from(nil).to(1)
end
end
end
end
# rubocop:enable RSpec/MessageChain

12
spec/models/sales_log_spec.rb

@ -995,5 +995,17 @@ RSpec.describe SalesLog, type: :model do
expect(sales_log.reload.is_la_inferred).to eq(false)
end
end
describe "#process_address_change!" do
context "when uprn_selection is uprn_not_listed" do
let(:log) { build(:sales_log, uprn_selection: "uprn_not_listed", address_line1_input: "Address line 1", postcode_full_input: "AA1 1AA") }
it "sets log address fields, including postcode known" do
expect { log.process_address_change! }.to change(log, :address_line1).from(nil).to("Address line 1")
.and change(log, :postcode_full).from(nil).to("AA1 1AA")
.and change(log, :pcodenk).from(nil).to(0)
end
end
end
end
# rubocop:enable RSpec/MessageChain

Loading…
Cancel
Save