diff --git a/Gemfile b/Gemfile index 6af48e3..91a3d70 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,7 @@ group :development, :test do end group :development do + gem "annotate" gem "graphql_playground-rails" gem "web-console", ">= 4.1.0" diff --git a/Gemfile.lock b/Gemfile.lock index d77b31e..f894b7f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,6 +72,9 @@ GEM momentjs-rails (~> 2.8) sassc-rails (~> 2.1) selectize-rails (~> 0.6) + annotate (3.1.1) + activerecord (>= 3.2, < 7.0) + rake (>= 10.4, < 14.0) ast (2.4.2) bcrypt (3.1.16) bindex (0.8.1) @@ -310,6 +313,7 @@ PLATFORMS DEPENDENCIES administrate + annotate bootsnap (>= 1.4.4) capybara devise diff --git a/app/models/admin_user.rb b/app/models/admin_user.rb index 9380387..3d62e8d 100644 --- a/app/models/admin_user.rb +++ b/app/models/admin_user.rb @@ -1,4 +1,23 @@ # frozen_string_literal: true + +# == Schema Information +# +# Table name: admin_users +# +# id :bigint not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# remember_created_at :datetime +# reset_password_sent_at :datetime +# reset_password_token :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_admin_users_on_email (email) UNIQUE +# index_admin_users_on_reset_password_token (reset_password_token) UNIQUE +# class AdminUser < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable diff --git a/db/schema.rb b/db/schema.rb index 70fae2b..4abad79 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -27,10 +27,4 @@ ActiveRecord::Schema.define(version: 2021_08_03_222524) do t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true end - create_table "customers", force: :cascade do |t| - t.string "name" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - end - end diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake new file mode 100644 index 0000000..9e736fc --- /dev/null +++ b/lib/tasks/auto_annotate_models.rake @@ -0,0 +1,60 @@ +# frozen_string_literal: true +# NOTE: only doing this in development as some production environments (Heroku) +# NOTE: are sensitive to local FS writes, and besides -- it's just not proper +# NOTE: to have a dev-mode tool do its thing in production. +if Rails.env.development? + require "annotate" + task set_annotation_options: :environment do + # You can override any of these by setting an environment variable of the + # same name. + Annotate.set_defaults( + "active_admin" => "false", + "additional_file_patterns" => [], + "routes" => "false", + "models" => "true", + "position_in_routes" => "before", + "position_in_class" => "before", + "position_in_test" => "before", + "position_in_fixture" => "before", + "position_in_factory" => "before", + "position_in_serializer" => "before", + "show_foreign_keys" => "true", + "show_complete_foreign_keys" => "false", + "show_indexes" => "true", + "simple_indexes" => "false", + "model_dir" => "app/models", + "root_dir" => "", + "include_version" => "false", + "require" => "", + "exclude_tests" => "false", + "exclude_fixtures" => "false", + "exclude_factories" => "false", + "exclude_serializers" => "false", + "exclude_scaffolds" => "true", + "exclude_controllers" => "true", + "exclude_helpers" => "true", + "exclude_sti_subclasses" => "false", + "ignore_model_sub_dir" => "false", + "ignore_columns" => nil, + "ignore_routes" => nil, + "ignore_unknown_models" => "false", + "hide_limit_column_types" => "integer,bigint,boolean", + "hide_default_column_types" => "json,jsonb,hstore", + "skip_on_db_migrate" => "false", + "format_bare" => "true", + "format_rdoc" => "false", + "format_yard" => "false", + "format_markdown" => "false", + "sort" => "false", + "force" => "false", + "frozen" => "false", + "classified_sort" => "true", + "trace" => "false", + "wrapper_open" => nil, + "wrapper_close" => nil, + "with_comment" => "true" + ) + end + + Annotate.load_tasks +end diff --git a/spec/models/admin_user_spec.rb b/spec/models/admin_user_spec.rb index cea59fd..a6218ff 100644 --- a/spec/models/admin_user_spec.rb +++ b/spec/models/admin_user_spec.rb @@ -1,4 +1,23 @@ # frozen_string_literal: true + +# == Schema Information +# +# Table name: admin_users +# +# id :bigint not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# remember_created_at :datetime +# reset_password_sent_at :datetime +# reset_password_token :string +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_admin_users_on_email (email) UNIQUE +# index_admin_users_on_reset_password_token (reset_password_token) UNIQUE +# require "rails_helper" RSpec.describe(AdminUser, type: :model) do