Browse Source

CLDC-3768: Call process_postcode_changes when setting postcode_full from postcode_full_input

pull/2803/head
Rachael Booth 7 months ago
parent
commit
232fa6a4bd
  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

@ -2006,5 +2006,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

@ -978,5 +978,17 @@ RSpec.describe SalesLog, type: :model do
end
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