diff --git a/app/admin/organisations.rb b/app/admin/organisations.rb index 4d24a6c44..50f2893ae 100644 --- a/app/admin/organisations.rb +++ b/app/admin/organisations.rb @@ -17,7 +17,7 @@ ActiveAdmin.register Organisation do selectable_column id_column column :name - column :providertype + column "org_type", :providertype column "Address Line 1", :address_line1 column "Address Line 2", :address_line2 column :postcode diff --git a/app/constants/db_enums.rb b/app/constants/db_enums.rb index d7187ae18..ee5769409 100644 --- a/app/constants/db_enums.rb +++ b/app/constants/db_enums.rb @@ -741,7 +741,7 @@ module DbEnums } end - def self.providertype + def self.org_type { "LA" => 1, "PRP" => 2, diff --git a/app/models/case_log.rb b/app/models/case_log.rb index cc9358467..ea0278cf0 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -192,7 +192,7 @@ private self.incref = 1 if net_income_known == "Prefer not to say" self.hhmemb = other_hhmemb + 1 if other_hhmemb.present? self.renttype = RENT_TYPE_MAPPING[rent_type] - self.lettype = "#{renttype} #{needstype} #{owning_organisation.providertype}" if renttype.present? && needstype.present? && owning_organisation.providertype.present? + self.lettype = "#{renttype} #{needstype} #{owning_organisation.org_type}" if renttype.present? && needstype.present? && owning_organisation.org_type.present? end def all_fields_completed? diff --git a/app/models/organisation.rb b/app/models/organisation.rb index 21b63119f..c550bf375 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -4,13 +4,12 @@ class Organisation < ApplicationRecord has_many :managed_case_logs, class_name: "CaseLog", foreign_key: "managing_organisation_id" include DbEnums - enum providertype: DbEnums.providertype, _suffix: true + enum org_type: DbEnums.org_type, _suffix: true def case_logs CaseLog.for_organisation(self) end - def completed_case_logs case_logs.completed end @@ -28,7 +27,7 @@ class Organisation < ApplicationRecord name: name, address: address_string, telephone_number: phone, - type: providertype, + type: org_type, local_authorities_operated_in: local_authorities, holds_own_stock: holds_own_stock, other_stock_owners: other_stock_owners, diff --git a/spec/factories/organisation.rb b/spec/factories/organisation.rb index 48d7de4ff..74bd0e44a 100644 --- a/spec/factories/organisation.rb +++ b/spec/factories/organisation.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :organisation do name { "DLUHC" } - providertype { "LA" } + org_type { "LA" } address_line1 { "2 Marsham Street" } address_line2 { "London" } postcode { "SW1P 4DF" } diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 6f2e151f2..064429a64 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -838,7 +838,7 @@ RSpec.describe Form, type: :model do describe "derived variables" do require "date" - let(:organisation) { FactoryBot.create(:organisation, providertype: "PRP") } + let(:organisation) { FactoryBot.create(:organisation, org_type: "PRP") } let!(:case_log) do CaseLog.create({ managing_organisation: organisation, diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb index 94c7ac7a2..c5f2aaffc 100644 --- a/spec/models/organisation_spec.rb +++ b/spec/models/organisation_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Organisation, type: :model do let(:organisation) { user.organisation } it "has expected fields" do - expect(organisation.attribute_names).to include("name", "phone", "providertype") + expect(organisation.attribute_names).to include("name", "phone", "org_type") end it "has users" do