From 19e5633e8bdcf3415cdf8561c2950d7e67988f26 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Fri, 3 Dec 2021 11:23:29 +0000 Subject: [PATCH] Domain specific constants (#144) --- app/models/case_log.rb | 2 +- app/models/constants/{db_enums.rb => case_log.rb} | 7 +------ app/models/constants/organisation.rb | 6 ++++++ app/models/organisation.rb | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) rename app/models/constants/{db_enums.rb => case_log.rb} (99%) create mode 100644 app/models/constants/organisation.rb diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 6809d8a9c..08ec3ae3a 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -30,7 +30,7 @@ end class CaseLog < ApplicationRecord include Discard::Model include Validations::SoftValidations - include Constants::DbEnums + include Constants::CaseLog include Constants::IncomeRanges default_scope -> { kept } diff --git a/app/models/constants/db_enums.rb b/app/models/constants/case_log.rb similarity index 99% rename from app/models/constants/db_enums.rb rename to app/models/constants/case_log.rb index e4c5ace27..e7f1b84b2 100644 --- a/app/models/constants/db_enums.rb +++ b/app/models/constants/case_log.rb @@ -1,4 +1,4 @@ -module Constants::DbEnums +module Constants::CaseLog BENEFITCAP = { "Yes - benefit cap" => 5, "Yes - removal of the spare room subsidy" => 4, @@ -676,11 +676,6 @@ module Constants::DbEnums "Supported housing" => 2, }.freeze - ORG_TYPE = { - "LA" => 1, - "PRP" => 2, - }.freeze - LET_TYPE = { "Social Rent General needs PRP" => 1, "Social Rent Supported housing PRP" => 2, diff --git a/app/models/constants/organisation.rb b/app/models/constants/organisation.rb new file mode 100644 index 000000000..2a6501383 --- /dev/null +++ b/app/models/constants/organisation.rb @@ -0,0 +1,6 @@ +module Constants::Organisation + ORG_TYPE = { + "LA" => 1, + "PRP" => 2, + }.freeze +end diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 84ab477bb..efd72bae5 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -3,7 +3,7 @@ class Organisation < ApplicationRecord has_many :owned_case_logs, class_name: "CaseLog", foreign_key: "owning_organisation_id" has_many :managed_case_logs, class_name: "CaseLog", foreign_key: "managing_organisation_id" - include Constants::DbEnums + include Constants::Organisation enum "Org type": ORG_TYPE, _suffix: true def case_logs