diff --git a/.rubocop.yml b/.rubocop.yml index 47498329c..088cfb508 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -388,6 +388,9 @@ Rails/DynamicFindBy: - find_by_slug_or_id! - find_by_manager_login +Rails/EnumSyntax: + Enabled: true + Rails/EnumUniqueness: Enabled: true diff --git a/app/models/dashboard/action.rb b/app/models/dashboard/action.rb index cfac18315..bd8391ecb 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, :resource] validates :title, presence: true, allow_blank: false, length: { in: 4..80 } diff --git a/app/models/poll/shift.rb b/app/models/poll/shift.rb index 452eb8b45..8bae96426 100644 --- a/app/models/poll/shift.rb +++ b/app/models/poll/shift.rb @@ -8,7 +8,7 @@ class Poll validates :date, presence: true, uniqueness: { scope: [:officer_id, :booth_id, :task] } validates :task, presence: true - enum task: { vote_collection: 0, recount_scrutiny: 1 } + enum :task, { vote_collection: 0, recount_scrutiny: 1 } scope :current, -> { where(date: Date.current) } diff --git a/app/models/progress_bar.rb b/app/models/progress_bar.rb index c966f6c9f..8852b6549 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, %i[primary secondary] belongs_to :progressable, polymorphic: true diff --git a/app/models/sdg/phase.rb b/app/models/sdg/phase.rb index 3796dcf21..3108c06a8 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, %w[sensitization planning monitoring] validates :kind, presence: true, uniqueness: true def self.[](kind) diff --git a/app/models/tenant.rb b/app/models/tenant.rb index e39d3cd9c..f03136b98 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, %w[subdomain domain] validates :schema, presence: true, diff --git a/app/models/votation_type.rb b/app/models/votation_type.rb index 00fca0ecf..de1fac364 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, %w[unique multiple] validates :questionable, presence: true validates :questionable_type, inclusion: { in: ->(*) { QUESTIONABLE_TYPES }}