Browse Source

Remove duplicate_logs_for_organisation

pull/1762/head
Kat 3 years ago
parent
commit
716bb64246
  1. 1
      app/models/lettings_log.rb
  2. 1
      app/models/sales_log.rb
  3. 18
      spec/models/lettings_log_spec.rb
  4. 16
      spec/models/sales_log_spec.rb

1
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.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) .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 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 OPTIONAL_FIELDS = %w[first_time_property_let_as_social_housing tenancycode propcode chcharge].freeze

1
app/models/sales_log.rb

@ -47,7 +47,6 @@ class SalesLog < Log
.where.not(status: "deleted") .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") .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 OPTIONAL_FIELDS = %w[purchid othtype].freeze
RETIREMENT_AGES = { "M" => 65, "F" => 60, "X" => 65 }.freeze RETIREMENT_AGES = { "M" => 65, "F" => 60, "X" => 65 }.freeze

18
spec/models/lettings_log_spec.rb

@ -2921,24 +2921,6 @@ RSpec.describe LettingsLog do
end end
end 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 end
describe "#retirement_age_for_person" do describe "#retirement_age_for_person" do

16
spec/models/sales_log_spec.rb

@ -251,22 +251,6 @@ RSpec.describe SalesLog, type: :model do
end end
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 describe "derived variables" do
let(:sales_log) { create(:sales_log, :completed) } let(:sales_log) { create(:sales_log, :completed) }

Loading…
Cancel
Save