@ -2836,8 +2836,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 )
@ -2852,7 +2853,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 )
@ -2860,7 +2861,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 )
@ -2868,7 +2869,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 )
@ -2876,7 +2877,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 )
@ -2884,7 +2885,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 )
@ -2892,7 +2893,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 )
@ -2900,7 +2901,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 )
@ -2908,7 +2909,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 )
@ -2916,7 +2917,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 )
@ -2925,7 +2926,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 )
@ -2934,7 +2935,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 )
@ -2946,8 +2947,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 )