|
|
|
|
@ -2831,8 +2831,9 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when filtering duplicate logs" do |
|
|
|
|
let(:log) { create(:lettings_log, :duplicate) } |
|
|
|
|
let!(:duplicate_log) { create(:lettings_log, :duplicate) } |
|
|
|
|
let(:organisation) { create(:organisation) } |
|
|
|
|
let(:log) { create(:lettings_log, :duplicate, owning_organisation: organisation) } |
|
|
|
|
let!(:duplicate_log) { create(:lettings_log, :duplicate, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "returns all duplicate logs for given log" do |
|
|
|
|
expect(described_class.duplicate_logs(log).count).to eq(1) |
|
|
|
|
@ -2847,7 +2848,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a deleted duplicate log" do |
|
|
|
|
let!(:deleted_duplicate_log) { create(:lettings_log, :duplicate, discarded_at: Time.zone.now) } |
|
|
|
|
let!(:deleted_duplicate_log) { create(:lettings_log, :duplicate, discarded_at: Time.zone.now, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return the deleted log as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(log)).not_to include(deleted_duplicate_log) |
|
|
|
|
@ -2855,7 +2856,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with a different start date" do |
|
|
|
|
let!(:different_start_date_log) { create(:lettings_log, :duplicate, startdate: Time.zone.tomorrow) } |
|
|
|
|
let!(:different_start_date_log) { create(:lettings_log, :duplicate, startdate: Time.zone.tomorrow, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return a log with a different start date as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(log)).not_to include(different_start_date_log) |
|
|
|
|
@ -2863,7 +2864,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with a different age1" do |
|
|
|
|
let!(:different_age1) { create(:lettings_log, :duplicate, age1: 50) } |
|
|
|
|
let!(:different_age1) { create(:lettings_log, :duplicate, age1: 50, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return a log with a different age1 as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(log)).not_to include(different_age1) |
|
|
|
|
@ -2871,7 +2872,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with a different sex1" do |
|
|
|
|
let!(:different_sex1) { create(:lettings_log, :duplicate, sex1: "F") } |
|
|
|
|
let!(:different_sex1) { create(:lettings_log, :duplicate, sex1: "F", owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return a log with a different sex1 as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(log)).not_to include(different_sex1) |
|
|
|
|
@ -2879,7 +2880,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with a different ecstat1" do |
|
|
|
|
let!(:different_ecstat1) { create(:lettings_log, :duplicate, ecstat1: 1) } |
|
|
|
|
let!(:different_ecstat1) { create(:lettings_log, :duplicate, ecstat1: 1, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return a log with a different ecstat1 as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(log)).not_to include(different_ecstat1) |
|
|
|
|
@ -2887,7 +2888,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with a different tcharge" do |
|
|
|
|
let!(:different_tcharge) { create(:lettings_log, :duplicate, brent: 100) } |
|
|
|
|
let!(:different_tcharge) { create(:lettings_log, :duplicate, brent: 100, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return a log with a different tcharge as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(log)).not_to include(different_tcharge) |
|
|
|
|
@ -2895,7 +2896,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with a different tenancycode" do |
|
|
|
|
let!(:different_tenancycode) { create(:lettings_log, :duplicate, tenancycode: "different") } |
|
|
|
|
let!(:different_tenancycode) { create(:lettings_log, :duplicate, tenancycode: "different", owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return a log with a different tenancycode as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(log)).not_to include(different_tenancycode) |
|
|
|
|
@ -2903,7 +2904,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with a different postcode_full" do |
|
|
|
|
let!(:different_postcode_full) { create(:lettings_log, :duplicate, postcode_full: "B1 1AA") } |
|
|
|
|
let!(:different_postcode_full) { create(:lettings_log, :duplicate, postcode_full: "B1 1AA", owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return a log with a different postcode_full as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(log)).not_to include(different_postcode_full) |
|
|
|
|
@ -2911,7 +2912,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with nil values for duplicate check fields" do |
|
|
|
|
let!(:duplicate_check_fields_not_given) { create(:lettings_log, :duplicate, age1: nil, sex1: nil, ecstat1: nil, postcode_known: 2, postcode_full: nil) } |
|
|
|
|
let!(:duplicate_check_fields_not_given) { create(:lettings_log, :duplicate, age1: nil, sex1: nil, ecstat1: nil, postcode_known: 2, postcode_full: nil, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "does not return a log with nil values as a duplicate" do |
|
|
|
|
log.update!(age1: nil, sex1: nil, ecstat1: nil, postcode_known: 2, postcode_full: nil) |
|
|
|
|
@ -2920,7 +2921,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with nil values for tenancycode" do |
|
|
|
|
let!(:tenancycode_not_given) { create(:lettings_log, :duplicate, tenancycode: nil) } |
|
|
|
|
let!(:tenancycode_not_given) { create(:lettings_log, :duplicate, tenancycode: nil, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "returns the log as a duplicate if tenancy code is nil" do |
|
|
|
|
log.update!(tenancycode: nil) |
|
|
|
|
@ -2929,7 +2930,7 @@ RSpec.describe LettingsLog do
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there is a log with age1 not known" do |
|
|
|
|
let!(:age1_not_known) { create(:lettings_log, :duplicate, age1_known: 1, age1: nil) } |
|
|
|
|
let!(:age1_not_known) { create(:lettings_log, :duplicate, age1_known: 1, age1: nil, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "returns the log as a duplicate if age1 is not known" do |
|
|
|
|
log.update!(age1_known: 1, age1: nil) |
|
|
|
|
@ -2941,8 +2942,8 @@ RSpec.describe LettingsLog do
|
|
|
|
|
let(:scheme) { create(:scheme) } |
|
|
|
|
let(:location) { create(:location, scheme:) } |
|
|
|
|
let(:location_2) { create(:location, scheme:) } |
|
|
|
|
let(:supported_housing_log) { create(:lettings_log, :duplicate, needstype: 2, location:, scheme:) } |
|
|
|
|
let!(:duplicate_supported_housing_log) { create(:lettings_log, :duplicate, needstype: 2, location:, scheme:) } |
|
|
|
|
let(:supported_housing_log) { create(:lettings_log, :duplicate, needstype: 2, location:, scheme:, owning_organisation: organisation) } |
|
|
|
|
let!(:duplicate_supported_housing_log) { create(:lettings_log, :duplicate, needstype: 2, location:, scheme:, owning_organisation: organisation) } |
|
|
|
|
|
|
|
|
|
it "returns the log as a duplicate" do |
|
|
|
|
expect(described_class.duplicate_logs(supported_housing_log)).to include(duplicate_supported_housing_log) |
|
|
|
|
|