|
|
|
@ -111,44 +111,83 @@ RSpec.describe LettingsLog, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "deriving household member fields" do |
|
|
|
describe "deriving household member fields" do |
|
|
|
before do |
|
|
|
context "when it is 2024", metadata: { year: 24 } do |
|
|
|
log.assign_attributes( |
|
|
|
let(:startdate) { collection_start_date_for_year(2024) } |
|
|
|
relat2: "X", |
|
|
|
|
|
|
|
relat3: "X", |
|
|
|
|
|
|
|
relat4: "X", |
|
|
|
|
|
|
|
relat5: "X", |
|
|
|
|
|
|
|
# relat7 is derived |
|
|
|
|
|
|
|
relat8: "X", |
|
|
|
|
|
|
|
age1: 22, |
|
|
|
|
|
|
|
age2: 16, |
|
|
|
|
|
|
|
age4: 60, |
|
|
|
|
|
|
|
age6: 88, |
|
|
|
|
|
|
|
age7: 14, |
|
|
|
|
|
|
|
age8: 42, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.set_derived_fields! |
|
|
|
before do |
|
|
|
end |
|
|
|
log.assign_attributes( |
|
|
|
|
|
|
|
relat2: "X", |
|
|
|
|
|
|
|
relat3: "C", |
|
|
|
|
|
|
|
relat4: "X", |
|
|
|
|
|
|
|
relat5: "C", |
|
|
|
|
|
|
|
relat7: "C", |
|
|
|
|
|
|
|
relat8: "X", |
|
|
|
|
|
|
|
age1: 22, |
|
|
|
|
|
|
|
age2: 16, |
|
|
|
|
|
|
|
age4: 60, |
|
|
|
|
|
|
|
age6: 88, |
|
|
|
|
|
|
|
age7: 14, |
|
|
|
|
|
|
|
age8: 42, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totchild" do |
|
|
|
log.set_derived_fields! |
|
|
|
expect(log.totchild).to eq 1 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totelder" do |
|
|
|
it "correctly derives totchild" do |
|
|
|
expect(log.totelder).to eq 2 |
|
|
|
expect(log.totchild).to eq 3 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totadult" do |
|
|
|
it "correctly derives totelder" do |
|
|
|
expect(log.totadult).to eq 3 |
|
|
|
expect(log.totelder).to eq 2 |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totadult" do |
|
|
|
|
|
|
|
expect(log.totadult).to eq 3 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives economic status for tenants under 16" do |
|
|
|
it "correctly derives economic status for tenants under 16" do |
|
|
|
expect(log.ecstat7).to eq 9 |
|
|
|
expect(log.ecstat7).to eq 9 |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when it is 2025", metadata: { year: 25 } do |
|
|
|
context "when it is 2025", metadata: { year: 25 } do |
|
|
|
let(:startdate) { collection_start_date_for_year(2025) } |
|
|
|
let(:startdate) { collection_start_date_for_year(2025) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
log.assign_attributes( |
|
|
|
|
|
|
|
relat2: "X", |
|
|
|
|
|
|
|
relat3: "X", |
|
|
|
|
|
|
|
relat4: "X", |
|
|
|
|
|
|
|
relat5: "X", |
|
|
|
|
|
|
|
# relat7 is derived |
|
|
|
|
|
|
|
relat8: "X", |
|
|
|
|
|
|
|
age1: 22, |
|
|
|
|
|
|
|
age2: 16, |
|
|
|
|
|
|
|
age4: 60, |
|
|
|
|
|
|
|
age6: 88, |
|
|
|
|
|
|
|
age7: 14, |
|
|
|
|
|
|
|
age8: 42, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.set_derived_fields! |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totchild" do |
|
|
|
|
|
|
|
expect(log.totchild).to eq 1 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totelder" do |
|
|
|
|
|
|
|
expect(log.totelder).to eq 2 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totadult" do |
|
|
|
|
|
|
|
expect(log.totadult).to eq 3 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives economic status for tenants under 16" do |
|
|
|
|
|
|
|
expect(log.ecstat7).to eq 9 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "does not derive relationship for tenants under 16" do |
|
|
|
it "does not derive relationship for tenants under 16" do |
|
|
|
expect(log.relat7).to be_nil |
|
|
|
expect(log.relat7).to be_nil |
|
|
|
end |
|
|
|
end |
|
|
|
@ -157,6 +196,41 @@ RSpec.describe LettingsLog, type: :model do |
|
|
|
context "when it is 2026", metadata: { year: 26 } do |
|
|
|
context "when it is 2026", metadata: { year: 26 } do |
|
|
|
let(:startdate) { collection_start_date_for_year(2026) } |
|
|
|
let(:startdate) { collection_start_date_for_year(2026) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
log.assign_attributes( |
|
|
|
|
|
|
|
relat2: "X", |
|
|
|
|
|
|
|
relat3: "X", |
|
|
|
|
|
|
|
relat4: "X", |
|
|
|
|
|
|
|
relat5: "X", |
|
|
|
|
|
|
|
# relat7 is derived |
|
|
|
|
|
|
|
relat8: "X", |
|
|
|
|
|
|
|
age1: 22, |
|
|
|
|
|
|
|
age2: 16, |
|
|
|
|
|
|
|
age4: 60, |
|
|
|
|
|
|
|
age6: 88, |
|
|
|
|
|
|
|
age7: 14, |
|
|
|
|
|
|
|
age8: 42, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.set_derived_fields! |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totchild" do |
|
|
|
|
|
|
|
expect(log.totchild).to eq 1 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totelder" do |
|
|
|
|
|
|
|
expect(log.totelder).to eq 2 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives totadult" do |
|
|
|
|
|
|
|
expect(log.totadult).to eq 3 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "correctly derives economic status for tenants under 16" do |
|
|
|
|
|
|
|
expect(log.ecstat7).to eq 9 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "derives relationship for tenants under 16" do |
|
|
|
it "derives relationship for tenants under 16" do |
|
|
|
expect(log.relat7).to eq "X" |
|
|
|
expect(log.relat7).to eq "X" |
|
|
|
end |
|
|
|
end |
|
|
|
|