sorbet-rails 0.5.8.1 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +27 -4
  4. data/lib/bundled_rbi/active_record_relation.rbi +79 -0
  5. data/lib/sorbet-rails/gem_plugins/active_flag_plugin.rb +47 -0
  6. data/lib/sorbet-rails/gem_plugins/kaminari_plugin.rb +20 -1
  7. data/lib/sorbet-rails/gem_plugins/paperclip_plugin.rb +33 -0
  8. data/lib/sorbet-rails/model_plugins/active_record_assoc.rb +22 -6
  9. data/lib/sorbet-rails/model_plugins/active_record_attribute.rb +10 -2
  10. data/lib/sorbet-rails/model_plugins/active_record_finder_methods.rb +46 -35
  11. data/lib/sorbet-rails/model_plugins/enumerable_collections.rb +40 -34
  12. data/lib/sorbet-rails/model_plugins/plugins.rb +6 -0
  13. data/lib/sorbet-rails/routes_rbi_formatter.rb +4 -0
  14. data/lib/sorbet-rails/tasks/rails_rbi.rake +2 -1
  15. data/sorbet-rails.gemspec +2 -2
  16. data/spec/generators/rails-template.rb +25 -3
  17. data/spec/generators/sorbet_test_cases.rb +5 -0
  18. data/spec/model_rbi_formatter_spec.rb +1 -1
  19. data/spec/rake_rails_rbi_models_spec.rb +1 -0
  20. data/spec/support/v5.0/Gemfile +1 -1
  21. data/spec/support/v5.0/Gemfile.lock +18 -14
  22. data/spec/support/v5.0/app/models/school.rb +3 -0
  23. data/spec/support/v5.0/app/models/spell_book.rb +3 -1
  24. data/spec/support/v5.0/app/models/wizard.rb +3 -0
  25. data/spec/support/v5.0/config/environments/development.rb +1 -1
  26. data/spec/support/v5.0/config/initializers/sorbet_rails.rb +1 -1
  27. data/spec/support/v5.0/db/migrate/20190620000003_create_spell_books.rb +1 -1
  28. data/spec/support/v5.0/db/migrate/20190620000008_add_robe_to_wizard.rb +1 -1
  29. data/spec/support/v5.0/db/migrate/20190620000009_add_school.rb +10 -0
  30. data/spec/support/v5.0/db/schema.rb +9 -4
  31. data/spec/support/v5.0/sorbet_test_cases.rb +5 -0
  32. data/spec/support/v5.1/Gemfile +1 -1
  33. data/spec/support/v5.1/Gemfile.lock +18 -14
  34. data/spec/support/v5.1/app/models/school.rb +3 -0
  35. data/spec/support/v5.1/app/models/spell_book.rb +3 -1
  36. data/spec/support/v5.1/app/models/wizard.rb +3 -0
  37. data/spec/support/v5.1/config/environments/test.rb +1 -1
  38. data/spec/support/v5.1/config/initializers/sorbet_rails.rb +1 -1
  39. data/spec/support/v5.1/db/migrate/20190620000003_create_spell_books.rb +1 -1
  40. data/spec/support/v5.1/db/migrate/20190620000008_add_robe_to_wizard.rb +1 -1
  41. data/spec/support/v5.1/db/migrate/20190620000009_add_school.rb +10 -0
  42. data/spec/support/v5.1/db/schema.rb +9 -4
  43. data/spec/support/v5.1/sorbet_test_cases.rb +5 -0
  44. data/spec/support/v5.2/Gemfile +1 -1
  45. data/spec/support/v5.2/Gemfile.lock +54 -50
  46. data/spec/support/v5.2/app/models/school.rb +3 -0
  47. data/spec/support/v5.2/app/models/spell_book.rb +3 -1
  48. data/spec/support/v5.2/app/models/wizard.rb +3 -0
  49. data/spec/support/v5.2/config/environments/development.rb +1 -1
  50. data/spec/support/v5.2/config/initializers/sorbet_rails.rb +1 -1
  51. data/spec/support/v5.2/db/migrate/20190620000003_create_spell_books.rb +1 -1
  52. data/spec/support/v5.2/db/migrate/20190620000008_add_robe_to_wizard.rb +1 -1
  53. data/spec/support/v5.2/db/migrate/20190620000009_add_school.rb +10 -0
  54. data/spec/support/v5.2/db/schema.rb +9 -4
  55. data/spec/support/v5.2/sorbet_test_cases.rb +5 -0
  56. data/spec/support/v6.0/Gemfile +1 -1
  57. data/spec/support/v6.0/Gemfile.lock +70 -66
  58. data/spec/support/v6.0/app/models/school.rb +3 -0
  59. data/spec/support/v6.0/app/models/spell_book.rb +3 -1
  60. data/spec/support/v6.0/app/models/wizard.rb +3 -0
  61. data/spec/support/v6.0/config/environments/development.rb +1 -1
  62. data/spec/support/v6.0/config/initializers/sorbet_rails.rb +1 -1
  63. data/spec/support/v6.0/db/migrate/20190620000003_create_spell_books.rb +1 -1
  64. data/spec/support/v6.0/db/migrate/20190620000008_add_robe_to_wizard.rb +1 -1
  65. data/spec/support/v6.0/db/migrate/20190620000009_add_school.rb +10 -0
  66. data/spec/support/v6.0/db/schema.rb +10 -4
  67. data/spec/support/v6.0/sorbet_test_cases.rb +5 -0
  68. data/spec/test_data/v5.0/expected_internal_metadata.rbi +0 -77
  69. data/spec/test_data/v5.0/expected_potion.rbi +0 -77
  70. data/spec/test_data/v5.0/expected_robe.rbi +23 -77
  71. data/spec/test_data/v5.0/expected_routes.rbi +4 -0
  72. data/spec/test_data/v5.0/expected_schema_migration.rbi +0 -77
  73. data/spec/test_data/v5.0/expected_school.rbi +651 -0
  74. data/spec/test_data/v5.0/expected_spell_book.rbi +3 -80
  75. data/spec/test_data/v5.0/expected_squib.rbi +17 -79
  76. data/spec/test_data/v5.0/expected_wand.rbi +4 -81
  77. data/spec/test_data/v5.0/expected_wizard.rbi +17 -79
  78. data/spec/test_data/v5.0/expected_wizard_wo_spellbook.rbi +17 -79
  79. data/spec/test_data/v5.1/expected_internal_metadata.rbi +0 -77
  80. data/spec/test_data/v5.1/expected_potion.rbi +0 -77
  81. data/spec/test_data/v5.1/expected_robe.rbi +23 -77
  82. data/spec/test_data/v5.1/expected_routes.rbi +4 -0
  83. data/spec/test_data/v5.1/expected_schema_migration.rbi +0 -77
  84. data/spec/test_data/v5.1/expected_school.rbi +663 -0
  85. data/spec/test_data/v5.1/expected_spell_book.rbi +3 -80
  86. data/spec/test_data/v5.1/expected_squib.rbi +17 -79
  87. data/spec/test_data/v5.1/expected_wand.rbi +4 -81
  88. data/spec/test_data/v5.1/expected_wizard.rbi +17 -79
  89. data/spec/test_data/v5.1/expected_wizard_wo_spellbook.rbi +17 -79
  90. data/spec/test_data/v5.2/expected_attachment.rbi +0 -77
  91. data/spec/test_data/v5.2/expected_blob.rbi +0 -77
  92. data/spec/test_data/v5.2/expected_internal_metadata.rbi +0 -77
  93. data/spec/test_data/v5.2/expected_potion.rbi +0 -77
  94. data/spec/test_data/v5.2/expected_robe.rbi +23 -77
  95. data/spec/test_data/v5.2/expected_routes.rbi +4 -0
  96. data/spec/test_data/v5.2/expected_schema_migration.rbi +0 -77
  97. data/spec/test_data/v5.2/expected_school.rbi +663 -0
  98. data/spec/test_data/v5.2/expected_spell_book.rbi +3 -80
  99. data/spec/test_data/v5.2/expected_squib.rbi +17 -79
  100. data/spec/test_data/v5.2/expected_wand.rbi +4 -81
  101. data/spec/test_data/v5.2/expected_wizard.rbi +17 -79
  102. data/spec/test_data/v5.2/expected_wizard_wo_spellbook.rbi +17 -79
  103. data/spec/test_data/v6.0/expected_attachment.rbi +0 -77
  104. data/spec/test_data/v6.0/expected_blob.rbi +0 -77
  105. data/spec/test_data/v6.0/expected_internal_metadata.rbi +0 -77
  106. data/spec/test_data/v6.0/expected_potion.rbi +0 -77
  107. data/spec/test_data/v6.0/expected_robe.rbi +23 -77
  108. data/spec/test_data/v6.0/expected_routes.rbi +4 -0
  109. data/spec/test_data/v6.0/expected_schema_migration.rbi +0 -77
  110. data/spec/test_data/v6.0/expected_school.rbi +711 -0
  111. data/spec/test_data/v6.0/expected_spell_book.rbi +3 -80
  112. data/spec/test_data/v6.0/expected_squib.rbi +17 -79
  113. data/spec/test_data/v6.0/expected_wand.rbi +4 -81
  114. data/spec/test_data/v6.0/expected_wizard.rbi +17 -79
  115. data/spec/test_data/v6.0/expected_wizard_wo_spellbook.rbi +17 -79
  116. metadata +31 -4
