Browse Source

Rename org_type column

pull/127/head
Kat 4 years ago
parent
commit
f0083b7ac8
  1. 4
      app/admin/organisations.rb
  2. 2
      app/constants/db_enums.rb
  3. 2
      app/models/case_log.rb
  4. 2
      app/models/organisation.rb
  5. 5
      db/migrate/20211201144335_rename_org_type.rb
  6. 4
      db/schema.rb
  7. 2
      spec/controllers/admin/organisations_controller_spec.rb
  8. 2
      spec/factories/organisation.rb
  9. 2
      spec/models/case_log_spec.rb
  10. 2
      spec/models/organisation_spec.rb

4
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

2
app/constants/db_enums.rb

@ -741,7 +741,7 @@ module DbEnums
}
end
def self.org_type
def self.providertype
{
"LA" => 1,
"PRP" => 2,

2
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?

2
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)

5
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

4
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"

2
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

2
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" }

2
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,

2
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

Loading…
Cancel
Save