diff --git a/app/admin/organisations.rb b/app/admin/organisations.rb index bbf9efe90..4d24a6c44 100644 --- a/app/admin/organisations.rb +++ b/app/admin/organisations.rb @@ -2,7 +2,7 @@ ActiveAdmin.register Organisation do permit_params do permitted = %i[name phone - org_type + providertype address_line1 address_line2 postcode @@ -17,7 +17,7 @@ ActiveAdmin.register Organisation do selectable_column id_column column :name - column :org_type + column :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 ee5769409..d7187ae18 100644 --- a/app/constants/db_enums.rb +++ b/app/constants/db_enums.rb @@ -741,7 +741,7 @@ module DbEnums } end - def self.org_type + def self.providertype { "LA" => 1, "PRP" => 2, diff --git a/app/models/case_log.rb b/app/models/case_log.rb index ea0278cf0..cc9358467 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.org_type}" if renttype.present? && needstype.present? && owning_organisation.org_type.present? + self.lettype = "#{renttype} #{needstype} #{owning_organisation.providertype}" if renttype.present? && needstype.present? && owning_organisation.providertype.present? end def all_fields_completed? diff --git a/app/models/organisation.rb b/app/models/organisation.rb index c550bf375..14649f8d7 100644 --- a/app/models/organisation.rb +++ b/app/models/organisation.rb @@ -4,7 +4,7 @@ class Organisation < ApplicationRecord has_many :managed_case_logs, class_name: "CaseLog", foreign_key: "managing_organisation_id" include DbEnums - enum org_type: DbEnums.org_type, _suffix: true + enum providertype: DbEnums.providertype, _suffix: true def case_logs CaseLog.for_organisation(self) diff --git a/db/migrate/20211201144335_rename_org_type.rb b/db/migrate/20211201144335_rename_org_type.rb new file mode 100644 index 000000000..c4a7b6a3e --- /dev/null +++ b/db/migrate/20211201144335_rename_org_type.rb @@ -0,0 +1,5 @@ +class RenameOrgType < ActiveRecord::Migration[6.1] + def change + rename_column :organisations, :org_type, :providertype + end +end diff --git a/db/schema.rb b/db/schema.rb index ce175dafd..c9570f994 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_12_01_114814) do +ActiveRecord::Schema.define(version: 2021_12_01_144335) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -177,7 +177,7 @@ ActiveRecord::Schema.define(version: 2021_12_01_114814) do create_table "organisations", force: :cascade do |t| t.string "name" t.integer "phone" - t.integer "org_type" + t.integer "providertype" t.string "address_line1" t.string "address_line2" t.string "postcode" diff --git a/spec/controllers/admin/organisations_controller_spec.rb b/spec/controllers/admin/organisations_controller_spec.rb index 276742898..2afa99b44 100644 --- a/spec/controllers/admin/organisations_controller_spec.rb +++ b/spec/controllers/admin/organisations_controller_spec.rb @@ -36,7 +36,7 @@ describe Admin::OrganisationsController, type: :controller do it "creates a new admin users" do expect(page).to have_field("organisation_name") - expect(page).to have_field("organisation_org_type") + expect(page).to have_field("organisation_providertype") expect(page).to have_field("organisation_phone") end end diff --git a/spec/factories/organisation.rb b/spec/factories/organisation.rb index 74bd0e44a..48d7de4ff 100644 --- a/spec/factories/organisation.rb +++ b/spec/factories/organisation.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :organisation do name { "DLUHC" } - org_type { "LA" } + providertype { "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 064429a64..6f2e151f2 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, org_type: "PRP") } + let(:organisation) { FactoryBot.create(:organisation, providertype: "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 c5f2aaffc..94c7ac7a2 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", "org_type") + expect(organisation.attribute_names).to include("name", "phone", "providertype") end it "has users" do