@@ -1,67 +1,70 @@
1
1
  PATH
2
2
  remote: ../../..
3
3
  specs:
4
- sorbet-rails (0.5.8.1)
5
- parlour (~> 0.8.0)
4
+ sorbet-rails (0.5.9)
5
+ parlour (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.2.3)
11
- actionpack (= 5.2.3)
10
+ actioncable (5.2.4)
11
+ actionpack (= 5.2.4)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailer (5.2.3)
15
- actionpack (= 5.2.3)
16
- actionview (= 5.2.3)
17
- activejob (= 5.2.3)
14
+ actionmailer (5.2.4)
15
+ actionpack (= 5.2.4)
16
+ actionview (= 5.2.4)
17
+ activejob (= 5.2.4)
18
18
  mail (~> 2.5, >= 2.5.4)
19
19
  rails-dom-testing (~> 2.0)
20
- actionpack (5.2.3)
21
- actionview (= 5.2.3)
22
- activesupport (= 5.2.3)
20
+ actionpack (5.2.4)
21
+ actionview (= 5.2.4)
22
+ activesupport (= 5.2.4)
23
23
  rack (~> 2.0)
24
24
  rack-test (>= 0.6.3)
25
25
  rails-dom-testing (~> 2.0)
26
26
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.2.3)
28
- activesupport (= 5.2.3)
27
+ actionview (5.2.4)
28
+ activesupport (= 5.2.4)
29
29
  builder (~> 3.1)
