sorbet-rails 0.7.33 → 0.7.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci-master.yml +1 -1
- data/.github/workflows/ci.yml +1 -1
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +4 -0
- data/README.md +1 -1
- data/Rakefile +27 -1
- data/lib/sorbet-rails/active_record_rbi_formatter.rb +1 -1
- data/lib/sorbet-rails/model_plugins/active_record_querying.rb +14 -0
- data/lib/sorbet-rails/rails_mixins/active_record_overrides.rb +1 -1
- data/lib/sorbet-rails/tasks/rails_rbi.rake +15 -0
- data/sorbet-rails.gemspec +1 -1
- data/spec/bin/run_all_specs.sh +1 -0
- data/spec/generators/rails-template.rb +2 -7
- data/spec/rails_helper.rb +2 -0
- data/spec/rake_rails_rbi_models_spec.rb +1 -1
- data/spec/support/v5.2/sorbet_test_cases.rb +8 -0
- data/spec/support/v6.0/sorbet_test_cases.rb +8 -0
- data/spec/support/v6.1/sorbet_test_cases.rb +8 -0
- data/spec/support/v7.0/.gitattributes +7 -0
- data/spec/support/v7.0/.gitignore +35 -0
- data/spec/support/v7.0/Gemfile +48 -0
- data/spec/support/v7.0/Gemfile.lock +218 -0
- data/spec/support/v7.0/README.md +24 -0
- data/spec/support/v7.0/Rakefile +6 -0
- data/spec/support/v7.0/app/assets/images/.keep +0 -0
- data/spec/support/v7.0/app/assets/stylesheets/application.css +1 -0
- data/spec/support/v7.0/app/controllers/application_controller.rb +3 -0
- data/spec/support/v7.0/app/controllers/concerns/.keep +0 -0
- data/spec/support/v7.0/app/helpers/application_helper.rb +3 -0
- data/spec/support/v7.0/app/helpers/bar_helper.rb +3 -0
- data/spec/support/v7.0/app/helpers/baz_helper.rb +3 -0
- data/spec/support/v7.0/app/helpers/foo_helper.rb +3 -0
- data/spec/support/v7.0/app/jobs/application_job.rb +8 -0
- data/spec/support/v7.0/app/jobs/award_house_point_hourglasses.rb +12 -0
- data/spec/support/v7.0/app/mailers/application_mailer.rb +5 -0
- data/spec/support/v7.0/app/mailers/daily_prophet_mailer.rb +9 -0
- data/spec/support/v7.0/app/mailers/hogwarts_acceptance_mailer.rb +29 -0
- data/spec/support/v7.0/app/models/application_record.rb +4 -0
- data/spec/support/v7.0/app/models/concerns/.keep +0 -0
- data/spec/support/v7.0/app/models/concerns/mythical.rb +11 -0
- data/spec/support/v7.0/app/models/headmaster.rb +8 -0
- data/spec/support/v7.0/app/models/potion.rb +6 -0
- data/spec/support/v7.0/app/models/robe.rb +4 -0
- data/spec/support/v7.0/app/models/school.rb +5 -0
- data/spec/support/v7.0/app/models/spell.rb +5 -0
- data/spec/support/v7.0/app/models/spell_book.rb +18 -0
- data/spec/support/v7.0/app/models/squib.rb +6 -0
- data/spec/support/v7.0/app/models/subject.rb +5 -0
- data/spec/support/v7.0/app/models/wand.rb +19 -0
- data/spec/support/v7.0/app/models/wizard.rb +65 -0
- data/spec/support/v7.0/app/views/layouts/application.html.erb +15 -0
- data/spec/support/v7.0/app/views/layouts/mailer.html.erb +13 -0
- data/spec/support/v7.0/app/views/layouts/mailer.text.erb +1 -0
- data/spec/support/v7.0/bin/bundle +114 -0
- data/spec/support/v7.0/bin/rails +4 -0
- data/spec/support/v7.0/bin/rake +4 -0
- data/spec/support/v7.0/bin/setup +33 -0
- data/spec/support/v7.0/config/application.rb +38 -0
- data/spec/support/v7.0/config/boot.rb +4 -0
- data/spec/support/v7.0/config/database.yml +25 -0
- data/spec/support/v7.0/config/environment.rb +6 -0
- data/spec/support/v7.0/config/environments/development.rb +69 -0
- data/spec/support/v7.0/config/environments/production.rb +83 -0
- data/spec/support/v7.0/config/environments/test.rb +61 -0
- data/spec/support/v7.0/config/initializers/content_security_policy.rb +26 -0
- data/spec/support/v7.0/config/initializers/filter_parameter_logging.rb +9 -0
- data/spec/support/v7.0/config/initializers/inflections.rb +17 -0
- data/spec/support/v7.0/config/initializers/permissions_policy.rb +12 -0
- data/spec/support/v7.0/config/initializers/sorbet_rails.rb +3 -0
- data/spec/support/v7.0/config/locales/en.yml +33 -0
- data/spec/support/v7.0/config/puma.rb +44 -0
- data/spec/support/v7.0/config/routes.rb +8 -0
- data/spec/support/v7.0/config/storage.yml +34 -0
- data/spec/support/v7.0/config.ru +6 -0
- data/spec/support/v7.0/db/migrate/20190620000001_create_wizards.rb +14 -0
- data/spec/support/v7.0/db/migrate/20190620000002_create_wands.rb +12 -0
- data/spec/support/v7.0/db/migrate/20190620000003_create_spell_books.rb +10 -0
- data/spec/support/v7.0/db/migrate/20190620000004_add_more_column_types_to_wands.rb +14 -0
- data/spec/support/v7.0/db/migrate/20190620000005_add_broom_to_wizard.rb +6 -0
- data/spec/support/v7.0/db/migrate/20190620000006_add_more_enums_to_wizard.rb +9 -0
- data/spec/support/v7.0/db/migrate/20190620000007_add_type_to_wizard.rb +6 -0
- data/spec/support/v7.0/db/migrate/20190620000008_add_robe_to_wizard.rb +8 -0
- data/spec/support/v7.0/db/migrate/20190620000009_add_school.rb +10 -0
- data/spec/support/v7.0/db/migrate/20190620000010_add_subject.rb +8 -0
- data/spec/support/v7.0/db/migrate/20190620000011_add_subjects_wizards.rb +8 -0
- data/spec/support/v7.0/db/migrate/20190620000012_add_spell.rb +8 -0
- data/spec/support/v7.0/db/migrate/20190620000013_add_spells_spell_books.rb +8 -0
- data/spec/support/v7.0/db/migrate/20190620000014_create_headmasters.rb +9 -0
- data/spec/support/v7.0/db/migrate/20190620000015_add_serialized_to_wizards.rb +9 -0
- data/spec/support/v7.0/db/schema.rb +98 -0
- data/spec/support/v7.0/db/seeds.rb +8 -0
- data/spec/support/v7.0/lib/assets/.keep +0 -0
- data/spec/support/v7.0/lib/mythical_rbi_plugin.rb +16 -0
- data/spec/support/v7.0/lib/tasks/.keep +0 -0
- data/spec/support/v7.0/log/.keep +0 -0
- data/spec/support/v7.0/sorbet_test_cases.rb +439 -0
- data/spec/support/v7.0/storage/.keep +0 -0
- data/spec/support/v7.0/tmp/.keep +0 -0
- data/spec/support/v7.0/tmp/pids/.keep +0 -0
- data/spec/support/v7.0/tmp/storage/.keep +0 -0
- data/spec/support/v7.0/vendor/.keep +0 -0
- data/spec/test_data/v5.2/expected_active_record_base.rbi +6 -0
- data/spec/test_data/v5.2/expected_active_record_relation.rbi +6 -0
- data/spec/test_data/v6.0/expected_active_record_base.rbi +6 -0
- data/spec/test_data/v6.0/expected_active_record_relation.rbi +6 -0
- data/spec/test_data/v6.1/expected_active_record_base.rbi +6 -0
- data/spec/test_data/v6.1/expected_active_record_relation.rbi +6 -0
- data/spec/test_data/v7.0/expected_active_record_base.rbi +119 -0
- data/spec/test_data/v7.0/expected_active_record_relation.rbi +180 -0
- data/spec/test_data/v7.0/expected_application_job.rbi +20 -0
- data/spec/test_data/v7.0/expected_application_mailer.rbi +5 -0
- data/spec/test_data/v7.0/expected_attachment.rbi +358 -0
- data/spec/test_data/v7.0/expected_award_house_point_hourglasses.rbi +20 -0
- data/spec/test_data/v7.0/expected_blob.rbi +394 -0
- data/spec/test_data/v7.0/expected_custom_application_job.rbi +21 -0
- data/spec/test_data/v7.0/expected_custom_application_mailer.rbi +6 -0
- data/spec/test_data/v7.0/expected_custom_award_house_point_hourglasses.rbi +21 -0
- data/spec/test_data/v7.0/expected_custom_daily_prophet_mailer.rbi +8 -0
- data/spec/test_data/v7.0/expected_custom_hogwarts_acceptance_mailer.rbi +21 -0
- data/spec/test_data/v7.0/expected_daily_prophet_mailer.rbi +7 -0
- data/spec/test_data/v7.0/expected_headmaster.rbi +376 -0
- data/spec/test_data/v7.0/expected_helpers.rbi +27 -0
- data/spec/test_data/v7.0/expected_helpers_with_application_and_devise_helpers.rbi +34 -0
- data/spec/test_data/v7.0/expected_hogwarts_acceptance_mailer.rbi +20 -0
- data/spec/test_data/v7.0/expected_internal_metadata.rbi +346 -0
- data/spec/test_data/v7.0/expected_no_routes.rbi +4 -0
- data/spec/test_data/v7.0/expected_potion.rbi +328 -0
- data/spec/test_data/v7.0/expected_record.rbi +307 -0
- data/spec/test_data/v7.0/expected_robe.rbi +349 -0
- data/spec/test_data/v7.0/expected_routes.rbi +182 -0
- data/spec/test_data/v7.0/expected_schema_migration.rbi +319 -0
- data/spec/test_data/v7.0/expected_school.rbi +349 -0
- data/spec/test_data/v7.0/expected_spell/habtm_spell_books.rbi +367 -0
- data/spec/test_data/v7.0/expected_spell.rbi +340 -0
- data/spec/test_data/v7.0/expected_spell_book/habtm_spells.rbi +367 -0
- data/spec/test_data/v7.0/expected_spell_book.rbi +499 -0
- data/spec/test_data/v7.0/expected_squib.rbi +1204 -0
- data/spec/test_data/v7.0/expected_srb_tc_output.txt +1 -0
- data/spec/test_data/v7.0/expected_subject/habtm_wizards.rbi +367 -0
- data/spec/test_data/v7.0/expected_subject.rbi +340 -0
- data/spec/test_data/v7.0/expected_variant_record.rbi +382 -0
- data/spec/test_data/v7.0/expected_wand.rbi +611 -0
- data/spec/test_data/v7.0/expected_wizard/habtm_subjects.rbi +367 -0
- data/spec/test_data/v7.0/expected_wizard.rbi +1280 -0
- data/spec/test_data/v7.0/expected_wizard_wo_spellbook.rbi +1274 -0
- metadata +243 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ae993b835bd73f18fd64cacdf0fb9f3ba8e44d8ad42cb59fa103d1f2d8a481
|
4
|
+
data.tar.gz: d47b11ca70a73985bd8e811f56fee3394960c063b8e1850470f5ff1c1202bc63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 372bb4773d316e81a5318e3749a215fec0c3c7c72dd1f363bb3c342775a93be4d82b634943d29e31552a912833ed1b3c4a4291f48acc982a9710cc28f59939b5
|
7
|
+
data.tar.gz: feaf6bcf6955f9eb9941f8f52e572c80a90a5bde285d9ccb3ec3741fad54ad51dec140dc591de041f676d26728a5c2da6b26470ed0da30b21d07b0dbe1fb2d03
|
data/.github/workflows/ci.yml
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -90,6 +90,7 @@ You can also switch to a version of Rails with `RAILS_VERSION`:
|
|
90
90
|
❯ RAILS_VERSION=5.2 ./spec/bin/run_spec.sh
|
91
91
|
❯ RAILS_VERSION=6.0 ./spec/bin/run_spec.sh
|
92
92
|
❯ RAILS_VERSION=6.1 ./spec/bin/run_spec.sh
|
93
|
+
❯ RAILS_VERSION=7.0 ./spec/bin/run_spec.sh
|
93
94
|
```
|
94
95
|
|
95
96
|
#### Debugging
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -70,7 +70,7 @@ The generation task currently creates the following signatures:
|
|
70
70
|
|
71
71
|
It is possible to add custom RBI generation logic for your custom module or gems via the plugin system. Check out the [plugins section](#extending-model-generation-task-with-custom-plugins) below if you are interested.
|
72
72
|
|
73
|
-
We also add following methods to make type-checking
|
73
|
+
We also add following methods to make type-checking easier:
|
74
74
|
- [`find_n`, `first_n`, `last_n`](https://github.com/chanzuckerberg/sorbet-rails#find-first-and-last)
|
75
75
|
- [`pluck_to_tstruct`](#pluck_to_tstruct-instead-of-pluck)
|
76
76
|
- [`typed_enum`](#typed_enum-instead-of-enum)
|
data/Rakefile
CHANGED
@@ -10,11 +10,37 @@ namespace :update_spec do
|
|
10
10
|
|
11
11
|
desc "Generate Rails apps for all versions."
|
12
12
|
task :all do |t, args|
|
13
|
+
Rake::Task['update_spec:v7_0'].invoke
|
13
14
|
Rake::Task['update_spec:v6_1'].invoke
|
14
15
|
Rake::Task['update_spec:v6_0'].invoke
|
15
16
|
Rake::Task['update_spec:v5_2'].invoke
|
16
17
|
end
|
17
18
|
|
19
|
+
desc "Delete the Rails 7.0 spec directory and regenerate it."
|
20
|
+
task :v7_0 do |t, args|
|
21
|
+
Bundler.with_clean_env do
|
22
|
+
FileUtils.rm_rf 'spec/support/v7.0' if File.directory?('spec/support/v7.0')
|
23
|
+
system("gem install rails -v 7.0.3")
|
24
|
+
system("rails _7.0.3_ -v")
|
25
|
+
command = [
|
26
|
+
"RAILS_VERSION='7.0'",
|
27
|
+
"rails _7.0.3_ new",
|
28
|
+
"--template spec/generators/rails-template.rb",
|
29
|
+
"spec/support/v7.0",
|
30
|
+
"--skip-action-cable",
|
31
|
+
"--skip-action-text",
|
32
|
+
"--skip-asset-pipeline",
|
33
|
+
"--skip-bootsnap",
|
34
|
+
"--skip-hotwire",
|
35
|
+
"--skip-javascript",
|
36
|
+
"--skip-listen",
|
37
|
+
"--skip-spring",
|
38
|
+
"--skip-test"
|
39
|
+
].join(" ")
|
40
|
+
system(command)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
18
44
|
desc "Delete the Rails 6.1 spec directory and regenerate it."
|
19
45
|
task :v6_1 do |t, args|
|
20
46
|
Bundler.with_clean_env do
|
@@ -47,7 +73,7 @@ namespace :update_spec do
|
|
47
73
|
|
48
74
|
desc "Update sorbet_test_cases.rb in all the Rails apps in spec/support."
|
49
75
|
task :sorbet_test_cases do |t, args|
|
50
|
-
['v6.1', 'v6.0', 'v5.2'].each do |version|
|
76
|
+
['v7.0', 'v6.1', 'v6.0', 'v5.2'].each do |version|
|
51
77
|
FileUtils.cp("spec/generators/sorbet_test_cases.rb", "spec/support/#{version}/sorbet_test_cases.rb")
|
52
78
|
end
|
53
79
|
end
|
@@ -220,7 +220,7 @@ class SorbetRails::ActiveRecordRbiFormatter
|
|
220
220
|
)
|
221
221
|
end
|
222
222
|
|
223
|
-
item_methods = %w(first first! second second! third third! third_to_last third_to_last! second_to_last second_to_last! last last!)
|
223
|
+
item_methods = %w(first first! second second! third third! third_to_last third_to_last! second_to_last second_to_last! last last! take take!)
|
224
224
|
item_methods.each do |item_method|
|
225
225
|
class_rbi.create_method(
|
226
226
|
item_method,
|
@@ -30,6 +30,7 @@ class SorbetRails::ModelPlugins::ActiveRecordQuerying < SorbetRails::ModelPlugin
|
|
30
30
|
:where, :rewhere, :preload, :extract_associated, :eager_load, :includes, :from, :lock, :readonly, :or,
|
31
31
|
:having, :create_with, :distinct, :references, :none, :unscope, :optimizer_hints, :merge, :except, :only,
|
32
32
|
]
|
33
|
+
|
33
34
|
model_query_relation_methods.each do |method_name|
|
34
35
|
add_relation_query_method(
|
35
36
|
root,
|
@@ -77,6 +78,19 @@ class SorbetRails::ModelPlugins::ActiveRecordQuerying < SorbetRails::ModelPlugin
|
|
77
78
|
)
|
78
79
|
end
|
79
80
|
|
81
|
+
# https://api.rubyonrails.org/v7.0.0/classes/ActiveRecord/QueryMethods.html#method-i-in_order_of
|
82
|
+
if Rails.version >= "7.0"
|
83
|
+
add_relation_query_method(
|
84
|
+
root,
|
85
|
+
"in_order_of",
|
86
|
+
parameters: [
|
87
|
+
Parameter.new("column", type: "Symbol"),
|
88
|
+
Parameter.new("values", type: "T::Array[T.untyped]")
|
89
|
+
],
|
90
|
+
builtin_query_method: true,
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
80
94
|
add_relation_query_method(
|
81
95
|
root,
|
82
96
|
"extending",
|
@@ -55,7 +55,7 @@ module ::ActiveRecord::Enum
|
|
55
55
|
sig { params(definitions: T::Hash[Symbol, T.untyped]).void }
|
56
56
|
def _define_enum(definitions)
|
57
57
|
ActiveRecordOverrides.instance.store_enum_call(self, definitions)
|
58
|
-
old_enum(definitions)
|
58
|
+
old_enum(**definitions)
|
59
59
|
end
|
60
60
|
|
61
61
|
sig { params(definitions: T::Hash[Symbol, T.untyped]).void }
|
@@ -26,6 +26,9 @@ namespace :rails_rbi do
|
|
26
26
|
|
27
27
|
desc "Generate rbis for rails routes"
|
28
28
|
task :routes, [:root_dir] => :environment do |t, args|
|
29
|
+
# Skip ActionDispatch if not included
|
30
|
+
next unless defined?(ActionDispatch)
|
31
|
+
|
29
32
|
all_routes = Rails.application.routes.routes
|
30
33
|
require "action_dispatch/routing/inspector"
|
31
34
|
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
@@ -61,6 +64,9 @@ namespace :rails_rbi do
|
|
61
64
|
|
62
65
|
desc "Generate rbis for rails models. Pass models name to regenerate rbi for only the given models."
|
63
66
|
task models: :environment do |t, args|
|
67
|
+
# Skip ActiveRecord if not included
|
68
|
+
next unless defined?(ActiveRecord)
|
69
|
+
|
64
70
|
SorbetRails::Utils.rails_eager_load_all!
|
65
71
|
|
66
72
|
all_models = Set.new(ActiveRecord::Base.descendants + whitelisted_models - blacklisted_models)
|
@@ -95,6 +101,9 @@ namespace :rails_rbi do
|
|
95
101
|
|
96
102
|
desc "Generate rbis for rails helpers."
|
97
103
|
task helpers: :environment do |t, args|
|
104
|
+
# Skip ActionController if not included
|
105
|
+
next unless defined?(ActionController)
|
106
|
+
|
98
107
|
SorbetRails::Utils.rails_eager_load_all!
|
99
108
|
|
100
109
|
# API controller does not include ActionController::Helpers
|
@@ -120,6 +129,9 @@ namespace :rails_rbi do
|
|
120
129
|
|
121
130
|
desc "Generate rbis for rails mailers"
|
122
131
|
task :mailers, [:root_dir] => :environment do |t, args|
|
132
|
+
# Skip ActiveRecord if not included
|
133
|
+
next unless defined?(ActionMailer)
|
134
|
+
|
123
135
|
SorbetRails::Utils.rails_eager_load_all!
|
124
136
|
all_mailers = ActionMailer::Base.descendants
|
125
137
|
|
@@ -138,6 +150,9 @@ namespace :rails_rbi do
|
|
138
150
|
|
139
151
|
desc "Generate rbis for rails mailers"
|
140
152
|
task :jobs, [:root_dir] => :environment do |t, args|
|
153
|
+
# Skip ActiveJob if not included
|
154
|
+
next unless defined?(ActiveJob)
|
155
|
+
|
141
156
|
SorbetRails::Utils.rails_eager_load_all!
|
142
157
|
all_jobs = ActiveJob::Base.descendants
|
143
158
|
|
data/sorbet-rails.gemspec
CHANGED
data/spec/bin/run_all_specs.sh
CHANGED
@@ -125,12 +125,6 @@ def create_models
|
|
125
125
|
end
|
126
126
|
RUBY
|
127
127
|
|
128
|
-
# A nasty hack to add has_one_attached and has_many_attached to the models/wizard.rb file.
|
129
|
-
attachments = nil
|
130
|
-
if ['5.2', '6.0', '6.1'].include?(ENV["RAILS_VERSION"])
|
131
|
-
attachments = "has_one_attached :school_photo\n has_many_attached :hats"
|
132
|
-
end
|
133
|
-
|
134
128
|
file "app/models/wizard.rb", <<~RUBY
|
135
129
|
class Wizard < ApplicationRecord
|
136
130
|
validates :name, length: { minimum: 5 }, presence: true
|
@@ -194,7 +188,8 @@ def create_models
|
|
194
188
|
belongs_to :school, optional: true
|
195
189
|
|
196
190
|
scope :recent, -> { where('created_at > ?', 1.month.ago) }
|
197
|
-
|
191
|
+
has_one_attached :school_photo
|
192
|
+
has_many_attached :hats
|
198
193
|
end
|
199
194
|
RUBY
|
200
195
|
|
data/spec/rails_helper.rb
CHANGED
@@ -32,6 +32,8 @@ T.assert_type!(wizard.spell_book_ids, T::Array[Integer])
|
|
32
32
|
# Finder methods -- Model
|
33
33
|
T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
|
34
34
|
T.assert_type!(Wizard.find(wizard.id), Wizard)
|
35
|
+
T.assert_type!(Wizard.take, T.nilable(Wizard))
|
36
|
+
T.assert_type!(Wizard.take!, Wizard)
|
35
37
|
T.assert_type!(Wizard.first!, Wizard)
|
36
38
|
T.assert_type!(Wizard.first, T.nilable(Wizard))
|
37
39
|
T.assert_type!(Wizard.second!, Wizard)
|
@@ -90,6 +92,8 @@ T.assert_type!(Wizard.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
|
|
90
92
|
# Finder methods -- ActiveRecord::Relation
|
91
93
|
T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
|
92
94
|
T.assert_type!(Wizard.all.find(wizard.id), Wizard)
|
95
|
+
T.assert_type!(Wizard.all.take, T.nilable(Wizard))
|
96
|
+
T.assert_type!(Wizard.all.take!, Wizard)
|
93
97
|
T.assert_type!(Wizard.all.first!, Wizard)
|
94
98
|
T.assert_type!(Wizard.all.first, T.nilable(Wizard))
|
95
99
|
T.assert_type!(Wizard.all.second!, Wizard)
|
@@ -161,6 +165,8 @@ spell_book = wizard.spell_books.first!
|
|
161
165
|
spell_books = wizard.spell_books
|
162
166
|
T.assert_type!(spell_books.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
163
167
|
T.assert_type!(spell_books.find(spell_book.id), SpellBook)
|
168
|
+
T.assert_type!(spell_books.take, T.nilable(SpellBook))
|
169
|
+
T.assert_type!(spell_books.take!, SpellBook)
|
164
170
|
T.assert_type!(spell_books.first!, SpellBook)
|
165
171
|
T.assert_type!(spell_books.first, T.nilable(SpellBook))
|
166
172
|
T.assert_type!(spell_books.second!, SpellBook)
|
@@ -240,6 +246,8 @@ T.assert_type!(spell_books.push([spell_book]), SpellBook::ActiveRecord_Associati
|
|
240
246
|
spell_books_query = spell_books.where(wizard_id: wizard.id)
|
241
247
|
T.assert_type!(spell_books_query.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
242
248
|
T.assert_type!(spell_books_query.find(spell_book.id), SpellBook)
|
249
|
+
T.assert_type!(spell_books_query.take, T.nilable(SpellBook))
|
250
|
+
T.assert_type!(spell_books_query.take!, SpellBook)
|
243
251
|
T.assert_type!(spell_books_query.first!, SpellBook)
|
244
252
|
T.assert_type!(spell_books_query.first, T.nilable(SpellBook))
|
245
253
|
T.assert_type!(spell_books_query.second!, SpellBook)
|
@@ -32,6 +32,8 @@ T.assert_type!(wizard.spell_book_ids, T::Array[Integer])
|
|
32
32
|
# Finder methods -- Model
|
33
33
|
T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
|
34
34
|
T.assert_type!(Wizard.find(wizard.id), Wizard)
|
35
|
+
T.assert_type!(Wizard.take, T.nilable(Wizard))
|
36
|
+
T.assert_type!(Wizard.take!, Wizard)
|
35
37
|
T.assert_type!(Wizard.first!, Wizard)
|
36
38
|
T.assert_type!(Wizard.first, T.nilable(Wizard))
|
37
39
|
T.assert_type!(Wizard.second!, Wizard)
|
@@ -90,6 +92,8 @@ T.assert_type!(Wizard.select_columns(:id, :name), Wizard::ActiveRecord_Relation)
|
|
90
92
|
# Finder methods -- ActiveRecord::Relation
|
91
93
|
T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
|
92
94
|
T.assert_type!(Wizard.all.find(wizard.id), Wizard)
|
95
|
+
T.assert_type!(Wizard.all.take, T.nilable(Wizard))
|
96
|
+
T.assert_type!(Wizard.all.take!, Wizard)
|
93
97
|
T.assert_type!(Wizard.all.first!, Wizard)
|
94
98
|
T.assert_type!(Wizard.all.first, T.nilable(Wizard))
|
95
99
|
T.assert_type!(Wizard.all.second!, Wizard)
|
@@ -161,6 +165,8 @@ spell_book = wizard.spell_books.first!
|
|
161
165
|
spell_books = wizard.spell_books
|
162
166
|
T.assert_type!(spell_books.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
163
167
|
T.assert_type!(spell_books.find(spell_book.id), SpellBook)
|
168
|
+
T.assert_type!(spell_books.take, T.nilable(SpellBook))
|
169
|
+
T.assert_type!(spell_books.take!, SpellBook)
|
164
170
|
T.assert_type!(spell_books.first!, SpellBook)
|
165
171
|
T.assert_type!(spell_books.first, T.nilable(SpellBook))
|
166
172
|
T.assert_type!(spell_books.second!, SpellBook)
|
@@ -240,6 +246,8 @@ T.assert_type!(spell_books.push([spell_book]), SpellBook::ActiveRecord_Associati
|
|
240
246
|
spell_books_query = spell_books.where(wizard_id: wizard.id)
|
241
247
|
T.assert_type!(spell_books_query.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
242
248
|
T.assert_type!(spell_books_query.find(spell_book.id), SpellBook)
|
249
|
+
T.assert_type!(spell_books_query.take, T.nilable(SpellBook))
|
250
|
+
T.assert_type!(spell_books_query.take!, SpellBook)
|
243
251
|
T.assert_type!(spell_books_query.first!, SpellBook)
|
244
252
|
T.assert_type!(spell_books_query.first, T.nilable(SpellBook))
|
245
253
|
T.assert_type!(spell_books_query.second!, SpellBook)
|
@@ -32,6 +32,8 @@ T.assert_type!(wizard.spell_book_ids, T::Array[Integer])
|
|
32
32
|
# Finder methods -- Model
|
33
33
|
T.assert_type!(Wizard.exists?(name: 'Test'), T::Boolean)
|
34
34
|
T.assert_type!(Wizard.find(wizard.id), Wizard)
|
35
|
+
T.assert_type!(Wizard.take, T.nilable(Wizard))
|
36
|
+
T.assert_type!(Wizard.take!, Wizard)
|
35
37
|
T.assert_type!(Wizard.first!, Wizard)
|
36
38
|
T.assert_type!(Wizard.first, T.nilable(Wizard))
|
37
39
|
T.assert_type!(Wizard.second!, Wizard)
|
@@ -91,6 +93,8 @@ T.assert_type!(Wizard.where_missing(:wand), Wizard::ActiveRecord_Relation)
|
|
91
93
|
# Finder methods -- ActiveRecord::Relation
|
92
94
|
T.assert_type!(Wizard.all.exists?(name: 'Harry Potter'), T::Boolean)
|
93
95
|
T.assert_type!(Wizard.all.find(wizard.id), Wizard)
|
96
|
+
T.assert_type!(Wizard.all.take, T.nilable(Wizard))
|
97
|
+
T.assert_type!(Wizard.all.take!, Wizard)
|
94
98
|
T.assert_type!(Wizard.all.first!, Wizard)
|
95
99
|
T.assert_type!(Wizard.all.first, T.nilable(Wizard))
|
96
100
|
T.assert_type!(Wizard.all.second!, Wizard)
|
@@ -163,6 +167,8 @@ spell_book = wizard.spell_books.first!
|
|
163
167
|
spell_books = wizard.spell_books
|
164
168
|
T.assert_type!(spell_books.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
165
169
|
T.assert_type!(spell_books.find(spell_book.id), SpellBook)
|
170
|
+
T.assert_type!(spell_books.take, T.nilable(SpellBook))
|
171
|
+
T.assert_type!(spell_books.take!, SpellBook)
|
166
172
|
T.assert_type!(spell_books.first!, SpellBook)
|
167
173
|
T.assert_type!(spell_books.first, T.nilable(SpellBook))
|
168
174
|
T.assert_type!(spell_books.second!, SpellBook)
|
@@ -243,6 +249,8 @@ T.assert_type!(spell_books.push([spell_book]), SpellBook::ActiveRecord_Associati
|
|
243
249
|
spell_books_query = spell_books.where(wizard_id: wizard.id)
|
244
250
|
T.assert_type!(spell_books_query.exists?(name: 'Fantastic Beasts'), T::Boolean)
|
245
251
|
T.assert_type!(spell_books_query.find(spell_book.id), SpellBook)
|
252
|
+
T.assert_type!(spell_books_query.take, T.nilable(SpellBook))
|
253
|
+
T.assert_type!(spell_books_query.take!, SpellBook)
|
246
254
|
T.assert_type!(spell_books_query.first!, SpellBook)
|
247
255
|
T.assert_type!(spell_books_query.first, T.nilable(SpellBook))
|
248
256
|
T.assert_type!(spell_books_query.second!, SpellBook)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-*
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*
|
16
|
+
/tmp/*
|
17
|
+
!/log/.keep
|
18
|
+
!/tmp/.keep
|
19
|
+
|
20
|
+
# Ignore pidfiles, but keep the directory.
|
21
|
+
/tmp/pids/*
|
22
|
+
!/tmp/pids/
|
23
|
+
!/tmp/pids/.keep
|
24
|
+
|
25
|
+
# Ignore uploaded files in development.
|
26
|
+
/storage/*
|
27
|
+
!/storage/.keep
|
28
|
+
/tmp/storage/*
|
29
|
+
!/tmp/storage/
|
30
|
+
!/tmp/storage/.keep
|
31
|
+
|
32
|
+
/public/assets
|
33
|
+
|
34
|
+
# Ignore master key for decrypting credentials and more.
|
35
|
+
/config/master.key
|
@@ -0,0 +1,48 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
ruby "3.0.1"
|
5
|
+
|
6
|
+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
7
|
+
gem "rails", "~> 7.0.3"
|
8
|
+
|
9
|
+
# Use sqlite3 as the database for Active Record
|
10
|
+
gem "sqlite3", "~> 1.4"
|
11
|
+
|
12
|
+
# Use the Puma web server [https://github.com/puma/puma]
|
13
|
+
gem "puma", "~> 5.0"
|
14
|
+
|
15
|
+
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
|
16
|
+
gem "jbuilder"
|
17
|
+
|
18
|
+
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
|
19
|
+
# gem "kredis"
|
20
|
+
|
21
|
+
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
|
22
|
+
# gem "bcrypt", "~> 3.1.7"
|
23
|
+
|
24
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
25
|
+
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
|
26
|
+
|
27
|
+
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
28
|
+
# gem "image_processing", "~> 1.2"
|
29
|
+
|
30
|
+
group :development, :test do
|
31
|
+
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
32
|
+
gem "debug", platforms: %i[ mri mingw x64_mingw ]
|
33
|
+
end
|
34
|
+
|
35
|
+
group :development do
|
36
|
+
# Use console on exceptions pages [https://github.com/rails/web-console]
|
37
|
+
gem "web-console"
|
38
|
+
|
39
|
+
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
|
40
|
+
# gem "rack-mini-profiler"
|
41
|
+
|
42
|
+
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
|
43
|
+
# gem "spring"
|
44
|
+
end
|
45
|
+
|
46
|
+
gem "sorbet-rails", path: "../../../."
|
47
|
+
gem "sorbet"
|
48
|
+
gem "sorbet-runtime"
|