Rubocop tests

This commit is contained in:
Karel Pičman 2023-05-22 10:34:34 +02:00
parent 3e432ecd6d
commit 4b7d972232
2 changed files with 8 additions and 4 deletions

View File

@ -56,5 +56,9 @@ Metrics/CyclomaticComplexity:
Rails/HasAndBelongsToMany: Rails/HasAndBelongsToMany:
Enabled: false Enabled: false
Rails/SkipsModelValidations:
Exclude:
- db/migrate/20210210144000_change_default_active_boolean_value_to_custom_workflows.rb
Style/ExpandPathArguments: Style/ExpandPathArguments:
Enabled: false Enabled: false

View File

@ -25,15 +25,15 @@ class ChangeDefaultActiveBooleanValueToCustomWorkflows < ActiveRecord::Migration
return unless ActiveRecord::Base.connection.adapter_name.match?(/sqlite/i) return unless ActiveRecord::Base.connection.adapter_name.match?(/sqlite/i)
change_column_default :custom_workflows, :active, from: true, to: 1 change_column_default :custom_workflows, :active, from: true, to: 1
CustomWorkflow.where(active: 't').each { |w| w.update(active: 1) } CustomWorkflow.where(active: 't').update_all active: 1
CustomWorkflow.where(active: 'f').each { |w| w.update(active: 0) } CustomWorkflow.where(active: 'f').update_all active: 0
end end
def down def down
return unless ActiveRecord::Base.connection.adapter_name.match?(/sqlite/i) return unless ActiveRecord::Base.connection.adapter_name.match?(/sqlite/i)
change_column_default :custom_workflows, :active, from: 1, to: true change_column_default :custom_workflows, :active, from: 1, to: true
CustomWorkflow.where(active: 1).each { |w| w.update(active: 't') } CustomWorkflow.where(active: 1).update_all active: 't'
CustomWorkflow.where(active: 0).each { |w| w.update(active: 'f') } CustomWorkflow.where(active: 0).update_all active: 'f'
end end
end end