30
30
  erubi (~> 1.4)
31
31
  rails-dom-testing (~> 2.0)
32
32
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.2.3)
34
- activesupport (= 5.2.3)
33
+ activejob (5.2.4)
34
+ activesupport (= 5.2.4)
35
35
  globalid (>= 0.3.6)
36
- activemodel (5.2.3)
37
- activesupport (= 5.2.3)
38
- activerecord (5.2.3)
39
- activemodel (= 5.2.3)
40
- activesupport (= 5.2.3)
36
+ activemodel (5.2.4)
37
+ activesupport (= 5.2.4)
38
+ activerecord (5.2.4)
39
+ activemodel (= 5.2.4)
40
+ activesupport (= 5.2.4)
41
41
  arel (>= 9.0)
42
- activestorage (5.2.3)
43
- actionpack (= 5.2.3)
44
- activerecord (= 5.2.3)
42
+ activestorage (5.2.4)
43
+ actionpack (= 5.2.4)
44
+ activerecord (= 5.2.4)
45
45
  marcel (~> 0.3.1)
46
- activesupport (5.2.3)
46
+ activesupport (5.2.4)
47
47
  concurrent-ruby (~> 1.0, >= 1.0.2)
48
48
  i18n (>= 0.7, < 2)
49
49
  minitest (~> 5.1)
50
50
  tzinfo (~> 1.1)
51
51
  arel (9.0.0)
52
52
  bindex (0.8.1)
53
- builder (3.2.3)
53
+ builder (3.2.4)
54
54
  byebug (11.0.1)
55
+ commander (4.4.7)
56
+ highline (~> 2.0.0)
55
57
  concurrent-ruby (1.1.5)
56
58
  crass (1.0.5)
57
59
  erubi (1.9.0)
58
60
  globalid (0.4.2)
59
61
  activesupport (>= 4.2.0)
62
+ highline (2.0.3)
60
63
  i18n (1.7.0)
61
64
  concurrent-ruby (~> 1.0)
62
65
  jbuilder (2.9.1)
63
66
  activesupport (>= 4.2.0)
64
- loofah (2.3.0)
67
+ loofah (2.4.0)
65
68
  crass (~> 1.0.2)
66
69
  nokogiri (>= 1.5.9)
67
70
  mail (2.7.1)
