sorbet-rails 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- 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 +9 -2
- data/lib/sorbet-rails/model_plugins/active_record_attribute.rb +0 -1
- 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 +5 -1
- data/lib/sorbet-rails/model_plugins/base.rb +2 -1
- data/lib/sorbet-rails/model_rbi_formatter.rb +4 -8
- data/lib/sorbet-rails/model_utils.rb +68 -30
- data/lib/sorbet-rails/tasks/rails_rbi.rake +13 -21
- data/sorbet-rails.gemspec +1 -1
- data/spec/generators/rails-template.rb +3 -6
- data/spec/generators/sorbet_test_cases.rb +41 -26
- data/spec/support/v5.0/Gemfile.lock +2 -2
- data/spec/support/v5.0/app/models/spell_book.rb +2 -0
- data/spec/support/v5.0/app/models/wizard.rb +1 -1
- data/spec/support/v5.0/sorbet_test_cases.rb +41 -26
- data/spec/support/v5.1/Gemfile.lock +2 -2
- data/spec/support/v5.1/app/models/spell_book.rb +2 -0
- data/spec/support/v5.1/app/models/wizard.rb +1 -1
- data/spec/support/v5.1/sorbet_test_cases.rb +41 -26
- data/spec/support/v5.2/Gemfile.lock +2 -2
- data/spec/support/v5.2/app/models/spell_book.rb +2 -0
- data/spec/support/v5.2/app/models/wizard.rb +1 -1
- data/spec/support/v5.2/sorbet_test_cases.rb +41 -26
- data/spec/support/v6.0/Gemfile.lock +2 -2
- data/spec/support/v6.0/app/models/spell_book.rb +2 -0
- data/spec/support/v6.0/app/models/wizard.rb +1 -1
- data/spec/support/v6.0/sorbet_test_cases.rb +41 -26
- data/spec/test_data/v5.0/expected_headmaster.rbi +18 -190
- data/spec/test_data/v5.0/expected_internal_metadata.rbi +18 -188
- data/spec/test_data/v5.0/expected_potion.rbi +18 -188
- data/spec/test_data/v5.0/expected_robe.rbi +18 -190
- data/spec/test_data/v5.0/expected_schema_migration.rbi +18 -188
- data/spec/test_data/v5.0/expected_school.rbi +18 -190
- data/spec/test_data/v5.0/expected_spell.rbi +18 -190
- data/spec/test_data/v5.0/expected_spell/habtm_spell_books.rbi +18 -190
- data/spec/test_data/v5.0/expected_spell_book.rbi +55 -217
- data/spec/test_data/v5.0/expected_spell_book/habtm_spells.rbi +18 -190
- data/spec/test_data/v5.0/expected_squib.rbi +90 -264
- data/spec/test_data/v5.0/expected_subject.rbi +18 -190
- data/spec/test_data/v5.0/expected_subject/habtm_wizards.rbi +18 -190
- data/spec/test_data/v5.0/expected_wand.rbi +53 -227
- data/spec/test_data/v5.0/expected_wizard.rbi +90 -264
- data/spec/test_data/v5.0/expected_wizard/habtm_subjects.rbi +18 -190
- data/spec/test_data/v5.0/expected_wizard_wo_spellbook.rbi +90 -264
- data/spec/test_data/v5.1/expected_headmaster.rbi +18 -196
- data/spec/test_data/v5.1/expected_internal_metadata.rbi +18 -194
- data/spec/test_data/v5.1/expected_potion.rbi +18 -194
- data/spec/test_data/v5.1/expected_robe.rbi +18 -196
- data/spec/test_data/v5.1/expected_schema_migration.rbi +18 -194
- data/spec/test_data/v5.1/expected_school.rbi +18 -196
- data/spec/test_data/v5.1/expected_spell.rbi +18 -196
- data/spec/test_data/v5.1/expected_spell/habtm_spell_books.rbi +18 -196
- data/spec/test_data/v5.1/expected_spell_book.rbi +55 -223
- data/spec/test_data/v5.1/expected_spell_book/habtm_spells.rbi +18 -196
- data/spec/test_data/v5.1/expected_squib.rbi +91 -271
- data/spec/test_data/v5.1/expected_subject.rbi +18 -196
- data/spec/test_data/v5.1/expected_subject/habtm_wizards.rbi +18 -196
- data/spec/test_data/v5.1/expected_wand.rbi +53 -233
- data/spec/test_data/v5.1/expected_wizard.rbi +91 -271
- data/spec/test_data/v5.1/expected_wizard/habtm_subjects.rbi +18 -196
- data/spec/test_data/v5.1/expected_wizard_wo_spellbook.rbi +91 -271
- data/spec/test_data/v5.2/expected_attachment.rbi +18 -194
- data/spec/test_data/v5.2/expected_blob.rbi +39 -215
- data/spec/test_data/v5.2/expected_headmaster.rbi +18 -196
- data/spec/test_data/v5.2/expected_internal_metadata.rbi +18 -194
- data/spec/test_data/v5.2/expected_potion.rbi +18 -194
- data/spec/test_data/v5.2/expected_robe.rbi +18 -196
- data/spec/test_data/v5.2/expected_schema_migration.rbi +18 -194
- data/spec/test_data/v5.2/expected_school.rbi +18 -196
- data/spec/test_data/v5.2/expected_spell.rbi +18 -196
- data/spec/test_data/v5.2/expected_spell/habtm_spell_books.rbi +18 -196
- data/spec/test_data/v5.2/expected_spell_book.rbi +55 -223
- data/spec/test_data/v5.2/expected_spell_book/habtm_spells.rbi +18 -196
- data/spec/test_data/v5.2/expected_squib.rbi +95 -275
- data/spec/test_data/v5.2/expected_subject.rbi +18 -196
- data/spec/test_data/v5.2/expected_subject/habtm_wizards.rbi +18 -196
- data/spec/test_data/v5.2/expected_wand.rbi +53 -233
- data/spec/test_data/v5.2/expected_wizard.rbi +95 -275
- data/spec/test_data/v5.2/expected_wizard/habtm_subjects.rbi +18 -196
- data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +95 -275
- data/spec/test_data/v6.0/expected_attachment.rbi +18 -218
- data/spec/test_data/v6.0/expected_blob.rbi +31 -243
- data/spec/test_data/v6.0/expected_headmaster.rbi +18 -220
- data/spec/test_data/v6.0/expected_internal_metadata.rbi +18 -218
- data/spec/test_data/v6.0/expected_potion.rbi +18 -218
- data/spec/test_data/v6.0/expected_robe.rbi +18 -220
- data/spec/test_data/v6.0/expected_schema_migration.rbi +18 -218
- data/spec/test_data/v6.0/expected_school.rbi +18 -220
- data/spec/test_data/v6.0/expected_spell.rbi +18 -220
- data/spec/test_data/v6.0/expected_spell/habtm_spell_books.rbi +18 -220
- data/spec/test_data/v6.0/expected_spell_book.rbi +24 -258
- data/spec/test_data/v6.0/expected_spell_book/habtm_spells.rbi +18 -220
- data/spec/test_data/v6.0/expected_squib.rbi +31 -457
- data/spec/test_data/v6.0/expected_subject.rbi +18 -220
- data/spec/test_data/v6.0/expected_subject/habtm_wizards.rbi +18 -220
- data/spec/test_data/v6.0/expected_wand.rbi +18 -270
- data/spec/test_data/v6.0/expected_wizard.rbi +31 -457
- data/spec/test_data/v6.0/expected_wizard/habtm_subjects.rbi +18 -220
- data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +31 -457
- metadata +1 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../..
|
3
3
|
specs:
|
4
|
-
sorbet-rails (0.6.
|
4
|
+
sorbet-rails (0.6.4)
|
5
5
|
method_source (>= 0.9.2)
|
6
6
|
parlour (~> 2.0)
|
7
7
|
parser (>= 2.7)
|
@@ -81,7 +81,7 @@ GEM
|
|
81
81
|
parser
|
82
82
|
rainbow (~> 3.0)
|
83
83
|
sorbet-runtime (>= 0.5)
|
84
|
-
parser (2.7.1.
|
84
|
+
parser (2.7.1.2)
|
85
85
|
ast (~> 2.4.0)
|
86
86
|
polyfill (1.8.0)
|
87
87
|
puma (3.12.4)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class Wizard < ApplicationRecord
|
3
3
|
validates :name, length: { minimum: 5 }, presence: true
|
4
4
|
# simulate conditional validation
|
5
|
-
validates :parent_email, presence: true, if:
|
5
|
+
validates :parent_email, presence: true, if: :Slytherin?
|
6
6
|
|
7
7
|
typed_enum house: {
|
8
8
|
Gryffindor: 0,
|
@@ -29,26 +29,6 @@ T.assert_type!(T.must(wizard.wand).wizard, Wizard)
|
|
29
29
|
T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Associations_CollectionProxy)
|
30
30
|
T.assert_type!(wizard.spell_book_ids, T::Array[Integer])
|
31
31
|
|
32
|
-
# -- model relation
|
33
|
-
# default
|
34
|
-
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
35
|
-
|
36
|
-
# custom scope
|
37
|
-
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation)
|
38
|
-
|
39
|
-
# enum scope
|
40
|
-
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation)
|
41
|
-
|
42
|
-
# ActiveRecord Querying
|
43
|
-
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
44
|
-
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
45
|
-
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
46
|
-
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
47
|
-
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
48
|
-
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
49
|
-
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
50
|
-
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
51
|
-
|
52
32
|
# Finder methods -- Model
|
53
33
|
T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
|
54
34
|
T.assert_type!(Wizard.find(wizard.id), Wizard)
|
@@ -90,6 +70,18 @@ T.assert_type!(Wizard.none?, T::Boolean)
|
|
90
70
|
T.assert_type!(Wizard.one?, T::Boolean)
|
91
71
|
# T.assert_type!(Wizard.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
|
92
72
|
# T.assert_type!(Wizard.delete_all, Integer) # Ignored until we add support
|
73
|
+
# Query methods
|
74
|
+
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
75
|
+
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation) # Named scope
|
76
|
+
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
|
77
|
+
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
78
|
+
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
79
|
+
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
80
|
+
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
81
|
+
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
82
|
+
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
83
|
+
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
84
|
+
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
93
85
|
|
94
86
|
# Finder methods -- ActiveRecord::Relation
|
95
87
|
T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
|
@@ -133,6 +125,18 @@ T.assert_type!(Wizard.all.none?, T::Boolean)
|
|
133
125
|
T.assert_type!(Wizard.all.one?, T::Boolean)
|
134
126
|
# T.assert_type!(Wizard.all.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
|
135
127
|
# T.assert_type!(Wizard.all.delete_all, Integer) # Ignored until we add support
|
128
|
+
# Query methods
|
129
|
+
T.assert_type!(Wizard.all.all, Wizard::ActiveRecord_Relation)
|
130
|
+
T.assert_type!(Wizard.all.recent, Wizard::ActiveRecord_Relation) # Named scope
|
131
|
+
T.assert_type!(Wizard.all.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
|
132
|
+
T.assert_type!(Wizard.all.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
133
|
+
T.assert_type!(Wizard.all.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
134
|
+
T.assert_type!(Wizard.all.where(id: 1), Wizard::ActiveRecord_Relation)
|
135
|
+
T.assert_type!(Wizard.all.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
136
|
+
T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
137
|
+
T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
138
|
+
T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
139
|
+
T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
|
136
140
|
# Enumerable methods
|
137
141
|
Wizard.all.each { |w| T.assert_type!(w, Wizard) }
|
138
142
|
Wizard.all.map { |w| T.assert_type!(w, Wizard) }
|
@@ -183,13 +187,18 @@ T.assert_type!(spell_books.none?, T::Boolean)
|
|
183
187
|
T.assert_type!(spell_books.one?, T::Boolean)
|
184
188
|
# T.assert_type!(spell_books.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
|
185
189
|
# T.assert_type!(spell_books.delete_all, Integer) # Ignored until we add support
|
186
|
-
#
|
190
|
+
# Query methods
|
191
|
+
T.assert_type!(spell_books.all, SpellBook::ActiveRecord_AssociationRelation)
|
192
|
+
T.assert_type!(spell_books.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
|
193
|
+
T.assert_type!(spell_books.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
|
194
|
+
T.assert_type!(spell_books.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
|
195
|
+
T.assert_type!(spell_books.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
|
187
196
|
T.assert_type!(spell_books.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
197
|
+
T.assert_type!(spell_books.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
|
198
|
+
T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
188
199
|
T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
189
200
|
T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
190
201
|
T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
191
|
-
T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
192
|
-
T.assert_type!(spell_books.biology, SpellBook::ActiveRecord_AssociationRelation)
|
193
202
|
# Enumerable methods
|
194
203
|
spell_books.each { |s| T.assert_type!(s, SpellBook) }
|
195
204
|
spell_books.map { |s| T.assert_type!(s, SpellBook) }
|
@@ -248,12 +257,18 @@ T.assert_type!(spell_books_query.none?, T::Boolean)
|
|
248
257
|
T.assert_type!(spell_books_query.one?, T::Boolean)
|
249
258
|
# T.assert_type!(spell_books_query.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
|
250
259
|
# T.assert_type!(spell_books_query.delete_all, Integer) # Ignored until we add support
|
251
|
-
# Query
|
260
|
+
# Query methods
|
261
|
+
T.assert_type!(spell_books_query.all, SpellBook::ActiveRecord_AssociationRelation)
|
262
|
+
T.assert_type!(spell_books_query.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
|
263
|
+
T.assert_type!(spell_books_query.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
|
264
|
+
T.assert_type!(spell_books_query.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
|
265
|
+
T.assert_type!(spell_books_query.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
|
266
|
+
T.assert_type!(spell_books_query.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
267
|
+
T.assert_type!(spell_books_query.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
|
268
|
+
T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
252
269
|
T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
253
270
|
T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
254
271
|
T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
255
|
-
T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
256
|
-
T.assert_type!(spell_books_query.biology, SpellBook::ActiveRecord_AssociationRelation)
|
257
272
|
# Enumerable methods
|
258
273
|
spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
|
259
274
|
spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../..
|
3
3
|
specs:
|
4
|
-
sorbet-rails (0.6.
|
4
|
+
sorbet-rails (0.6.4)
|
5
5
|
method_source (>= 0.9.2)
|
6
6
|
parlour (~> 2.0)
|
7
7
|
parser (>= 2.7)
|
@@ -82,7 +82,7 @@ GEM
|
|
82
82
|
parser
|
83
83
|
rainbow (~> 3.0)
|
84
84
|
sorbet-runtime (>= 0.5)
|
85
|
-
parser (2.7.1.
|
85
|
+
parser (2.7.1.2)
|
86
86
|
ast (~> 2.4.0)
|
87
87
|
polyfill (1.8.0)
|
88
88
|
puma (3.12.4)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class Wizard < ApplicationRecord
|
3
3
|
validates :name, length: { minimum: 5 }, presence: true
|
4
4
|
# simulate conditional validation
|
5
|
-
validates :parent_email, presence: true, if:
|
5
|
+
validates :parent_email, presence: true, if: :Slytherin?
|
6
6
|
|
7
7
|
typed_enum house: {
|
8
8
|
Gryffindor: 0,
|
@@ -29,26 +29,6 @@ T.assert_type!(T.must(wizard.wand).wizard, Wizard)
|
|
29
29
|
T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Associations_CollectionProxy)
|
30
30
|
T.assert_type!(wizard.spell_book_ids, T::Array[Integer])
|
31
31
|
|
32
|
-
# -- model relation
|
33
|
-
# default
|
34
|
-
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
35
|
-
|
36
|
-
# custom scope
|
37
|
-
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation)
|
38
|
-
|
39
|
-
# enum scope
|
40
|
-
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation)
|
41
|
-
|
42
|
-
# ActiveRecord Querying
|
43
|
-
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
44
|
-
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
45
|
-
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
46
|
-
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
47
|
-
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
48
|
-
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
49
|
-
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
50
|
-
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
51
|
-
|
52
32
|
# Finder methods -- Model
|
53
33
|
T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
|
54
34
|
T.assert_type!(Wizard.find(wizard.id), Wizard)
|
@@ -90,6 +70,18 @@ T.assert_type!(Wizard.none?, T::Boolean)
|
|
90
70
|
T.assert_type!(Wizard.one?, T::Boolean)
|
91
71
|
# T.assert_type!(Wizard.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
|
92
72
|
# T.assert_type!(Wizard.delete_all, Integer) # Ignored until we add support
|
73
|
+
# Query methods
|
74
|
+
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
75
|
+
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation) # Named scope
|
76
|
+
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
|
77
|
+
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
78
|
+
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
79
|
+
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
80
|
+
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
81
|
+
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
82
|
+
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
83
|
+
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
84
|
+
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
93
85
|
|
94
86
|
# Finder methods -- ActiveRecord::Relation
|
95
87
|
T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
|
@@ -133,6 +125,18 @@ T.assert_type!(Wizard.all.none?, T::Boolean)
|
|
133
125
|
T.assert_type!(Wizard.all.one?, T::Boolean)
|
134
126
|
# T.assert_type!(Wizard.all.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
|
135
127
|
# T.assert_type!(Wizard.all.delete_all, Integer) # Ignored until we add support
|
128
|
+
# Query methods
|
129
|
+
T.assert_type!(Wizard.all.all, Wizard::ActiveRecord_Relation)
|
130
|
+
T.assert_type!(Wizard.all.recent, Wizard::ActiveRecord_Relation) # Named scope
|
131
|
+
T.assert_type!(Wizard.all.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
|
132
|
+
T.assert_type!(Wizard.all.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
133
|
+
T.assert_type!(Wizard.all.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
134
|
+
T.assert_type!(Wizard.all.where(id: 1), Wizard::ActiveRecord_Relation)
|
135
|
+
T.assert_type!(Wizard.all.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
136
|
+
T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
137
|
+
T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
138
|
+
T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
139
|
+
T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
|
136
140
|
# Enumerable methods
|
137
141
|
Wizard.all.each { |w| T.assert_type!(w, Wizard) }
|
138
142
|
Wizard.all.map { |w| T.assert_type!(w, Wizard) }
|
@@ -183,13 +187,18 @@ T.assert_type!(spell_books.none?, T::Boolean)
|
|
183
187
|
T.assert_type!(spell_books.one?, T::Boolean)
|
184
188
|
# T.assert_type!(spell_books.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
|
185
189
|
# T.assert_type!(spell_books.delete_all, Integer) # Ignored until we add support
|
186
|
-
#
|
190
|
+
# Query methods
|
191
|
+
T.assert_type!(spell_books.all, SpellBook::ActiveRecord_AssociationRelation)
|
192
|
+
T.assert_type!(spell_books.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
|
193
|
+
T.assert_type!(spell_books.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
|
194
|
+
T.assert_type!(spell_books.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
|
195
|
+
T.assert_type!(spell_books.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
|
187
196
|
T.assert_type!(spell_books.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
197
|
+
T.assert_type!(spell_books.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
|
198
|
+
T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
188
199
|
T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
189
200
|
T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
190
201
|
T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
191
|
-
T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
192
|
-
T.assert_type!(spell_books.biology, SpellBook::ActiveRecord_AssociationRelation)
|
193
202
|
# Enumerable methods
|
194
203
|
spell_books.each { |s| T.assert_type!(s, SpellBook) }
|
195
204
|
spell_books.map { |s| T.assert_type!(s, SpellBook) }
|
@@ -248,12 +257,18 @@ T.assert_type!(spell_books_query.none?, T::Boolean)
|
|
248
257
|
T.assert_type!(spell_books_query.one?, T::Boolean)
|
249
258
|
# T.assert_type!(spell_books_query.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
|
250
259
|
# T.assert_type!(spell_books_query.delete_all, Integer) # Ignored until we add support
|
251
|
-
# Query
|
260
|
+
# Query methods
|
261
|
+
T.assert_type!(spell_books_query.all, SpellBook::ActiveRecord_AssociationRelation)
|
262
|
+
T.assert_type!(spell_books_query.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
|
263
|
+
T.assert_type!(spell_books_query.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
|
264
|
+
T.assert_type!(spell_books_query.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
|
265
|
+
T.assert_type!(spell_books_query.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
|
266
|
+
T.assert_type!(spell_books_query.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
267
|
+
T.assert_type!(spell_books_query.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
|
268
|
+
T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
252
269
|
T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
253
270
|
T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
254
271
|
T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
255
|
-
T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
256
|
-
T.assert_type!(spell_books_query.biology, SpellBook::ActiveRecord_AssociationRelation)
|
257
272
|
# Enumerable methods
|
258
273
|
spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
|
259
274
|
spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../..
|
3
3
|
specs:
|
4
|
-
sorbet-rails (0.6.
|
4
|
+
sorbet-rails (0.6.4)
|
5
5
|
method_source (>= 0.9.2)
|
6
6
|
parlour (~> 2.0)
|
7
7
|
parser (>= 2.7)
|
@@ -89,7 +89,7 @@ GEM
|
|
89
89
|
parser
|
90
90
|
rainbow (~> 3.0)
|
91
91
|
sorbet-runtime (>= 0.5)
|
92
|
-
parser (2.7.1.
|
92
|
+
parser (2.7.1.2)
|
93
93
|
ast (~> 2.4.0)
|
94
94
|
polyfill (1.8.0)
|
95
95
|
puma (3.12.4)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class Wizard < ApplicationRecord
|
3
3
|
validates :name, length: { minimum: 5 }, presence: true
|
4
4
|
# simulate conditional validation
|
5
|
-
validates :parent_email, presence: true, if:
|
5
|
+
validates :parent_email, presence: true, if: :Slytherin?
|
6
6
|
|
7
7
|
typed_enum house: {
|
8
8
|
Gryffindor: 0,
|
@@ -29,26 +29,6 @@ T.assert_type!(T.must(wizard.wand).wizard, Wizard)
|
|
29
29
|
T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Associations_CollectionProxy)
|
30
30
|
T.assert_type!(wizard.spell_book_ids, T::Array[Integer])
|
31
31
|
|
32
|
-
# -- model relation
|
33
|
-
# default
|
34
|
-
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
35
|
-
|
36
|
-
# custom scope
|
37
|
-
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation)
|
38
|
-
|
39
|
-
# enum scope
|
40
|
-
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation)
|
41
|
-
|
42
|
-
# ActiveRecord Querying
|
43
|
-
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
44
|
-
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
45
|
-
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
46
|
-
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
47
|
-
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
48
|
-
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
49
|
-
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
50
|
-
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
51
|
-
|
52
32
|
# Finder methods -- Model
|
53
33
|
T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
|
54
34
|
T.assert_type!(Wizard.find(wizard.id), Wizard)
|
@@ -90,6 +70,18 @@ T.assert_type!(Wizard.none?, T::Boolean)
|
|
90
70
|
T.assert_type!(Wizard.one?, T::Boolean)
|
91
71
|
# T.assert_type!(Wizard.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
|
92
72
|
# T.assert_type!(Wizard.delete_all, Integer) # Ignored until we add support
|
73
|
+
# Query methods
|
74
|
+
T.assert_type!(Wizard.all, Wizard::ActiveRecord_Relation)
|
75
|
+
T.assert_type!(Wizard.recent, Wizard::ActiveRecord_Relation) # Named scope
|
76
|
+
T.assert_type!(Wizard.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
|
77
|
+
T.assert_type!(Wizard.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
78
|
+
T.assert_type!(Wizard.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
79
|
+
T.assert_type!(Wizard.where(id: 1), Wizard::ActiveRecord_Relation)
|
80
|
+
T.assert_type!(Wizard.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
81
|
+
T.assert_type!(Wizard.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
82
|
+
T.assert_type!(Wizard.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
83
|
+
T.assert_type!(Wizard.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
84
|
+
T.assert_type!(Wizard.order(:id), Wizard::ActiveRecord_Relation)
|
93
85
|
|
94
86
|
# Finder methods -- ActiveRecord::Relation
|
95
87
|
T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
|
@@ -133,6 +125,18 @@ T.assert_type!(Wizard.all.none?, T::Boolean)
|
|
133
125
|
T.assert_type!(Wizard.all.one?, T::Boolean)
|
134
126
|
# T.assert_type!(Wizard.all.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
|
135
127
|
# T.assert_type!(Wizard.all.delete_all, Integer) # Ignored until we add support
|
128
|
+
# Query methods
|
129
|
+
T.assert_type!(Wizard.all.all, Wizard::ActiveRecord_Relation)
|
130
|
+
T.assert_type!(Wizard.all.recent, Wizard::ActiveRecord_Relation) # Named scope
|
131
|
+
T.assert_type!(Wizard.all.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
|
132
|
+
T.assert_type!(Wizard.all.Gryffindor.recent, Wizard::ActiveRecord_Relation)
|
133
|
+
T.assert_type!(Wizard.all.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
|
134
|
+
T.assert_type!(Wizard.all.where(id: 1), Wizard::ActiveRecord_Relation)
|
135
|
+
T.assert_type!(Wizard.all.where(id: 1).recent, Wizard::ActiveRecord_Relation)
|
136
|
+
T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
|
137
|
+
T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
|
138
|
+
T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
|
139
|
+
T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
|
136
140
|
# Enumerable methods
|
137
141
|
Wizard.all.each { |w| T.assert_type!(w, Wizard) }
|
138
142
|
Wizard.all.map { |w| T.assert_type!(w, Wizard) }
|
@@ -183,13 +187,18 @@ T.assert_type!(spell_books.none?, T::Boolean)
|
|
183
187
|
T.assert_type!(spell_books.one?, T::Boolean)
|
184
188
|
# T.assert_type!(spell_books.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
|
185
189
|
# T.assert_type!(spell_books.delete_all, Integer) # Ignored until we add support
|
186
|
-
#
|
190
|
+
# Query methods
|
191
|
+
T.assert_type!(spell_books.all, SpellBook::ActiveRecord_AssociationRelation)
|
192
|
+
T.assert_type!(spell_books.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
|
193
|
+
T.assert_type!(spell_books.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
|
194
|
+
T.assert_type!(spell_books.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
|
195
|
+
T.assert_type!(spell_books.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
|
187
196
|
T.assert_type!(spell_books.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
197
|
+
T.assert_type!(spell_books.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
|
198
|
+
T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
188
199
|
T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
189
200
|
T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
190
201
|
T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
191
|
-
T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
192
|
-
T.assert_type!(spell_books.biology, SpellBook::ActiveRecord_AssociationRelation)
|
193
202
|
# Enumerable methods
|
194
203
|
spell_books.each { |s| T.assert_type!(s, SpellBook) }
|
195
204
|
spell_books.map { |s| T.assert_type!(s, SpellBook) }
|
@@ -248,12 +257,18 @@ T.assert_type!(spell_books_query.none?, T::Boolean)
|
|
248
257
|
T.assert_type!(spell_books_query.one?, T::Boolean)
|
249
258
|
# T.assert_type!(spell_books_query.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
|
250
259
|
# T.assert_type!(spell_books_query.delete_all, Integer) # Ignored until we add support
|
251
|
-
# Query
|
260
|
+
# Query methods
|
261
|
+
T.assert_type!(spell_books_query.all, SpellBook::ActiveRecord_AssociationRelation)
|
262
|
+
T.assert_type!(spell_books_query.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
|
263
|
+
T.assert_type!(spell_books_query.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
|
264
|
+
T.assert_type!(spell_books_query.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
|
265
|
+
T.assert_type!(spell_books_query.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
|
266
|
+
T.assert_type!(spell_books_query.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
267
|
+
T.assert_type!(spell_books_query.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
|
268
|
+
T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
252
269
|
T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
253
270
|
T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
|
254
271
|
T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
|
255
|
-
T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
|
256
|
-
T.assert_type!(spell_books_query.biology, SpellBook::ActiveRecord_AssociationRelation)
|
257
272
|
# Enumerable methods
|
258
273
|
spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
|
259
274
|
spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../../..
|
3
3
|
specs:
|
4
|
-
sorbet-rails (0.6.
|
4
|
+
sorbet-rails (0.6.4)
|
5
5
|
method_source (>= 0.9.2)
|
6
6
|
parlour (~> 2.0)
|
7
7
|
parser (>= 2.7)
|
@@ -102,7 +102,7 @@ GEM
|
|
102
102
|
parser
|
103
103
|
rainbow (~> 3.0)
|
104
104
|
sorbet-runtime (>= 0.5)
|
105
|
-
parser (2.7.1.
|
105
|
+
parser (2.7.1.2)
|
106
106
|
ast (~> 2.4.0)
|
107
107
|
polyfill (1.8.0)
|
108
108
|
puma (3.12.4)
|