sorbet-rails 0.7.32 → 0.7.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci-master.yml +1 -1
  3. data/.github/workflows/ci.yml +1 -1
  4. data/.github/workflows/publish-gem.yml +9 -19
  5. data/CONTRIBUTING.md +1 -0
  6. data/Gemfile +4 -0
  7. data/README.md +1 -3
  8. data/Rakefile +27 -1
  9. data/lib/sorbet-rails/active_record_rbi_formatter.rb +4 -4
  10. data/lib/sorbet-rails/model_plugins/active_record_querying.rb +14 -0
  11. data/lib/sorbet-rails/model_rbi_formatter.rb +3 -3
  12. data/lib/sorbet-rails/rails_mixins/active_record_overrides.rb +1 -1
  13. data/lib/sorbet-rails/tasks/rails_rbi.rake +15 -0
  14. data/sorbet-rails.gemspec +2 -2
  15. data/spec/bin/run_all_specs.sh +1 -0
  16. data/spec/generators/rails-template.rb +2 -7
  17. data/spec/rails_helper.rb +2 -0
  18. data/spec/rake_rails_rbi_models_spec.rb +1 -1
  19. data/spec/support/v5.2/Gemfile.lock +76 -67
  20. data/spec/support/v5.2/sorbet_test_cases.rb +8 -0
  21. data/spec/support/v6.0/Gemfile.lock +93 -85
  22. data/spec/support/v6.0/sorbet_test_cases.rb +8 -0
  23. data/spec/support/v6.1/Gemfile +1 -1
  24. data/spec/support/v6.1/Gemfile.lock +115 -108
  25. data/spec/support/v6.1/sorbet_test_cases.rb +8 -0
  26. data/spec/support/v7.0/.gitattributes +7 -0
  27. data/spec/support/v7.0/.gitignore +35 -0
  28. data/spec/support/v7.0/Gemfile +48 -0
  29. data/spec/support/v7.0/Gemfile.lock +218 -0
  30. data/spec/support/v7.0/README.md +24 -0
  31. data/spec/support/v7.0/Rakefile +6 -0
  32. data/spec/support/v7.0/app/assets/images/.keep +0 -0
  33. data/spec/support/v7.0/app/assets/stylesheets/application.css +1 -0
  34. data/spec/support/v7.0/app/controllers/application_controller.rb +3 -0
  35. data/spec/support/v7.0/app/controllers/concerns/.keep +0 -0
  36. data/spec/support/v7.0/app/helpers/application_helper.rb +3 -0
  37. data/spec/support/v7.0/app/helpers/bar_helper.rb +3 -0
  38. data/spec/support/v7.0/app/helpers/baz_helper.rb +3 -0
  39. data/spec/support/v7.0/app/helpers/foo_helper.rb +3 -0
  40. data/spec/support/v7.0/app/jobs/application_job.rb +8 -0
  41. data/spec/support/v7.0/app/jobs/award_house_point_hourglasses.rb +12 -0
  42. data/spec/support/v7.0/app/mailers/application_mailer.rb +5 -0
  43. data/spec/support/v7.0/app/mailers/daily_prophet_mailer.rb +9 -0
  44. data/spec/support/v7.0/app/mailers/hogwarts_acceptance_mailer.rb +29 -0
  45. data/spec/support/v7.0/app/models/application_record.rb +4 -0
  46. data/spec/support/v7.0/app/models/concerns/.keep +0 -0
  47. data/spec/support/v7.0/app/models/concerns/mythical.rb +11 -0
  48. data/spec/support/v7.0/app/models/headmaster.rb +8 -0
  49. data/spec/support/v7.0/app/models/potion.rb +6 -0
  50. data/spec/support/v7.0/app/models/robe.rb +4 -0
  51. data/spec/support/v7.0/app/models/school.rb +5 -0
  52. data/spec/support/v7.0/app/models/spell.rb +5 -0
  53. data/spec/support/v7.0/app/models/spell_book.rb +18 -0
  54. data/spec/support/v7.0/app/models/squib.rb +6 -0
  55. data/spec/support/v7.0/app/models/subject.rb +5 -0
  56. data/spec/support/v7.0/app/models/wand.rb +19 -0
  57. data/spec/support/v7.0/app/models/wizard.rb +65 -0
  58. data/spec/support/v7.0/app/views/layouts/application.html.erb +15 -0
  59. data/spec/support/v7.0/app/views/layouts/mailer.html.erb +13 -0
  60. data/spec/support/v7.0/app/views/layouts/mailer.text.erb +1 -0
  61. data/spec/support/v7.0/bin/bundle +114 -0
  62. data/spec/support/v7.0/bin/rails +4 -0
  63. data/spec/support/v7.0/bin/rake +4 -0
  64. data/spec/support/v7.0/bin/setup +33 -0
  65. data/spec/support/v7.0/config/application.rb +38 -0
  66. data/spec/support/v7.0/config/boot.rb +4 -0
  67. data/spec/support/v7.0/config/database.yml +25 -0
  68. data/spec/support/v7.0/config/environment.rb +6 -0
  69. data/spec/support/v7.0/config/environments/development.rb +69 -0
  70. data/spec/support/v7.0/config/environments/production.rb +83 -0
  71. data/spec/support/v7.0/config/environments/test.rb +61 -0
  72. data/spec/support/v7.0/config/initializers/content_security_policy.rb +26 -0
  73. data/spec/support/v7.0/config/initializers/filter_parameter_logging.rb +9 -0
  74. data/spec/support/v7.0/config/initializers/inflections.rb +17 -0
  75. data/spec/support/v7.0/config/initializers/permissions_policy.rb +12 -0
  76. data/spec/support/v7.0/config/initializers/sorbet_rails.rb +3 -0
  77. data/spec/support/v7.0/config/locales/en.yml +33 -0
  78. data/spec/support/v7.0/config/puma.rb +44 -0
  79. data/spec/support/v7.0/config/routes.rb +8 -0
  80. data/spec/support/v7.0/config/storage.yml +34 -0
  81. data/spec/support/v7.0/config.ru +6 -0
  82. data/spec/support/v7.0/db/migrate/20190620000001_create_wizards.rb +14 -0
  83. data/spec/support/v7.0/db/migrate/20190620000002_create_wands.rb +12 -0
  84. data/spec/support/v7.0/db/migrate/20190620000003_create_spell_books.rb +10 -0
  85. data/spec/support/v7.0/db/migrate/20190620000004_add_more_column_types_to_wands.rb +14 -0
  86. data/spec/support/v7.0/db/migrate/20190620000005_add_broom_to_wizard.rb +6 -0
  87. data/spec/support/v7.0/db/migrate/20190620000006_add_more_enums_to_wizard.rb +9 -0
  88. data/spec/support/v7.0/db/migrate/20190620000007_add_type_to_wizard.rb +6 -0
  89. data/spec/support/v7.0/db/migrate/20190620000008_add_robe_to_wizard.rb +8 -0
  90. data/spec/support/v7.0/db/migrate/20190620000009_add_school.rb +10 -0
  91. data/spec/support/v7.0/db/migrate/20190620000010_add_subject.rb +8 -0
  92. data/spec/support/v7.0/db/migrate/20190620000011_add_subjects_wizards.rb +8 -0
  93. data/spec/support/v7.0/db/migrate/20190620000012_add_spell.rb +8 -0
  94. data/spec/support/v7.0/db/migrate/20190620000013_add_spells_spell_books.rb +8 -0
  95. data/spec/support/v7.0/db/migrate/20190620000014_create_headmasters.rb +9 -0
  96. data/spec/support/v7.0/db/migrate/20190620000015_add_serialized_to_wizards.rb +9 -0
  97. data/spec/support/v7.0/db/schema.rb +98 -0
  98. data/spec/support/v7.0/db/seeds.rb +8 -0
  99. data/spec/support/v7.0/lib/assets/.keep +0 -0
  100. data/spec/support/v7.0/lib/mythical_rbi_plugin.rb +16 -0
  101. data/spec/support/v7.0/lib/tasks/.keep +0 -0
  102. data/spec/support/v7.0/log/.keep +0 -0
  103. data/spec/support/v7.0/sorbet_test_cases.rb +439 -0
  104. data/spec/support/v7.0/storage/.keep +0 -0
  105. data/spec/support/v7.0/tmp/.keep +0 -0
  106. data/spec/support/v7.0/tmp/pids/.keep +0 -0
  107. data/spec/support/v7.0/tmp/storage/.keep +0 -0
  108. data/spec/support/v7.0/vendor/.keep +0 -0
  109. data/spec/test_data/v5.2/expected_active_record_base.rbi +6 -0
  110. data/spec/test_data/v5.2/expected_active_record_relation.rbi +8 -2
  111. data/spec/test_data/v5.2/expected_attachment.rbi +3 -3
  112. data/spec/test_data/v5.2/expected_blob.rbi +3 -3
  113. data/spec/test_data/v5.2/expected_habtm_subjects.rbi +3 -3
  114. data/spec/test_data/v5.2/expected_habtm_wizards.rbi +3 -3
  115. data/spec/test_data/v5.2/expected_headmaster.rbi +3 -3
  116. data/spec/test_data/v5.2/expected_internal_metadata.rbi +3 -3
  117. data/spec/test_data/v5.2/expected_potion.rbi +3 -3
  118. data/spec/test_data/v5.2/expected_robe.rbi +3 -3
  119. data/spec/test_data/v5.2/expected_schema_migration.rbi +3 -3
  120. data/spec/test_data/v5.2/expected_school.rbi +3 -3
  121. data/spec/test_data/v5.2/expected_spell/habtm_spell_books.rbi +3 -3
  122. data/spec/test_data/v5.2/expected_spell.rbi +3 -3
  123. data/spec/test_data/v5.2/expected_spell_book/habtm_spell_books.rbi +3 -3
  124. data/spec/test_data/v5.2/expected_spell_book/habtm_spells.rbi +3 -3
  125. data/spec/test_data/v5.2/expected_spell_book.rbi +3 -3
  126. data/spec/test_data/v5.2/expected_squib.rbi +3 -3
  127. data/spec/test_data/v5.2/expected_subject/habtm_wizards.rbi +3 -3
  128. data/spec/test_data/v5.2/expected_subject.rbi +3 -3
  129. data/spec/test_data/v5.2/expected_wand.rbi +3 -3
  130. data/spec/test_data/v5.2/expected_wizard/habtm_subjects.rbi +3 -3
  131. data/spec/test_data/v5.2/expected_wizard.rbi +3 -3
  132. data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +3 -3
  133. data/spec/test_data/v6.0/expected_active_record_base.rbi +6 -0
  134. data/spec/test_data/v6.0/expected_active_record_relation.rbi +8 -2
  135. data/spec/test_data/v6.0/expected_attachment.rbi +3 -3
  136. data/spec/test_data/v6.0/expected_blob.rbi +3 -3
  137. data/spec/test_data/v6.0/expected_habtm_subjects.rbi +3 -3
  138. data/spec/test_data/v6.0/expected_habtm_wizards.rbi +3 -3
  139. data/spec/test_data/v6.0/expected_headmaster.rbi +3 -3
  140. data/spec/test_data/v6.0/expected_internal_metadata.rbi +3 -3
  141. data/spec/test_data/v6.0/expected_potion.rbi +3 -3
  142. data/spec/test_data/v6.0/expected_robe.rbi +3 -3
  143. data/spec/test_data/v6.0/expected_schema_migration.rbi +3 -3
  144. data/spec/test_data/v6.0/expected_school.rbi +3 -3
  145. data/spec/test_data/v6.0/expected_spell/habtm_spell_books.rbi +3 -3
  146. data/spec/test_data/v6.0/expected_spell.rbi +3 -3
  147. data/spec/test_data/v6.0/expected_spell_book/habtm_spell_books.rbi +3 -3
  148. data/spec/test_data/v6.0/expected_spell_book/habtm_spells.rbi +3 -3
  149. data/spec/test_data/v6.0/expected_spell_book.rbi +3 -3
  150. data/spec/test_data/v6.0/expected_squib.rbi +3 -3
  151. data/spec/test_data/v6.0/expected_subject/habtm_wizards.rbi +3 -3
  152. data/spec/test_data/v6.0/expected_subject.rbi +3 -3
  153. data/spec/test_data/v6.0/expected_wand.rbi +3 -3
  154. data/spec/test_data/v6.0/expected_wizard/habtm_subjects.rbi +3 -3
  155. data/spec/test_data/v6.0/expected_wizard.rbi +3 -3
  156. data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +3 -3
  157. data/spec/test_data/v6.1/expected_active_record_base.rbi +6 -0
  158. data/spec/test_data/v6.1/expected_active_record_relation.rbi +8 -2
  159. data/spec/test_data/v6.1/expected_attachment.rbi +3 -3
  160. data/spec/test_data/v6.1/expected_blob.rbi +3 -3
  161. data/spec/test_data/v6.1/expected_habtm_subjects.rbi +3 -3
  162. data/spec/test_data/v6.1/expected_habtm_wizards.rbi +3 -3
  163. data/spec/test_data/v6.1/expected_headmaster.rbi +3 -3
  164. data/spec/test_data/v6.1/expected_internal_metadata.rbi +3 -3
  165. data/spec/test_data/v6.1/expected_potion.rbi +3 -3
  166. data/spec/test_data/v6.1/expected_record.rbi +3 -3
  167. data/spec/test_data/v6.1/expected_robe.rbi +3 -3
  168. data/spec/test_data/v6.1/expected_schema_migration.rbi +3 -3
  169. data/spec/test_data/v6.1/expected_school.rbi +3 -3
  170. data/spec/test_data/v6.1/expected_spell/habtm_spell_books.rbi +3 -3
  171. data/spec/test_data/v6.1/expected_spell.rbi +3 -3
  172. data/spec/test_data/v6.1/expected_spell_book/habtm_spell_books.rbi +3 -3
  173. data/spec/test_data/v6.1/expected_spell_book/habtm_spells.rbi +3 -3
  174. data/spec/test_data/v6.1/expected_spell_book.rbi +3 -3
  175. data/spec/test_data/v6.1/expected_squib.rbi +3 -3
  176. data/spec/test_data/v6.1/expected_subject/habtm_wizards.rbi +3 -3
  177. data/spec/test_data/v6.1/expected_subject.rbi +3 -3
  178. data/spec/test_data/v6.1/expected_variant_record.rbi +3 -3
  179. data/spec/test_data/v6.1/expected_wand.rbi +3 -3
  180. data/spec/test_data/v6.1/expected_wizard/habtm_subjects.rbi +3 -3
  181. data/spec/test_data/v6.1/expected_wizard.rbi +3 -3
  182. data/spec/test_data/v6.1/expected_wizard_wo_spellbook.rbi +3 -3
  183. data/spec/test_data/v7.0/expected_active_record_base.rbi +119 -0
  184. data/spec/test_data/v7.0/expected_active_record_relation.rbi +180 -0
  185. data/spec/test_data/v7.0/expected_application_job.rbi +20 -0
  186. data/spec/test_data/v7.0/expected_application_mailer.rbi +5 -0
  187. data/spec/test_data/v7.0/expected_attachment.rbi +358 -0
  188. data/spec/test_data/v7.0/expected_award_house_point_hourglasses.rbi +20 -0
  189. data/spec/test_data/v7.0/expected_blob.rbi +394 -0
  190. data/spec/test_data/v7.0/expected_custom_application_job.rbi +21 -0
  191. data/spec/test_data/v7.0/expected_custom_application_mailer.rbi +6 -0
  192. data/spec/test_data/v7.0/expected_custom_award_house_point_hourglasses.rbi +21 -0
  193. data/spec/test_data/v7.0/expected_custom_daily_prophet_mailer.rbi +8 -0
  194. data/spec/test_data/v7.0/expected_custom_hogwarts_acceptance_mailer.rbi +21 -0
  195. data/spec/test_data/v7.0/expected_daily_prophet_mailer.rbi +7 -0
  196. data/spec/test_data/v7.0/expected_headmaster.rbi +376 -0
  197. data/spec/test_data/v7.0/expected_helpers.rbi +27 -0
  198. data/spec/test_data/v7.0/expected_helpers_with_application_and_devise_helpers.rbi +34 -0
  199. data/spec/test_data/v7.0/expected_hogwarts_acceptance_mailer.rbi +20 -0
  200. data/spec/test_data/v7.0/expected_internal_metadata.rbi +346 -0
  201. data/spec/test_data/v7.0/expected_no_routes.rbi +4 -0
  202. data/spec/test_data/v7.0/expected_potion.rbi +328 -0
  203. data/spec/test_data/v7.0/expected_record.rbi +307 -0
  204. data/spec/test_data/v7.0/expected_robe.rbi +349 -0
  205. data/spec/test_data/v7.0/expected_routes.rbi +182 -0
  206. data/spec/test_data/v7.0/expected_schema_migration.rbi +319 -0
  207. data/spec/test_data/v7.0/expected_school.rbi +349 -0
  208. data/spec/test_data/v7.0/expected_spell/habtm_spell_books.rbi +367 -0
  209. data/spec/test_data/v7.0/expected_spell.rbi +340 -0
  210. data/spec/test_data/v7.0/expected_spell_book/habtm_spells.rbi +367 -0
  211. data/spec/test_data/v7.0/expected_spell_book.rbi +499 -0
  212. data/spec/test_data/v7.0/expected_squib.rbi +1204 -0
  213. data/spec/test_data/v7.0/expected_srb_tc_output.txt +1 -0
  214. data/spec/test_data/v7.0/expected_subject/habtm_wizards.rbi +367 -0
  215. data/spec/test_data/v7.0/expected_subject.rbi +340 -0
  216. data/spec/test_data/v7.0/expected_variant_record.rbi +382 -0
  217. data/spec/test_data/v7.0/expected_wand.rbi +611 -0
  218. data/spec/test_data/v7.0/expected_wizard/habtm_subjects.rbi +367 -0
  219. data/spec/test_data/v7.0/expected_wizard.rbi +1280 -0
  220. data/spec/test_data/v7.0/expected_wizard_wo_spellbook.rbi +1274 -0
  221. metadata +245 -3
