|
|
|
|
@ -1637,8 +1637,12 @@ RSpec.describe LettingsLog, type: :model do
|
|
|
|
|
.and change { log.read_attribute(:county) }.from(county).to(nil) |
|
|
|
|
.and change { log.read_attribute(:postcode_full) }.from(postcode_full).to(nil) |
|
|
|
|
.and change { log.read_attribute(:uprn_selection) }.from(uprn_selection).to(nil) |
|
|
|
|
.and change { log.read_attribute(:postcode_known) }.from(postcode_known).to(nil) |
|
|
|
|
.and change { log.read_attribute(:manual_address_entry_selected) }.from(manual_address_entry_selected).to(nil) |
|
|
|
|
.and(change { log.read_attribute(:postcode_known) }.from(postcode_known).to(nil)) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not reset `manual_address_entry_selected`;" do |
|
|
|
|
expect { log.set_derived_fields! } |
|
|
|
|
.not_to(change { log.read_attribute(:manual_address_entry_selected) }) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the log is a new-build first let" do |
|
|
|
|
@ -1664,8 +1668,12 @@ RSpec.describe LettingsLog, type: :model do
|
|
|
|
|
.and change { log.read_attribute(:county) }.from(county).to(nil) |
|
|
|
|
.and change { log.read_attribute(:postcode_full) }.from(postcode_full).to(nil) |
|
|
|
|
.and change { log.read_attribute(:uprn_selection) }.from(uprn_selection).to(nil) |
|
|
|
|
.and change { log.read_attribute(:postcode_known) }.from(postcode_known).to(nil) |
|
|
|
|
.and change { log.read_attribute(:manual_address_entry_selected) }.from(manual_address_entry_selected).to(nil) |
|
|
|
|
.and(change { log.read_attribute(:postcode_known) }.from(postcode_known).to(nil)) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not reset `manual_address_entry_selected`;" do |
|
|
|
|
expect { log.set_derived_fields! } |
|
|
|
|
.not_to(change { log.read_attribute(:manual_address_entry_selected) }) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
@ -1690,6 +1698,32 @@ RSpec.describe LettingsLog, type: :model do
|
|
|
|
|
.to change(log, :manual_address_entry_selected).from(false).to(true) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when a log is changed from a confidential to a non-confidential scheme" do |
|
|
|
|
# The confidential logic must leave manual_address_entry_selected in a |
|
|
|
|
# routable state (default false), otherwise neither address page routes after the |
|
|
|
|
# switch and the address question is never shown again. |
|
|
|
|
let(:confidential_scheme) { create(:scheme, sensitive: 1) } |
|
|
|
|
let(:non_confidential_scheme) { create(:scheme, sensitive: 0) } |
|
|
|
|
let(:confidential_location) { create(:location, scheme: confidential_scheme) } |
|
|
|
|
let(:non_confidential_location) { create(:location, scheme: non_confidential_scheme) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
log.assign_attributes(manual_address_entry_selected: false) |
|
|
|
|
log.scheme = confidential_scheme |
|
|
|
|
log.location = confidential_location |
|
|
|
|
log.set_derived_fields! |
|
|
|
|
|
|
|
|
|
log.scheme = non_confidential_scheme |
|
|
|
|
log.location = non_confidential_location |
|
|
|
|
log.set_derived_fields! |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "asks the address question again with a routable value for `manual_address_entry_selected` (i.e., not nil)" do |
|
|
|
|
expect(log.is_address_asked?).to be true |
|
|
|
|
expect(log.manual_address_entry_selected).to be false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#infer_at_most_one_relationship!" do |
|
|
|
|
|