@@ -72,47 +75,48 @@ GEM
72
75
  mimemagic (0.3.3)
73
76
  mini_mime (1.0.2)
74
77
  mini_portile2 (2.4.0)
75
- minitest (5.12.2)
78
+ minitest (5.13.0)
76
79
  nio4r (2.5.2)
77
- nokogiri (1.10.4)
80
+ nokogiri (1.10.7)
78
81
  mini_portile2 (~> 2.4.0)
79
- parlour (0.8.1)
82
+ parlour (1.0.0)
83
+ commander (~> 4.4.0)
80
84
  rainbow (~> 3.0.0)
81
85
  sorbet-runtime
82
- puma (3.12.1)
86
+ puma (3.12.2)
83
87
  rack (2.0.7)
84
88
  rack-test (1.1.0)
85
89
  rack (>= 1.0, < 3)
86
- rails (5.2.3)
87
- actioncable (= 5.2.3)
88
- actionmailer (= 5.2.3)
89
- actionpack (= 5.2.3)
90
- actionview (= 5.2.3)
91
- activejob (= 5.2.3)
92
- activemodel (= 5.2.3)
93
- activerecord (= 5.2.3)
94
- activestorage (= 5.2.3)
95
- activesupport (= 5.2.3)
90
+ rails (5.2.4)
91
+ actioncable (= 5.2.4)
92
+ actionmailer (= 5.2.4)
93
+ actionpack (= 5.2.4)
94
+ actionview (= 5.2.4)
95
+ activejob (= 5.2.4)
96
+ activemodel (= 5.2.4)
97
+ activerecord (= 5.2.4)
98
+ activestorage (= 5.2.4)
99
+ activesupport (= 5.2.4)
96
100
  bundler (>= 1.3.0)
97
- railties (= 5.2.3)
101
+ railties (= 5.2.4)
98
102
  sprockets-rails (>= 2.0.0)
99
103
  rails-dom-testing (2.0.3)
100
104
  activesupport (>= 4.2.0)
101
105
  nokogiri (>= 1.6)
102
106
  rails-html-sanitizer (1.3.0)
103
107
  loofah (~> 2.3)
104
- railties (5.2.3)
105
- actionpack (= 5.2.3)
106
- activesupport (= 5.2.3)
108
+ railties (5.2.4)
109
+ actionpack (= 5.2.4)
110
+ activesupport (= 5.2.4)
107
111
  method_source
108
112
  rake (>= 0.8.7)
109
113
  thor (>= 0.19.0, < 2.0)
110
114
  rainbow (3.0.0)
111
- rake (13.0.0)
112
- sorbet (0.4.4878)
113
- sorbet-static (= 0.4.4878)
114
- sorbet-runtime (0.4.4878)
115
- sorbet-static (0.4.4878-universal-darwin-14)
115
+ rake (13.0.1)
116
+ sorbet (0.4.5135)
117
+ sorbet-static (= 0.4.5135)
118
+ sorbet-runtime (0.4.5135)
119
+ sorbet-static (0.4.5135-universal-darwin-14)
116
120
  sprockets (4.0.0)
117
121
  concurrent-ruby (~> 1.0)
118
122
  rack (> 1, < 3)
@@ -140,7 +144,7 @@ PLATFORMS
140
144
  DEPENDENCIES
141
145
  byebug
142
146
  jbuilder (~> 2.5)
143
- puma (~> 3.11)
147
+ puma (~> 3.12)
144
148
  rails (~> 5.2.3)
145
149
  sorbet
146
150
  sorbet-rails!
@@ -0,0 +1,3 @@
1
+ # typed: strong
2
+ class School < ApplicationRecord
3
+ end
@@ -1,7 +1,9 @@
1
1
  # typed: strict
2
2
  class SpellBook < ApplicationRecord
3
3
  validates :name, length: { minimum: 5 }, presence: true
4
- belongs_to :wizard
4
+
5
+ # simulate when belongs_to is optional by default, but it is enforced at the DB level
6
+ belongs_to :wizard, optional: true
5
7
 
