diff --git a/.rubocop.yml b/.rubocop.yml index 088cfb508..50a37133e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -388,6 +388,9 @@ Rails/DynamicFindBy: - find_by_slug_or_id! - find_by_manager_login +Rails/EnumHash: + Enabled: true + Rails/EnumSyntax: Enabled: true diff --git a/app/models/dashboard/action.rb b/app/models/dashboard/action.rb index bd8391ecb..ca625a900 100644 --- a/app/models/dashboard/action.rb +++ b/app/models/dashboard/action.rb @@ -9,7 +9,7 @@ class Dashboard::Action < ApplicationRecord class_name: "Dashboard::ExecutedAction" has_many :proposals, through: :executed_actions - enum :action_type, [:proposed_action, :resource] + enum :action_type, { proposed_action: 0, resource: 1 } validates :title, presence: true, allow_blank: false, length: { in: 4..80 } diff --git a/app/models/progress_bar.rb b/app/models/progress_bar.rb index 8852b6549..d79f61b8f 100644 --- a/app/models/progress_bar.rb +++ b/app/models/progress_bar.rb @@ -2,7 +2,7 @@ class ProgressBar < ApplicationRecord self.inheritance_column = nil RANGE = (0..100) - enum :kind, %i[primary secondary] + enum :kind, { primary: 0, secondary: 1 } belongs_to :progressable, polymorphic: true diff --git a/app/models/sdg/phase.rb b/app/models/sdg/phase.rb index 3108c06a8..4a57fb531 100644 --- a/app/models/sdg/phase.rb +++ b/app/models/sdg/phase.rb @@ -1,6 +1,6 @@ class SDG::Phase < ApplicationRecord include Cardable - enum :kind, %w[sensitization planning monitoring] + enum :kind, { sensitization: 0, planning: 1, monitoring: 2 } validates :kind, presence: true, uniqueness: true def self.[](kind) diff --git a/app/models/tenant.rb b/app/models/tenant.rb index f03136b98..6c1bcac80 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -1,5 +1,5 @@ class Tenant < ApplicationRecord - enum :schema_type, %w[subdomain domain] + enum :schema_type, { subdomain: 0, domain: 1 } validates :schema, presence: true, diff --git a/app/models/votation_type.rb b/app/models/votation_type.rb index de1fac364..71d61c62d 100644 --- a/app/models/votation_type.rb +++ b/app/models/votation_type.rb @@ -3,7 +3,7 @@ class VotationType < ApplicationRecord QUESTIONABLE_TYPES = %w[Poll::Question].freeze - enum :vote_type, %w[unique multiple] + enum :vote_type, { unique: 0, multiple: 1 } validates :questionable, presence: true validates :questionable_type, inclusion: { in: ->(*) { QUESTIONABLE_TYPES }}