sorbet-rails 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +0 -2
- data/CONTRIBUTING.md +2 -4
- data/Gemfile +0 -4
- data/README.md +41 -7
- data/Rakefile +3 -14
- data/lib/bundled_rbi/parameters.rbi +4 -26
- data/lib/bundled_rbi/pluck_to_tstruct.rbi +22 -0
- data/lib/bundled_rbi/type_assert.rbi +27 -0
- data/lib/sorbet-rails/gem_plugins/elastic_search_plugin.rb +40 -0
- data/lib/sorbet-rails/gem_plugins/shrine_plugin.rb +76 -0
- data/lib/sorbet-rails/model_plugins/active_record_assoc.rb +2 -11
- data/lib/sorbet-rails/model_plugins/active_record_attribute.rb +3 -6
- data/lib/sorbet-rails/model_plugins/active_record_querying.rb +10 -2
- data/lib/sorbet-rails/model_plugins/plugins.rb +6 -0
- data/lib/sorbet-rails/rails_mixins/pluck_to_tstruct.rb +33 -0
- data/lib/sorbet-rails/railtie.rb +4 -0
- data/lib/sorbet-rails/sorbet_utils.rb +4 -1
- data/lib/sorbet-rails/tasks/rails_rbi.rake +16 -6
- data/sorbet-rails.gemspec +1 -1
- data/spec/bin/run_all_specs.sh +0 -1
- data/spec/bin/run_spec.sh +4 -6
- data/spec/generators/rails-template.rb +67 -124
- data/spec/generators/sorbet_test_cases.rb +26 -16
- data/spec/pluck_to_tstruct_spec.rb +79 -0
- data/spec/rails_helper.rb +0 -2
- data/spec/rake_rails_rbi_models_spec.rb +2 -0
- data/spec/sorbet_utils_spec.rb +37 -0
- data/spec/spec_helper.rb +1 -2
- data/spec/support/v5.0/Gemfile.lock +6 -6
- data/spec/support/v5.0/config/boot.rb +1 -1
- data/spec/support/v5.0/config/initializers/sorbet_rails.rb +1 -1
- data/spec/support/v5.0/db/migrate/20190620000004_add_more_column_types_to_wands.rb +1 -1
- data/spec/support/v5.0/sorbet_test_cases.rb +26 -16
- data/spec/support/v5.1/Gemfile.lock +6 -6
- data/spec/support/v5.1/config/boot.rb +1 -1
- data/spec/support/v5.1/config/initializers/sorbet_rails.rb +1 -1
- data/spec/support/v5.1/db/migrate/20190620000004_add_more_column_types_to_wands.rb +1 -1
- data/spec/support/v5.1/sorbet_test_cases.rb +26 -16
- data/spec/support/v5.2/Gemfile.lock +6 -6
- data/spec/support/v5.2/config/boot.rb +1 -1
- data/spec/support/v5.2/config/initializers/sorbet_rails.rb +1 -1
- data/spec/support/v5.2/db/migrate/20190620000004_add_more_column_types_to_wands.rb +1 -1
- data/spec/support/v5.2/sorbet_test_cases.rb +26 -16
- data/spec/support/v6.0/Gemfile.lock +6 -6
- data/spec/support/v6.0/config/boot.rb +1 -1
- data/spec/support/v6.0/config/initializers/sorbet_rails.rb +1 -1
- data/spec/support/v6.0/config/initializers/wrap_parameters.rb +1 -1
- data/spec/support/v6.0/db/migrate/20190620000004_add_more_column_types_to_wands.rb +1 -1
- data/spec/support/v6.0/sorbet_test_cases.rb +26 -16
- data/spec/test_data/v5.0/expected_internal_metadata.rbi +209 -197
- data/spec/test_data/v5.0/expected_potion.rbi +208 -196
- data/spec/test_data/v5.0/expected_schema_migration.rbi +209 -197
- data/spec/test_data/v5.0/expected_spell_book.rbi +208 -196
- data/spec/test_data/v5.0/expected_squib.rbi +209 -197
- data/spec/test_data/v5.0/expected_wand.rbi +208 -196
- data/spec/test_data/v5.0/expected_wizard.rbi +209 -197
- data/spec/test_data/v5.0/expected_wizard_wo_spellbook.rbi +209 -197
- data/spec/test_data/v5.1/expected_internal_metadata.rbi +213 -213
- data/spec/test_data/v5.1/expected_potion.rbi +212 -212
- data/spec/test_data/v5.1/expected_schema_migration.rbi +213 -213
- data/spec/test_data/v5.1/expected_spell_book.rbi +212 -212
- data/spec/test_data/v5.1/expected_squib.rbi +213 -213
- data/spec/test_data/v5.1/expected_wand.rbi +212 -212
- data/spec/test_data/v5.1/expected_wizard.rbi +213 -213
- data/spec/test_data/v5.1/expected_wizard_wo_spellbook.rbi +213 -213
- data/spec/test_data/v5.2/expected_attachment.rbi +212 -212
- data/spec/test_data/v5.2/expected_blob.rbi +212 -212
- data/spec/test_data/v5.2/expected_internal_metadata.rbi +213 -213
- data/spec/test_data/v5.2/expected_potion.rbi +212 -212
- data/spec/test_data/v5.2/expected_schema_migration.rbi +213 -213
- data/spec/test_data/v5.2/expected_spell_book.rbi +212 -212
- data/spec/test_data/v5.2/expected_squib.rbi +213 -213
- data/spec/test_data/v5.2/expected_wand.rbi +212 -212
- data/spec/test_data/v5.2/expected_wizard.rbi +213 -213
- data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +213 -213
- data/spec/test_data/v6.0/expected_attachment.rbi +244 -244
- data/spec/test_data/v6.0/expected_blob.rbi +244 -244
- data/spec/test_data/v6.0/expected_internal_metadata.rbi +245 -245
- data/spec/test_data/v6.0/expected_potion.rbi +244 -244
- data/spec/test_data/v6.0/expected_schema_migration.rbi +245 -245
- data/spec/test_data/v6.0/expected_spell_book.rbi +244 -244
- data/spec/test_data/v6.0/expected_squib.rbi +245 -245
- data/spec/test_data/v6.0/expected_wand.rbi +244 -244
- data/spec/test_data/v6.0/expected_wizard.rbi +245 -245
- data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +245 -245
- metadata +8 -185
- data/spec/bin/install.sh +0 -11
- data/spec/support/v4.2/.gitignore +0 -17
- data/spec/support/v4.2/Gemfile +0 -33
- data/spec/support/v4.2/Gemfile.lock +0 -128
- data/spec/support/v4.2/README.rdoc +0 -28
- data/spec/support/v4.2/Rakefile +0 -6
- data/spec/support/v4.2/app/assets/images/.keep +0 -0
- data/spec/support/v4.2/app/assets/stylesheets/application.css +0 -15
- data/spec/support/v4.2/app/controllers/application_controller.rb +0 -6
- data/spec/support/v4.2/app/controllers/concerns/.keep +0 -0
- data/spec/support/v4.2/app/helpers/application_helper.rb +0 -3
- data/spec/support/v4.2/app/helpers/bar_helper.rb +0 -3
- data/spec/support/v4.2/app/helpers/baz_helper.rb +0 -3
- data/spec/support/v4.2/app/helpers/foo_helper.rb +0 -3
- data/spec/support/v4.2/app/mailers/.keep +0 -0
- data/spec/support/v4.2/app/mailers/application_mailer.rb +0 -3
- data/spec/support/v4.2/app/mailers/daily_prophet_mailer.rb +0 -9
- data/spec/support/v4.2/app/mailers/hogwarts_acceptance_mailer.rb +0 -13
- data/spec/support/v4.2/app/models/.keep +0 -0
- data/spec/support/v4.2/app/models/application_record.rb +0 -4
- data/spec/support/v4.2/app/models/concerns/.keep +0 -0
- data/spec/support/v4.2/app/models/concerns/mythical.rb +0 -11
- data/spec/support/v4.2/app/models/potion.rb +0 -5
- data/spec/support/v4.2/app/models/spell_book.rb +0 -11
- data/spec/support/v4.2/app/models/squib.rb +0 -6
- data/spec/support/v4.2/app/models/wand.rb +0 -19
- data/spec/support/v4.2/app/models/wizard.rb +0 -29
- data/spec/support/v4.2/app/views/layouts/application.html.erb +0 -13
- data/spec/support/v4.2/bin/bundle +0 -3
- data/spec/support/v4.2/bin/rails +0 -4
- data/spec/support/v4.2/bin/rake +0 -4
- data/spec/support/v4.2/bin/setup +0 -29
- data/spec/support/v4.2/config.ru +0 -4
- data/spec/support/v4.2/config/application.rb +0 -36
- data/spec/support/v4.2/config/boot.rb +0 -4
- data/spec/support/v4.2/config/database.yml +0 -25
- data/spec/support/v4.2/config/environment.rb +0 -6
- data/spec/support/v4.2/config/environments/development.rb +0 -29
- data/spec/support/v4.2/config/environments/production.rb +0 -68
- data/spec/support/v4.2/config/environments/test.rb +0 -43
- data/spec/support/v4.2/config/initializers/backtrace_silencers.rb +0 -8
- data/spec/support/v4.2/config/initializers/cookies_serializer.rb +0 -4
- data/spec/support/v4.2/config/initializers/filter_parameter_logging.rb +0 -5
- data/spec/support/v4.2/config/initializers/inflections.rb +0 -17
- data/spec/support/v4.2/config/initializers/mime_types.rb +0 -5
- data/spec/support/v4.2/config/initializers/session_store.rb +0 -4
- data/spec/support/v4.2/config/initializers/sorbet_rails.rb +0 -3
- data/spec/support/v4.2/config/initializers/to_time_preserves_timezone.rb +0 -11
- data/spec/support/v4.2/config/initializers/wrap_parameters.rb +0 -15
- data/spec/support/v4.2/config/locales/en.yml +0 -23
- data/spec/support/v4.2/config/routes.rb +0 -58
- data/spec/support/v4.2/db/migrate/20190620000001_create_wizards.rb +0 -13
- data/spec/support/v4.2/db/migrate/20190620000002_create_wands.rb +0 -12
- data/spec/support/v4.2/db/migrate/20190620000003_create_spell_books.rb +0 -10
- data/spec/support/v4.2/db/migrate/20190620000004_add_more_column_types_to_wands.rb +0 -17
- data/spec/support/v4.2/db/migrate/20190620000005_add_broom_to_wizard.rb +0 -6
- data/spec/support/v4.2/db/migrate/20190620000007_add_type_to_wizard.rb +0 -6
- data/spec/support/v4.2/db/schema.rb +0 -49
- data/spec/support/v4.2/db/seeds.rb +0 -8
- data/spec/support/v4.2/lib/assets/.keep +0 -0
- data/spec/support/v4.2/lib/mythical_rbi_plugin.rb +0 -16
- data/spec/support/v4.2/lib/tasks/.keep +0 -0
- data/spec/support/v4.2/log/.keep +0 -0
- data/spec/support/v4.2/sorbet_test_cases.rb +0 -238
- data/spec/support/v4.2/test/controllers/.keep +0 -0
- data/spec/support/v4.2/test/fixtures/.keep +0 -0
- data/spec/support/v4.2/test/helpers/.keep +0 -0
- data/spec/support/v4.2/test/integration/.keep +0 -0
- data/spec/support/v4.2/test/mailers/.keep +0 -0
- data/spec/support/v4.2/test/models/.keep +0 -0
- data/spec/support/v4.2/test/test_helper.rb +0 -11
- data/spec/support/v4.2/typed-override.yaml +0 -2
- data/spec/support/v4.2/vendor/assets/stylesheets/.keep +0 -0
- data/spec/test_data/v4.2/expected_application_mailer.rbi +0 -5
- data/spec/test_data/v4.2/expected_daily_prophet_mailer.rbi +0 -7
- data/spec/test_data/v4.2/expected_helpers.rbi +0 -22
- data/spec/test_data/v4.2/expected_helpers_with_application_and_devise_helpers.rbi +0 -29
- data/spec/test_data/v4.2/expected_hogwarts_acceptance_mailer.rbi +0 -10
- data/spec/test_data/v4.2/expected_no_routes.rbi +0 -4
- data/spec/test_data/v4.2/expected_potion.rbi +0 -657
- data/spec/test_data/v4.2/expected_routes.rbi +0 -19
- data/spec/test_data/v4.2/expected_spell_book.rbi +0 -771
- data/spec/test_data/v4.2/expected_squib.rbi +0 -912
- data/spec/test_data/v4.2/expected_srb_tc_output.txt +0 -65
- data/spec/test_data/v4.2/expected_wand.rbi +0 -873
- data/spec/test_data/v4.2/expected_wizard.rbi +0 -912
- data/spec/test_data/v4.2/expected_wizard_wo_spellbook.rbi +0 -912
@@ -1,43 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
Rails.application.configure do
|
3
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
4
|
-
|
5
|
-
# The test environment is used exclusively to run your application's
|
6
|
-
# test suite. You never need to work with it otherwise. Remember that
|
7
|
-
# your test database is "scratch space" for the test suite and is wiped
|
8
|
-
# and recreated between test runs. Don't rely on the data there!
|
9
|
-
config.cache_classes = true
|
10
|
-
|
11
|
-
# Do not eager load code on boot. This avoids loading your whole application
|
12
|
-
# just for the purpose of running a single test. If you are using a tool that
|
13
|
-
# preloads Rails for running tests, you may have to set it to true.
|
14
|
-
config.eager_load = false
|
15
|
-
|
16
|
-
# Configure static file server for tests with Cache-Control for performance.
|
17
|
-
config.serve_static_files = true
|
18
|
-
config.static_cache_control = 'public, max-age=3600'
|
19
|
-
|
20
|
-
# Show full error reports and disable caching.
|
21
|
-
config.consider_all_requests_local = true
|
22
|
-
config.action_controller.perform_caching = false
|
23
|
-
|
24
|
-
# Raise exceptions instead of rendering exception templates.
|
25
|
-
config.action_dispatch.show_exceptions = false
|
26
|
-
|
27
|
-
# Disable request forgery protection in test environment.
|
28
|
-
config.action_controller.allow_forgery_protection = false
|
29
|
-
|
30
|
-
# Tell Action Mailer not to deliver emails to the real world.
|
31
|
-
# The :test delivery method accumulates sent emails in the
|
32
|
-
# ActionMailer::Base.deliveries array.
|
33
|
-
config.action_mailer.delivery_method = :test
|
34
|
-
|
35
|
-
# Randomize the order test cases are executed.
|
36
|
-
config.active_support.test_order = :random
|
37
|
-
|
38
|
-
# Print deprecation notices to the stderr.
|
39
|
-
config.active_support.deprecation = :stderr
|
40
|
-
|
41
|
-
# Raises error for missing translations
|
42
|
-
# config.action_view.raise_on_missing_translations = true
|
43
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# Be sure to restart your server when you modify this file.
|
3
|
-
|
4
|
-
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
5
|
-
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
6
|
-
|
7
|
-
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
8
|
-
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# Be sure to restart your server when you modify this file.
|
3
|
-
|
4
|
-
# Add new inflection rules using the following format. Inflections
|
5
|
-
# are locale specific, and you may define rules for as many different
|
6
|
-
# locales as you wish. All of these examples are active by default:
|
7
|
-
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
8
|
-
# inflect.plural /^(ox)$/i, '\1en'
|
9
|
-
# inflect.singular /^(ox)en/i, '\1'
|
10
|
-
# inflect.irregular 'person', 'people'
|
11
|
-
# inflect.uncountable %w( fish sheep )
|
12
|
-
# end
|
13
|
-
|
14
|
-
# These inflection rules are supported but not enabled by default:
|
15
|
-
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
16
|
-
# inflect.acronym 'RESTful'
|
17
|
-
# end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# Be sure to restart your server when you modify this file.
|
3
|
-
|
4
|
-
# Preserve the timezone of the receiver when calling to `to_time`.
|
5
|
-
# Ruby 2.4 will change the behavior of `to_time` to preserve the timezone
|
6
|
-
# when converting to an instance of `Time` instead of the previous behavior
|
7
|
-
# of converting to the local system timezone.
|
8
|
-
#
|
9
|
-
# Rails 5.0 introduced this config option so that apps made with earlier
|
10
|
-
# versions of Rails are not affected when upgrading.
|
11
|
-
ActiveSupport.to_time_preserves_timezone = true
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# Be sure to restart your server when you modify this file.
|
3
|
-
|
4
|
-
# This file contains settings for ActionController::ParamsWrapper which
|
5
|
-
# is enabled by default.
|
6
|
-
|
7
|
-
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
8
|
-
ActiveSupport.on_load(:action_controller) do
|
9
|
-
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
10
|
-
end
|
11
|
-
|
12
|
-
# To enable root element in JSON for ActiveRecord objects.
|
13
|
-
# ActiveSupport.on_load(:active_record) do
|
14
|
-
# self.include_root_in_json = true
|
15
|
-
# end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# Files in the config/locales directory are used for internationalization
|
2
|
-
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
-
# than English, add the necessary files in this directory.
|
4
|
-
#
|
5
|
-
# To use the locales, use `I18n.t`:
|
6
|
-
#
|
7
|
-
# I18n.t 'hello'
|
8
|
-
#
|
9
|
-
# In views, this is aliased to just `t`:
|
10
|
-
#
|
11
|
-
# <%= t('hello') %>
|
12
|
-
#
|
13
|
-
# To use a different locale, set it with `I18n.locale`:
|
14
|
-
#
|
15
|
-
# I18n.locale = :es
|
16
|
-
#
|
17
|
-
# This would use the information in config/locales/es.yml.
|
18
|
-
#
|
19
|
-
# To learn more, please read the Rails Internationalization guide
|
20
|
-
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
-
|
22
|
-
en:
|
23
|
-
hello: "Hello world"
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
Rails.application.routes.draw do
|
3
|
-
get 'test/index' => 'test#index'
|
4
|
-
# The priority is based upon order of creation: first created -> highest priority.
|
5
|
-
# See how all your routes lay out with "rake routes".
|
6
|
-
|
7
|
-
# You can have the root of your site routed with "root"
|
8
|
-
# root 'welcome#index'
|
9
|
-
|
10
|
-
# Example of regular route:
|
11
|
-
# get 'products/:id' => 'catalog#view'
|
12
|
-
|
13
|
-
# Example of named route that can be invoked with purchase_url(id: product.id)
|
14
|
-
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
15
|
-
|
16
|
-
# Example resource route (maps HTTP verbs to controller actions automatically):
|
17
|
-
# resources :products
|
18
|
-
|
19
|
-
# Example resource route with options:
|
20
|
-
# resources :products do
|
21
|
-
# member do
|
22
|
-
# get 'short'
|
23
|
-
# post 'toggle'
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# collection do
|
27
|
-
# get 'sold'
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
|
31
|
-
# Example resource route with sub-resources:
|
32
|
-
# resources :products do
|
33
|
-
# resources :comments, :sales
|
34
|
-
# resource :seller
|
35
|
-
# end
|
36
|
-
|
37
|
-
# Example resource route with more complex sub-resources:
|
38
|
-
# resources :products do
|
39
|
-
# resources :comments
|
40
|
-
# resources :sales do
|
41
|
-
# get 'recent', on: :collection
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
|
45
|
-
# Example resource route with concerns:
|
46
|
-
# concern :toggleable do
|
47
|
-
# post 'toggle'
|
48
|
-
# end
|
49
|
-
# resources :posts, concerns: :toggleable
|
50
|
-
# resources :photos, concerns: :toggleable
|
51
|
-
|
52
|
-
# Example resource route within a namespace:
|
53
|
-
# namespace :admin do
|
54
|
-
# # Directs /admin/products/* to Admin::ProductsController
|
55
|
-
# # (app/controllers/admin/products_controller.rb)
|
56
|
-
# resources :products
|
57
|
-
# end
|
58
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# typed: false
|
2
|
-
class AddMoreColumnTypesToWands < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
add_column :wands, :flexibility, :float, null: false, default: 0.5
|
5
|
-
add_column :wands, :hardness, :decimal, null: false, precision: 10, scale: 10, default: 5
|
6
|
-
add_column :wands, :reflectance, :decimal, null: false, precision: 10, scale: 0, default: 0.5
|
7
|
-
add_column :wands, :broken, :boolean, null: false, default: false
|
8
|
-
add_column :wands, :broken_at, :datetime, null: true
|
9
|
-
add_column :wands, :chosen_at_date, :date
|
10
|
-
add_column :wands, :chosen_at_time, :time
|
11
|
-
# JSON column type is only supported on 5.2 or higher
|
12
|
-
unless ['4.2', '5.0', '5.1'].include?(ENV['RAILS_VERSION'])
|
13
|
-
add_column :wands, :spell_history, :json
|
14
|
-
add_column :wands, :maker_info, :json, null: false, default: '{}'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# typed: false
|
2
|
-
# encoding: UTF-8
|
3
|
-
# This file is auto-generated from the current state of the database. Instead
|
4
|
-
# of editing this file, please use the migrations feature of Active Record to
|
5
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
6
|
-
#
|
7
|
-
# Note that this schema.rb definition is the authoritative source for your
|
8
|
-
# database schema. If you need to create the application database on another
|
9
|
-
# system, you should be using db:schema:load, not running all the migrations
|
10
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
11
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
12
|
-
#
|
13
|
-
# It's strongly recommended that you check this file into your version control system.
|
14
|
-
|
15
|
-
ActiveRecord::Schema.define(version: 20190620000007) do
|
16
|
-
|
17
|
-
create_table "spell_books", force: :cascade do |t|
|
18
|
-
t.string "name"
|
19
|
-
t.integer "wizard_id"
|
20
|
-
t.integer "book_type", default: 0, null: false
|
21
|
-
end
|
22
|
-
|
23
|
-
create_table "wands", force: :cascade do |t|
|
24
|
-
t.integer "wizard_id", null: false
|
25
|
-
t.string "wood_type"
|
26
|
-
t.integer "core_type"
|
27
|
-
t.datetime "created_at"
|
28
|
-
t.datetime "updated_at"
|
29
|
-
t.float "flexibility", default: 0.5, null: false
|
30
|
-
t.decimal "hardness", precision: 10, scale: 10, default: 5.0, null: false
|
31
|
-
t.decimal "reflectance", precision: 10, default: 0, null: false
|
32
|
-
t.boolean "broken", default: false, null: false
|
33
|
-
t.datetime "broken_at"
|
34
|
-
t.date "chosen_at_date"
|
35
|
-
t.time "chosen_at_time"
|
36
|
-
end
|
37
|
-
|
38
|
-
create_table "wizards", force: :cascade do |t|
|
39
|
-
t.string "name"
|
40
|
-
t.integer "house"
|
41
|
-
t.string "parent_email"
|
42
|
-
t.text "notes"
|
43
|
-
t.datetime "created_at", null: false
|
44
|
-
t.datetime "updated_at", null: false
|
45
|
-
t.string "broom"
|
46
|
-
t.string "type", default: "Wizard", null: false
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# This file should contain all the record creation needed to seed the database with its default values.
|
3
|
-
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
4
|
-
#
|
5
|
-
# Examples:
|
6
|
-
#
|
7
|
-
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
8
|
-
# Mayor.create(name: 'Emanuel', city: cities.first)
|
File without changes
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
class MythicalRbiPlugin < SorbetRails::ModelPlugins::Base
|
3
|
-
def generate(root)
|
4
|
-
return unless @model_class.include?(Mythical)
|
5
|
-
|
6
|
-
model_class_rbi = root.create_class(self.model_class_name)
|
7
|
-
|
8
|
-
# ActiveSupport::Concern class method will be inserted to the class
|
9
|
-
# directly. We need to also put the sig in the model class rbi directly
|
10
|
-
model_class_rbi.create_method(
|
11
|
-
'mythicals',
|
12
|
-
class_method: true,
|
13
|
-
return_type: "T::Array[#{@model_class.name}]",
|
14
|
-
)
|
15
|
-
end
|
16
|
-
end
|
File without changes
|
data/spec/support/v4.2/log/.keep
DELETED
File without changes
|
@@ -1,238 +0,0 @@
|
|
1
|
-
# typed: false
|
2
|
-
require 'sorbet-runtime'
|
3
|
-
|
4
|
-
wand = Wand.first!
|
5
|
-
wizard = Wizard.first!
|
6
|
-
T.assert_type!(wizard, Wizard)
|
7
|
-
|
8
|
-
# -- model columns
|
9
|
-
T.assert_type!(wizard.name, T.nilable(String))
|
10
|
-
|
11
|
-
# -- time/date columns
|
12
|
-
T.assert_type!(wizard.created_at, ActiveSupport::TimeWithZone)
|
13
|
-
T.assert_type!(wand.broken_at, T.nilable(Time))
|
14
|
-
T.assert_type!(wand.chosen_at_date, T.nilable(Date))
|
15
|
-
|
16
|
-
# assert that TZ aware attributes are casted to TimeWithZone after assigning
|
17
|
-
wizard.created_at = DateTime.now
|
18
|
-
T.assert_type!(wizard.created_at, ActiveSupport::TimeWithZone)
|
19
|
-
|
20
|
-
if ENV["RAILS_VERSION"] != "4.2"
|
21
|
-
# note: this is expected to fail in Rails 4.2, because in that version only
|
22
|
-
# `datetime` fields are made time zone aware (so this will have the type
|
23
|
-
# `T.nilable(Time)` instead)
|
24
|
-
T.assert_type!(wand.chosen_at_time, T.nilable(ActiveSupport::TimeWithZone))
|
25
|
-
end
|
26
|
-
|
27
|
-
# -- model associations
|
28
|
-
T.assert_type!(wizard.wand, T.nilable(Wand))
|
29
|
-
T.assert_type!(T.must(wizard.wand).wizard, Wizard)
|
30
|
-
|
31
|
-
# need the exact type to works! they aren't subclass of each other
|
32
|
-
# T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Relation)
|
33
|
-
# T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_AssociationRelation)
|
34
|
-
T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Associations_CollectionProxy)
|
35
|
-
|
36
|
-
# -- model relation
|
37
|
-
# default
|
38
|
-
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
39
|
-
|
40
|
-
# custom scope
|
41
|
-
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation)
|
42
|
-
|
43
|
-
# enum scope
|
44
|
-
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation)
|
45
|
-
|
46
|
-
# ActiveRecord Querying
|
47
|
-
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
48
|
-
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
49
|
-
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
50
|
-
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
51
|
-
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
52
|
-
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
53
|
-
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
54
|
-
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
55
|
-
|
56
|
-
# Finder methods -- Model
|
57
|
-
T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
|
58
|
-
T.assert_type!(Wizard.find(wizard.id), Wizard)
|
59
|
-
T.assert_type!(Wizard.first!, Wizard)
|
60
|
-
T.assert_type!(Wizard.first, T.nilable(Wizard))
|
61
|
-
T.assert_type!(Wizard.last!, Wizard)
|
62
|
-
T.assert_type!(Wizard.last, T.nilable(Wizard))
|
63
|
-
T.assert_type!(Wizard.first_n(5), T::Array[Wizard])
|
64
|
-
T.assert_type!(Wizard.last_n(5), T::Array[Wizard])
|
65
|
-
T.assert_type!(Wizard.find_by(name: 'Harry Potter'), T.nilable(Wizard))
|
66
|
-
T.assert_type!(Wizard.find_by!(name: 'Harry Potter'), Wizard)
|
67
|
-
T.assert_type!(Wizard.find_by_id(wizard.id), T.nilable(Wizard))
|
68
|
-
T.assert_type!(Wizard.find_by_id!(wizard.id), Wizard)
|
69
|
-
|
70
|
-
# Finder methods -- ActiveRecord::Relation
|
71
|
-
T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
|
72
|
-
T.assert_type!(Wizard.all.find(wizard.id), Wizard)
|
73
|
-
T.assert_type!(Wizard.all.first!, Wizard)
|
74
|
-
T.assert_type!(Wizard.all.first, T.nilable(Wizard))
|
75
|
-
T.assert_type!(Wizard.all.last!, Wizard)
|
76
|
-
T.assert_type!(Wizard.all.last, T.nilable(Wizard))
|
77
|
-
T.assert_type!(Wizard.all.first_n(5), T::Array[Wizard])
|
78
|
-
T.assert_type!(Wizard.all.last_n(5), T::Array[Wizard])
|
79
|
-
T.assert_type!(Wizard.all.find_by(name: 'Harry Potter'), T.nilable(Wizard))
|
80
|
-
T.assert_type!(Wizard.all.find_by!(name: 'Harry Potter'), Wizard)
|
81
|
-
T.assert_type!(Wizard.all.find_by_id(wizard.id), T.nilable(Wizard))
|
82
|
-
T.assert_type!(Wizard.all.find_by_id!(wizard.id), Wizard)
|
83
|
-
|
84
|
-
# Finder methods -- CollectionProxy
|
85
|
-
spell_book = wizard.spell_books.first!
|
86
|
-
spell_books = wizard.spell_books
|
87
|
-
T.assert_type!(spell_books.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
88
|
-
T.assert_type!(spell_books.find(spell_book.id), SpellBook)
|
89
|
-
T.assert_type!(spell_books.first!, SpellBook)
|
90
|
-
# T.assert_type!(spell_books.first, T.nilable(SpellBook)) # TODO fix sig for 4.2 and 5.0
|
91
|
-
T.assert_type!(spell_books.last!, SpellBook)
|
92
|
-
# T.assert_type!(spell_books.last, T.nilable(SpellBook)) # TODO fix sig for 4.2 and 5.0
|
93
|
-
T.assert_type!(spell_books.first_n(5), T::Array[SpellBook])
|
94
|
-
T.assert_type!(spell_books.last_n(5), T::Array[SpellBook])
|
95
|
-
T.assert_type!(spell_books.find_by(name: 'Fantastic Beasts'), T.nilable(SpellBook))
|
96
|
-
T.assert_type!(spell_books.find_by!(name: 'Fantastic Beasts'), SpellBook)
|
97
|
-
T.assert_type!(spell_books.find_by_id(spell_book.id), T.nilable(SpellBook))
|
98
|
-
T.assert_type!(spell_books.find_by_id!(spell_book.id), SpellBook)
|
99
|
-
# CollectionProxy query also typed correctly!
|
100
|
-
T.assert_type!(spell_books.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
101
|
-
T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
102
|
-
T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
103
|
-
T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
104
|
-
T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
105
|
-
T.assert_type!(spell_books.biology, SpellBook::ActiveRecord_AssociationRelation)
|
106
|
-
|
107
|
-
# finder methods -- AssociationRelation
|
108
|
-
spell_books_query = spell_books.where(id: 1)
|
109
|
-
T.assert_type!(spell_books_query.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
110
|
-
T.assert_type!(spell_books_query.find(spell_book.id), SpellBook)
|
111
|
-
T.assert_type!(spell_books_query.first!, SpellBook)
|
112
|
-
# T.assert_type!(spell_books_query.first, T.nilable(SpellBook)) # TODO fix sig for 4.2 and 5.0
|
113
|
-
T.assert_type!(spell_books_query.last!, SpellBook)
|
114
|
-
# T.assert_type!(spell_books_query.last, T.nilable(SpellBook)) # TODO fix sig for 4.2 and 5.0
|
115
|
-
T.assert_type!(spell_books_query.first_n(5), T::Array[SpellBook])
|
116
|
-
T.assert_type!(spell_books_query.last_n(5), T::Array[SpellBook])
|
117
|
-
T.assert_type!(spell_books_query.find_by(name: 'Fantastic Beasts'), T.nilable(SpellBook))
|
118
|
-
T.assert_type!(spell_books_query.find_by!(name: 'Fantastic Beasts'), SpellBook)
|
119
|
-
T.assert_type!(spell_books_query.find_by_id(spell_book.id), T.nilable(SpellBook))
|
120
|
-
T.assert_type!(spell_books_query.find_by_id!(spell_book.id), SpellBook)
|
121
|
-
# Query chaining
|
122
|
-
T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
123
|
-
T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
124
|
-
T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
125
|
-
T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
126
|
-
T.assert_type!(spell_books_query.biology, SpellBook::ActiveRecord_AssociationRelation)
|
127
|
-
|
128
|
-
# Enumerable on activerecord relation
|
129
|
-
T.assert_type!(Wizard.all.to_a, T::Array[Wizard])
|
130
|
-
Wizard.all.each do |w|
|
131
|
-
T.assert_type!(w, Wizard)
|
132
|
-
end
|
133
|
-
Wizard.all.map do |w|
|
134
|
-
T.assert_type!(w, Wizard)
|
135
|
-
end
|
136
|
-
Wizard.all.to_a.map do |w|
|
137
|
-
T.assert_type!(w, Wizard)
|
138
|
-
end
|
139
|
-
|
140
|
-
# enum on association collection proxy
|
141
|
-
T.assert_type!(wizard.spell_books.to_a, T::Array[SpellBook])
|
142
|
-
wizard.spell_books.each do |sp|
|
143
|
-
T.assert_type!(sp, SpellBook)
|
144
|
-
end
|
145
|
-
wizard.spell_books.map do |sp|
|
146
|
-
T.assert_type!(sp, SpellBook)
|
147
|
-
end
|
148
|
-
wizard.spell_books.to_a.map do |sp|
|
149
|
-
T.assert_type!(sp, SpellBook)
|
150
|
-
end
|
151
|
-
|
152
|
-
# enum on association relation
|
153
|
-
T.assert_type!(wizard.spell_books.where(id: 1).to_a, T::Array[SpellBook])
|
154
|
-
wizard.spell_books.where(id: 1).each do |sp|
|
155
|
-
T.assert_type!(sp, SpellBook)
|
156
|
-
end
|
157
|
-
wizard.spell_books.where(id: 1).map do |sp|
|
158
|
-
T.assert_type!(sp, SpellBook)
|
159
|
-
end
|
160
|
-
wizard.spell_books.where(id: 1).to_a.map do |sp|
|
161
|
-
T.assert_type!(sp, SpellBook)
|
162
|
-
end
|
163
|
-
|
164
|
-
# Model columns
|
165
|
-
T.assert_type!(wizard.id, Integer)
|
166
|
-
T.assert_type!(wizard.id?, T::Boolean)
|
167
|
-
T.assert_type!(wizard.notes, T.nilable(String))
|
168
|
-
|
169
|
-
# Model enum
|
170
|
-
T.assert_type!(wizard.Gryffindor?, T::Boolean)
|
171
|
-
T.assert_type!(wizard.house, T.nilable(String))
|
172
|
-
T.assert_type!(Wizard.houses, T::Hash[T.any(String, Symbol), Integer])
|
173
|
-
T.assert_type!(Wizard.brooms, T::Hash[T.any(String, Symbol), String])
|
174
|
-
T.assert_type!(spell_book.biology?, T::Boolean)
|
175
|
-
T.assert_type!(spell_book.book_type, String)
|
176
|
-
T.assert_type!(SpellBook.book_types, T::Hash[T.any(String, Symbol), Integer])
|
177
|
-
|
178
|
-
# Mythical plugin
|
179
|
-
T.assert_type!(Wand.mythicals, T::Array[Wand])
|
180
|
-
|
181
|
-
T.assert_type!(HogwartsAcceptanceMailer.notify(wizard), ActionMailer::MessageDelivery)
|
182
|
-
|
183
|
-
if ENV["RAILS_VERSION"] != "4.2"
|
184
|
-
T.assert_type!(wizard.broom_nimbus?, T::Boolean)
|
185
|
-
T.assert_type!(wizard.color_brown_eyes?, T::Boolean)
|
186
|
-
T.assert_type!(wizard.quidditch_keeper?, T::Boolean)
|
187
|
-
T.assert_type!(wizard.brown_hair?, T::Boolean)
|
188
|
-
end
|
189
|
-
|
190
|
-
# -- Custom ActionController::Parameters Methods
|
191
|
-
params = ActionController::Parameters.new({
|
192
|
-
age: 11,
|
193
|
-
name: 'Harry Potter',
|
194
|
-
info: {
|
195
|
-
birthday: Date.parse('1980-07-31'),
|
196
|
-
friends: [
|
197
|
-
'Hermione',
|
198
|
-
'Ron',
|
199
|
-
],
|
200
|
-
grandson: nil,
|
201
|
-
},
|
202
|
-
})
|
203
|
-
# -- require_typed
|
204
|
-
T.assert_type!(
|
205
|
-
params.require_typed(:age, TA[Integer].new),
|
206
|
-
Integer,
|
207
|
-
)
|
208
|
-
T.assert_type!(
|
209
|
-
params.require_typed(:name, TA[String].new),
|
210
|
-
String,
|
211
|
-
)
|
212
|
-
info = params.require_typed(:info, TA[ActionController::Parameters].new)
|
213
|
-
T.assert_type!(info, ActionController::Parameters)
|
214
|
-
T.assert_type!(
|
215
|
-
info.require_typed(:friends, TA[T::Array[String]].new),
|
216
|
-
T::Array[String],
|
217
|
-
)
|
218
|
-
# -- fetch_typed
|
219
|
-
T.assert_type!(
|
220
|
-
params.fetch_typed(:age, TA[Integer].new),
|
221
|
-
Integer,
|
222
|
-
)
|
223
|
-
T.assert_type!(
|
224
|
-
params.fetch_typed(:name, TA[String].new),
|
225
|
-
String,
|
226
|
-
)
|
227
|
-
T.assert_type!(
|
228
|
-
params.fetch_typed(:nonexistence, TA[String].new, ''),
|
229
|
-
String,
|
230
|
-
)
|
231
|
-
T.assert_type!(
|
232
|
-
params.fetch_typed(:nonexistence, TA[T.nilable(String)].new, nil),
|
233
|
-
T.nilable(String),
|
234
|
-
)
|
235
|
-
T.assert_type!(
|
236
|
-
params.fetch_typed(:nonexistence, TA[T::Array[Integer]].new, []),
|
237
|
-
T::Array[Integer],
|
238
|
-
)
|