From 716bb642468db379967f04c8745695dedc4f3407 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 10 Jul 2023 12:09:50 +0100 Subject: [PATCH] Remove duplicate_logs_for_organisation --- app/models/lettings_log.rb | 1 - app/models/sales_log.rb | 1 - spec/models/lettings_log_spec.rb | 18 ------------------ spec/models/sales_log_spec.rb | 16 ---------------- 4 files changed, 36 deletions(-) diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index cd31eb656..971684bbb 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -60,7 +60,6 @@ class LettingsLog < Log .where.not("startdate IS NULL OR age1 IS NULL OR sex1 IS NULL OR ecstat1 IS NULL OR tcharge IS NULL OR postcode_full IS NULL OR propcode IS NULL OR needstype IS NULL") .where("location_id = ? OR needstype = 1", log.location_id) } - scope :duplicate_logs_for_organisation, ->(org, log) { filter_by_organisation(org).duplicate_logs(log) } AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze OPTIONAL_FIELDS = %w[first_time_property_let_as_social_housing tenancycode propcode chcharge].freeze diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 25d37858f..8039d845e 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -47,7 +47,6 @@ class SalesLog < Log .where.not(status: "deleted") .where.not("saledate is NULL OR age1 IS NULL OR sex1 IS NULL OR ecstat1 IS NULL OR postcode_full IS NULL") } - scope :duplicate_logs_for_organisation, ->(org, log) { filter_by_organisation(org).duplicate_logs(log) } OPTIONAL_FIELDS = %w[purchid othtype].freeze RETIREMENT_AGES = { "M" => 65, "F" => 60, "X" => 65 }.freeze diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index 3299bce59..b5b5e99cb 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -2921,24 +2921,6 @@ RSpec.describe LettingsLog do end end end - - context "when filtering duplicate logs for organisation" do - let(:organisation) { create(:organisation) } - let(:log) { create(:lettings_log, :duplicate, owning_organisation: organisation) } - let!(:duplicate_log_same_owning_org) { create(:lettings_log, :duplicate, owning_organisation: organisation) } - let!(:duplicate_log_same_managing_org) { create(:lettings_log, :duplicate, managing_organisation: organisation) } - let!(:duplicate_log_different_org) { create(:lettings_log, :duplicate) } - - it "returns all duplicate logs for given log" do - expect(described_class.duplicate_logs_for_organisation(organisation, log).count).to eq(2) - end - - it "returns duplicate log" do - expect(described_class.duplicate_logs_for_organisation(organisation, log)).to include(duplicate_log_same_owning_org) - expect(described_class.duplicate_logs_for_organisation(organisation, log)).to include(duplicate_log_same_managing_org) - expect(described_class.duplicate_logs_for_organisation(organisation, log)).not_to include(duplicate_log_different_org) - end - end end describe "#retirement_age_for_person" do diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index 39b77ed03..c382c364b 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -251,22 +251,6 @@ RSpec.describe SalesLog, type: :model do end end - context "when filtering duplicate logs for organisation" do - let(:organisation) { create(:organisation) } - let(:log) { create(:sales_log, :duplicate, owning_organisation: organisation) } - let!(:duplicate_log_same_owning_org) { create(:sales_log, :duplicate, owning_organisation: organisation) } - let!(:duplicate_log_different_org) { create(:sales_log, :duplicate) } - - it "returns all duplicate logs for given log" do - expect(described_class.duplicate_logs_for_organisation(organisation, log).count).to eq(1) - end - - it "returns duplicate log" do - expect(described_class.duplicate_logs_for_organisation(organisation, log)).to include(duplicate_log_same_owning_org) - expect(described_class.duplicate_logs_for_organisation(organisation, log)).not_to include(duplicate_log_different_org) - end - end - describe "derived variables" do let(:sales_log) { create(:sales_log, :completed) }