6
8
  enum book_type: {
7
9
  unclassified: 0,
@@ -44,6 +44,9 @@ class Wizard < ApplicationRecord
44
44
  has_one :wand
45
45
  has_many :spell_books
46
46
 
47
+ # simulate when belongs_to is optional by default
48
+ belongs_to :school, optional: true
49
+
47
50
  scope :recent, -> { where('created_at > ?', 1.month.ago) }
48
51
  has_one_attached :school_photo
49
52
  has_many_attached :hats
@@ -1,4 +1,4 @@
1
- # typed: false
1
+ # typed: strict
2
2
  Rails.application.configure do
3
3
  # Settings specified here will take precedence over those in config/application.rb.
4
4
 
@@ -1,3 +1,3 @@
1
- # typed: false
1
+ # typed: strict
2
2
  require(Rails.root.join('lib/mythical_rbi_plugin'))
3
3
  SorbetRails::ModelRbiFormatter.register_plugin(MythicalRbiPlugin)
@@ -3,7 +3,7 @@ class CreateSpellBooks < ActiveRecord::Migration[5.2]
3
3
  def change
4
4
  create_table :spell_books do |t|
5
5
  t.string :name
6
- t.references :wizard
6
+ t.references :wizard, null: false
7
7
  t.integer :book_type, null: false, default: 0
8
8
  end
9
9
  end
@@ -1,7 +1,7 @@
1
1
  # typed: true
2
2
  class AddRobeToWizard < ActiveRecord::Migration[5.2]
3
3
  def change
4
- create_table :robe do |t|
4
+ create_table :robes do |t|
5
5
  t.references :wizard
6
6
  end
7
7
  end
@@ -0,0 +1,10 @@
1
+ # typed: true
2
+ class AddSchool < ActiveRecord::Migration[5.2]
3
+ def change
4
+ create_table :schools do |t|
5
+ t.string :name
6
+ end
7
+ add_column :wizards, :school_id, :integer
8
+ add_foreign_key :wizards, :schools
9
+ end
10
+ end
@@ -11,16 +11,20 @@
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: 2019_06_20_000008) do
14
+ ActiveRecord::Schema.define(version: 2019_06_20_000009) do
15
15
 
16
- create_table "robe", force: :cascade do |t|
16
+ create_table "robes", force: :cascade do |t|
17
17
  t.integer "wizard_id"
18
- t.index ["wizard_id"], name: "index_robe_on_wizard_id"
18
+ t.index ["wizard_id"], name: "index_robes_on_wizard_id"
19
+ end
20
+
21
+ create_table "schools", force: :cascade do |t|
22
+ t.string "name"
19
23
  end
20
24
 
21
25
  create_table "spell_books", force: :cascade do |t|
22
26
  t.string "name"
23
- t.integer "wizard_id"
27
+ t.integer "wizard_id", null: false
24
28
  t.integer "book_type", default: 0, null: false
25
29
  t.index ["wizard_id"], name: "index_spell_books_on_wizard_id"
26
30
  end
@@ -56,6 +60,7 @@ ActiveRecord::Schema.define(version: 2019_06_20_000008) do
56
60
  t.integer "eye_color"
57
61
  t.integer "hair_length"
58
62
  t.string "type", default: "Wizard", null: false
63
+ t.integer "school_id"
59
64
  end
60
65
 
61
66
  end
@@ -180,6 +180,11 @@ T.assert_type!(wizard.color_brown_eyes?, T::Boolean)
180
180
  T.assert_type!(wizard.quidditch_keeper?, T::Boolean)
181
181
  T.assert_type!(wizard.brown_hair?, T::Boolean)
182
182
 
183
+ # Relations
184
+ T.assert_type!(wizard.spell_books.any?, T::Boolean)
185
+ T.assert_type!(wizard.spell_books.none?, T::Boolean)
186
+ T.assert_type!(wizard.spell_books.one?, T::Boolean)
187
+
183
188
  # -- Custom ActionController::Parameters Methods
