sorbet-rails 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/ci-master.yml +28 -0
- data/.github/workflows/ci.yml +26 -0
- data/.github/workflows/publish-gem.yml +21 -0
- data/CONTRIBUTING.md +1 -2
- data/Gemfile +7 -9
- data/README.md +7 -3
- data/Rakefile +13 -24
- data/lib/sorbet-rails/active_record_rbi_formatter.rb +12 -9
- data/lib/sorbet-rails/dependent_gem_rbis/activerecord.rbi +4 -0
- data/lib/sorbet-rails/dependent_gem_rbis/parlour.rbi +1 -1
- data/lib/sorbet-rails/gem_plugins/aasm_plugin.rb +50 -0
- data/lib/sorbet-rails/gem_plugins/money_rails_plugin.rb +76 -0
- data/lib/sorbet-rails/job_rbi_formatter.rb +1 -1
- data/lib/sorbet-rails/model_plugins/active_record_serialized_attribute.rb +3 -2
- data/lib/sorbet-rails/model_plugins/base.rb +8 -1
- data/lib/sorbet-rails/model_plugins/custom_finder_methods.rb +1 -1
- data/lib/sorbet-rails/model_plugins/plugins.rb +6 -0
- data/lib/sorbet-rails/railtie.rb +1 -1
- data/lib/sorbet-rails/routes_rbi_formatter.rb +8 -0
- data/lib/sorbet-rails/tasks/rails_rbi.rake +12 -8
- data/sorbet-rails.gemspec +2 -2
- data/spec/bin/run_all_specs.sh +3 -4
- data/spec/bin/run_spec.sh +4 -1
- data/spec/generators/rails-template.rb +3 -20
- data/spec/generators/sorbet_test_cases.rb +17 -4
- data/spec/rails_helper.rb +5 -5
- data/spec/rake_rails_rbi_models_spec.rb +11 -4
- data/spec/sorbet_spec.rb +2 -1
- data/spec/support/v5.2/Gemfile +1 -3
- data/spec/support/v5.2/Gemfile.lock +66 -71
- data/spec/support/v5.2/app/controllers/application_controller.rb +1 -1
- data/spec/support/v5.2/app/mailers/application_mailer.rb +1 -1
- data/spec/support/v5.2/app/mailers/daily_prophet_mailer.rb +1 -1
- data/spec/support/v5.2/app/mailers/hogwarts_acceptance_mailer.rb +1 -1
- data/spec/support/v5.2/app/models/spell_book.rb +1 -1
- data/spec/support/v5.2/app/models/wand.rb +1 -1
- data/spec/support/v5.2/app/models/wizard.rb +1 -1
- data/spec/support/v5.2/config/environments/development.rb +1 -1
- data/spec/support/v5.2/config/environments/production.rb +1 -1
- data/spec/support/v5.2/config/environments/test.rb +1 -1
- data/spec/support/v5.2/config/routes.rb +1 -1
- data/spec/support/v5.2/sorbet_test_cases.rb +17 -4
- data/spec/support/v6.0/Gemfile +1 -1
- data/spec/support/v6.0/Gemfile.lock +81 -85
- data/spec/support/v6.0/app/mailers/application_mailer.rb +1 -1
- data/spec/support/v6.0/config/environments/development.rb +1 -1
- data/spec/support/v6.0/config/environments/test.rb +1 -1
- data/spec/support/v6.0/config/initializers/cookies_serializer.rb +1 -1
- data/spec/support/v6.0/config/initializers/sorbet_rails.rb +1 -1
- data/spec/support/v6.0/config/routes.rb +1 -1
- data/spec/support/v6.0/sorbet_test_cases.rb +17 -4
- data/spec/support/{v5.1 → v6.1}/.gitignore +13 -2
- data/spec/support/{v5.1 → v6.1}/Gemfile +12 -15
- data/spec/support/{v5.1 → v6.1}/Gemfile.lock +87 -59
- data/spec/support/{v5.0 → v6.1}/README.md +0 -0
- data/spec/support/{v5.0 → v6.1}/Rakefile +0 -0
- data/spec/support/{v5.0 → v6.1}/app/assets/config/manifest.js +0 -0
- data/spec/support/{v5.0 → v6.1}/app/assets/images/.keep +0 -0
- data/spec/support/{v5.1 → v6.1}/app/assets/stylesheets/application.css +0 -0
- data/spec/support/{v5.0 → v6.1}/app/controllers/application_controller.rb +1 -2
- data/spec/support/{v5.0 → v6.1}/app/controllers/concerns/.keep +0 -0
- data/spec/support/{v5.0 → v6.1}/app/helpers/application_helper.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/helpers/bar_helper.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/helpers/baz_helper.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/helpers/foo_helper.rb +0 -0
- data/spec/support/v6.1/app/jobs/application_job.rb +8 -0
- data/spec/support/{v5.0 → v6.1}/app/jobs/award_house_point_hourglasses.rb +0 -0
- data/spec/support/{v5.1 → v6.1}/app/mailers/application_mailer.rb +1 -1
- data/spec/support/{v5.0 → v6.1}/app/mailers/daily_prophet_mailer.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/mailers/hogwarts_acceptance_mailer.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/models/application_record.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/models/concerns/.keep +0 -0
- data/spec/support/{v5.0 → v6.1}/app/models/concerns/mythical.rb +0 -0
- data/spec/support/{v5.1 → v6.1}/app/models/headmaster.rb +1 -1
- data/spec/support/{v5.1 → v6.1}/app/models/potion.rb +0 -0
- data/spec/support/{v5.1 → v6.1}/app/models/robe.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/models/school.rb +1 -1
- data/spec/support/{v5.1 → v6.1}/app/models/spell.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/models/spell_book.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/models/squib.rb +0 -0
- data/spec/support/{v5.1 → v6.1}/app/models/subject.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/models/wand.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/models/wizard.rb +2 -1
- data/spec/support/{v5.1 → v6.1}/app/views/layouts/application.html.erb +2 -1
- data/spec/support/{v5.0 → v6.1}/app/views/layouts/mailer.html.erb +0 -0
- data/spec/support/{v5.0 → v6.1}/app/views/layouts/mailer.text.erb +0 -0
- data/spec/support/v6.1/bin/bundle +114 -0
- data/spec/support/{v5.0 → v6.1}/bin/rails +0 -0
- data/spec/support/{v5.0 → v6.1}/bin/rake +0 -0
- data/spec/support/{v5.1 → v6.1}/bin/setup +6 -11
- data/spec/support/{v5.1 → v6.1}/config/application.rb +8 -4
- data/spec/support/{v5.0 → v6.1}/config/boot.rb +0 -0
- data/spec/support/{v5.1 → v6.1}/config/database.yml +1 -1
- data/spec/support/{v5.0 → v6.1}/config/environment.rb +0 -0
- data/spec/support/{v5.1 → v6.1}/config/environments/development.rb +12 -4
- data/spec/support/{v5.1 → v6.1}/config/environments/production.rb +29 -7
- data/spec/support/{v5.1 → v6.1}/config/environments/test.rb +13 -7
- data/spec/support/{v5.0 → v6.1}/config/initializers/application_controller_renderer.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/support/v6.1/config/initializers/content_security_policy.rb +29 -0
- data/spec/support/{v5.1 → v6.1}/config/initializers/cookies_serializer.rb +1 -1
- data/spec/support/{v5.0 → v6.1}/config/initializers/filter_parameter_logging.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/config/initializers/inflections.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/config/initializers/mime_types.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/config/initializers/sorbet_rails.rb +1 -1
- data/spec/support/{v5.0 → v6.1}/config/initializers/wrap_parameters.rb +0 -0
- data/spec/support/{v5.1 → v6.1}/config/locales/en.yml +1 -1
- data/spec/support/{v5.1 → v6.1}/config/puma.rb +8 -26
- data/spec/support/v6.1/config/routes.rb +5 -0
- data/spec/support/v6.1/config/storage.yml +34 -0
- data/spec/support/{v5.0 → v6.1}/config.ru +0 -0
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000001_create_wizards.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000002_create_wands.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000003_create_spell_books.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000004_add_more_column_types_to_wands.rb +2 -2
- data/spec/support/v6.1/db/migrate/20190620000005_add_broom_to_wizard.rb +6 -0
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000006_add_more_enums_to_wizard.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000007_add_type_to_wizard.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000008_add_robe_to_wizard.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000009_add_school.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000010_add_subject.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000011_add_subjects_wizards.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000012_add_spell.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/migrate/20190620000013_add_spells_spell_books.rb +2 -2
- data/spec/support/{v5.0 → v6.1}/db/migrate/20190620000014_create_headmasters.rb +2 -2
- data/spec/support/{v5.0 → v6.1}/db/migrate/20190620000015_add_serialized_to_wizards.rb +2 -2
- data/spec/support/{v5.1 → v6.1}/db/schema.rb +14 -11
- data/spec/support/{v5.0 → v6.1}/db/seeds.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/lib/assets/.keep +0 -0
- data/spec/support/{v5.0 → v6.1}/lib/mythical_rbi_plugin.rb +0 -0
- data/spec/support/{v5.0 → v6.1}/lib/tasks/.keep +0 -0
- data/spec/support/{v5.0 → v6.1}/log/.keep +0 -0
- data/spec/support/{v5.0 → v6.1}/sorbet_test_cases.rb +17 -4
- data/spec/support/{v5.0/tmp → v6.1/storage}/.keep +0 -0
- data/spec/support/{v5.0/vendor/assets/stylesheets → v6.1/tmp}/.keep +0 -0
- data/spec/support/{v5.1/app/assets/images → v6.1/tmp/pids}/.keep +0 -0
- data/spec/support/{v5.1/app/controllers/concerns → v6.1/vendor}/.keep +0 -0
- data/spec/test_data/v5.2/expected_active_record_base.rbi +10 -10
- data/spec/test_data/v5.2/expected_active_record_relation.rbi +10 -10
- data/spec/test_data/v5.2/expected_attachment.rbi +1 -1
- data/spec/test_data/v5.2/expected_blob.rbi +1 -1
- data/spec/test_data/v5.2/expected_headmaster.rbi +1 -1
- data/spec/test_data/v5.2/expected_internal_metadata.rbi +1 -1
- data/spec/test_data/v5.2/expected_potion.rbi +1 -1
- data/spec/test_data/v5.2/expected_robe.rbi +1 -1
- data/spec/test_data/v5.2/expected_routes.rbi +8 -0
- data/spec/test_data/v5.2/expected_schema_migration.rbi +1 -1
- data/spec/test_data/v5.2/expected_school.rbi +1 -1
- data/spec/test_data/v5.2/expected_spell/habtm_spell_books.rbi +1 -1
- data/spec/test_data/v5.2/expected_spell.rbi +1 -1
- data/spec/test_data/v5.2/expected_spell_book/habtm_spells.rbi +1 -1
- data/spec/test_data/v5.2/expected_spell_book.rbi +1 -1
- data/spec/test_data/v5.2/expected_squib.rbi +3 -3
- data/spec/test_data/v5.2/expected_subject/habtm_wizards.rbi +1 -1
- data/spec/test_data/v5.2/expected_subject.rbi +1 -1
- data/spec/test_data/v5.2/expected_wand.rbi +1 -1
- data/spec/test_data/v5.2/expected_wizard/habtm_subjects.rbi +1 -1
- data/spec/test_data/v5.2/expected_wizard.rbi +3 -3
- data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +3 -3
- data/spec/test_data/v6.0/expected_active_record_base.rbi +10 -10
- data/spec/test_data/v6.0/expected_active_record_relation.rbi +10 -10
- data/spec/test_data/v6.0/expected_attachment.rbi +1 -1
- data/spec/test_data/v6.0/expected_blob.rbi +1 -1
- data/spec/test_data/v6.0/expected_headmaster.rbi +1 -1
- data/spec/test_data/v6.0/expected_internal_metadata.rbi +1 -1
- data/spec/test_data/v6.0/expected_potion.rbi +1 -1
- data/spec/test_data/v6.0/expected_robe.rbi +1 -1
- data/spec/test_data/v6.0/expected_routes.rbi +8 -0
- data/spec/test_data/v6.0/expected_schema_migration.rbi +1 -1
- data/spec/test_data/v6.0/expected_school.rbi +1 -1
- data/spec/test_data/v6.0/expected_spell/habtm_spell_books.rbi +1 -1
- data/spec/test_data/v6.0/expected_spell.rbi +1 -1
- data/spec/test_data/v6.0/expected_spell_book/habtm_spells.rbi +1 -1
- data/spec/test_data/v6.0/expected_spell_book.rbi +1 -1
- data/spec/test_data/v6.0/expected_squib.rbi +3 -3
- data/spec/test_data/v6.0/expected_subject/habtm_wizards.rbi +1 -1
- data/spec/test_data/v6.0/expected_subject.rbi +1 -1
- data/spec/test_data/v6.0/expected_wand.rbi +1 -1
- data/spec/test_data/v6.0/expected_wizard/habtm_subjects.rbi +1 -1
- data/spec/test_data/v6.0/expected_wizard.rbi +3 -3
- data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +3 -3
- data/spec/test_data/{v5.1 → v6.1}/expected_active_record_base.rbi +16 -16
- data/spec/test_data/{v5.1 → v6.1}/expected_active_record_relation.rbi +26 -29
- data/spec/test_data/{v5.0 → v6.1}/expected_application_job.rbi +0 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_application_mailer.rbi +0 -0
- data/spec/test_data/v6.1/expected_attachment.rbi +328 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_award_house_point_hourglasses.rbi +0 -0
- data/spec/test_data/v6.1/expected_blob.rbi +376 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_custom_application_job.rbi +0 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_custom_application_mailer.rbi +0 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_custom_award_house_point_hourglasses.rbi +0 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_custom_daily_prophet_mailer.rbi +0 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_custom_hogwarts_acceptance_mailer.rbi +0 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_daily_prophet_mailer.rbi +0 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_habtm_subjects.rbi +48 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_habtm_wizards.rbi +48 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_headmaster.rbi +25 -1
- data/spec/test_data/{v5.0 → v6.1}/expected_helpers.rbi +0 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_helpers_with_application_and_devise_helpers.rbi +0 -0
- data/spec/test_data/{v5.0 → v6.1}/expected_hogwarts_acceptance_mailer.rbi +0 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_internal_metadata.rbi +25 -1
- data/spec/test_data/{v5.0 → v6.1}/expected_no_routes.rbi +0 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_potion.rbi +25 -1
- data/spec/test_data/v6.1/expected_record.rbi +289 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_robe.rbi +25 -1
- data/spec/test_data/v6.1/expected_routes.rbi +175 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_schema_migration.rbi +25 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_school.rbi +25 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_spell/habtm_spell_books.rbi +25 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_spell.rbi +25 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_spell_book/habtm_spell_books.rbi +48 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_spell_book/habtm_spells.rbi +25 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_spell_book.rbi +61 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_squib.rbi +497 -59
- data/spec/test_data/{v5.0 → v6.1}/expected_srb_tc_output.txt +0 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_subject/habtm_wizards.rbi +25 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_subject.rbi +25 -1
- data/spec/test_data/v6.1/expected_variant_record.rbi +364 -0
- data/spec/test_data/{v5.1 → v6.1}/expected_wand.rbi +91 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_wizard/habtm_subjects.rbi +25 -1
- data/spec/test_data/{v5.1 → v6.1}/expected_wizard.rbi +497 -59
- data/spec/test_data/{v5.1 → v6.1}/expected_wizard_wo_spellbook.rbi +491 -53
- metadata +266 -501
- data/.travis.yml +0 -42
- data/lib/sorbet-rails/type_assert/actionpack.rbi +0 -4
- data/spec/support/v5.0/.gitignore +0 -21
- data/spec/support/v5.0/Gemfile +0 -37
- data/spec/support/v5.0/Gemfile.lock +0 -161
- data/spec/support/v5.0/app/assets/stylesheets/application.css +0 -15
- data/spec/support/v5.0/app/jobs/application_job.rb +0 -3
- data/spec/support/v5.0/app/mailers/application_mailer.rb +0 -5
- data/spec/support/v5.0/app/models/headmaster.rb +0 -8
- data/spec/support/v5.0/app/models/potion.rb +0 -6
- data/spec/support/v5.0/app/models/robe.rb +0 -4
- data/spec/support/v5.0/app/models/spell.rb +0 -5
- data/spec/support/v5.0/app/models/subject.rb +0 -5
- data/spec/support/v5.0/app/views/layouts/application.html.erb +0 -13
- data/spec/support/v5.0/bin/bundle +0 -3
- data/spec/support/v5.0/bin/setup +0 -34
- data/spec/support/v5.0/bin/update +0 -29
- data/spec/support/v5.0/config/application.rb +0 -27
- data/spec/support/v5.0/config/database.yml +0 -25
- data/spec/support/v5.0/config/environments/development.rb +0 -48
- data/spec/support/v5.0/config/environments/production.rb +0 -75
- data/spec/support/v5.0/config/environments/test.rb +0 -43
- data/spec/support/v5.0/config/initializers/cookies_serializer.rb +0 -6
- data/spec/support/v5.0/config/initializers/new_framework_defaults.rb +0 -27
- data/spec/support/v5.0/config/initializers/session_store.rb +0 -4
- data/spec/support/v5.0/config/locales/en.yml +0 -23
- data/spec/support/v5.0/config/puma.rb +0 -48
- data/spec/support/v5.0/config/routes.rb +0 -5
- data/spec/support/v5.0/db/migrate/20190620000001_create_wizards.rb +0 -14
- data/spec/support/v5.0/db/migrate/20190620000002_create_wands.rb +0 -12
- data/spec/support/v5.0/db/migrate/20190620000003_create_spell_books.rb +0 -10
- data/spec/support/v5.0/db/migrate/20190620000004_add_more_column_types_to_wands.rb +0 -17
- data/spec/support/v5.0/db/migrate/20190620000005_add_broom_to_wizard.rb +0 -6
- data/spec/support/v5.0/db/migrate/20190620000006_add_more_enums_to_wizard.rb +0 -9
- data/spec/support/v5.0/db/migrate/20190620000007_add_type_to_wizard.rb +0 -6
- data/spec/support/v5.0/db/migrate/20190620000008_add_robe_to_wizard.rb +0 -8
- data/spec/support/v5.0/db/migrate/20190620000009_add_school.rb +0 -10
- data/spec/support/v5.0/db/migrate/20190620000010_add_subject.rb +0 -8
- data/spec/support/v5.0/db/migrate/20190620000011_add_subjects_wizards.rb +0 -8
- data/spec/support/v5.0/db/migrate/20190620000012_add_spell.rb +0 -8
- data/spec/support/v5.0/db/migrate/20190620000013_add_spells_spell_books.rb +0 -8
- data/spec/support/v5.0/db/schema.rb +0 -96
- data/spec/support/v5.0/public/robots.txt +0 -5
- data/spec/support/v5.1/README.md +0 -24
- data/spec/support/v5.1/Rakefile +0 -6
- data/spec/support/v5.1/app/assets/config/manifest.js +0 -2
- data/spec/support/v5.1/app/controllers/application_controller.rb +0 -4
- data/spec/support/v5.1/app/helpers/application_helper.rb +0 -3
- data/spec/support/v5.1/app/helpers/bar_helper.rb +0 -3
- data/spec/support/v5.1/app/helpers/baz_helper.rb +0 -3
- data/spec/support/v5.1/app/helpers/foo_helper.rb +0 -3
- data/spec/support/v5.1/app/jobs/application_job.rb +0 -3
- data/spec/support/v5.1/app/jobs/award_house_point_hourglasses.rb +0 -12
- data/spec/support/v5.1/app/mailers/daily_prophet_mailer.rb +0 -9
- data/spec/support/v5.1/app/mailers/hogwarts_acceptance_mailer.rb +0 -29
- data/spec/support/v5.1/app/models/application_record.rb +0 -4
- data/spec/support/v5.1/app/models/concerns/.keep +0 -0
- data/spec/support/v5.1/app/models/concerns/mythical.rb +0 -11
- data/spec/support/v5.1/app/models/school.rb +0 -5
- data/spec/support/v5.1/app/models/spell_book.rb +0 -18
- data/spec/support/v5.1/app/models/squib.rb +0 -6
- data/spec/support/v5.1/app/models/wand.rb +0 -19
- data/spec/support/v5.1/app/models/wizard.rb +0 -65
- data/spec/support/v5.1/app/views/layouts/mailer.html.erb +0 -13
- data/spec/support/v5.1/app/views/layouts/mailer.text.erb +0 -1
- data/spec/support/v5.1/bin/bundle +0 -3
- data/spec/support/v5.1/bin/rails +0 -4
- data/spec/support/v5.1/bin/rake +0 -4
- data/spec/support/v5.1/bin/update +0 -29
- data/spec/support/v5.1/bin/yarn +0 -11
- data/spec/support/v5.1/config/boot.rb +0 -4
- data/spec/support/v5.1/config/environment.rb +0 -6
- data/spec/support/v5.1/config/initializers/application_controller_renderer.rb +0 -9
- data/spec/support/v5.1/config/initializers/backtrace_silencers.rb +0 -8
- data/spec/support/v5.1/config/initializers/filter_parameter_logging.rb +0 -5
- data/spec/support/v5.1/config/initializers/inflections.rb +0 -17
- data/spec/support/v5.1/config/initializers/mime_types.rb +0 -5
- data/spec/support/v5.1/config/initializers/sorbet_rails.rb +0 -3
- data/spec/support/v5.1/config/initializers/wrap_parameters.rb +0 -15
- data/spec/support/v5.1/config/routes.rb +0 -5
- data/spec/support/v5.1/config.ru +0 -5
- data/spec/support/v5.1/db/migrate/20190620000005_add_broom_to_wizard.rb +0 -6
- data/spec/support/v5.1/db/migrate/20190620000014_create_headmasters.rb +0 -9
- data/spec/support/v5.1/db/migrate/20190620000015_add_serialized_to_wizards.rb +0 -9
- data/spec/support/v5.1/db/seeds.rb +0 -8
- data/spec/support/v5.1/lib/assets/.keep +0 -0
- data/spec/support/v5.1/lib/mythical_rbi_plugin.rb +0 -16
- data/spec/support/v5.1/lib/tasks/.keep +0 -0
- data/spec/support/v5.1/log/.keep +0 -0
- data/spec/support/v5.1/package.json +0 -5
- data/spec/support/v5.1/public/robots.txt +0 -1
- data/spec/support/v5.1/sorbet_test_cases.rb +0 -409
- data/spec/support/v5.1/tmp/.keep +0 -0
- data/spec/support/v5.1/vendor/.keep +0 -0
- data/spec/test_data/v5.0/expected_active_record_base.rbi +0 -113
- data/spec/test_data/v5.0/expected_active_record_relation.rbi +0 -198
- data/spec/test_data/v5.0/expected_habtm_subjects.rbi +0 -660
- data/spec/test_data/v5.0/expected_habtm_wizards.rbi +0 -660
- data/spec/test_data/v5.0/expected_headmaster.rbi +0 -328
- data/spec/test_data/v5.0/expected_internal_metadata.rbi +0 -298
- data/spec/test_data/v5.0/expected_potion.rbi +0 -280
- data/spec/test_data/v5.0/expected_robe.rbi +0 -301
- data/spec/test_data/v5.0/expected_routes.rbi +0 -27
- data/spec/test_data/v5.0/expected_schema_migration.rbi +0 -271
- data/spec/test_data/v5.0/expected_school.rbi +0 -301
- data/spec/test_data/v5.0/expected_spell/habtm_spell_books.rbi +0 -319
- data/spec/test_data/v5.0/expected_spell.rbi +0 -292
- data/spec/test_data/v5.0/expected_spell_book/habtm_spell_books.rbi +0 -637
- data/spec/test_data/v5.0/expected_spell_book/habtm_spells.rbi +0 -319
- data/spec/test_data/v5.0/expected_spell_book.rbi +0 -415
- data/spec/test_data/v5.0/expected_squib.rbi +0 -832
- data/spec/test_data/v5.0/expected_subject/habtm_wizards.rbi +0 -319
- data/spec/test_data/v5.0/expected_subject.rbi +0 -292
- data/spec/test_data/v5.0/expected_wand.rbi +0 -497
- data/spec/test_data/v5.0/expected_wizard/habtm_subjects.rbi +0 -319
- data/spec/test_data/v5.0/expected_wizard.rbi +0 -908
- data/spec/test_data/v5.0/expected_wizard_wo_spellbook.rbi +0 -902
- data/spec/test_data/v5.1/expected_application_job.rbi +0 -20
- data/spec/test_data/v5.1/expected_application_mailer.rbi +0 -5
- data/spec/test_data/v5.1/expected_award_house_point_hourglasses.rbi +0 -20
- data/spec/test_data/v5.1/expected_custom_application_job.rbi +0 -21
- data/spec/test_data/v5.1/expected_custom_application_mailer.rbi +0 -6
- data/spec/test_data/v5.1/expected_custom_award_house_point_hourglasses.rbi +0 -21
- data/spec/test_data/v5.1/expected_custom_daily_prophet_mailer.rbi +0 -8
- data/spec/test_data/v5.1/expected_custom_hogwarts_acceptance_mailer.rbi +0 -21
- data/spec/test_data/v5.1/expected_daily_prophet_mailer.rbi +0 -7
- data/spec/test_data/v5.1/expected_helpers.rbi +0 -27
- data/spec/test_data/v5.1/expected_helpers_with_application_and_devise_helpers.rbi +0 -34
- data/spec/test_data/v5.1/expected_hogwarts_acceptance_mailer.rbi +0 -20
- data/spec/test_data/v5.1/expected_no_routes.rbi +0 -4
- data/spec/test_data/v5.1/expected_routes.rbi +0 -27
- data/spec/test_data/v5.1/expected_srb_tc_output.txt +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19c59c20c90b7bc42d394b78ba48351d8e39c0721707e8463e337ca8141efe0b
|
4
|
+
data.tar.gz: 30e0524281e51eb3614c346dbb67d966df524c7b2873b29967442924e525a64d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a53b6bb92d2f307dc64682b42cdefb5badff876c65328d56bed5511c996e7c7d89ad9b07a25287d5bb8e212224283f80a98b30b8da92d5bd513ddfca7a6fd4a4
|
7
|
+
data.tar.gz: 2745eb20e8f3058105f23b5b159e837da6f64e382860aa68f85dc49b5acfdae83d697e73daa54baf06aacb059fb5e3904921fbaaba93255c7379a35a4c1add8f
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: ci-master
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: # Trigger only on the main branch to avoid duplicate runs on PR branches
|
6
|
+
- master
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
rspec:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
ruby: [2.5, 2.6, 2.7]
|
16
|
+
rails: [5.2, 6.0, 6.1]
|
17
|
+
|
18
|
+
env:
|
19
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
20
|
+
CI: true
|
21
|
+
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
27
|
+
# bundler-cache: true -- this messes up some dynamic constants
|
28
|
+
- run: "./spec/bin/run_spec.sh"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request: # Trigger All PRs
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
rspec:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
ruby: [2.5, 2.6, 2.7]
|
14
|
+
rails: [5.2, 6.0, 6.1]
|
15
|
+
|
16
|
+
env:
|
17
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
18
|
+
CI: true
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
- uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
# bundler-cache: true -- this messes up some dynamic constants
|
26
|
+
- run: "./spec/bin/run_spec.sh"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: publish-gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request: # test with pull request
|
5
|
+
# push:
|
6
|
+
# branches: # Trigger only on the main branch to avoid duplicate runs on PR branches
|
7
|
+
# - master
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
env:
|
14
|
+
CI: true
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Release Gem
|
19
|
+
uses: dawidd6/action-publish-gem@v1
|
20
|
+
with:
|
21
|
+
api_key: ${{secrets.RUBYGEMS_API_KEY}}
|
data/CONTRIBUTING.md
CHANGED
@@ -87,10 +87,9 @@ To run the tests against all supported Rails branches, use:
|
|
87
87
|
You can also switch to a version of Rails with `RAILS_VERSION`:
|
88
88
|
|
89
89
|
```sh
|
90
|
-
❯ RAILS_VERSION=5.0 ./spec/bin/run_spec.sh
|
91
|
-
❯ RAILS_VERSION=5.1 ./spec/bin/run_spec.sh
|
92
90
|
❯ RAILS_VERSION=5.2 ./spec/bin/run_spec.sh
|
93
91
|
❯ RAILS_VERSION=6.0 ./spec/bin/run_spec.sh
|
92
|
+
❯ RAILS_VERSION=6.1 ./spec/bin/run_spec.sh
|
94
93
|
```
|
95
94
|
|
96
95
|
#### Debugging
|
data/Gemfile
CHANGED
@@ -2,6 +2,8 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
+
gem 'rspec-core', '~> 3.8.0'
|
6
|
+
|
5
7
|
group :test do
|
6
8
|
gem 'simplecov', require: false
|
7
9
|
gem 'codecov', require: false
|
@@ -13,14 +15,6 @@ case rails_version
|
|
13
15
|
when "master"
|
14
16
|
gem "rails", {github: "rails/rails"}
|
15
17
|
gem "bundler", ">= 1.3.0"
|
16
|
-
when "5.0"
|
17
|
-
gem "rails", "~> 5.0.7"
|
18
|
-
gem "bundler", ">= 2.0"
|
19
|
-
gem "sqlite3", "~> 1.3.6"
|
20
|
-
when "5.1"
|
21
|
-
gem "rails", "~> 5.1.7"
|
22
|
-
gem "bundler", ">= 2.0"
|
23
|
-
gem "sqlite3", "~> 1.4.1"
|
24
18
|
when "5.2"
|
25
19
|
gem "rails", "~> 5.2.3"
|
26
20
|
gem "bundler", ">= 2.0"
|
@@ -29,8 +23,12 @@ when "6.0"
|
|
29
23
|
gem "rails", "~> 6.0.0"
|
30
24
|
gem "bundler", ">= 2.0"
|
31
25
|
gem "sqlite3", "~> 1.4.1"
|
26
|
+
when "6.1"
|
27
|
+
gem "rails", "~> 6.1.0"
|
28
|
+
gem "bundler", ">= 2.0"
|
29
|
+
gem "sqlite3", "~> 1.4.1"
|
32
30
|
else
|
33
|
-
gem "rails", "~>
|
31
|
+
gem "rails", "~> 6.0.0"
|
34
32
|
gem "bundler", ">= 2.0"
|
35
33
|
gem "sqlite3", "~> 1.4.1"
|
36
34
|
end
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# sorbet-rails
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/sorbet-rails.svg)](https://badge.fury.io/rb/sorbet-rails)
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/chanzuckerberg/sorbet-rails/actions/workflows/ci-master.yml/badge.svg)](https://github.com/chanzuckerberg/sorbet-rails)
|
4
4
|
[![codecov](https://codecov.io/gh/chanzuckerberg/sorbet-rails/branch/master/graph/badge.svg)](https://codecov.io/gh/chanzuckerberg/sorbet-rails)
|
5
5
|
|
6
6
|
A set of tools to make the [Sorbet](https://sorbet.org) typechecker work with Ruby on Rails seamlessly.
|
@@ -206,7 +206,7 @@ end
|
|
206
206
|
❯ bundle exec rake rails_rbi:custom
|
207
207
|
```
|
208
208
|
|
209
|
-
`sorbet-rails` adds `TypedParams` to
|
209
|
+
`sorbet-rails` adds `TypedParams` to extract typed controller parameters.
|
210
210
|
|
211
211
|
TypedParams takes a parameter definition, which is a subclass of `T::Struct` and coerces the `params` object into an instance of that subclass using [sorbet-coerce](https://github.com/chanzuckerberg/sorbet-coerce):
|
212
212
|
```ruby
|
@@ -311,7 +311,7 @@ It is worth going through the list of files that is ignored and resolve them (an
|
|
311
311
|
|
312
312
|
### Overriding generated signatures if needed
|
313
313
|
|
314
|
-
`sorbet-rails` relies on Rails reflection to generate signatures. There are features this gem doesn't support yet such as [
|
314
|
+
`sorbet-rails` relies on Rails reflection to generate signatures. There are features this gem doesn't support yet such as [attribute custom types](https://github.com/chanzuckerberg/sorbet-rails/issues/16). The gem also doesn't know the signature of any methods you have overridden. However, it is possible to override the signatures that `sorbet-rails` generates.
|
315
315
|
|
316
316
|
For example, here is how to override the signature for a method in a model:
|
317
317
|
|
@@ -524,6 +524,8 @@ These are the currently-supported gems and their symbolized names:
|
|
524
524
|
| [Paperclip] | `:paperclip` |
|
525
525
|
| [AttrJson] | `:attr_json` |
|
526
526
|
| [FlagShihTzu] | `:flag_shih_tzu` |
|
527
|
+
| [AASM] | `:aasm` |
|
528
|
+
| [Money-Rails] | `:money_rails` |
|
527
529
|
|
528
530
|
You can also configure the core model plugins if needed. The default plugins are defined in the [config](https://github.com/chanzuckerberg/sorbet-rails/blob/master/lib/sorbet-rails/config.rb). For the full list of plugin symbols, check out [here](https://github.com/chanzuckerberg/sorbet-rails/blob/master/lib/sorbet-rails/model_plugins/plugins.rb).
|
529
531
|
|
@@ -537,6 +539,8 @@ You can also configure the core model plugins if needed. The default plugins are
|
|
537
539
|
[Paperclip]: https://github.com/thoughtbot/paperclip
|
538
540
|
[AttrJson]: https://github.com/jrochkind/attr_json
|
539
541
|
[FlagShihTzu]: https://github.com/pboling/flag_shih_tzu
|
542
|
+
[AASM]: https://github.com/aasm/aasm
|
543
|
+
[Money-Rails]: https://github.com/RubyMoney/money-rails
|
540
544
|
|
541
545
|
### Customize Generation Class
|
542
546
|
|
data/Rakefile
CHANGED
@@ -10,13 +10,22 @@ namespace :update_spec do
|
|
10
10
|
|
11
11
|
desc "Generate Rails apps for all versions."
|
12
12
|
task :all do |t, args|
|
13
|
+
Rake::Task['update_spec:v6_1'].invoke
|
13
14
|
Rake::Task['update_spec:v6_0'].invoke
|
14
15
|
Rake::Task['update_spec:v5_2'].invoke
|
15
|
-
Rake::Task['update_spec:v5_1'].invoke
|
16
|
-
Rake::Task['update_spec:v5_0'].invoke
|
17
16
|
end
|
18
17
|
|
19
|
-
desc "Delete the Rails 6 spec directory and regenerate it."
|
18
|
+
desc "Delete the Rails 6.1 spec directory and regenerate it."
|
19
|
+
task :v6_1 do |t, args|
|
20
|
+
Bundler.with_clean_env do
|
21
|
+
FileUtils.rm_rf 'spec/support/v6.1' if File.directory?('spec/support/v6.1')
|
22
|
+
system("gem install rails -v 6.1.4")
|
23
|
+
system("rails _6.1.4_ -v")
|
24
|
+
system("RAILS_VERSION='6.1' rails _6.1.4_ new --template spec/generators/rails-template.rb spec/support/v6.0 --skip-javascript --skip-action-cable --skip-test --skip-sprockets --skip-spring --skip-bootsnap --skip-listen")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Delete the Rails 6.0 spec directory and regenerate it."
|
20
29
|
task :v6_0 do |t, args|
|
21
30
|
Bundler.with_clean_env do
|
22
31
|
FileUtils.rm_rf 'spec/support/v6.0' if File.directory?('spec/support/v6.0')
|
@@ -36,29 +45,9 @@ namespace :update_spec do
|
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
39
|
-
desc "Delete the Rails 5.1 spec directory and regenerate it."
|
40
|
-
task :v5_1 do |t, args|
|
41
|
-
Bundler.with_clean_env do
|
42
|
-
FileUtils.rm_rf 'spec/support/v5.1' if File.directory?('spec/support/v5.1')
|
43
|
-
system("gem install rails -v 5.1.7")
|
44
|
-
system("rails _5.1.7_ -v")
|
45
|
-
system("RAILS_VERSION='5.1' rails _5.1.7_ new --template spec/generators/rails-template.rb spec/support/v5.1 --skip-javascript --skip-action-cable --skip-test --skip-sprockets --skip-spring --skip-listen")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
desc "Delete the Rails 5.0 spec directory and regenerate it."
|
50
|
-
task :v5_0 do |t, args|
|
51
|
-
Bundler.with_clean_env do
|
52
|
-
FileUtils.rm_rf 'spec/support/v5.0' if File.directory?('spec/support/v5.0')
|
53
|
-
system("gem install rails -v 5.0.7")
|
54
|
-
system("rails _5.0.7_ -v")
|
55
|
-
system("RAILS_VERSION='5.0' rails _5.0.7_ new --template spec/generators/rails-template.rb spec/support/v5.0 --skip-javascript --skip-action-cable --skip-test --skip-sprockets --skip-spring --skip-listen")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
48
|
desc "Update sorbet_test_cases.rb in all the Rails apps in spec/support."
|
60
49
|
task :sorbet_test_cases do |t, args|
|
61
|
-
['v6.
|
50
|
+
['v6.1', 'v6.0', 'v5.2'].each do |version|
|
62
51
|
FileUtils.cp("spec/generators/sorbet_test_cases.rb", "spec/support/#{version}/sorbet_test_cases.rb")
|
63
52
|
end
|
64
53
|
end
|
@@ -273,6 +273,18 @@ class SorbetRails::ActiveRecordRbiFormatter
|
|
273
273
|
class_method: class_method,
|
274
274
|
)
|
275
275
|
end
|
276
|
+
|
277
|
+
boolean_methods = %w(any? many? none? one?)
|
278
|
+
boolean_methods.each do |boolean_method|
|
279
|
+
class_rbi.create_method(
|
280
|
+
boolean_method,
|
281
|
+
parameters: [
|
282
|
+
Parameter.new("&block", type: "T.nilable(T.proc.params(e: #{type}).returns(T::Boolean))"),
|
283
|
+
],
|
284
|
+
return_type: "T::Boolean",
|
285
|
+
class_method: class_method,
|
286
|
+
)
|
287
|
+
end
|
276
288
|
end
|
277
289
|
|
278
290
|
sig {
|
@@ -288,14 +300,5 @@ class SorbetRails::ActiveRecordRbiFormatter
|
|
288
300
|
return_type: "T::Boolean",
|
289
301
|
class_method: class_method,
|
290
302
|
)
|
291
|
-
|
292
|
-
boolean_methods = %w(any? many? none? one?)
|
293
|
-
boolean_methods.each do |boolean_method|
|
294
|
-
class_rbi.create_method(
|
295
|
-
boolean_method,
|
296
|
-
return_type: "T::Boolean",
|
297
|
-
class_method: class_method,
|
298
|
-
)
|
299
|
-
end
|
300
303
|
end
|
301
304
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# typed: false
|
2
|
+
class AasmPlugin < SorbetRails::ModelPlugins::Base
|
3
|
+
sig { override.params(root: Parlour::RbiGenerator::Namespace).void }
|
4
|
+
def generate(root)
|
5
|
+
return unless @model_class.include?(::AASM)
|
6
|
+
|
7
|
+
model_rbi = root.create_class(
|
8
|
+
model_class_name
|
9
|
+
)
|
10
|
+
|
11
|
+
aasm_events = @model_class.aasm.events.map(&:name)
|
12
|
+
aasm_states = @model_class.aasm.states.map(&:name)
|
13
|
+
|
14
|
+
# If you have an event like :bazify, you get these methods:
|
15
|
+
# - `may_bazify?`
|
16
|
+
# - `bazify`
|
17
|
+
# - `bazify!`
|
18
|
+
# - `bazify_without_validation!`
|
19
|
+
aasm_events.each do |event|
|
20
|
+
model_rbi.create_method(
|
21
|
+
"may_#{event}?",
|
22
|
+
return_type: 'T::Boolean'
|
23
|
+
)
|
24
|
+
|
25
|
+
model_rbi.create_method(
|
26
|
+
event.to_s,
|
27
|
+
return_type: 'T::Boolean'
|
28
|
+
)
|
29
|
+
|
30
|
+
model_rbi.create_method(
|
31
|
+
"#{event}!",
|
32
|
+
return_type: 'T::Boolean'
|
33
|
+
)
|
34
|
+
|
35
|
+
model_rbi.create_method(
|
36
|
+
"#{event}_without_validation!",
|
37
|
+
return_type: 'T::Boolean'
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
# - If you have a state like :baz, you get these methods:
|
42
|
+
# - `baz?`
|
43
|
+
aasm_states.each do |state|
|
44
|
+
model_rbi.create_method(
|
45
|
+
"#{state}?",
|
46
|
+
return_type: 'T::Boolean'
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# typed: strict
|
2
|
+
class MoneyRailsPlugin < SorbetRails::ModelPlugins::Base
|
3
|
+
sig { params(attribute: T.any(Symbol, String)).returns(T::Boolean) }
|
4
|
+
def allows_nil(attribute)
|
5
|
+
validators = model_class.validators_on(attribute)
|
6
|
+
return false if validators.empty?
|
7
|
+
|
8
|
+
validators.any? do |validator|
|
9
|
+
validator.respond_to?(:options) &&
|
10
|
+
validator.options[:allow_nil]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
sig { override.params(root: Parlour::RbiGenerator::Namespace).void }
|
15
|
+
def generate(root)
|
16
|
+
return unless exists_class_method?(:monetize)
|
17
|
+
|
18
|
+
# money-rails gives us a hash mapping the monetized attribute to its subunit
|
19
|
+
# equivalent, eg: `{"price": "price_cents"}`
|
20
|
+
monetized_attributes = T.let(
|
21
|
+
T.unsafe(model_class).monetized_attributes,
|
22
|
+
T::Hash[String,String]
|
23
|
+
)
|
24
|
+
|
25
|
+
return if monetized_attributes.empty?
|
26
|
+
|
27
|
+
module_name = model_module_name("GeneratedMoneyRailsMethods")
|
28
|
+
module_rbi = root.create_module(module_name)
|
29
|
+
|
30
|
+
model_class_rbi = root.create_class(model_class_name)
|
31
|
+
model_class_rbi.create_include(module_name)
|
32
|
+
|
33
|
+
monetized_attributes.each do |name, subunit_name|
|
34
|
+
validators = model_class.validators_on(name)
|
35
|
+
|
36
|
+
money_attribute_type = allows_nil(name) ? "T.nilable(::Money)" : "::Money"
|
37
|
+
subunit_attribute_type = allows_nil(name) ? "T.nilable(Integer)" : "Integer"
|
38
|
+
|
39
|
+
module_rbi.create_method(
|
40
|
+
name,
|
41
|
+
return_type: money_attribute_type
|
42
|
+
)
|
43
|
+
|
44
|
+
module_rbi.create_method(
|
45
|
+
subunit_name,
|
46
|
+
return_type: subunit_attribute_type
|
47
|
+
)
|
48
|
+
|
49
|
+
module_rbi.create_method(
|
50
|
+
"#{name}_money_before_type_cast",
|
51
|
+
return_type: 'T.untyped'
|
52
|
+
)
|
53
|
+
|
54
|
+
module_rbi.create_method(
|
55
|
+
"#{name}=",
|
56
|
+
parameters: [
|
57
|
+
Parlour::RbiGenerator::Parameter.new("value", type: money_attribute_type)
|
58
|
+
],
|
59
|
+
return_type: nil
|
60
|
+
)
|
61
|
+
|
62
|
+
module_rbi.create_method(
|
63
|
+
"#{subunit_name}=",
|
64
|
+
parameters: [
|
65
|
+
Parlour::RbiGenerator::Parameter.new("value", type: subunit_attribute_type)
|
66
|
+
],
|
67
|
+
return_type: nil
|
68
|
+
)
|
69
|
+
|
70
|
+
module_rbi.create_method(
|
71
|
+
"currency_for_#{name}",
|
72
|
+
return_type: "T.nilable(::Money::Currency)"
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -60,9 +60,10 @@ class SorbetRails::ModelPlugins::ActiveRecordSerializedAttribute < SorbetRails::
|
|
60
60
|
# ActiveSupport::JSON.encode/ActiveSupport::JSON.decode
|
61
61
|
# note that Hash keys are Strings since this is JSON
|
62
62
|
'T.any(T::Array[T.untyped], T::Boolean, Float, T::Hash[String, T.untyped], Integer, String)'
|
63
|
-
|
64
|
-
# unknown uses YAML.load/YAML.dump
|
63
|
+
when 'Object', ''
|
65
64
|
'T.any(T::Array[T.untyped], T::Boolean, Float, T::Hash[T.untyped, T.untyped], Integer, String)'
|
65
|
+
else
|
66
|
+
serialization_coder.to_s
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
@@ -35,7 +35,14 @@ module SorbetRails::ModelPlugins
|
|
35
35
|
column_type = @model_class.type_for_attribute(column_name)
|
36
36
|
return unless column_type.is_a?(ActiveRecord::Type::Serialized)
|
37
37
|
|
38
|
-
column_type.coder.try(:object_class)
|
38
|
+
object_class = column_type.coder.try(:object_class)
|
39
|
+
if object_class
|
40
|
+
object_class
|
41
|
+
elsif column_type.coder.is_a? Class
|
42
|
+
column_type.coder
|
43
|
+
else
|
44
|
+
Object
|
45
|
+
end
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
@@ -39,7 +39,7 @@ class SorbetRails::ModelPlugins::CustomFinderMethods < SorbetRails::ModelPlugins
|
|
39
39
|
# allow common cases find_by_id
|
40
40
|
custom_module_rbi.create_method(
|
41
41
|
"find_by_id",
|
42
|
-
parameters: [ Parameter.new("id", type: "Integer") ],
|
42
|
+
parameters: [ Parameter.new("id", type: "T.nilable(Integer)") ],
|
43
43
|
return_type: "T.nilable(#{self.model_class_name})",
|
44
44
|
)
|
45
45
|
custom_module_rbi.create_method(
|
@@ -87,6 +87,12 @@ module SorbetRails::ModelPlugins
|
|
87
87
|
when :flag_shih_tzu
|
88
88
|
require('sorbet-rails/gem_plugins/flag_shih_tzu_plugin')
|
89
89
|
FlagShihTzuPlugin
|
90
|
+
when :aasm
|
91
|
+
require('sorbet-rails/gem_plugins/aasm_plugin')
|
92
|
+
AasmPlugin
|
93
|
+
when :money_rails
|
94
|
+
require('sorbet-rails/gem_plugins/money_rails_plugin')
|
95
|
+
MoneyRailsPlugin
|
90
96
|
else
|
91
97
|
raise UnrecognizedPluginName.new(
|
92
98
|
"Unrecognized plugin with name: #{plugin_name}. Please check available plugins in the
|
data/lib/sorbet-rails/railtie.rb
CHANGED
@@ -39,6 +39,14 @@ class SorbetRails::RoutesRbiFormatter
|
|
39
39
|
@parlour.root.create_class('ActionMailer::Base') do |mod|
|
40
40
|
mod.create_include('GeneratedUrlHelpers')
|
41
41
|
end
|
42
|
+
|
43
|
+
@parlour.root.create_class('ActionDispatch::IntegrationTest') do |mod|
|
44
|
+
mod.create_include('GeneratedUrlHelpers')
|
45
|
+
end
|
46
|
+
|
47
|
+
@parlour.root.create_class('ActionDispatch::SystemTestCase') do |mod|
|
48
|
+
mod.create_include('GeneratedUrlHelpers')
|
49
|
+
end
|
42
50
|
end
|
43
51
|
|
44
52
|
sig { params(routes: T.untyped, filter: T.untyped).void }
|
@@ -16,12 +16,12 @@ namespace :rails_rbi do
|
|
16
16
|
FileUtils.rm_rf(rails_rbi_root_path)
|
17
17
|
|
18
18
|
# run all rake tasks
|
19
|
-
Rake::Task['
|
20
|
-
Rake::Task['
|
21
|
-
Rake::Task['
|
22
|
-
Rake::Task['
|
23
|
-
Rake::Task['
|
24
|
-
Rake::Task['
|
19
|
+
Rake::Task[rails_rbi_task_name(t, 'routes')].invoke
|
20
|
+
Rake::Task[rails_rbi_task_name(t, 'models')].invoke
|
21
|
+
Rake::Task[rails_rbi_task_name(t, 'helpers')].invoke
|
22
|
+
Rake::Task[rails_rbi_task_name(t, 'mailers')].invoke
|
23
|
+
Rake::Task[rails_rbi_task_name(t, 'jobs')].invoke
|
24
|
+
Rake::Task[rails_rbi_task_name(t, 'custom')].invoke
|
25
25
|
end
|
26
26
|
|
27
27
|
desc "Generate rbis for rails routes"
|
@@ -36,7 +36,7 @@ namespace :rails_rbi do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
desc "Copy custom rbis for typed_params, pluck_to_struct, etc."
|
39
|
-
task custom: :environment do
|
39
|
+
task custom: :environment do |t, args|
|
40
40
|
copy_bundled_rbi('type_assert.rbi')
|
41
41
|
copy_bundled_rbi('pluck_to_tstruct.rbi')
|
42
42
|
copy_bundled_rbi('typed_params.rbi')
|
@@ -44,7 +44,7 @@ namespace :rails_rbi do
|
|
44
44
|
|
45
45
|
# These files were previously bundled_rbi but are now generated so this
|
46
46
|
# is needed for backwards compatibility with anyone using `rails_rbi:custom`
|
47
|
-
Rake::Task['
|
47
|
+
Rake::Task[rails_rbi_task_name(t, 'active_record')].invoke
|
48
48
|
end
|
49
49
|
|
50
50
|
desc "Generate rbis for rails active_record base"
|
@@ -182,4 +182,8 @@ namespace :rails_rbi do
|
|
182
182
|
FileUtils.mkdir_p(File.dirname(copy_to_path))
|
183
183
|
FileUtils.cp(bundled_rbi_file_path, copy_to_path)
|
184
184
|
end
|
185
|
+
|
186
|
+
def rails_rbi_task_name(current_task, target_task_suffix)
|
187
|
+
current_task.to_s.sub(/\w+$/, target_task_suffix)
|
188
|
+
end
|
185
189
|
end
|
data/sorbet-rails.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{sorbet-rails}
|
3
|
-
s.version = "0.7.
|
3
|
+
s.version = "0.7.5"
|
4
4
|
s.date = %q{2019-04-18}
|
5
5
|
s.summary = %q{Set of tools to make Sorbet work with Rails seamlessly.}
|
6
6
|
s.authors = ["Chan Zuckerberg Initiative"]
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency 'rspec', '~> 3.8', '>= 3.8'
|
26
26
|
# Debugging
|
27
27
|
s.add_development_dependency 'awesome_print', '~>1.8.0', '>=1.8.0'
|
28
|
-
s.add_development_dependency 'byebug', '~>11.
|
28
|
+
s.add_development_dependency 'byebug', '~>11.1.3', '>=11.1.3'
|
29
29
|
|
30
30
|
# for testing a gem with a rails app (controller specs)
|
31
31
|
s.add_development_dependency 'rspec-rails', '>=3.8.2'
|
data/spec/bin/run_all_specs.sh
CHANGED
@@ -3,9 +3,8 @@
|
|
3
3
|
|
4
4
|
wd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
5
5
|
|
6
|
-
RAILS_VERSION=5.
|
7
|
-
RAILS_VERSION=
|
8
|
-
RAILS_VERSION=6.0 bash $wd/run_spec.sh
|
6
|
+
RAILS_VERSION=5.2 bash $wd/run_spec.sh
|
7
|
+
RAILS_VERSION=6.1 bash $wd/run_spec.sh
|
9
8
|
|
10
|
-
# Always end with the default version, which is Rails
|
9
|
+
# Always end with the default version, which is Rails 6.0
|
11
10
|
bash $wd/run_spec.sh
|
data/spec/bin/run_spec.sh
CHANGED
@@ -6,7 +6,7 @@ wd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
6
6
|
current_dir=$(pwd)
|
7
7
|
|
8
8
|
if [[ -z $RAILS_VERSION ]]; then
|
9
|
-
rails_dir="$wd/../support/
|
9
|
+
rails_dir="$wd/../support/v6.0"
|
10
10
|
else
|
11
11
|
rails_dir="$wd/../support/v$RAILS_VERSION"
|
12
12
|
fi
|
@@ -15,7 +15,10 @@ fi
|
|
15
15
|
rm $wd/../../Gemfile.lock 2>/dev/null # clean up Gemfile.lock first
|
16
16
|
bundle install
|
17
17
|
|
18
|
+
echo "===================================================================="
|
19
|
+
echo "Run test for folder:"
|
18
20
|
echo $rails_dir
|
21
|
+
echo "===================================================================="
|
19
22
|
|
20
23
|
# update gems in rails_dir
|
21
24
|
cd $rails_dir
|
@@ -127,7 +127,7 @@ def create_models
|
|
127
127
|
|
128
128
|
# A nasty hack to add has_one_attached and has_many_attached to the models/wizard.rb file.
|
129
129
|
attachments = nil
|
130
|
-
if ['5.2', '6.0'].include?(ENV["RAILS_VERSION"])
|
130
|
+
if ['5.2', '6.0', '6.1'].include?(ENV["RAILS_VERSION"])
|
131
131
|
attachments = "has_one_attached :school_photo\n has_many_attached :hats"
|
132
132
|
end
|
133
133
|
|
@@ -313,11 +313,8 @@ def create_migrations
|
|
313
313
|
add_column :wands, :broken_at, :datetime, null: true
|
314
314
|
add_column :wands, :chosen_at_date, :date
|
315
315
|
add_column :wands, :chosen_at_time, :time
|
316
|
-
|
317
|
-
|
318
|
-
add_column :wands, :spell_history, :json
|
319
|
-
add_column :wands, :maker_info, :json, null: false, default: '{}'
|
320
|
-
end
|
316
|
+
add_column :wands, :spell_history, :json
|
317
|
+
add_column :wands, :maker_info, :json, null: false, default: '{}'
|
321
318
|
end
|
322
319
|
end
|
323
320
|
RUBY
|
@@ -507,20 +504,6 @@ end
|
|
507
504
|
# Main setup
|
508
505
|
source_paths
|
509
506
|
|
510
|
-
if ['5.0'].include?(ENV["RAILS_VERSION"])
|
511
|
-
File.open('Gemfile', 'r+') do |f|
|
512
|
-
out = ""
|
513
|
-
f.each do |line|
|
514
|
-
# We remove sdoc and web-console because they misbehave.
|
515
|
-
# sqlite needs to be limited to 1.3.x or it won't work.
|
516
|
-
out << line.gsub("gem 'sqlite3'", "gem 'sqlite3', '~> 1.3.6'") unless line =~ /gem \'(sdoc|web-console)\'.*/
|
517
|
-
end
|
518
|
-
f.pos = 0
|
519
|
-
f.print out
|
520
|
-
f.truncate(f.pos)
|
521
|
-
end
|
522
|
-
end
|
523
|
-
|
524
507
|
add_gems
|
525
508
|
|
526
509
|
after_bundle do
|