diff --git a/Gemfile b/Gemfile index 678b45a..87b4aff 100644 --- a/Gemfile +++ b/Gemfile @@ -40,6 +40,8 @@ group :development do gem 'rubocop' gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' + # annotate + gem 'annotate' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index b57bf72..0c4c380 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -56,6 +56,9 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 2.1, >= 2.1.8) + annotate (3.0.3) + activerecord (>= 3.2, < 7.0) + rake (>= 10.4, < 14.0) ast (2.4.0) bcrypt (3.1.13) bootsnap (1.4.5) @@ -225,6 +228,7 @@ PLATFORMS ruby DEPENDENCIES + annotate bootsnap (>= 1.4.2) byebug database_cleaner diff --git a/app/models/flowchart.rb b/app/models/flowchart.rb index ba010b9..82a2650 100644 --- a/app/models/flowchart.rb +++ b/app/models/flowchart.rb @@ -1,5 +1,19 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: flowcharts +# +# id :bigint not null, primary key +# title :string not null +# description :string not null +# height :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# root_id :bigint +# deleted :boolean default(FALSE), not null +# + class Flowchart < ApplicationRecord validates :title, presence: true validates :description, presence: true diff --git a/app/models/flowchart_node.rb b/app/models/flowchart_node.rb index 8dea4b8..1c7859e 100644 --- a/app/models/flowchart_node.rb +++ b/app/models/flowchart_node.rb @@ -1,5 +1,23 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: flowchart_nodes +# +# id :bigint not null, primary key +# text :string not null +# header :string not null +# button_text :string +# next_question :string +# child_id :bigint +# sibling_id :bigint +# is_root :boolean not null +# flowchart_id :bigint not null +# created_at :datetime not null +# updated_at :datetime not null +# deleted :boolean default(FALSE), not null +# + class FlowchartNode < ApplicationRecord belongs_to :flowchart validates :text, presence: true diff --git a/app/models/question.rb b/app/models/question.rb index 55910d0..12e85b7 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -1,4 +1,13 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: questions +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# + class Question < ApplicationRecord end diff --git a/app/models/user.rb b/app/models/user.rb index add9314..cf7c5e9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,17 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: users +# +# id :bigint not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# created_at :datetime not null +# updated_at :datetime not null +# jti :string not null +# + class User < ApplicationRecord include Devise::JWT::RevocationStrategies::JTIMatcher devise :database_authenticatable, :validatable, :rememberable, diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake new file mode 100644 index 0000000..7cece0b --- /dev/null +++ b/lib/tasks/auto_annotate_models.rake @@ -0,0 +1,59 @@ +# 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 do + # You can override any of these by setting an environment variable of the + # same name. + Annotate.set_defaults( + '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_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/factories/users.rb b/spec/factories/users.rb index 32033ed..d6c068d 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,5 +1,17 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: users +# +# id :bigint not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# created_at :datetime not null +# updated_at :datetime not null +# jti :string not null +# + FactoryBot.define do factory :user do end diff --git a/spec/models/flowchart_spec.rb b/spec/models/flowchart_spec.rb index e65831d..16920f4 100644 --- a/spec/models/flowchart_spec.rb +++ b/spec/models/flowchart_spec.rb @@ -1,5 +1,19 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: flowcharts +# +# id :bigint not null, primary key +# title :string not null +# description :string not null +# height :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# root_id :bigint +# deleted :boolean default(FALSE), not null +# + require 'rails_helper' RSpec.describe Flowchart, type: :model do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9e91d38..75933df 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,5 +1,17 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: users +# +# id :bigint not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# created_at :datetime not null +# updated_at :datetime not null +# jti :string not null +# + require 'rails_helper' RSpec.describe User, type: :model do diff --git a/test/models/question_test.rb b/test/models/question_test.rb index 8a14cbb..b8afa60 100644 --- a/test/models/question_test.rb +++ b/test/models/question_test.rb @@ -1,5 +1,14 @@ # frozen_string_literal: true +# == Schema Information +# +# Table name: questions +# +# id :bigint not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class QuestionTest < ActiveSupport::TestCase