184
189
  params = ActionController::Parameters.new({
185
190
  age: 11,
@@ -8,7 +8,7 @@ gem 'rails', '~> 6.0.0'
8
8
  # Use sqlite3 as the database for Active Record
9
9
  gem 'sqlite3', '~> 1.4'
10
10
  # Use Puma as the app server
11
- gem 'puma', '~> 3.11'
11
+ gem 'puma', '~> 3.12'
12
12
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
13
13
  gem 'jbuilder', '~> 2.7'
14
14
  # Use Active Model has_secure_password
@@ -1,80 +1,83 @@
1
1
  PATH
2
2
  remote: ../../..
3
3
  specs:
4
- sorbet-rails (0.5.8.1)
5
- parlour (~> 0.8.0)
4
+ sorbet-rails (0.5.9)
5
+ parlour (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (6.0.0)
11
- actionpack (= 6.0.0)
10
+ actioncable (6.0.1)
11
+ actionpack (= 6.0.1)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailbox (6.0.0)
15
- actionpack (= 6.0.0)
16
- activejob (= 6.0.0)
17
- activerecord (= 6.0.0)
18
- activestorage (= 6.0.0)
19
- activesupport (= 6.0.0)
14
+ actionmailbox (6.0.1)
15
+ actionpack (= 6.0.1)
16
+ activejob (= 6.0.1)
17
+ activerecord (= 6.0.1)
18
+ activestorage (= 6.0.1)
19
+ activesupport (= 6.0.1)
20
20
  mail (>= 2.7.1)
21
- actionmailer (6.0.0)
22
- actionpack (= 6.0.0)
23
- actionview (= 6.0.0)
24
- activejob (= 6.0.0)
21
+ actionmailer (6.0.1)
22
+ actionpack (= 6.0.1)
23
+ actionview (= 6.0.1)
24
+ activejob (= 6.0.1)
25
25
  mail (~> 2.5, >= 2.5.4)
26
26
  rails-dom-testing (~> 2.0)
27
- actionpack (6.0.0)
28
- actionview (= 6.0.0)
29
- activesupport (= 6.0.0)
27
+ actionpack (6.0.1)
28
+ actionview (= 6.0.1)
29
+ activesupport (= 6.0.1)
30
30
  rack (~> 2.0)
31
31
  rack-test (>= 0.6.3)
32
32
  rails-dom-testing (~> 2.0)
33
33
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
- actiontext (6.0.0)
35
- actionpack (= 6.0.0)
36
- activerecord (= 6.0.0)
37
- activestorage (= 6.0.0)
38
- activesupport (= 6.0.0)
34
+ actiontext (6.0.1)
35
+ actionpack (= 6.0.1)
36
+ activerecord (= 6.0.1)
37
+ activestorage (= 6.0.1)
38
+ activesupport (= 6.0.1)
39
39
  nokogiri (>= 1.8.5)
40
- actionview (6.0.0)
41
- activesupport (= 6.0.0)
40
+ actionview (6.0.1)
41
+ activesupport (= 6.0.1)
42
42
  builder (~> 3.1)
43
43
  erubi (~> 1.4)
44
44
  rails-dom-testing (~> 2.0)
45
45
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
- activejob (6.0.0)
47
- activesupport (= 6.0.0)
46
+ activejob (6.0.1)
47
+ activesupport (= 6.0.1)
48
48
  globalid (>= 0.3.6)
49
- activemodel (6.0.0)
50
- activesupport (= 6.0.0)
51
- activerecord (6.0.0)
52
- activemodel (= 6.0.0)
53
- activesupport (= 6.0.0)
54
- activestorage (6.0.0)
55
- actionpack (= 6.0.0)
56
- activejob (= 6.0.0)
57
- activerecord (= 6.0.0)
49
+ activemodel (6.0.1)
50
+ activesupport (= 6.0.1)
51
+ activerecord (6.0.1)
52
+ activemodel (= 6.0.1)
53
+ activesupport (= 6.0.1)
54
+ activestorage (6.0.1)
55
+ actionpack (= 6.0.1)
56
+ activejob (= 6.0.1)
57
+ activerecord (= 6.0.1)
58
58
  marcel (~> 0.3.1)
59
- activesupport (6.0.0)
59
+ activesupport (6.0.1)
60
60
  concurrent-ruby (~> 1.0, >= 1.0.2)
61
61
  i18n (>= 0.7, < 2)
62
62
  minitest (~> 5.1)
63
63
  tzinfo (~> 1.1)
64
- zeitwerk (~> 2.1, >= 2.1.8)
64
+ zeitwerk (~> 2.2)
65
65
  bindex (0.8.1)
66
- builder (3.2.3)
66
+ builder (3.2.4)
67
67
  byebug (11.0.1)
68
+ commander (4.4.7)
69
+ highline (~> 2.0.0)
68
70
  concurrent-ruby (1.1.5)
69
71
  crass (1.0.5)
70
72
  erubi (1.9.0)
71
73
  globalid (0.4.2)
72
74
  activesupport (>= 4.2.0)
75
+ highline (2.0.3)
73
76
  i18n (1.7.0)
74
77
  concurrent-ruby (~> 1.0)
75
78
  jbuilder (2.9.1)
76
79
  activesupport (>= 4.2.0)
77
- loofah (2.3.0)
80
+ loofah (2.4.0)
78
81
  crass (~> 1.0.2)
79
82
  nokogiri (>= 1.5.9)
80
83
  mail (2.7.1)
@@ -85,49 +88,50 @@ GEM
85
88
  mimemagic (0.3.3)
86
89
  mini_mime (1.0.2)
87
90
  mini_portile2 (2.4.0)
88
- minitest (5.12.2)
91
+ minitest (5.13.0)
89
92
  nio4r (2.5.2)
90
- nokogiri (1.10.4)
93
+ nokogiri (1.10.7)
91
94
  mini_portile2 (~> 2.4.0)
92
- parlour (0.8.1)
95
+ parlour (1.0.0)
96
+ commander (~> 4.4.0)
93
97
  rainbow (~> 3.0.0)
94
98
  sorbet-runtime
95
- puma (3.12.1)
99
+ puma (3.12.2)
96
100
  rack (2.0.7)
97
101
  rack-test (1.1.0)
98
102
  rack (>= 1.0, < 3)
99
- rails (6.0.0)
100
- actioncable (= 6.0.0)
101
- actionmailbox (= 6.0.0)
102
- actionmailer (= 6.0.0)
103
- actionpack (= 6.0.0)
104
- actiontext (= 6.0.0)
105
- actionview (= 6.0.0)
106
- activejob (= 6.0.0)
107
- activemodel (= 6.0.0)
108
- activerecord (= 6.0.0)
109
- activestorage (= 6.0.0)
110
- activesupport (= 6.0.0)
103
+ rails (6.0.1)
104
+ actioncable (= 6.0.1)
105
+ actionmailbox (= 6.0.1)
106
+ actionmailer (= 6.0.1)
107
+ actionpack (= 6.0.1)
108
+ actiontext (= 6.0.1)
109
+ actionview (= 6.0.1)
110
+ activejob (= 6.0.1)
111
+ activemodel (= 6.0.1)
112
+ activerecord (= 6.0.1)
113
+ activestorage (= 6.0.1)
114
+ activesupport (= 6.0.1)
111
115
  bundler (>= 1.3.0)
112
- railties (= 6.0.0)
116
+ railties (= 6.0.1)
113
117
  sprockets-rails (>= 2.0.0)
114
118
  rails-dom-testing (2.0.3)
115
119
  activesupport (>= 4.2.0)
116
120
  nokogiri (>= 1.6)
117
121
  rails-html-sanitizer (1.3.0)
118
122
  loofah (~> 2.3)
119
- railties (6.0.0)
120
- actionpack (= 6.0.0)
121
- activesupport (= 6.0.0)
123
+ railties (6.0.1)
124
+ actionpack (= 6.0.1)
125
+ activesupport (= 6.0.1)
122
126
  method_source
123
127
  rake (>= 0.8.7)
124
128
  thor (>= 0.20.3, < 2.0)
125
129
  rainbow (3.0.0)
126
- rake (13.0.0)
127
- sorbet (0.4.4878)
128
- sorbet-static (= 0.4.4878)
129
- sorbet-runtime (0.4.4878)
130
- sorbet-static (0.4.4878-universal-darwin-14)
130
+ rake (13.0.1)
131
+ sorbet (0.4.5135)
132
+ sorbet-static (= 0.4.5135)
133
+ sorbet-runtime (0.4.5135)
134
+ sorbet-static (0.4.5135-universal-darwin-14)
131
135
  sprockets (4.0.0)
132
136
  concurrent-ruby (~> 1.0)
133
137
  rack (> 1, < 3)
@@ -148,7 +152,7 @@ GEM
148
152
  websocket-driver (0.7.1)
149
153
  websocket-extensions (>= 0.1.0)
150
154
  websocket-extensions (0.1.4)
151
- zeitwerk (2.2.0)
155
+ zeitwerk (2.2.2)
152
156
 
153
157
  PLATFORMS
154
158
  ruby
@@ -156,7 +160,7 @@ PLATFORMS
156
160
  DEPENDENCIES
157
161
  byebug
158
162
  jbuilder (~> 2.7)
159
- puma (~> 3.11)
163
+ puma (~> 3.12)
160
164
  rails (~> 6.0.0)
161
165
  sorbet
162
166
  sorbet-rails!
@@ -0,0 +1,3 @@
1
+ # typed: strong
2
+ class School < ApplicationRecord
3
+ end
@@ -1,7 +1,9 @@
1
1
  # typed: strict
2
2
  class SpellBook < ApplicationRecord
3
3
  validates :name, length: { minimum: 5 }, presence: true
4
- belongs_to :wizard
4
+
5
+ # simulate when belongs_to is optional by default, but it is enforced at the DB level
6
+ belongs_to :wizard, optional: true
5
7
 
6
8
  enum book_type: {
7
9
  unclassified: 0,
@@ -44,6 +44,9 @@ class Wizard < ApplicationRecord
44
44
  has_one :wand
45
45
  has_many :spell_books
46
46
 
47
+ # simulate when belongs_to is optional by default
48
+ belongs_to :school, optional: true
49
+
47
50
  scope :recent, -> { where('created_at > ?', 1.month.ago) }
48
51
  has_one_attached :school_photo
49
52
  has_many_attached :hats
@@ -1,4 +1,4 @@
1
- # typed: false
1
+ # typed: strict
2
2
  Rails.application.configure do
3
3
  # Settings specified here will take precedence over those in config/application.rb.
4
4
 
@@ -1,3 +1,3 @@
1
- # typed: false
1
+ # typed: strict
2
2
  require(Rails.root.join('lib/mythical_rbi_plugin'))
3
3
  SorbetRails::ModelRbiFormatter.register_plugin(MythicalRbiPlugin)
@@ -3,7 +3,7 @@ class CreateSpellBooks < ActiveRecord::Migration[6.0]
3
3
  def change
4
4
  create_table :spell_books do |t|
5
5
  t.string :name
6
- t.references :wizard
6
+ t.references :wizard, null: false
7
7
  t.integer :book_type, null: false, default: 0
8
8
  end
9
9
  end
@@ -1,7 +1,7 @@
1
1
  # typed: true
2
2
  class AddRobeToWizard < ActiveRecord::Migration[6.0]
3
3
  def change
4
- create_table :robe do |t|
4
+ create_table :robes do |t|
5
5
  t.references :wizard
6
6
  end
7
7
  end
@@ -0,0 +1,10 @@
1
+ # typed: true
2
+ class AddSchool < ActiveRecord::Migration[6.0]
3
+ def change
4
+ create_table :schools do |t|
5
+ t.string :name
6
+ end
7
+ add_column :wizards, :school_id, :integer
8
+ add_foreign_key :wizards, :schools
9
+ end
10
+ end
@@ -11,16 +11,20 @@
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: 2019_06_20_000008) do
14
+ ActiveRecord::Schema.define(version: 2019_06_20_000009) do
15
15
 
16
- create_table "robe", force: :cascade do |t|
16
+ create_table "robes", force: :cascade do |t|
17
17
  t.integer "wizard_id"
18
- t.index ["wizard_id"], name: "index_robe_on_wizard_id"
18
+ t.index ["wizard_id"], name: "index_robes_on_wizard_id"
19
+ end
20
+
21
+ create_table "schools", force: :cascade do |t|
22
+ t.string "name"
19
23
  end
20
24
 
21
25
  create_table "spell_books", force: :cascade do |t|
22
26
  t.string "name"
23
- t.integer "wizard_id"
27
+ t.integer "wizard_id", null: false
24
28
  t.integer "book_type", default: 0, null: false
25
29
  t.index ["wizard_id"], name: "index_spell_books_on_wizard_id"
26
30
  end
@@ -56,6 +60,8 @@ ActiveRecord::Schema.define(version: 2019_06_20_000008) do
56
60
  t.integer "eye_color"
57
61
  t.integer "hair_length"
58
62
  t.string "type", default: "Wizard", null: false
63
+ t.integer "school_id"
59
64
  end
60
65
 
66
+ add_foreign_key "wizards", "schools"
61
67
  end
@@ -180,6 +180,11 @@ T.assert_type!(wizard.color_brown_eyes?, T::Boolean)
180
180
  T.assert_type!(wizard.quidditch_keeper?, T::Boolean)
181
181
  T.assert_type!(wizard.brown_hair?, T::Boolean)
182
182
 
183
+ # Relations
184
+ T.assert_type!(wizard.spell_books.any?, T::Boolean)
185
+ T.assert_type!(wizard.spell_books.none?, T::Boolean)
186
+ T.assert_type!(wizard.spell_books.one?, T::Boolean)
187
+
183
188
  # -- Custom ActionController::Parameters Methods
184
189
  params = ActionController::Parameters.new({
185
190
  age: 11,