@@ -0,0 +1,439 @@
1
+ # typed: true
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
+ T.assert_type!(wand.chosen_at_time, T.nilable(ActiveSupport::TimeWithZone))
21
+
22
+ # -- model associations
23
+ T.assert_type!(wizard.wand, T.nilable(Wand))
24
+ T.assert_type!(T.must(wizard.wand).wizard, Wizard)
25
+
26
+ # need the exact type to works! they aren't subclass of each other
27
+ # T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Relation)
28
+ # T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_AssociationRelation)
29
+ T.assert_type!(wizard.spell_books, SpellBook::ActiveRecord_Associations_CollectionProxy)
30
+ T.assert_type!(wizard.spell_book_ids, T::Array[Integer])
31
+
32
+ # Finder methods -- Model
33
+ T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
34
+ T.assert_type!(Wizard.find(wizard.id), Wizard)
35
+ T.assert_type!(Wizard.first!, Wizard)
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))
45
+ T.assert_type!(Wizard.last!, Wizard)
46
+ T.assert_type!(Wizard.last, T.nilable(Wizard))
47
+ T.assert_type!(Wizard.first_n(5), T::Array[Wizard])
48
+ T.assert_type!(Wizard.last_n(5), T::Array[Wizard])
49
+ T.assert_type!(Wizard.find_by(name: 'Harry Potter'), T.nilable(Wizard))
50
+ T.assert_type!(Wizard.find_by!(name: 'Harry Potter'), Wizard)
51
+ T.assert_type!(Wizard.find_by_id(wizard.id), T.nilable(Wizard))
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)
87
+ T.assert_type!(Wizard.select { |r| r.id == 1 }, T::Array[Wizard])
88
+ T.assert_type!(Wizard.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
89
+ T.assert_type!(Wizard.where_missing(:wand), Wizard::ActiveRecord_Relation)
90
+ T.assert_type!(Wizard.in_order_of(:id, [1, 2, 3]), Wizard::ActiveRecord_Relation)
91
+
92
+ # Finder methods -- ActiveRecord::Relation
93
+ T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
94
+ T.assert_type!(Wizard.all.find(wizard.id), Wizard)
95
+ T.assert_type!(Wizard.all.first!, Wizard)
96
+ T.assert_type!(Wizard.all.first, T.nilable(Wizard))
97
+ T.assert_type!(Wizard.all.second!, Wizard)
98
+ T.assert_type!(Wizard.all.second, T.nilable(Wizard))
99
+ T.assert_type!(Wizard.all.third!, Wizard)
100
+ T.assert_type!(Wizard.all.third, T.nilable(Wizard))
101
+ T.assert_type!(Wizard.all.third_to_last!, Wizard)
102
+ T.assert_type!(Wizard.all.third_to_last, T.nilable(Wizard))
103
+ T.assert_type!(Wizard.all.second_to_last!, Wizard)
104
+ T.assert_type!(Wizard.all.second_to_last, T.nilable(Wizard))
105
+ T.assert_type!(Wizard.all.last!, Wizard)
106
+ T.assert_type!(Wizard.all.last, T.nilable(Wizard))
107
+ T.assert_type!(Wizard.all.first_n(5), T::Array[Wizard])
108
+ T.assert_type!(Wizard.all.last_n(5), T::Array[Wizard])
109
+ T.assert_type!(Wizard.all.find_by(name: 'Harry Potter'), T.nilable(Wizard))
110
+ T.assert_type!(Wizard.all.find_by!(name: 'Harry Potter'), Wizard)
111
+ T.assert_type!(Wizard.all.find_by_id(wizard.id), T.nilable(Wizard))
112
+ T.assert_type!(Wizard.all.find_by_id!(wizard.id), Wizard)
113
+ T.assert_type!(Wizard.all.find_or_initialize_by(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
114
+ T.assert_type!(Wizard.all.find_or_create_by(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
115
+ T.assert_type!(Wizard.all.find_or_create_by!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
116
+ T.assert_type!(Wizard.all.new { |w| T.assert_type!(w, Wizard) }, Wizard)
117
+ T.assert_type!(Wizard.all.build { |w| T.assert_type!(w, Wizard) }, Wizard)
118
+ T.assert_type!(Wizard.all.create(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
119
+ T.assert_type!(Wizard.all.create!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
120
+ T.assert_type!(Wizard.all.first_or_create(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
121
+ T.assert_type!(Wizard.all.first_or_create!(name: 'Harry Potter') { |w| T.assert_type!(w, Wizard) }, Wizard)
122
+ T.assert_type!(Wizard.all.first_or_initialize { |w| T.assert_type!(w, Wizard) }, Wizard)
123
+ Wizard.all.find_each { |w| T.assert_type!(w, Wizard) }
124
+ T.assert_type!(Wizard.all.find_each, T::Enumerator[Wizard])
125
+ Wizard.all.find_in_batches { |w| T.assert_type!(w, T::Array[Wizard]) }
126
+ T.assert_type!(Wizard.all.find_in_batches, T::Enumerator[T::Array[Wizard]])
127
+ Wizard.all.in_batches { |w| T.assert_type!(w, Wizard::ActiveRecord_Relation) }
128
+ T.assert_type!(Wizard.all.in_batches, ActiveRecord::Batches::BatchEnumerator)
129
+ # T.assert_type!(Wizard.all.destroy_all, T::Array[Wizard]) # Ignored until we add support
130
+ T.assert_type!(Wizard.all.any?, T::Boolean)
131
+ T.assert_type!(Wizard.all.many?, T::Boolean)
132
+ T.assert_type!(Wizard.all.none?, T::Boolean)
133
+ T.assert_type!(Wizard.all.one?, T::Boolean)
134
+ T.assert_type!(Wizard.all.any? { |r| r.id > 1 }, T::Boolean)
135
+ T.assert_type!(Wizard.all.many? { |r| r.id > 1 }, T::Boolean)
136
+ T.assert_type!(Wizard.all.none? { |r| r.id > 1 }, T::Boolean)
137
+ T.assert_type!(Wizard.all.one? { |r| r.id > 1 }, T::Boolean)
138
+
139
+ # T.assert_type!(Wizard.all.update_all(name: 'Harry Potter'), Integer) # Ignored until we add support
140
+ # T.assert_type!(Wizard.all.delete_all, Integer) # Ignored until we add support
141
+ # Query methods
142
+ T.assert_type!(Wizard.all.all, Wizard::ActiveRecord_Relation)
143
+ T.assert_type!(Wizard.all.recent, Wizard::ActiveRecord_Relation) # Named scope
144
+ T.assert_type!(Wizard.all.Gryffindor, Wizard::ActiveRecord_Relation) # Enum scope
145
+ T.assert_type!(Wizard.all.Gryffindor.recent, Wizard::ActiveRecord_Relation)
146
+ T.assert_type!(Wizard.all.Gryffindor.recent.unscoped, Wizard::ActiveRecord_Relation)
147
+ T.assert_type!(Wizard.all.where(id: 1), Wizard::ActiveRecord_Relation)
148
+ T.assert_type!(Wizard.all.where(id: 1).recent, Wizard::ActiveRecord_Relation)
149
+ T.assert_type!(Wizard.all.where.not(id: 1), Wizard::ActiveRecord_Relation)
150
+ T.assert_type!(Wizard.all.preload(:spell_books), Wizard::ActiveRecord_Relation)
151
+ T.assert_type!(Wizard.all.eager_load(:spell_books), Wizard::ActiveRecord_Relation)
152
+ T.assert_type!(Wizard.all.order(:id), Wizard::ActiveRecord_Relation)
153
+ T.assert_type!(Wizard.all.select { |r| r.id == 1 }, T::Array[Wizard])
154
+ T.assert_type!(Wizard.all.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
155
+ T.assert_type!(Wizard.all.where_missing(:wand), Wizard::ActiveRecord_Relation)
156
+ T.assert_type!(Wizard.all.in_order_of(:id, [1, 2, 3]), Wizard::ActiveRecord_Relation)
157
+
158
+ # Enumerable methods
159
+ Wizard.all.each { |w| T.assert_type!(w, Wizard) }
160
+ Wizard.all.map { |w| T.assert_type!(w, Wizard) }
161
+ T.assert_type!(Wizard.all.to_a, T::Array[Wizard])
162
+ T.assert_type!(Wizard.all.empty?, T::Boolean)
163
+
164
+ # Finder methods -- CollectionProxy
165
+ spell_book = wizard.spell_books.first!
166
+ spell_books = wizard.spell_books
167
+ T.assert_type!(spell_books.exists?(name: 'Fantastic Beasts'), T::Boolean)
168
+ T.assert_type!(spell_books.find(spell_book.id), SpellBook)
169
+ T.assert_type!(spell_books.first!, SpellBook)
170
+ T.assert_type!(spell_books.first, T.nilable(SpellBook))
171
+ T.assert_type!(spell_books.second!, SpellBook)
172
+ T.assert_type!(spell_books.second, T.nilable(SpellBook))
173
+ T.assert_type!(spell_books.third!, SpellBook)
174
+ T.assert_type!(spell_books.third, T.nilable(SpellBook))
175
+ T.assert_type!(spell_books.third_to_last!, SpellBook)
176
+ T.assert_type!(spell_books.third_to_last, T.nilable(SpellBook))
177
+ T.assert_type!(spell_books.second_to_last!, SpellBook)
178
+ T.assert_type!(spell_books.second_to_last, T.nilable(SpellBook))
179
+ T.assert_type!(spell_books.last!, SpellBook)
180
+ T.assert_type!(spell_books.last, T.nilable(SpellBook))
181
+ T.assert_type!(spell_books.first_n(5), T::Array[SpellBook])
182
+ T.assert_type!(spell_books.last_n(5), T::Array[SpellBook])
183
+ T.assert_type!(spell_books.find_by(name: 'Fantastic Beasts'), T.nilable(SpellBook))
184
+ T.assert_type!(spell_books.find_by!(name: 'Fantastic Beasts'), SpellBook)
185
+ T.assert_type!(spell_books.find_by_id(spell_book.id), T.nilable(SpellBook))
186
+ T.assert_type!(spell_books.find_by_id!(spell_book.id), SpellBook)
187
+ T.assert_type!(spell_books.find_or_initialize_by(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
188
+ T.assert_type!(spell_books.find_or_create_by(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
189
+ T.assert_type!(spell_books.find_or_create_by!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
190
+ T.assert_type!(spell_books.new { |s| T.assert_type!(s, SpellBook) }, SpellBook)
191
+ T.assert_type!(spell_books.build { |s| T.assert_type!(s, SpellBook) }, SpellBook)
192
+ T.assert_type!(spell_books.create(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
193
+ T.assert_type!(spell_books.create!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
194
+ T.assert_type!(spell_books.first_or_create(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
195
+ T.assert_type!(spell_books.first_or_create!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
196
+ T.assert_type!(spell_books.first_or_initialize { |s| T.assert_type!(s, SpellBook) }, SpellBook)
197
+ spell_books.find_each { |s| T.assert_type!(s, SpellBook) }
198
+ T.assert_type!(spell_books.find_each, T::Enumerator[SpellBook])
199
+ spell_books.find_in_batches { |s| T.assert_type!(s, T::Array[SpellBook]) }
200
+ T.assert_type!(spell_books.find_in_batches, T::Enumerator[T::Array[SpellBook]])
201
+ spell_books.in_batches { |s| T.assert_type!(s, SpellBook::ActiveRecord_AssociationRelation) }
202
+ T.assert_type!(spell_books.in_batches, ActiveRecord::Batches::BatchEnumerator)
203
+ # T.assert_type!(spell_books.destroy_all, T::Array[SpellBook]) # Ignored until we add support
204
+ T.assert_type!(spell_books.any?, T::Boolean)
205
+ T.assert_type!(spell_books.many?, T::Boolean)
206
+ T.assert_type!(spell_books.none?, T::Boolean)
207
+ T.assert_type!(spell_books.one?, T::Boolean)
208
+ T.assert_type!(spell_books.any? { |r| r.id > 1 }, T::Boolean)
209
+ T.assert_type!(spell_books.many? { |r| r.id > 1 }, T::Boolean)
210
+ T.assert_type!(spell_books.none? { |r| r.id > 1 }, T::Boolean)
211
+ T.assert_type!(spell_books.one? { |r| r.id > 1 }, T::Boolean)
212
+ # T.assert_type!(spell_books.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
213
+ # T.assert_type!(spell_books.delete_all, Integer) # Ignored until we add support
214
+
215
+ # Query methods
216
+ T.assert_type!(spell_books.all, SpellBook::ActiveRecord_AssociationRelation)
217
+ T.assert_type!(spell_books.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
218
+ T.assert_type!(spell_books.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
219
+ T.assert_type!(spell_books.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
220
+ T.assert_type!(spell_books.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
221
+ T.assert_type!(spell_books.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
222
+ T.assert_type!(spell_books.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
223
+ T.assert_type!(spell_books.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
224
+ T.assert_type!(spell_books.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
225
+ T.assert_type!(spell_books.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
226
+ T.assert_type!(spell_books.order(:id), SpellBook::ActiveRecord_AssociationRelation)
227
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
228
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
229
+ T.assert_type!(spell_books.where_missing(:wizard), SpellBook::ActiveRecord_AssociationRelation)
230
+ T.assert_type!(spell_books.in_order_of(:id, [1, 2, 3]), SpellBook::ActiveRecord_AssociationRelation)
231
+
232
+ # Enumerable methods
233
+ spell_books.each { |s| T.assert_type!(s, SpellBook) }
234
+ spell_books.map { |s| T.assert_type!(s, SpellBook) }
235
+ T.assert_type!(spell_books.to_a, T::Array[SpellBook])
236
+ T.assert_type!(spell_books.empty?, T::Boolean)
237
+ # Push methods
238
+ T.assert_type!(spell_books << spell_book, SpellBook::ActiveRecord_Associations_CollectionProxy)
239
+ T.assert_type!(spell_books << [spell_book], SpellBook::ActiveRecord_Associations_CollectionProxy)
240
+ T.assert_type!(spell_books.append(spell_book), SpellBook::ActiveRecord_Associations_CollectionProxy)
241
+ T.assert_type!(spell_books.append([spell_book]), SpellBook::ActiveRecord_Associations_CollectionProxy)
242
+ T.assert_type!(spell_books.push(spell_book), SpellBook::ActiveRecord_Associations_CollectionProxy)
243
+ T.assert_type!(spell_books.push([spell_book]), SpellBook::ActiveRecord_Associations_CollectionProxy)
244
+ # 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
245
+ # 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
246
+
247
+ # finder methods -- AssociationRelation
248
+ spell_books_query = spell_books.where(wizard_id: wizard.id)
249
+ T.assert_type!(spell_books_query.exists?(name: 'Fantastic Beasts'), T::Boolean)
250
+ T.assert_type!(spell_books_query.find(spell_book.id), SpellBook)
251
+ T.assert_type!(spell_books_query.first!, SpellBook)
252
+ T.assert_type!(spell_books_query.first, T.nilable(SpellBook))
253
+ T.assert_type!(spell_books_query.second!, SpellBook)
254
+ T.assert_type!(spell_books_query.second, T.nilable(SpellBook))
255
+ T.assert_type!(spell_books_query.third!, SpellBook)
256
+ T.assert_type!(spell_books_query.third, T.nilable(SpellBook))
257
+ T.assert_type!(spell_books_query.third_to_last!, SpellBook)
258
+ T.assert_type!(spell_books_query.third_to_last, T.nilable(SpellBook))
259
+ T.assert_type!(spell_books_query.second_to_last!, SpellBook)
260
+ T.assert_type!(spell_books_query.second_to_last, T.nilable(SpellBook))
261
+ T.assert_type!(spell_books_query.last!, SpellBook)
262
+ T.assert_type!(spell_books_query.last, T.nilable(SpellBook))
263
+ T.assert_type!(spell_books_query.first_n(5), T::Array[SpellBook])
264
+ T.assert_type!(spell_books_query.last_n(5), T::Array[SpellBook])
265
+ T.assert_type!(spell_books_query.find_by(name: 'Fantastic Beasts'), T.nilable(SpellBook))
266
+ T.assert_type!(spell_books_query.find_by!(name: 'Fantastic Beasts'), SpellBook)
267
+ T.assert_type!(spell_books_query.find_by_id(spell_book.id), T.nilable(SpellBook))
268
+ T.assert_type!(spell_books_query.find_by_id!(spell_book.id), SpellBook)
269
+ T.assert_type!(spell_books_query.find_or_initialize_by(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
270
+ T.assert_type!(spell_books_query.find_or_create_by(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
271
+ T.assert_type!(spell_books_query.find_or_create_by!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook)
272
+ T.assert_type!(spell_books_query.new { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
273
+ T.assert_type!(spell_books_query.build { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support # Ignored until we add support
274
+ T.assert_type!(spell_books_query.create(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
275
+ T.assert_type!(spell_books_query.create!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
276
+ T.assert_type!(spell_books_query.first_or_create(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
277
+ T.assert_type!(spell_books_query.first_or_create!(name: 'Fantastic Beasts') { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
278
+ T.assert_type!(spell_books_query.first_or_initialize { |s| T.assert_type!(s, SpellBook) }, SpellBook) # Ignored until we add support
279
+ spell_books_query.find_each { |s| T.assert_type!(s, SpellBook) }
280
+ T.assert_type!(spell_books_query.find_each, T::Enumerator[SpellBook])
281
+ spell_books_query.find_in_batches { |s| T.assert_type!(s, T::Array[SpellBook]) }
282
+ T.assert_type!(spell_books_query.find_in_batches, T::Enumerator[T::Array[SpellBook]])
283
+ spell_books_query.in_batches { |s| T.assert_type!(s, SpellBook::ActiveRecord_AssociationRelation) }
284
+ T.assert_type!(spell_books_query.in_batches, ActiveRecord::Batches::BatchEnumerator)
285
+ # T.assert_type!(spell_books_query.destroy_all, T::Array[SpellBook]) # Ignored until we add support
286
+ T.assert_type!(spell_books_query.any?, T::Boolean)
287
+ T.assert_type!(spell_books_query.many?, T::Boolean)
288
+ T.assert_type!(spell_books_query.none?, T::Boolean)
289
+ T.assert_type!(spell_books_query.one?, T::Boolean)
290
+ T.assert_type!(spell_books_query.any? { |r| r.id > 1 }, T::Boolean)
291
+ T.assert_type!(spell_books_query.many? { |r| r.id > 1 }, T::Boolean)
292
+ T.assert_type!(spell_books_query.none? { |r| r.id > 1 }, T::Boolean)
293
+ T.assert_type!(spell_books_query.one? { |r| r.id > 1 }, T::Boolean)
294
+ # T.assert_type!(spell_books_query.update_all(name: 'Fantastic Beasts'), Integer) # Ignored until we add support
295
+ # T.assert_type!(spell_books_query.delete_all, Integer) # Ignored until we add support
296
+ # Query methods
297
+ T.assert_type!(spell_books_query.all, SpellBook::ActiveRecord_AssociationRelation)
298
+ T.assert_type!(spell_books_query.recent, SpellBook::ActiveRecord_AssociationRelation) # Named scope
299
+ T.assert_type!(spell_books_query.unclassified, SpellBook::ActiveRecord_AssociationRelation) # Enum scope
300
+ T.assert_type!(spell_books_query.unclassified.recent, SpellBook::ActiveRecord_AssociationRelation)
301
+ T.assert_type!(spell_books_query.unclassified.recent.unscoped, SpellBook::ActiveRecord_Relation) # Turns back into relation
302
+ T.assert_type!(spell_books_query.where(id: 1), SpellBook::ActiveRecord_AssociationRelation)
303
+ T.assert_type!(spell_books_query.where(id: 1).recent, SpellBook::ActiveRecord_AssociationRelation)
304
+ T.assert_type!(spell_books_query.where.not(id: 1), SpellBook::ActiveRecord_AssociationRelation)
305
+ T.assert_type!(spell_books_query.preload(:wizard), SpellBook::ActiveRecord_AssociationRelation)
306
+ T.assert_type!(spell_books_query.eager_load(:wizard), SpellBook::ActiveRecord_AssociationRelation)
307
+ T.assert_type!(spell_books_query.order(:id), SpellBook::ActiveRecord_AssociationRelation)
308
+ T.assert_type!(spell_books.select { |r| r.id == 1 }, T::Array[SpellBook])
309
+ T.assert_type!(spell_books.select_columns(:id, :name), SpellBook::ActiveRecord_AssociationRelation)
310
+ # Enumerable methods
311
+ spell_books_query.each { |s| T.assert_type!(s, SpellBook) }
312
+ spell_books_query.map { |s| T.assert_type!(s, SpellBook) }
313
+ T.assert_type!(spell_books_query.to_a, T::Array[SpellBook])
314
+ T.assert_type!(spell_books_query.empty?, T::Boolean)
315
+
316
+ # Model columns
317
+ T.assert_type!(wizard.id, Integer)
318
+ T.assert_type!(wizard.id?, T::Boolean)
319
+ T.assert_type!(wizard.notes, T.nilable(String))
320
+
321
+ # Model enum
322
+ T.assert_type!(wizard.Gryffindor?, T::Boolean)
323
+ T.assert_type!(Wizard.houses, T::Hash[T.any(String, Symbol), Integer])
324
+ T.assert_type!(Wizard.brooms, T::Hash[T.any(String, Symbol), String])
325
+ T.assert_type!(spell_book.biology?, T::Boolean)
326
+ T.assert_type!(spell_book.book_type, String)
327
+ T.assert_type!(SpellBook.book_types, T::Hash[T.any(String, Symbol), Integer])
328
+ # Model T::Enum
329
+ T.assert_type!(wizard.typed_house, T.nilable(Wizard::House))
330
+ T.assert_type!(wizard.typed_broom, T.nilable(Wizard::Broom))
331
+ T.assert_type!(wizard.typed_quidditch_position, T.nilable(Wizard::QuidditchPosition))
332
+ T.assert_type!(Wizard::House, T.class_of(T::Enum))
333
+ T.assert_type!(Wizard::House::Gryffindor, Wizard::House)
334
+ T.assert_type!(Wizard::House::Hufflepuff, Wizard::House)
335
+ T.assert_type!(Wizard::House::Ravenclaw, Wizard::House)
336
+ T.assert_type!(Wizard::House::Slytherin, Wizard::House)
337
+
338
+ # Serialization
339
+ T.assert_type!(
340
+ wizard.owl_results,
341
+ T.nilable(T::Hash[T.untyped, T.untyped])
342
+ )
343
+ T.assert_type!(
344
+ wizard.newt_subjects,
345
+ T.nilable(T.any(T::Array[T.untyped], T::Boolean, Float, T::Hash[T.untyped, T.untyped], Integer, String))
346
+ )
347
+ T.assert_type!(
348
+ wizard.patronus_characteristics,
349
+ T.nilable(ActiveRecord::Coders::JSON),
350
+ )
351
+ T.assert_type!(wizard.pets, T.nilable(T::Array[T.untyped]))
352
+
353
+ # Mythical plugin
354
+ T.assert_type!(Wand.mythicals, T::Array[Wand])
355
+
356
+ # Mailers
357
+ T.assert_type!(HogwartsAcceptanceMailer.notify(wizard), ActionMailer::MessageDelivery)
358
+
359
+ # Jobs
360
+ T.assert_type!(
361
+ AwardHousePointHourglasses.perform_later(student: wizard, point: 10),
362
+ AwardHousePointHourglasses
363
+ )
364
+ AwardHousePointHourglasses.perform_now(student: wizard, point: 10)
365
+ AwardHousePointHourglasses.
366
+ set(queue: :daily, wait: 5.minutes).
367
+ perform_later(student: wizard, point: 10)
368
+ AwardHousePointHourglasses.
369
+ set(priority: 10, wait_until: Time.now.tomorrow).
370
+ perform_later(student: wizard, point: 10)
371
+
372
+ T.assert_type!(wizard.broom_nimbus?, T::Boolean)
373
+ T.assert_type!(wizard.color_brown_eyes?, T::Boolean)
374
+ T.assert_type!(wizard.quidditch_keeper?, T::Boolean)
375
+ T.assert_type!(wizard.brown_hair?, T::Boolean)
376
+
377
+ # Relations
378
+ T.assert_type!(wizard.spell_books.any?, T::Boolean)
379
+ T.assert_type!(wizard.spell_books.none?, T::Boolean)
380
+ T.assert_type!(wizard.spell_books.one?, T::Boolean)
381
+
382
+ # -- Custom ActionController::Parameters Methods
383
+ class MyActionParams < T::Struct
384
+ class Info < T::Struct
385
+ const :birthday, Date
386
+ const :friends, T::Array[String]
387
+ const :grandson, T.nilable(String)
388
+ end
389
+
390
+ const :age, Integer
391
+ const :name, String
392
+ const :info, Info
393
+ end
394
+
395
+ params = ActionController::Parameters.new({
396
+ age: 11,
397
+ name: 'Harry Potter',
398
+ info: {
399
+ birthday: Date.parse('1980-07-31'),
400
+ friends: [
401
+ 'Hermione',
402
+ 'Ron',
403
+ ],
404
+ grandson: nil,
405
+ },
406
+ })
407
+
408
+ typed_params = TypedParams[MyActionParams].new.extract!(params)
409
+ T.assert_type!(typed_params, MyActionParams)
410
+
411
+ # -- pluck to tstruct
412
+ class WizardStruct < T::Struct
413
+ const :name, String
414
+ const :house, T.nilable(String)
415
+ end
416
+
417
+ T.assert_type!(Wizard.pluck_to_tstruct(TA[WizardStruct].new), T::Array[WizardStruct])
418
+ T.assert_type!(Wizard.all.pluck_to_tstruct(TA[WizardStruct].new), T::Array[WizardStruct])
419
+
420
+ Wizard.pluck_to_tstruct(TA[WizardStruct].new).each do |row|
421
+ T.assert_type!(row, WizardStruct)
422
+ end
423
+ Wizard.all.pluck_to_tstruct(TA[WizardStruct].new).each do |row|
424
+ T.assert_type!(row, WizardStruct)
425
+ end
426
+
427
+ # -- GeneratedUrlHelpers
428
+ class TestHelper
429
+ include GeneratedUrlHelpers
430
+ end
431
+
432
+ T.assert_type!(TestHelper.new.test_index_path, String)
433
+ # need to set this config for _url methods
434
+ Rails.application.routes.default_url_options = {
435
+ protocol: 'http',
436
+ host: 'localhost',
437
+ port: 3000,
438
+ }
439
+ T.assert_type!(TestHelper.new.test_index_url, String)
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -56,6 +56,12 @@ class ActiveRecord::Base
56
56
  sig { returns(T.attached_class) }
57
57
  def self.last!; end
58
58
 
59
+ sig { returns(T.nilable(T.attached_class)) }
60
+ def self.take; end
61
+
62
+ sig { returns(T.attached_class) }
63
+ def self.take!; end
64
+
59
65
  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: T.attached_class).void)).returns(T.attached_class) }
60
66
  def self.create(attributes = nil, &block); end
61
67
 
@@ -58,6 +58,12 @@ class ActiveRecord::Relation
58
58
  sig { returns(Elem) }
59
59
  def last!; end
60
60
 
61
+ sig { returns(T.nilable(Elem)) }
62
+ def take; end
63
+
64
+ sig { returns(Elem) }
65
+ def take!; end
66
+
61
67
  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
62
68
  def create(attributes = nil, &block); end
63
69
 
@@ -133,7 +139,7 @@ class ActiveRecord::Relation
133
139
  end
134
140
 
135
141
  class ActiveRecord::AssociationRelation < ActiveRecord::Relation
136
- Elem = type_member(fixed: T.untyped)
142
+ Elem = type_member {{fixed: T.untyped}}
137
143
 
138
144
  sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
139
145
  def new(*args, &block); end
@@ -149,7 +155,7 @@ class ActiveRecord::AssociationRelation < ActiveRecord::Relation
149
155
  end
150
156
 
151
157
  class ActiveRecord::Associations::CollectionProxy < ActiveRecord::Relation
152
- Elem = type_member(fixed: T.untyped)
158
+ Elem = type_member {{fixed: T.untyped}}
153
159
 
154
160
  sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: Elem).void)).returns(Elem) }
155
161
  def new(attributes = nil, &block); end
@@ -281,20 +281,20 @@ class ActiveStorage::Attachment::ActiveRecord_Relation < ActiveRecord::Relation
281
281
  include ActiveStorage::Attachment::ActiveRelation_WhereNot
282
282
  include ActiveStorage::Attachment::CustomFinderMethods
283
283
  include ActiveStorage::Attachment::QueryMethodsReturningRelation
284
- Elem = type_member(fixed: ActiveStorage::Attachment)
284
+ Elem = type_member {{fixed: ActiveStorage::Attachment}}
285
285
  end
286
286
 
287
287
  class ActiveStorage::Attachment::ActiveRecord_AssociationRelation < ActiveRecord::AssociationRelation
288
288
  include ActiveStorage::Attachment::ActiveRelation_WhereNot
289
289
  include ActiveStorage::Attachment::CustomFinderMethods
290
290
  include ActiveStorage::Attachment::QueryMethodsReturningAssociationRelation
291
- Elem = type_member(fixed: ActiveStorage::Attachment)
291
+ Elem = type_member {{fixed: ActiveStorage::Attachment}}
292
292
  end
293
293
 
294
294
  class ActiveStorage::Attachment::ActiveRecord_Associations_CollectionProxy < ActiveRecord::Associations::CollectionProxy
295
295
  include ActiveStorage::Attachment::CustomFinderMethods
296
296
  include ActiveStorage::Attachment::QueryMethodsReturningAssociationRelation
297
- Elem = type_member(fixed: ActiveStorage::Attachment)
297
+ Elem = type_member {{fixed: ActiveStorage::Attachment}}
298
298
 
299
299
  sig { params(records: T.any(ActiveStorage::Attachment, T::Array[ActiveStorage::Attachment])).returns(T.self_type) }
300
300
  def <<(*records); end
@@ -88,7 +88,7 @@ class ActiveStorage::Blob::ActiveRecord_Relation < ActiveRecord::Relation
88
88
  include ActiveStorage::Blob::ActiveRelation_WhereNot
89
89
  include ActiveStorage::Blob::CustomFinderMethods
90
90
  include ActiveStorage::Blob::QueryMethodsReturningRelation
91
- Elem = type_member(fixed: ActiveStorage::Blob)
91
+ Elem = type_member {{fixed: ActiveStorage::Blob}}
92
92
 
93
93
  sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_Relation) }
94
94
  def unattached(*args); end
@@ -101,7 +101,7 @@ class ActiveStorage::Blob::ActiveRecord_AssociationRelation < ActiveRecord::Asso
101
101
  include ActiveStorage::Blob::ActiveRelation_WhereNot
102
102
  include ActiveStorage::Blob::CustomFinderMethods
103
103
  include ActiveStorage::Blob::QueryMethodsReturningAssociationRelation
104
- Elem = type_member(fixed: ActiveStorage::Blob)
104
+ Elem = type_member {{fixed: ActiveStorage::Blob}}
105
105
 
106
106
  sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_AssociationRelation) }
107
107
  def unattached(*args); end
@@ -113,7 +113,7 @@ end
113
113
  class ActiveStorage::Blob::ActiveRecord_Associations_CollectionProxy < ActiveRecord::Associations::CollectionProxy
114
114
  include ActiveStorage::Blob::CustomFinderMethods
115
115
  include ActiveStorage::Blob::QueryMethodsReturningAssociationRelation
116
- Elem = type_member(fixed: ActiveStorage::Blob)
116
+ Elem = type_member {{fixed: ActiveStorage::Blob}}
117
117
 
118
118
  sig { params(args: T.untyped).returns(ActiveStorage::Blob::ActiveRecord_AssociationRelation) }
119
119
  def unattached(*args); end
@@ -182,7 +182,7 @@ class Wizard::HABTM_Subjects::ActiveRecord_Relation < ActiveRecord::Relation
182
182
  include Enumerable
183
183
  extend T::Sig
184
184
  extend T::Generic
185
- Elem = type_member(fixed: Wizard::HABTM_Subjects)
185
+ Elem = type_member {{fixed: Wizard::HABTM_Subjects}}
186
186
 
187
187
  sig { returns(Wizard::HABTM_Subjects::ActiveRecord_Relation) }
188
188
  def all; end
@@ -296,7 +296,7 @@ class Wizard::HABTM_Subjects::ActiveRecord_AssociationRelation < ActiveRecord::A
296
296
  include Enumerable
297
297
  extend T::Sig
298
298
  extend T::Generic
299
- Elem = type_member(fixed: Wizard::HABTM_Subjects)
299
+ Elem = type_member {{fixed: Wizard::HABTM_Subjects}}
300
300
 
301
301
  sig { returns(Wizard::HABTM_Subjects::ActiveRecord_AssociationRelation) }
302
302
  def all; end
@@ -480,7 +480,7 @@ class Wizard::HABTM_Subjects::ActiveRecord_Associations_CollectionProxy < Active
480
480
  include Enumerable
481
481
  extend T::Sig
482
482
  extend T::Generic
483
- Elem = type_member(fixed: Wizard::HABTM_Subjects)
483
+ Elem = type_member {{fixed: Wizard::HABTM_Subjects}}
484
484
 
485
485
  sig { returns(Wizard::HABTM_Subjects::ActiveRecord_AssociationRelation) }
486
486
  def all; end
@@ -182,7 +182,7 @@ class Subject::HABTM_Wizards::ActiveRecord_Relation < ActiveRecord::Relation
182
182
  include Enumerable
183
183
  extend T::Sig
184
184
  extend T::Generic
185
- Elem = type_member(fixed: Subject::HABTM_Wizards)
185
+ Elem = type_member {{fixed: Subject::HABTM_Wizards}}
186
186
 
187
187
  sig { returns(Subject::HABTM_Wizards::ActiveRecord_Relation) }
188
188
  def all; end
@@ -296,7 +296,7 @@ class Subject::HABTM_Wizards::ActiveRecord_AssociationRelation < ActiveRecord::A
296
296
  include Enumerable
297
297
  extend T::Sig
298
298
  extend T::Generic
299
- Elem = type_member(fixed: Subject::HABTM_Wizards)
299
+ Elem = type_member {{fixed: Subject::HABTM_Wizards}}
300
300
 
301
301
  sig { returns(Subject::HABTM_Wizards::ActiveRecord_AssociationRelation) }
302
302
  def all; end
@@ -480,7 +480,7 @@ class Subject::HABTM_Wizards::ActiveRecord_Associations_CollectionProxy < Active
480
480
  include Enumerable
481
481
  extend T::Sig
482
482
  extend T::Generic
483
- Elem = type_member(fixed: Subject::HABTM_Wizards)
483
+ Elem = type_member {{fixed: Subject::HABTM_Wizards}}
484
484
 
485
485
  sig { returns(Subject::HABTM_Wizards::ActiveRecord_AssociationRelation) }
486
486
  def all; end
@@ -311,20 +311,20 @@ class Headmaster::ActiveRecord_Relation < ActiveRecord::Relation
311
311
  include Headmaster::ActiveRelation_WhereNot
312
312
  include Headmaster::CustomFinderMethods
313
313
  include Headmaster::QueryMethodsReturningRelation
314
- Elem = type_member(fixed: Headmaster)
314
+ Elem = type_member {{fixed: Headmaster}}
315
315
  end
316
316
 
317
317
  class Headmaster::ActiveRecord_AssociationRelation < ActiveRecord::AssociationRelation
318
318
  include Headmaster::ActiveRelation_WhereNot
319
319
  include Headmaster::CustomFinderMethods
320
320
  include Headmaster::QueryMethodsReturningAssociationRelation
321
- Elem = type_member(fixed: Headmaster)
321
+ Elem = type_member {{fixed: Headmaster}}
322
322
  end
323
323
 
324
324
  class Headmaster::ActiveRecord_Associations_CollectionProxy < ActiveRecord::Associations::CollectionProxy
325
325
  include Headmaster::CustomFinderMethods
326
326
  include Headmaster::QueryMethodsReturningAssociationRelation
327
- Elem = type_member(fixed: Headmaster)
327
+ Elem = type_member {{fixed: Headmaster}}
328
328
 
329
329
  sig { params(records: T.any(Headmaster, T::Array[Headmaster])).returns(T.self_type) }
330
330
  def <<(*records); end
@@ -281,20 +281,20 @@ class ActiveRecord::InternalMetadata::ActiveRecord_Relation < ActiveRecord::Rela
281
281
  include ActiveRecord::InternalMetadata::ActiveRelation_WhereNot
282
282
  include ActiveRecord::InternalMetadata::CustomFinderMethods
283
283
  include ActiveRecord::InternalMetadata::QueryMethodsReturningRelation
284
- Elem = type_member(fixed: ActiveRecord::InternalMetadata)
284
+ Elem = type_member {{fixed: ActiveRecord::InternalMetadata}}
285
285
  end
286
286
 
287
287
  class ActiveRecord::InternalMetadata::ActiveRecord_AssociationRelation < ActiveRecord::AssociationRelation
288
288
  include ActiveRecord::InternalMetadata::ActiveRelation_WhereNot
289
289
  include ActiveRecord::InternalMetadata::CustomFinderMethods
290
290
  include ActiveRecord::InternalMetadata::QueryMethodsReturningAssociationRelation
291
- Elem = type_member(fixed: ActiveRecord::InternalMetadata)
291
+ Elem = type_member {{fixed: ActiveRecord::InternalMetadata}}
292
292
  end
293
293
 
294
294
  class ActiveRecord::InternalMetadata::ActiveRecord_Associations_CollectionProxy < ActiveRecord::Associations::CollectionProxy
295
295
  include ActiveRecord::InternalMetadata::CustomFinderMethods
296
296
  include ActiveRecord::InternalMetadata::QueryMethodsReturningAssociationRelation
297
- Elem = type_member(fixed: ActiveRecord::InternalMetadata)
297
+ Elem = type_member {{fixed: ActiveRecord::InternalMetadata}}
298
298
 
299
299
  sig { params(records: T.any(ActiveRecord::InternalMetadata, T::Array[ActiveRecord::InternalMetadata])).returns(T.self_type) }
300
300
  def <<(*records); end