From 765d405df1201ce23f78f3d9782cdbecf3ee0e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 19 Jun 2019 03:04:00 +0200 Subject: [PATCH] Use Rails 5 conventions in migrations and models We forgot to add these changes to pull requests which were in development before we upgraded to Rails 5. We're also moving the rubocop rules to the basic files, so we're notified when we inherit from `ActiveRecord::Base`. --- .rubocop.yml | 9 --------- .rubocop_basic.yml | 9 +++++++++ app/models/budget/investment/change_log.rb | 2 +- app/models/download_setting.rb | 2 +- db/migrate/20190312100543_create_download_settings.rb | 2 +- .../20190321144328_add_config_to_download_settings.rb | 2 +- db/migrate/20190408083819_add_actions_to_valuators.rb | 2 +- ...0190423084112_create_budget_investment_change_logs.rb | 2 +- .../20190429214633_add_date_of_birth_to_signatures.rb | 2 +- ...s_to_required_fields_to_verify_in_signature_sheets.rb | 2 +- .../20190430003908_add_postal_code_to_signatures.rb | 2 +- db/schema.rb | 4 ++-- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 07a45ca67..6936f6f78 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -93,18 +93,9 @@ Performance/UnfreezeString: Performance/UriDefaultParser: Enabled: true -Rails/ActionFilter: - Enabled: true - Rails/ActiveSupportAliases: Enabled: true -Rails/ApplicationJob: - Enabled: true - -Rails/ApplicationRecord: - Enabled: true - Rails/Blank: Enabled: true diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 8f5ba639d..41c7a619d 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -38,6 +38,15 @@ Lint/UselessAssignment: Metrics/LineLength: Max: 110 +Rails/ActionFilter: + Enabled: true + +Rails/ApplicationJob: + Enabled: true + +Rails/ApplicationRecord: + Enabled: true + RSpec/NotToNot: Enabled: true diff --git a/app/models/budget/investment/change_log.rb b/app/models/budget/investment/change_log.rb index b2ae65a3e..d93843e26 100644 --- a/app/models/budget/investment/change_log.rb +++ b/app/models/budget/investment/change_log.rb @@ -1,4 +1,4 @@ -class Budget::Investment::ChangeLog < ActiveRecord::Base +class Budget::Investment::ChangeLog < ApplicationRecord belongs_to :author, -> { with_hidden }, class_name: "User", foreign_key: "author_id", required: false validates :old_value, presence: true diff --git a/app/models/download_setting.rb b/app/models/download_setting.rb index 76c7f21c5..0058a2866 100644 --- a/app/models/download_setting.rb +++ b/app/models/download_setting.rb @@ -1,4 +1,4 @@ -class DownloadSetting < ActiveRecord::Base +class DownloadSetting < ApplicationRecord validates :name_model, presence: true validates :name_field, presence: true diff --git a/db/migrate/20190312100543_create_download_settings.rb b/db/migrate/20190312100543_create_download_settings.rb index ab28b09df..91d81e550 100644 --- a/db/migrate/20190312100543_create_download_settings.rb +++ b/db/migrate/20190312100543_create_download_settings.rb @@ -1,4 +1,4 @@ -class CreateDownloadSettings < ActiveRecord::Migration +class CreateDownloadSettings < ActiveRecord::Migration[4.2] def change create_table :download_settings do |t| t.string :name_model, null: false diff --git a/db/migrate/20190321144328_add_config_to_download_settings.rb b/db/migrate/20190321144328_add_config_to_download_settings.rb index 61fddcef3..74c650011 100644 --- a/db/migrate/20190321144328_add_config_to_download_settings.rb +++ b/db/migrate/20190321144328_add_config_to_download_settings.rb @@ -1,4 +1,4 @@ -class AddConfigToDownloadSettings < ActiveRecord::Migration +class AddConfigToDownloadSettings < ActiveRecord::Migration[4.2] def change add_column :download_settings, :config, :integer, default: 0, null: false diff --git a/db/migrate/20190408083819_add_actions_to_valuators.rb b/db/migrate/20190408083819_add_actions_to_valuators.rb index 62f5cf213..47a84a481 100644 --- a/db/migrate/20190408083819_add_actions_to_valuators.rb +++ b/db/migrate/20190408083819_add_actions_to_valuators.rb @@ -1,4 +1,4 @@ -class AddActionsToValuators < ActiveRecord::Migration +class AddActionsToValuators < ActiveRecord::Migration[4.2] def change add_column :valuators, :can_comment, :boolean, default: true add_column :valuators, :can_edit_dossier, :boolean, default: true diff --git a/db/migrate/20190423084112_create_budget_investment_change_logs.rb b/db/migrate/20190423084112_create_budget_investment_change_logs.rb index bd663ef49..af302f4ec 100644 --- a/db/migrate/20190423084112_create_budget_investment_change_logs.rb +++ b/db/migrate/20190423084112_create_budget_investment_change_logs.rb @@ -1,4 +1,4 @@ -class CreateBudgetInvestmentChangeLogs < ActiveRecord::Migration +class CreateBudgetInvestmentChangeLogs < ActiveRecord::Migration[4.2] def change create_table :budget_investment_change_logs do |t| t.integer :investment_id diff --git a/db/migrate/20190429214633_add_date_of_birth_to_signatures.rb b/db/migrate/20190429214633_add_date_of_birth_to_signatures.rb index 51d6e02c3..47dd2eea5 100644 --- a/db/migrate/20190429214633_add_date_of_birth_to_signatures.rb +++ b/db/migrate/20190429214633_add_date_of_birth_to_signatures.rb @@ -1,4 +1,4 @@ -class AddDateOfBirthToSignatures < ActiveRecord::Migration +class AddDateOfBirthToSignatures < ActiveRecord::Migration[4.2] def change add_column :signatures, :date_of_birth, :date end diff --git a/db/migrate/20190429214851_rename_document_numbers_to_required_fields_to_verify_in_signature_sheets.rb b/db/migrate/20190429214851_rename_document_numbers_to_required_fields_to_verify_in_signature_sheets.rb index 7da813a9f..7493a1dcf 100644 --- a/db/migrate/20190429214851_rename_document_numbers_to_required_fields_to_verify_in_signature_sheets.rb +++ b/db/migrate/20190429214851_rename_document_numbers_to_required_fields_to_verify_in_signature_sheets.rb @@ -1,4 +1,4 @@ -class RenameDocumentNumbersToRequiredFieldsToVerifyInSignatureSheets < ActiveRecord::Migration +class RenameDocumentNumbersToRequiredFieldsToVerifyInSignatureSheets < ActiveRecord::Migration[4.2] def change rename_column :signature_sheets, :document_numbers, :required_fields_to_verify end diff --git a/db/migrate/20190430003908_add_postal_code_to_signatures.rb b/db/migrate/20190430003908_add_postal_code_to_signatures.rb index 4d71687c8..beb4f019b 100644 --- a/db/migrate/20190430003908_add_postal_code_to_signatures.rb +++ b/db/migrate/20190430003908_add_postal_code_to_signatures.rb @@ -1,4 +1,4 @@ -class AddPostalCodeToSignatures < ActiveRecord::Migration +class AddPostalCodeToSignatures < ActiveRecord::Migration[4.2] def change add_column :signatures, :postal_code, :string end diff --git a/db/schema.rb b/db/schema.rb index 9d1a28d42..c6d9a6f88 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1460,10 +1460,10 @@ ActiveRecord::Schema.define(version: 20190607160900) do end create_table "signature_sheets", force: :cascade do |t| - t.integer "signable_id" t.string "signable_type" - t.boolean "processed", default: false + t.integer "signable_id" t.text "required_fields_to_verify" + t.boolean "processed", default: false t.integer "author_id" t.datetime "created_at" t.datetime "updated_at"