sorbet-rails 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +3 -3
- data/lib/bundled_rbi/typed_enum.rbi +7 -0
- data/lib/sorbet-rails.rb +0 -2
- data/lib/sorbet-rails/active_record_rbi_formatter.rb +301 -0
- data/lib/sorbet-rails/config.rb +0 -1
- data/lib/sorbet-rails/dependent_gem_rbis/activerecord.rbi +11 -0
- data/lib/sorbet-rails/deprecation.rb +5 -0
- data/lib/sorbet-rails/gem_plugins/active_flag_plugin.rb +0 -1
- data/lib/sorbet-rails/gem_plugins/paperclip_plugin.rb +0 -1
- data/lib/sorbet-rails/model_plugins/active_record_assoc.rb +36 -8
- data/lib/sorbet-rails/model_plugins/active_record_attribute.rb +20 -9
- data/lib/sorbet-rails/model_plugins/active_record_enum.rb +0 -1
- data/lib/sorbet-rails/model_plugins/active_record_named_scope.rb +15 -6
- data/lib/sorbet-rails/model_plugins/active_record_querying.rb +34 -3
- data/lib/sorbet-rails/model_plugins/active_storage_methods.rb +1 -1
- data/lib/sorbet-rails/model_plugins/base.rb +10 -0
- data/lib/sorbet-rails/model_plugins/enumerable_collections.rb +0 -50
- data/lib/sorbet-rails/model_plugins/plugins.rb +0 -3
- data/lib/sorbet-rails/model_rbi_formatter.rb +6 -10
- data/lib/sorbet-rails/model_utils.rb +83 -36
- data/lib/sorbet-rails/rails_mixins/generated_url_helpers.rb +2 -3
- data/lib/sorbet-rails/railtie.rb +0 -2
- data/lib/sorbet-rails/tasks/rails_rbi.rake +32 -24
- data/sorbet-rails.gemspec +2 -2
- data/spec/active_record_rbi_formatter_spec.rb +24 -0
- data/spec/generators/rails-template.rb +90 -6
- data/spec/generators/sorbet_test_cases.rb +204 -122
- data/spec/model_rbi_formatter_spec.rb +1 -1
- data/spec/rails_helper.rb +14 -1
- data/spec/rake_rails_rbi_active_record_spec.rb +21 -0
- data/spec/rake_rails_rbi_models_spec.rb +7 -0
- data/spec/sorbet_spec.rb +12 -1
- data/spec/support/v5.0/Gemfile.lock +8 -8
- data/spec/support/v5.0/app/models/headmaster.rb +8 -0
- data/spec/support/v5.0/app/models/school.rb +2 -0
- data/spec/support/v5.0/app/models/spell.rb +5 -0
- data/spec/support/v5.0/app/models/spell_book.rb +5 -0
- data/spec/support/v5.0/app/models/subject.rb +5 -0
- data/spec/support/v5.0/app/models/wizard.rb +6 -1
- data/spec/support/v5.0/db/migrate/20190620000010_add_subject.rb +8 -0
- data/spec/support/v5.0/db/migrate/20190620000011_add_subjects_wizards.rb +8 -0
- data/spec/support/v5.0/db/migrate/20190620000012_add_spell.rb +8 -0
- data/spec/support/v5.0/db/migrate/20190620000013_add_spells_spell_books.rb +8 -0
- data/spec/support/v5.0/db/migrate/20190620000014_create_headmasters.rb +9 -0
- data/spec/support/v5.0/db/schema.rb +28 -1
- data/spec/support/v5.0/lib/mythical_rbi_plugin.rb +1 -1
- data/spec/support/v5.0/sorbet_test_cases.rb +204 -122
- data/spec/support/v5.1/Gemfile.lock +8 -8
- data/spec/support/v5.1/app/models/headmaster.rb +8 -0
- data/spec/support/v5.1/app/models/school.rb +2 -0
- data/spec/support/v5.1/app/models/spell.rb +5 -0
- data/spec/support/v5.1/app/models/spell_book.rb +5 -0
- data/spec/support/v5.1/app/models/subject.rb +5 -0
- data/spec/support/v5.1/app/models/wizard.rb +6 -1
- data/spec/support/v5.1/db/migrate/20190620000010_add_subject.rb +8 -0
- data/spec/support/v5.1/db/migrate/20190620000011_add_subjects_wizards.rb +8 -0
- data/spec/support/v5.1/db/migrate/20190620000012_add_spell.rb +8 -0
- data/spec/support/v5.1/db/migrate/20190620000013_add_spells_spell_books.rb +8 -0
- data/spec/support/v5.1/db/migrate/20190620000014_create_headmasters.rb +9 -0
- data/spec/support/v5.1/db/schema.rb +28 -1
- data/spec/support/v5.1/lib/mythical_rbi_plugin.rb +1 -1
- data/spec/support/v5.1/sorbet_test_cases.rb +204 -122
- data/spec/support/v5.2/Gemfile +1 -1
- data/spec/support/v5.2/Gemfile.lock +9 -9
- data/spec/support/v5.2/app/models/headmaster.rb +8 -0
- data/spec/support/v5.2/app/models/school.rb +2 -0
- data/spec/support/v5.2/app/models/spell.rb +5 -0
- data/spec/support/v5.2/app/models/spell_book.rb +5 -0
- data/spec/support/v5.2/app/models/subject.rb +5 -0
- data/spec/support/v5.2/app/models/wizard.rb +5 -0
- data/spec/support/v5.2/config/puma.rb +3 -0
- data/spec/support/v5.2/db/migrate/20190620000010_add_subject.rb +8 -0
- data/spec/support/v5.2/db/migrate/20190620000011_add_subjects_wizards.rb +8 -0
- data/spec/support/v5.2/db/migrate/20190620000012_add_spell.rb +8 -0
- data/spec/support/v5.2/db/migrate/20190620000013_add_spells_spell_books.rb +8 -0
- data/spec/support/v5.2/db/migrate/20190620000014_create_headmasters.rb +9 -0
- data/spec/support/v5.2/db/schema.rb +28 -1
- data/spec/support/v5.2/lib/mythical_rbi_plugin.rb +1 -1
- data/spec/support/v5.2/sorbet_test_cases.rb +204 -122
- data/spec/support/v6.0/Gemfile.lock +8 -8
- data/spec/support/v6.0/app/models/headmaster.rb +8 -0
- data/spec/support/v6.0/app/models/school.rb +2 -0
- data/spec/support/v6.0/app/models/spell.rb +5 -0
- data/spec/support/v6.0/app/models/spell_book.rb +5 -0
- data/spec/support/v6.0/app/models/subject.rb +5 -0
- data/spec/support/v6.0/app/models/wizard.rb +6 -1
- data/spec/support/v6.0/db/migrate/20190620000010_add_subject.rb +8 -0
- data/spec/support/v6.0/db/migrate/20190620000011_add_subjects_wizards.rb +8 -0
- data/spec/support/v6.0/db/migrate/20190620000012_add_spell.rb +8 -0
- data/spec/support/v6.0/db/migrate/20190620000013_add_spells_spell_books.rb +8 -0
- data/spec/support/v6.0/db/migrate/20190620000014_create_headmasters.rb +9 -0
- data/spec/support/v6.0/db/schema.rb +28 -1
- data/spec/support/v6.0/lib/mythical_rbi_plugin.rb +1 -1
- data/spec/support/v6.0/sorbet_test_cases.rb +204 -122
- data/spec/test_data/v5.0/expected_active_record_base.rbi +113 -0
- data/spec/test_data/v5.0/expected_active_record_relation.rbi +199 -0
- data/spec/test_data/v5.0/expected_habtm_subjects.rbi +660 -0
- data/spec/test_data/v5.0/expected_habtm_wizards.rbi +660 -0
- data/spec/test_data/v5.0/expected_headmaster.rbi +304 -0
- data/spec/test_data/v5.0/expected_internal_metadata.rbi +38 -401
- data/spec/test_data/v5.0/expected_potion.rbi +38 -401
- data/spec/test_data/v5.0/expected_robe.rbi +38 -403
- data/spec/test_data/v5.0/expected_schema_migration.rbi +38 -401
- data/spec/test_data/v5.0/expected_school.rbi +47 -401
- data/spec/test_data/v5.0/expected_spell.rbi +292 -0
- data/spec/test_data/v5.0/expected_spell/habtm_spell_books.rbi +295 -0
- data/spec/test_data/v5.0/expected_spell_book.rbi +86 -432
- data/spec/test_data/v5.0/expected_spell_book/habtm_spell_books.rbi +637 -0
- data/spec/test_data/v5.0/expected_spell_book/habtm_spells.rbi +295 -0
- data/spec/test_data/v5.0/expected_squib.rbi +122 -477
- data/spec/test_data/v5.0/expected_subject.rbi +292 -0
- data/spec/test_data/v5.0/expected_subject/habtm_wizards.rbi +295 -0
- data/spec/test_data/v5.0/expected_wand.rbi +75 -442
- data/spec/test_data/v5.0/expected_wizard.rbi +144 -498
- data/spec/test_data/v5.0/expected_wizard/habtm_subjects.rbi +295 -0
- data/spec/test_data/v5.0/expected_wizard_wo_spellbook.rbi +138 -498
- data/spec/test_data/v5.1/expected_active_record_base.rbi +113 -0
- data/spec/test_data/v5.1/expected_active_record_relation.rbi +178 -0
- data/spec/test_data/v5.1/expected_habtm_subjects.rbi +672 -0
- data/spec/test_data/v5.1/expected_habtm_wizards.rbi +672 -0
- data/spec/test_data/v5.1/expected_headmaster.rbi +310 -0
- data/spec/test_data/v5.1/expected_internal_metadata.rbi +38 -407
- data/spec/test_data/v5.1/expected_potion.rbi +38 -407
- data/spec/test_data/v5.1/expected_robe.rbi +38 -409
- data/spec/test_data/v5.1/expected_schema_migration.rbi +38 -407
- data/spec/test_data/v5.1/expected_school.rbi +47 -407
- data/spec/test_data/v5.1/expected_spell.rbi +298 -0
- data/spec/test_data/v5.1/expected_spell/habtm_spell_books.rbi +301 -0
- data/spec/test_data/v5.1/expected_spell_book.rbi +86 -438
- data/spec/test_data/v5.1/expected_spell_book/habtm_spell_books.rbi +649 -0
- data/spec/test_data/v5.1/expected_spell_book/habtm_spells.rbi +301 -0
- data/spec/test_data/v5.1/expected_squib.rbi +123 -484
- data/spec/test_data/v5.1/expected_subject.rbi +298 -0
- data/spec/test_data/v5.1/expected_subject/habtm_wizards.rbi +301 -0
- data/spec/test_data/v5.1/expected_wand.rbi +75 -448
- data/spec/test_data/v5.1/expected_wizard.rbi +145 -505
- data/spec/test_data/v5.1/expected_wizard/habtm_subjects.rbi +301 -0
- data/spec/test_data/v5.1/expected_wizard_wo_spellbook.rbi +139 -505
- data/spec/test_data/v5.2/expected_active_record_base.rbi +113 -0
- data/spec/test_data/v5.2/expected_active_record_relation.rbi +175 -0
- data/spec/test_data/v5.2/expected_attachment.rbi +38 -407
- data/spec/test_data/v5.2/expected_blob.rbi +60 -426
- data/spec/test_data/v5.2/expected_habtm_subjects.rbi +672 -0
- data/spec/test_data/v5.2/expected_habtm_wizards.rbi +672 -0
- data/spec/test_data/v5.2/expected_headmaster.rbi +310 -0
- data/spec/test_data/v5.2/expected_internal_metadata.rbi +38 -407
- data/spec/test_data/v5.2/expected_potion.rbi +38 -407
- data/spec/test_data/v5.2/expected_robe.rbi +38 -409
- data/spec/test_data/v5.2/expected_schema_migration.rbi +38 -407
- data/spec/test_data/v5.2/expected_school.rbi +47 -407
- data/spec/test_data/v5.2/expected_spell.rbi +298 -0
- data/spec/test_data/v5.2/expected_spell/habtm_spell_books.rbi +301 -0
- data/spec/test_data/v5.2/expected_spell_book.rbi +86 -438
- data/spec/test_data/v5.2/expected_spell_book/habtm_spell_books.rbi +649 -0
- data/spec/test_data/v5.2/expected_spell_book/habtm_spells.rbi +301 -0
- data/spec/test_data/v5.2/expected_squib.rbi +133 -488
- data/spec/test_data/v5.2/expected_subject.rbi +298 -0
- data/spec/test_data/v5.2/expected_subject/habtm_wizards.rbi +301 -0
- data/spec/test_data/v5.2/expected_wand.rbi +75 -448
- data/spec/test_data/v5.2/expected_wizard.rbi +155 -509
- data/spec/test_data/v5.2/expected_wizard/habtm_subjects.rbi +301 -0
- data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +149 -509
- data/spec/test_data/v6.0/expected_active_record_base.rbi +113 -0
- data/spec/test_data/v6.0/expected_active_record_relation.rbi +175 -0
- data/spec/test_data/v6.0/expected_attachment.rbi +38 -431
- data/spec/test_data/v6.0/expected_blob.rbi +60 -450
- data/spec/test_data/v6.0/expected_habtm_subjects.rbi +720 -0
- data/spec/test_data/v6.0/expected_habtm_wizards.rbi +720 -0
- data/spec/test_data/v6.0/expected_headmaster.rbi +334 -0
- data/spec/test_data/v6.0/expected_internal_metadata.rbi +38 -431
- data/spec/test_data/v6.0/expected_potion.rbi +38 -431
- data/spec/test_data/v6.0/expected_robe.rbi +38 -433
- data/spec/test_data/v6.0/expected_routes.rbi +14 -7
- data/spec/test_data/v6.0/expected_schema_migration.rbi +38 -431
- data/spec/test_data/v6.0/expected_school.rbi +47 -431
- data/spec/test_data/v6.0/expected_spell.rbi +322 -0
- data/spec/test_data/v6.0/expected_spell/habtm_spell_books.rbi +325 -0
- data/spec/test_data/v6.0/expected_spell_book.rbi +98 -474
- data/spec/test_data/v6.0/expected_spell_book/habtm_spell_books.rbi +697 -0
- data/spec/test_data/v6.0/expected_spell_book/habtm_spells.rbi +325 -0
- data/spec/test_data/v6.0/expected_squib.rbi +162 -541
- data/spec/test_data/v6.0/expected_subject.rbi +322 -0
- data/spec/test_data/v6.0/expected_subject/habtm_wizards.rbi +325 -0
- data/spec/test_data/v6.0/expected_wand.rbi +91 -488
- data/spec/test_data/v6.0/expected_wizard.rbi +184 -562
- data/spec/test_data/v6.0/expected_wizard/habtm_subjects.rbi +325 -0
- data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +178 -562
- metadata +170 -24
- data/lib/bundled_rbi/active_record_base.rbi +0 -83
- data/lib/bundled_rbi/active_record_relation.rbi +0 -122
- data/lib/bundled_rbi/parameters.rbi +0 -28
- data/lib/sorbet-rails/custom_types/boolean_string.rb +0 -32
- data/lib/sorbet-rails/custom_types/integer_string.rb +0 -35
- data/lib/sorbet-rails/model_plugins/active_record_finder_methods.rb +0 -131
- data/lib/sorbet-rails/rails_mixins/custom_params_methods.rb +0 -46
- data/spec/boolean_string_spec.rb +0 -59
- data/spec/custom_params_methods_spec.rb +0 -138
- data/spec/integer_string_spec.rb +0 -46
- data/spec/support/v5.0/typed-override.yaml +0 -2
- data/spec/support/v5.1/typed-override.yaml +0 -2
- data/spec/support/v5.2/typed-override.yaml +0 -2
- data/spec/support/v6.0/typed-override.yaml +0 -2
data/spec/support/v5.2/Gemfile
CHANGED
@@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
4
4
|
ruby '2.5.5'
|
5
5
|
|
6
6
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
7
|
-
gem 'rails', '~> 5.2.
|
7
|
+
gem 'rails', '~> 5.2.4', '>= 5.2.4.2'
|
8
8
|
# Use sqlite3 as the database for Active Record
|
9
9
|
gem 'sqlite3'
|
10
10
|
# Use Puma as the app server
|
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../..
|
3
3
|
specs:
|
4
|
-
sorbet-rails (0.
|
4
|
+
sorbet-rails (0.7.0)
|
5
5
|
method_source (>= 0.9.2)
|
6
6
|
parlour (~> 2.0)
|
7
7
|
parser (>= 2.7)
|
8
|
-
sorbet-coerce (>= 0.2.
|
8
|
+
sorbet-coerce (>= 0.2.6)
|
9
9
|
sorbet-runtime (>= 0.5)
|
10
10
|
|
11
11
|
GEM
|
@@ -89,7 +89,7 @@ GEM
|
|
89
89
|
parser
|
90
90
|
rainbow (~> 3.0)
|
91
91
|
sorbet-runtime (>= 0.5)
|
92
|
-
parser (2.7.
|
92
|
+
parser (2.7.1.2)
|
93
93
|
ast (~> 2.4.0)
|
94
94
|
polyfill (1.8.0)
|
95
95
|
puma (3.12.4)
|
@@ -123,15 +123,15 @@ GEM
|
|
123
123
|
rainbow (3.0.0)
|
124
124
|
rake (13.0.1)
|
125
125
|
safe_type (1.1.1)
|
126
|
-
sorbet (0.5.
|
127
|
-
sorbet-static (= 0.5.
|
128
|
-
sorbet-coerce (0.2.
|
126
|
+
sorbet (0.5.5480)
|
127
|
+
sorbet-static (= 0.5.5480)
|
128
|
+
sorbet-coerce (0.2.7)
|
129
129
|
polyfill (~> 1.8)
|
130
130
|
safe_type (~> 1.1, >= 1.1.1)
|
131
131
|
sorbet (>= 0.4.4704)
|
132
132
|
sorbet-runtime (>= 0.4.4704)
|
133
|
-
sorbet-runtime (0.5.
|
134
|
-
sorbet-static (0.5.
|
133
|
+
sorbet-runtime (0.5.5480)
|
134
|
+
sorbet-static (0.5.5480-universal-darwin-14)
|
135
135
|
sprockets (4.0.0)
|
136
136
|
concurrent-ruby (~> 1.0)
|
137
137
|
rack (> 1, < 3)
|
@@ -160,7 +160,7 @@ DEPENDENCIES
|
|
160
160
|
byebug
|
161
161
|
jbuilder (~> 2.5)
|
162
162
|
puma (~> 3.11)
|
163
|
-
rails (~> 5.2.
|
163
|
+
rails (~> 5.2.4, >= 5.2.4.2)
|
164
164
|
sorbet
|
165
165
|
sorbet-rails!
|
166
166
|
sorbet-runtime
|
@@ -5,9 +5,14 @@ class SpellBook < ApplicationRecord
|
|
5
5
|
# simulate when belongs_to is optional by default, but it is enforced at the DB level
|
6
6
|
belongs_to :wizard, optional: true
|
7
7
|
|
8
|
+
# habtm enforced at the DB level
|
9
|
+
has_and_belongs_to_many :spells
|
10
|
+
|
8
11
|
enum book_type: {
|
9
12
|
unclassified: 0,
|
10
13
|
biology: 1,
|
11
14
|
dark_art: 999,
|
12
15
|
}
|
16
|
+
|
17
|
+
scope :recent, -> { where('created_at > ?', 1.month.ago) }
|
13
18
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# typed: strict
|
2
2
|
class Wizard < ApplicationRecord
|
3
3
|
validates :name, length: { minimum: 5 }, presence: true
|
4
|
+
# simulate conditional validation
|
5
|
+
validates :parent_email, presence: true, if: :Slytherin?
|
4
6
|
|
5
7
|
typed_enum house: {
|
6
8
|
Gryffindor: 0,
|
@@ -18,6 +20,7 @@ class Wizard < ApplicationRecord
|
|
18
20
|
"Pomona Sprout": 2,
|
19
21
|
"Filius Flitwick": 3,
|
20
22
|
"Hagrid": 4,
|
23
|
+
"Alastor 'Mad-Eye' Moody": 5,
|
21
24
|
}
|
22
25
|
|
23
26
|
typed_enum broom: {
|
@@ -46,6 +49,8 @@ class Wizard < ApplicationRecord
|
|
46
49
|
|
47
50
|
has_one :wand
|
48
51
|
has_many :spell_books
|
52
|
+
# habtm which is optional at the db level
|
53
|
+
has_and_belongs_to_many :subjects
|
49
54
|
|
50
55
|
# simulate when belongs_to is optional by default
|
51
56
|
belongs_to :school, optional: true
|
@@ -16,6 +16,9 @@ port ENV.fetch("PORT") { 3000 }
|
|
16
16
|
#
|
17
17
|
environment ENV.fetch("RAILS_ENV") { "development" }
|
18
18
|
|
19
|
+
# Specifies the `pidfile` that Puma will use.
|
20
|
+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
21
|
+
|
19
22
|
# Specifies the number of `workers` to boot in clustered mode.
|
20
23
|
# Workers are forked webserver processes. If using threads and workers together
|
21
24
|
# the concurrency of the application would be max `threads` * `workers`.
|
@@ -11,7 +11,14 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 2019_06_20_000014) do
|
15
|
+
|
16
|
+
create_table "headmasters", force: :cascade do |t|
|
17
|
+
t.integer "school_id"
|
18
|
+
t.integer "wizard_id"
|
19
|
+
t.index ["school_id"], name: "index_headmasters_on_school_id"
|
20
|
+
t.index ["wizard_id"], name: "index_headmasters_on_wizard_id"
|
21
|
+
end
|
15
22
|
|
16
23
|
create_table "robes", force: :cascade do |t|
|
17
24
|
t.integer "wizard_id"
|
@@ -29,6 +36,26 @@ ActiveRecord::Schema.define(version: 2019_06_20_000009) do
|
|
29
36
|
t.index ["wizard_id"], name: "index_spell_books_on_wizard_id"
|
30
37
|
end
|
31
38
|
|
39
|
+
create_table "spell_books_spells", id: false, force: :cascade do |t|
|
40
|
+
t.integer "spell_id", null: false
|
41
|
+
t.integer "spell_book_id", null: false
|
42
|
+
t.index ["spell_id", "spell_book_id"], name: "index_spell_books_spells_on_spell_id_and_spell_book_id"
|
43
|
+
end
|
44
|
+
|
45
|
+
create_table "spells", force: :cascade do |t|
|
46
|
+
t.string "name"
|
47
|
+
end
|
48
|
+
|
49
|
+
create_table "subjects", force: :cascade do |t|
|
50
|
+
t.string "name"
|
51
|
+
end
|
52
|
+
|
53
|
+
create_table "subjects_wizards", id: false, force: :cascade do |t|
|
54
|
+
t.integer "subject_id"
|
55
|
+
t.integer "wizard_id"
|
56
|
+
t.index ["subject_id", "wizard_id"], name: "index_subjects_wizards_on_subject_id_and_wizard_id"
|
57
|
+
end
|
58
|
+
|
32
59
|
create_table "wands", force: :cascade do |t|
|
33
60
|
t.integer "wizard_id", null: false
|
34
61
|
t.string "wood_type"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: true
|
2
2
|
require 'sorbet-runtime'
|
3
3
|
|
4
4
|
wand = Wand.first!
|
@@ -27,32 +27,21 @@ T.assert_type!(T.must(wizard.wand).wizard, Wizard)
|
|
27
27
|
# T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Relation)
|
28
28
|
# T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_AssociationRelation)
|
29
29
|
T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Associations_CollectionProxy)
|
30
|
-
|
31
|
-
# -- model relation
|
32
|
-
# default
|
33
|
-
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
34
|
-
|
35
|
-
# custom scope
|
36
|
-
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation)
|
37
|
-
|
38
|
-
# enum scope
|
39
|
-
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation)
|
40
|
-
|
41
|
-
# ActiveRecord Querying
|
42
|
-
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
43
|
-
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
44
|
-
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
45
|
-
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
46
|
-
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
47
|
-
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
48
|
-
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
49
|
-
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
30
|
+
T.assert_type!(wizard.spell_book_ids, T::Array[Integer])
|
50
31
|
|
51
32
|
# Finder methods -- Model
|
52
33
|
T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
|
53
34
|
T.assert_type!(Wizard.find(wizard.id), Wizard)
|
54
35
|
T.assert_type!(Wizard.first!, Wizard)
|
55
36
|
T.assert_type!(Wizard.first, T.nilable(Wizard))
|
37
|
+
T.assert_type!(Wizard.second!, Wizard)
|
38
|
+
T.assert_type!(Wizard.second, T.nilable(Wizard))
|
39
|
+
T.assert_type!(Wizard.third!, Wizard)
|
40
|
+
T.assert_type!(Wizard.third, T.nilable(Wizard))
|
41
|
+
T.assert_type!(Wizard.third_to_last!, Wizard)
|
42
|
+
T.assert_type!(Wizard.third_to_last, T.nilable(Wizard))
|
43
|
+
T.assert_type!(Wizard.second_to_last!, Wizard)
|
44
|
+
T.assert_type!(Wizard.second_to_last, T.nilable(Wizard))
|
56
45
|
T.assert_type!(Wizard.last!, Wizard)
|
57
46
|
T.assert_type!(Wizard.last, T.nilable(Wizard))
|
58
47
|
T.assert_type!(Wizard.first_n(5), T::Array[Wizard])
|
@@ -61,12 +50,54 @@ T.assert_type!(Wizard.find_by(name: 'Harry Potter'), T.nilable(Wizard))
|
|
61
50
|
T.assert_type!(Wizard.find_by!(name: 'Harry Potter'), Wizard)
|
62
51
|
T.assert_type!(Wizard.find_by_id(wizard.id), T.nilable(Wizard))
|
63
52
|
T.assert_type!(Wizard.find_by_id!(wizard.id), Wizard)
|
53
|
+
T.assert_type!(Wizard.find_or_initialize_by(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
54
|
+
T.assert_type!(Wizard.find_or_create_by(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
55
|
+
T.assert_type!(Wizard.find_or_create_by!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
56
|
+
T.assert_type!(Wizard.new { |w| T.assert_type!(w, Wizard) }, Wizard)
|
57
|
+
T.assert_type!(Wizard.create(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
58
|
+
T.assert_type!(Wizard.create!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
59
|
+
T.assert_type!(Wizard.first_or_create(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
60
|
+
T.assert_type!(Wizard.first_or_create!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
61
|
+
T.assert_type!(Wizard.first_or_initialize { |w| T.assert_type!(w, Wizard) }, Wizard)
|
62
|
+
Wizard.find_each { |w| T.assert_type!(w, Wizard) }
|
63
|
+
T.assert_type!(Wizard.find_each, T::Enumerator[Wizard])
|
64
|
+
Wizard.find_in_batches { |w| T.assert_type!(w, T::Array[Wizard]) }
|
65
|
+
T.assert_type!(Wizard.find_in_batches, T::Enumerator[T::Array[Wizard]])
|
66
|
+
Wizard.in_batches { |w| T.assert_type!(w, Wizard::ActiveRecord_Relation) }
|
67
|
+
T.assert_type!(Wizard.in_batches, ActiveRecord::Batches::BatchEnumerator)
|
68
|
+
# T.assert_type!(Wizard.destroy_all, T::Array[Wizard]) # Ignored until we add support
|
69
|
+
T.assert_type!(Wizard.any?, T::Boolean)
|
70
|
+
T.assert_type!(Wizard.many?, T::Boolean)
|
71
|
+
T.assert_type!(Wizard.none?, T::Boolean)
|
72
|
+
T.assert_type!(Wizard.one?, T::Boolean)
|
73
|
+
# T.assert_type!(Wizard.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
|
74
|
+
# T.assert_type!(Wizard.delete_all, Integer) # Ignored until we add support
|
75
|
+
# Query methods
|
76
|
+
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
77
|
+
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation) # Named scope
|
78
|
+
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
|
79
|
+
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
80
|
+
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
81
|
+
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
82
|
+
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
83
|
+
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
84
|
+
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
85
|
+
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
86
|
+
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
64
87
|
|
65
88
|
# Finder methods -- ActiveRecord::Relation
|
66
89
|
T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
|
67
90
|
T.assert_type!(Wizard.all.find(wizard.id), Wizard)
|
68
91
|
T.assert_type!(Wizard.all.first!, Wizard)
|
69
92
|
T.assert_type!(Wizard.all.first, T.nilable(Wizard))
|
93
|
+
T.assert_type!(Wizard.all.second!, Wizard)
|
94
|
+
T.assert_type!(Wizard.all.second, T.nilable(Wizard))
|
95
|
+
T.assert_type!(Wizard.all.third!, Wizard)
|
96
|
+
T.assert_type!(Wizard.all.third, T.nilable(Wizard))
|
97
|
+
T.assert_type!(Wizard.all.third_to_last!, Wizard)
|
98
|
+
T.assert_type!(Wizard.all.third_to_last, T.nilable(Wizard))
|
99
|
+
T.assert_type!(Wizard.all.second_to_last!, Wizard)
|
100
|
+
T.assert_type!(Wizard.all.second_to_last, T.nilable(Wizard))
|
70
101
|
T.assert_type!(Wizard.all.last!, Wizard)
|
71
102
|
T.assert_type!(Wizard.all.last, T.nilable(Wizard))
|
72
103
|
T.assert_type!(Wizard.all.first_n(5), T::Array[Wizard])
|
@@ -75,6 +106,46 @@ T.assert_type!(Wizard.all.find_by(name: 'Harry Potter'), T.nilable(Wizard))
|
|
75
106
|
T.assert_type!(Wizard.all.find_by!(name: 'Harry Potter'), Wizard)
|
76
107
|
T.assert_type!(Wizard.all.find_by_id(wizard.id), T.nilable(Wizard))
|
77
108
|
T.assert_type!(Wizard.all.find_by_id!(wizard.id), Wizard)
|
109
|
+
T.assert_type!(Wizard.all.find_or_initialize_by(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
110
|
+
T.assert_type!(Wizard.all.find_or_create_by(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
111
|
+
T.assert_type!(Wizard.all.find_or_create_by!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
112
|
+
T.assert_type!(Wizard.all.new { |w| T.assert_type!(w, Wizard) }, Wizard)
|
113
|
+
T.assert_type!(Wizard.all.build { |w| T.assert_type!(w, Wizard) }, Wizard)
|
114
|
+
T.assert_type!(Wizard.all.create(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
115
|
+
T.assert_type!(Wizard.all.create!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
116
|
+
T.assert_type!(Wizard.all.first_or_create(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
117
|
+
T.assert_type!(Wizard.all.first_or_create!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
|
118
|
+
T.assert_type!(Wizard.all.first_or_initialize { |w| T.assert_type!(w, Wizard) }, Wizard)
|
119
|
+
Wizard.all.find_each { |w| T.assert_type!(w, Wizard) }
|
120
|
+
T.assert_type!(Wizard.all.find_each, T::Enumerator[Wizard])
|
121
|
+
Wizard.all.find_in_batches { |w| T.assert_type!(w, T::Array[Wizard]) }
|
122
|
+
T.assert_type!(Wizard.all.find_in_batches, T::Enumerator[T::Array[Wizard]])
|
123
|
+
Wizard.all.in_batches { |w| T.assert_type!(w, Wizard::ActiveRecord_Relation) }
|
124
|
+
T.assert_type!(Wizard.all.in_batches, T::Enumerable[Wizard::ActiveRecord_Relation])
|
125
|
+
# T.assert_type!(Wizard.all.destroy_all, T::Array[Wizard]) # Ignored until we add support
|
126
|
+
T.assert_type!(Wizard.all.any?, T::Boolean)
|
127
|
+
T.assert_type!(Wizard.all.many?, T::Boolean)
|
128
|
+
T.assert_type!(Wizard.all.none?, T::Boolean)
|
129
|
+
T.assert_type!(Wizard.all.one?, T::Boolean)
|
130
|
+
# T.assert_type!(Wizard.all.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
|
131
|
+
# T.assert_type!(Wizard.all.delete_all, Integer) # Ignored until we add support
|
132
|
+
# Query methods
|
133
|
+
T.assert_type!(Wizard.all.all, Wizard::ActiveRecord_Relation)
|
134
|
+
T.assert_type!(Wizard.all.recent, Wizard::ActiveRecord_Relation) # Named scope
|
135
|
+
T.assert_type!(Wizard.all.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
|
136
|
+
T.assert_type!(Wizard.all.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
137
|
+
T.assert_type!(Wizard.all.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
138
|
+
T.assert_type!(Wizard.all.where(id: 1), Wizard::ActiveRecord_Relation)
|
139
|
+
T.assert_type!(Wizard.all.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
140
|
+
T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
141
|
+
T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
142
|
+
T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
143
|
+
T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
|
144
|
+
# Enumerable methods
|
145
|
+
Wizard.all.each { |w| T.assert_type!(w, Wizard) }
|
146
|
+
Wizard.all.map { |w| T.assert_type!(w, Wizard) }
|
147
|
+
T.assert_type!(Wizard.all.to_a, T::Array[Wizard])
|
148
|
+
T.assert_type!(Wizard.all.empty?, T::Boolean)
|
78
149
|
|
79
150
|
# Finder methods -- CollectionProxy
|
80
151
|
spell_book = wizard.spell_books.first!
|
@@ -82,79 +153,135 @@ spell_books = wizard.spell_books
|
|
82
153
|
T.assert_type!(spell_books.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
83
154
|
T.assert_type!(spell_books.find(spell_book.id), SpellBook)
|
84
155
|
T.assert_type!(spell_books.first!, SpellBook)
|
85
|
-
|
156
|
+
T.assert_type!(spell_books.first, T.nilable(SpellBook))
|
157
|
+
T.assert_type!(spell_books.second!, SpellBook)
|
158
|
+
T.assert_type!(spell_books.second, T.nilable(SpellBook))
|
159
|
+
T.assert_type!(spell_books.third!, SpellBook)
|
160
|
+
T.assert_type!(spell_books.third, T.nilable(SpellBook))
|
161
|
+
T.assert_type!(spell_books.third_to_last!, SpellBook)
|
162
|
+
T.assert_type!(spell_books.third_to_last, T.nilable(SpellBook))
|
163
|
+
T.assert_type!(spell_books.second_to_last!, SpellBook)
|
164
|
+
T.assert_type!(spell_books.second_to_last, T.nilable(SpellBook))
|
86
165
|
T.assert_type!(spell_books.last!, SpellBook)
|
87
|
-
|
166
|
+
T.assert_type!(spell_books.last, T.nilable(SpellBook))
|
88
167
|
T.assert_type!(spell_books.first_n(5), T::Array[SpellBook])
|
89
168
|
T.assert_type!(spell_books.last_n(5), T::Array[SpellBook])
|
90
169
|
T.assert_type!(spell_books.find_by(name: 'Fantastic Beasts'), T.nilable(SpellBook))
|
91
170
|
T.assert_type!(spell_books.find_by!(name: 'Fantastic Beasts'), SpellBook)
|
92
171
|
T.assert_type!(spell_books.find_by_id(spell_book.id), T.nilable(SpellBook))
|
93
172
|
T.assert_type!(spell_books.find_by_id!(spell_book.id), SpellBook)
|
94
|
-
|
173
|
+
T.assert_type!(spell_books.find_or_initialize_by(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
174
|
+
T.assert_type!(spell_books.find_or_create_by(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
175
|
+
T.assert_type!(spell_books.find_or_create_by!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
176
|
+
T.assert_type!(spell_books.new { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
177
|
+
T.assert_type!(spell_books.build { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
178
|
+
T.assert_type!(spell_books.create(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
179
|
+
T.assert_type!(spell_books.create!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
180
|
+
T.assert_type!(spell_books.first_or_create(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
181
|
+
T.assert_type!(spell_books.first_or_create!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
182
|
+
T.assert_type!(spell_books.first_or_initialize { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
183
|
+
spell_books.find_each { |s| T.assert_type!(s, SpellBook) }
|
184
|
+
T.assert_type!(spell_books.find_each, T::Enumerator[SpellBook])
|
185
|
+
spell_books.find_in_batches { |s| T.assert_type!(s, T::Array[SpellBook]) }
|
186
|
+
T.assert_type!(spell_books.find_in_batches, T::Enumerator[T::Array[SpellBook]])
|
187
|
+
spell_books.in_batches { |s| T.assert_type!(s, SpellBook::ActiveRecord_AssociationRelation) }
|
188
|
+
T.assert_type!(spell_books.in_batches, T::Enumerable[SpellBook::ActiveRecord_AssociationRelation])
|
189
|
+
# T.assert_type!(spell_books.destroy_all, T::Array[SpellBook]) # Ignored until we add support
|
190
|
+
T.assert_type!(spell_books.any?, T::Boolean)
|
191
|
+
T.assert_type!(spell_books.many?, T::Boolean)
|
192
|
+
T.assert_type!(spell_books.none?, T::Boolean)
|
193
|
+
T.assert_type!(spell_books.one?, T::Boolean)
|
194
|
+
# T.assert_type!(spell_books.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
|
195
|
+
# T.assert_type!(spell_books.delete_all, Integer) # Ignored until we add support
|
196
|
+
# Query methods
|
197
|
+
T.assert_type!(spell_books.all, SpellBook::ActiveRecord_AssociationRelation)
|
198
|
+
T.assert_type!(spell_books.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
|
199
|
+
T.assert_type!(spell_books.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
|
200
|
+
T.assert_type!(spell_books.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
|
201
|
+
T.assert_type!(spell_books.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
|
95
202
|
T.assert_type!(spell_books.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
203
|
+
T.assert_type!(spell_books.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
|
204
|
+
T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
96
205
|
T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
97
206
|
T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
98
207
|
T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
99
|
-
|
100
|
-
T.assert_type!(
|
208
|
+
# Enumerable methods
|
209
|
+
spell_books.each { |s| T.assert_type!(s, SpellBook) }
|
210
|
+
spell_books.map { |s| T.assert_type!(s, SpellBook) }
|
211
|
+
T.assert_type!(spell_books.to_a, T::Array[SpellBook])
|
212
|
+
T.assert_type!(spell_books.empty?, T::Boolean)
|
213
|
+
# Push methods
|
214
|
+
T.assert_type!(spell_books << spell_book, SpellBook::ActiveRecord_Associations_CollectionProxy)
|
215
|
+
T.assert_type!(spell_books << [spell_book], SpellBook::ActiveRecord_Associations_CollectionProxy)
|
216
|
+
T.assert_type!(spell_books.append(spell_book), SpellBook::ActiveRecord_Associations_CollectionProxy)
|
217
|
+
T.assert_type!(spell_books.append([spell_book]), SpellBook::ActiveRecord_Associations_CollectionProxy)
|
218
|
+
T.assert_type!(spell_books.push(spell_book), SpellBook::ActiveRecord_Associations_CollectionProxy)
|
219
|
+
T.assert_type!(spell_books.push([spell_book]), SpellBook::ActiveRecord_Associations_CollectionProxy)
|
220
|
+
# T.assert_type!(spell_books.concat(spell_book), SpellBook::ActiveRecord_Associations_CollectionProxy) # TODO: In Rails 5.0 and 5.1 this actually returns T::Array
|
221
|
+
# T.assert_type!(spell_books.concat([spell_book]), SpellBook::ActiveRecord_Associations_CollectionProxy) # TODO: In Rails 5.0 and 5.1 this actually returns T::Array
|
101
222
|
|
102
223
|
# finder methods -- AssociationRelation
|
103
|
-
spell_books_query = spell_books.where(
|
224
|
+
spell_books_query = spell_books.where(wizard_id: wizard.id)
|
104
225
|
T.assert_type!(spell_books_query.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
105
226
|
T.assert_type!(spell_books_query.find(spell_book.id), SpellBook)
|
106
227
|
T.assert_type!(spell_books_query.first!, SpellBook)
|
107
|
-
|
228
|
+
T.assert_type!(spell_books_query.first, T.nilable(SpellBook))
|
229
|
+
T.assert_type!(spell_books_query.second!, SpellBook)
|
230
|
+
T.assert_type!(spell_books_query.second, T.nilable(SpellBook))
|
231
|
+
T.assert_type!(spell_books_query.third!, SpellBook)
|
232
|
+
T.assert_type!(spell_books_query.third, T.nilable(SpellBook))
|
233
|
+
T.assert_type!(spell_books_query.third_to_last!, SpellBook)
|
234
|
+
T.assert_type!(spell_books_query.third_to_last, T.nilable(SpellBook))
|
235
|
+
T.assert_type!(spell_books_query.second_to_last!, SpellBook)
|
236
|
+
T.assert_type!(spell_books_query.second_to_last, T.nilable(SpellBook))
|
108
237
|
T.assert_type!(spell_books_query.last!, SpellBook)
|
109
|
-
|
238
|
+
T.assert_type!(spell_books_query.last, T.nilable(SpellBook))
|
110
239
|
T.assert_type!(spell_books_query.first_n(5), T::Array[SpellBook])
|
111
240
|
T.assert_type!(spell_books_query.last_n(5), T::Array[SpellBook])
|
112
241
|
T.assert_type!(spell_books_query.find_by(name: 'Fantastic Beasts'), T.nilable(SpellBook))
|
113
242
|
T.assert_type!(spell_books_query.find_by!(name: 'Fantastic Beasts'), SpellBook)
|
114
243
|
T.assert_type!(spell_books_query.find_by_id(spell_book.id), T.nilable(SpellBook))
|
115
244
|
T.assert_type!(spell_books_query.find_by_id!(spell_book.id), SpellBook)
|
116
|
-
|
245
|
+
T.assert_type!(spell_books_query.find_or_initialize_by(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
246
|
+
T.assert_type!(spell_books_query.find_or_create_by(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
247
|
+
T.assert_type!(spell_books_query.find_or_create_by!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
|
248
|
+
T.assert_type!(spell_books_query.new { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
|
249
|
+
T.assert_type!(spell_books_query.build { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support # Ignored until we add support
|
250
|
+
T.assert_type!(spell_books_query.create(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
|
251
|
+
T.assert_type!(spell_books_query.create!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
|
252
|
+
T.assert_type!(spell_books_query.first_or_create(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
|
253
|
+
T.assert_type!(spell_books_query.first_or_create!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
|
254
|
+
T.assert_type!(spell_books_query.first_or_initialize { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
|
255
|
+
spell_books_query.find_each { |s| T.assert_type!(s, SpellBook) }
|
256
|
+
T.assert_type!(spell_books_query.find_each, T::Enumerator[SpellBook])
|
257
|
+
spell_books_query.find_in_batches { |s| T.assert_type!(s, T::Array[SpellBook]) }
|
258
|
+
T.assert_type!(spell_books_query.find_in_batches, T::Enumerator[T::Array[SpellBook]])
|
259
|
+
spell_books_query.in_batches { |s| T.assert_type!(s, SpellBook::ActiveRecord_AssociationRelation) }
|
260
|
+
T.assert_type!(spell_books_query.in_batches, T::Enumerable[SpellBook::ActiveRecord_AssociationRelation])
|
261
|
+
# T.assert_type!(spell_books_query.destroy_all, T::Array[SpellBook]) # Ignored until we add support
|
262
|
+
T.assert_type!(spell_books_query.any?, T::Boolean)
|
263
|
+
T.assert_type!(spell_books_query.many?, T::Boolean)
|
264
|
+
T.assert_type!(spell_books_query.none?, T::Boolean)
|
265
|
+
T.assert_type!(spell_books_query.one?, T::Boolean)
|
266
|
+
# T.assert_type!(spell_books_query.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
|
267
|
+
# T.assert_type!(spell_books_query.delete_all, Integer) # Ignored until we add support
|
268
|
+
# Query methods
|
269
|
+
T.assert_type!(spell_books_query.all, SpellBook::ActiveRecord_AssociationRelation)
|
270
|
+
T.assert_type!(spell_books_query.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
|
271
|
+
T.assert_type!(spell_books_query.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
|
272
|
+
T.assert_type!(spell_books_query.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
|
273
|
+
T.assert_type!(spell_books_query.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
|
274
|
+
T.assert_type!(spell_books_query.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
275
|
+
T.assert_type!(spell_books_query.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
|
276
|
+
T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
117
277
|
T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
118
278
|
T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
119
279
|
T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
120
|
-
|
121
|
-
T.assert_type!(
|
122
|
-
|
123
|
-
|
124
|
-
T.assert_type!(
|
125
|
-
Wizard.all.each do |w|
|
126
|
-
T.assert_type!(w, Wizard)
|
127
|
-
end
|
128
|
-
Wizard.all.map do |w|
|
129
|
-
T.assert_type!(w, Wizard)
|
130
|
-
end
|
131
|
-
Wizard.all.to_a.map do |w|
|
132
|
-
T.assert_type!(w, Wizard)
|
133
|
-
end
|
134
|
-
|
135
|
-
# enum on association collection proxy
|
136
|
-
T.assert_type!(wizard.spell_books.to_a, T::Array[SpellBook])
|
137
|
-
wizard.spell_books.each do |sp|
|
138
|
-
T.assert_type!(sp, SpellBook)
|
139
|
-
end
|
140
|
-
wizard.spell_books.map do |sp|
|
141
|
-
T.assert_type!(sp, SpellBook)
|
142
|
-
end
|
143
|
-
wizard.spell_books.to_a.map do |sp|
|
144
|
-
T.assert_type!(sp, SpellBook)
|
145
|
-
end
|
146
|
-
|
147
|
-
# enum on association relation
|
148
|
-
T.assert_type!(wizard.spell_books.where(id: 1).to_a, T::Array[SpellBook])
|
149
|
-
wizard.spell_books.where(id: 1).each do |sp|
|
150
|
-
T.assert_type!(sp, SpellBook)
|
151
|
-
end
|
152
|
-
wizard.spell_books.where(id: 1).map do |sp|
|
153
|
-
T.assert_type!(sp, SpellBook)
|
154
|
-
end
|
155
|
-
wizard.spell_books.where(id: 1).to_a.map do |sp|
|
156
|
-
T.assert_type!(sp, SpellBook)
|
157
|
-
end
|
280
|
+
# Enumerable methods
|
281
|
+
spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
|
282
|
+
spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
|
283
|
+
T.assert_type!(spell_books_query.to_a, T::Array[SpellBook])
|
284
|
+
T.assert_type!(spell_books_query.empty?, T::Boolean)
|
158
285
|
|
159
286
|
# Model columns
|
160
287
|
T.assert_type!(wizard.id, Integer)
|
@@ -234,44 +361,6 @@ params = ActionController::Parameters.new({
|
|
234
361
|
typed_params = TypedParams[MyActionParams].new.extract!(params)
|
235
362
|
T.assert_type!(typed_params, MyActionParams)
|
236
363
|
|
237
|
-
# -- require_typed
|
238
|
-
T.assert_type!(
|
239
|
-
params.require_typed(:age, TA[Integer].new),
|
240
|
-
Integer,
|
241
|
-
)
|
242
|
-
T.assert_type!(
|
243
|
-
params.require_typed(:name, TA[String].new),
|
244
|
-
String,
|
245
|
-
)
|
246
|
-
info = params.require_typed(:info, TA[ActionController::Parameters].new)
|
247
|
-
T.assert_type!(info, ActionController::Parameters)
|
248
|
-
T.assert_type!(
|
249
|
-
info.require_typed(:friends, TA[T::Array[String]].new),
|
250
|
-
T::Array[String],
|
251
|
-
)
|
252
|
-
# -- fetch_typed
|
253
|
-
T.assert_type!(
|
254
|
-
params.fetch_typed(:age, TA[Integer].new),
|
255
|
-
Integer,
|
256
|
-
)
|
257
|
-
T.assert_type!(
|
258
|
-
params.fetch_typed(:name, TA[String].new),
|
259
|
-
String,
|
260
|
-
)
|
261
|
-
T.assert_type!(
|
262
|
-
params.fetch_typed(:nonexistence, TA[String].new, ''),
|
263
|
-
String,
|
264
|
-
)
|
265
|
-
T.assert_type!(
|
266
|
-
params.fetch_typed(:nonexistence, TA[T.nilable(String)].new, nil),
|
267
|
-
T.nilable(String),
|
268
|
-
)
|
269
|
-
T.assert_type!(
|
270
|
-
params.fetch_typed(:nonexistence, TA[T::Array[Integer]].new, []),
|
271
|
-
T::Array[Integer],
|
272
|
-
)
|
273
|
-
|
274
|
-
|
275
364
|
# -- pluck to tstruct
|
276
365
|
class WizardStruct < T::Struct
|
277
366
|
const :name, String
|
@@ -288,23 +377,16 @@ Wizard.all.pluck_to_tstruct(TA[WizardStruct].new).each do |row|
|
|
288
377
|
T.assert_type!(row, WizardStruct)
|
289
378
|
end
|
290
379
|
|
291
|
-
|
292
380
|
# -- GeneratedUrlHelpers
|
293
381
|
class TestHelper
|
294
382
|
include GeneratedUrlHelpers
|
295
|
-
|
296
|
-
# need to implement this for the url
|
297
|
-
def default_url_options
|
298
|
-
{
|
299
|
-
protocol: 'http',
|
300
|
-
host: 'localhost',
|
301
|
-
port: 3000,
|
302
|
-
}
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_url_helper
|
306
|
-
T.assert_type!(test_index_path, String)
|
307
|
-
T.assert_type!(test_index_url, String)
|
308
|
-
end
|
309
383
|
end
|
310
|
-
|
384
|
+
|
385
|
+
T.assert_type!(TestHelper.new.test_index_path, String)
|
386
|
+
# need to set this config for _url methods
|
387
|
+
Rails.application.routes.default_url_options = {
|
388
|
+
protocol: 'http',
|
389
|
+
host: 'localhost',
|
390
|
+
port: 3000,
|
391
|
+
}
|
392
|
+
T.assert_type!(TestHelper.new.test_index_url, String)
|