Browse Source

Remove enum deprecation warnings

pull/2856/head
Kat 6 months ago
parent
commit
65045f8871
  1. 6
      app/models/bulk_upload.rb
  2. 2
      app/models/csv_download.rb
  3. 6
      app/models/location.rb
  4. 6
      app/models/log.rb
  5. 2
      app/models/merge_request.rb
  6. 2
      app/models/organisation.rb
  7. 18
      app/models/scheme.rb
  8. 2
      app/models/user.rb

6
app/models/bulk_upload.rb

@ -1,7 +1,7 @@
class BulkUpload < ApplicationRecord
enum log_type: { lettings: "lettings", sales: "sales" }
enum rent_type_fix_status: { not_applied: "not_applied", applied: "applied", not_needed: "not_needed" }
enum failure_reason: { blank_template: "blank_template", wrong_template: "wrong_template" }
enum :log_type, { lettings: "lettings", sales: "sales" }
enum :rent_type_fix_status, { not_applied: "not_applied", applied: "applied", not_needed: "not_needed" }
enum :failure_reason, { blank_template: "blank_template", wrong_template: "wrong_template" }
belongs_to :user

2
app/models/csv_download.rb

@ -1,5 +1,5 @@
class CsvDownload < ApplicationRecord
enum download_type: { lettings: "lettings", sales: "sales", schemes: "schemes", locations: "locations", combined: "combined" }
enum :download_type, { lettings: "lettings", sales: "sales", schemes: "schemes", locations: "locations", combined: "combined" }
belongs_to :user
belongs_to :organisation

6
app/models/location.rb

@ -172,7 +172,7 @@ class Location < ApplicationRecord
LOCAL_AUTHORITIES = LocalAuthority.all.map { |la| [la.name, la.code] }.to_h
attribute :local_authorities, :string
enum local_authorities: LOCAL_AUTHORITIES
enum :local_authorities, LOCAL_AUTHORITIES
def self.local_authorities_for_current_year
LocalAuthority.all.active(Time.zone.today).england.map { |la| [la.code, la.name] }.to_h
end
@ -185,7 +185,7 @@ class Location < ApplicationRecord
"Missing": "X",
}.freeze
enum mobility_type: MOBILITY_TYPE
enum :mobility_type, MOBILITY_TYPE
TYPE_OF_UNIT = {
"Bungalow": 6,
@ -196,7 +196,7 @@ class Location < ApplicationRecord
"Shared house or hostel": 4,
}.freeze
enum type_of_unit: TYPE_OF_UNIT
enum :type_of_unit, TYPE_OF_UNIT
def self.find_by_id_on_multiple_fields(id)
return if id.nil?

6
app/models/log.rb

@ -18,14 +18,14 @@ class Log < ApplicationRecord
"pending" => 3,
"deleted" => 4,
}.freeze
enum status: STATUS
enum status_cache: STATUS, _prefix: true
enum :status, STATUS
enum :status_cache, STATUS, _prefix: true
CREATION_METHOD = {
"single log" => 1,
"bulk upload" => 2,
}.freeze
enum creation_method: CREATION_METHOD, _prefix: true
enum :creation_method, CREATION_METHOD, _prefix: true
scope :visible, -> { where(status: %w[not_started in_progress completed]) }
scope :exportable, -> { where(status: %w[not_started in_progress completed deleted]) }

2
app/models/merge_request.rb

@ -15,7 +15,7 @@ class MergeRequest < ApplicationRecord
}.freeze
attribute :status, :string
enum status: STATUS
enum :status, STATUS
scope :not_merged, -> { where(request_merged: [false, nil]) }
scope :merged, -> { where(request_merged: true) }

2
app/models/organisation.rb

@ -53,7 +53,7 @@ class Organisation < ApplicationRecord
PRP: 2,
}.freeze
enum provider_type: PROVIDER_TYPE
enum :provider_type, PROVIDER_TYPE
alias_method :la?, :LA?

18
app/models/scheme.rb

@ -145,7 +145,7 @@ class Scheme < ApplicationRecord
Yes: 1,
}.freeze
enum sensitive: SENSITIVE, _suffix: true
enum :sensitive, SENSITIVE, _suffix: true
REGISTERED_UNDER_CARE_ACT = {
"Yes – registered care home providing nursing care": 4,
@ -154,7 +154,7 @@ class Scheme < ApplicationRecord
"No": 1,
}.freeze
enum registered_under_care_act: REGISTERED_UNDER_CARE_ACT
enum :registered_under_care_act, REGISTERED_UNDER_CARE_ACT
SCHEME_TYPE = {
"Direct Access Hostel": 5,
@ -164,7 +164,7 @@ class Scheme < ApplicationRecord
"Missing": 0,
}.freeze
enum scheme_type: SCHEME_TYPE, _suffix: true
enum :scheme_type, SCHEME_TYPE, _suffix: true
SUPPORT_TYPE = {
"Missing": 0,
@ -175,7 +175,7 @@ class Scheme < ApplicationRecord
"Floating support": 6,
}.freeze
enum support_type: SUPPORT_TYPE, _suffix: true
enum :support_type, SUPPORT_TYPE, _suffix: true
PRIMARY_CLIENT_GROUP = {
"Homeless families with support needs": "O",
@ -197,8 +197,8 @@ class Scheme < ApplicationRecord
"Missing": "X",
}.freeze
enum primary_client_group: PRIMARY_CLIENT_GROUP, _suffix: true
enum secondary_client_group: PRIMARY_CLIENT_GROUP, _suffix: true
enum :primary_client_group, PRIMARY_CLIENT_GROUP, _suffix: true
enum :secondary_client_group, PRIMARY_CLIENT_GROUP, _suffix: true
INTENDED_STAY = {
"Very short stay": "V",
@ -213,8 +213,8 @@ class Scheme < ApplicationRecord
Yes: 1,
}.freeze
enum intended_stay: INTENDED_STAY, _suffix: true
enum has_other_client_group: HAS_OTHER_CLIENT_GROUP, _suffix: true
enum :intended_stay, INTENDED_STAY, _suffix: true
enum :has_other_client_group, HAS_OTHER_CLIENT_GROUP, _suffix: true
ARRANGEMENT_TYPE = {
"The same organisation that owns the housing stock": "D",
@ -226,7 +226,7 @@ class Scheme < ApplicationRecord
DUPLICATE_SCHEME_ATTRIBUTES = %w[scheme_type registered_under_care_act primary_client_group secondary_client_group has_other_client_group support_type intended_stay].freeze
enum arrangement_type: ARRANGEMENT_TYPE, _suffix: true
enum :arrangement_type, ARRANGEMENT_TYPE, _suffix: true
def self.find_by_id_on_multiple_fields(scheme_id, location_id)
return if scheme_id.nil?

2
app/models/user.rb

@ -56,7 +56,7 @@ class User < ApplicationRecord
unassign: "No, unassign the logs",
}.freeze
enum role: ROLES
enum :role, ROLES
scope :search_by_name, ->(name) { where("users.name ILIKE ?", "%#{name}%") }
scope :search_by_email, ->(email) { where("email ILIKE ?", "%#{email}%") }

Loading…
Cancel
Save