sorbet-rails 0.7.27 → 0.7.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e80eb4263d607a23eec096f9751339d944226b2feb2c1bc52ece8d2b7531128
4
- data.tar.gz: df11889efd6ebcddc194293ba868e80d9a2b1e88d4783d10aeb954a99a1e1422
3
+ metadata.gz: 8c8486bf0c5537443c859e1f51c4aebd3e62bd16370f78526a4f2e879b148c81
4
+ data.tar.gz: ffd9da9622e74e186ae94eb9547da174df0e86e294373b06bbdf4caf4d71736f
5
5
  SHA512:
6
- metadata.gz: 04f2af9fb19e21bf584686158e874a33553551226e5c926d497f8c981199226a63d80f46e8b6badba42e6198508bb593a89d8a619849c4d71319c858dfea01ed
7
- data.tar.gz: 0e14167c972be954efa22d1955dbb36938a73199f094c698a69759727eb95961b0a46e31a1a2b6d3bd3d9bb07cc60f3f16a755ae4c08e80f25f08fa2f4d713b8
6
+ metadata.gz: e9b9d08940d9c0c82984326439fd8c310955e6c3c59a1b6ed01c46c5ab05ca71680e9627f0bef456942ad2c08430d216ad969a0506c2478c0fec5863a3bb3d32
7
+ data.tar.gz: 82f9e89b908de82b1a63f02f60cef7aea5ded0108c2717b3e3aa1ee0ac2ee534476327fb5483a155d98d95f9f35640534ce133a2b017daf31797844725a91138
@@ -4,6 +4,8 @@ on:
4
4
  push:
5
5
  branches: # Trigger only on the main branch to avoid duplicate runs on PR branches
6
6
  - master
7
+ schedule: # trigger once a week to ensure that CI works even after dependent gem updates
8
+ - cron: 0 0 * * 1
7
9
 
8
10
  jobs:
9
11
  rspec:
data/README.md CHANGED
@@ -365,6 +365,7 @@ Following are the list of attribute dynamic methods and their static counterpart
365
365
  - `<attribute>_was` -> `attribute_was(<attribute>)`
366
366
  - `saved_change_to_<attribute>?` -> `saved_change_to_attribute?(<attribute>)`
367
367
  - `<attribute>_before_type_cast` -> `read_attribute_before_type_cast(<attribute>)`
368
+ - `will_save_change_to_<attribute>?` -> `will_save_change_to_attribute?(<attribute>)`
368
369
 
369
370
  ### `after_commit` and other callbacks
370
371
 
@@ -38,13 +38,18 @@ class AasmPlugin < SorbetRails::ModelPlugins::Base
38
38
  )
39
39
  end
40
40
 
41
- # - If you have a state like :baz, you get these methods:
42
- # - `baz?`
41
+ # - If you have a state like :baz, you get:
42
+ # - a method `baz?`
43
+ # - a constant `STATE_BAZ`
43
44
  aasm_states.each do |state|
44
45
  model_rbi.create_method(
45
46
  "#{state}?",
46
47
  return_type: 'T::Boolean'
47
48
  )
49
+
50
+ root.create_module(
51
+ "#{model_class_name}::STATE_#{state.to_s.upcase}"
52
+ )
48
53
  end
49
54
  end
50
55
  end
@@ -17,7 +17,7 @@ module SorbetRails::ModelColumnUtils
17
17
  type = base_type.to_s
18
18
  # A nullable array column should be T.nilable(T::Array[column_type]) not T::Array[T.nilable(column_type)]
19
19
  type = "T::Array[#{type}]" if array_type
20
- type = "T.nilable(#{type})" if nilable
20
+ type = "T.nilable(#{type})" if nilable && type != "T.untyped"
21
21
  type
22
22
  end
23
23
  end
@@ -34,7 +34,7 @@ class SorbetRails::ModelPlugins::ActiveRecordAssoc < SorbetRails::ModelPlugins::
34
34
  def populate_single_assoc_getter_setter(assoc_module_rbi, assoc_name, reflection)
35
35
  # TODO allow people to specify the possible values of polymorphic associations
36
36
  assoc_class = assoc_should_be_untyped?(reflection) ? "T.untyped" : "::#{reflection.klass.name}"
37
- assoc_type = (belongs_to_and_required?(reflection) || has_one_and_required?(reflection)) ? assoc_class : "T.nilable(#{assoc_class})"
37
+ assoc_type = (belongs_to_and_required?(reflection) || has_one_and_required?(reflection) || assoc_class == "T.untyped") ? assoc_class : "T.nilable(#{assoc_class})"
38
38
 
39
39
  params = [
40
40
  Parameter.new("*args", type: "T.untyped"),
data/spec/sorbet_spec.rb CHANGED
@@ -63,6 +63,9 @@ RSpec.describe 'sorbet' do
63
63
  # run sorbet-rails rake tasks
64
64
  Rake::Task['rails_rbi:all'].invoke
65
65
 
66
+ # ensure we remove sorbet-rails.rbi as there are conflicts which cause srb tc to fail
67
+ FileUtils.rm_f(Rails.root.join('sorbet/rbi/gems/sorbet-rails.rbi'))
68
+
66
69
  # Regenerate hidden-definitions because there might be conflicts between signature
67
70
  # generated by sorbet-rails & by hidden-definitions
68
71
  # They should be resolved when re-running this script
@@ -287,7 +287,7 @@ module Wizard::GeneratedAssociationMethods
287
287
  sig { params(value: T::Enumerable[::ActiveStorage::Blob]).void }
288
288
  def hats_blobs=(value); end
289
289
 
290
- sig { returns(T.nilable(T.untyped)) }
290
+ sig { returns(T.untyped) }
291
291
  def school; end
292
292
 
293
293
  sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
@@ -299,10 +299,10 @@ module Wizard::GeneratedAssociationMethods
299
299
  sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
300
300
  def create_school!(*args, &block); end
301
301
 
302
- sig { params(value: T.nilable(T.untyped)).void }
302
+ sig { params(value: T.untyped).void }
303
303
  def school=(value); end
304
304
 
305
- sig { returns(T.nilable(T.untyped)) }
305
+ sig { returns(T.untyped) }
306
306
  def reload_school; end
307
307
 
308
308
  sig { returns(T.nilable(::ActiveStorage::Attachment)) }
@@ -1134,7 +1134,7 @@ module Wizard::GeneratedAssociationMethods
1134
1134
  sig { params(value: T::Enumerable[::ActiveStorage::Blob]).void }
1135
1135
  def hats_blobs=(value); end
1136
1136
 
1137
- sig { returns(T.nilable(T.untyped)) }
1137
+ sig { returns(T.untyped) }
1138
1138
  def school; end
1139
1139
 
1140
1140
  sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
@@ -1146,10 +1146,10 @@ module Wizard::GeneratedAssociationMethods
1146
1146
  sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
1147
1147
  def create_school!(*args, &block); end
1148
1148
 
1149
- sig { params(value: T.nilable(T.untyped)).void }
1149
+ sig { params(value: T.untyped).void }
1150
1150
  def school=(value); end
1151
1151
 
1152
- sig { returns(T.nilable(T.untyped)) }
1152
+ sig { returns(T.untyped) }
1153
1153
  def reload_school; end
1154
1154
 
1155
1155
  sig { returns(T.nilable(::ActiveStorage::Attachment)) }
@@ -1254,7 +1254,7 @@ module Wizard::GeneratedAssociationMethods
1254
1254
  sig { params(value: T::Enumerable[::ActiveStorage::Blob]).void }
1255
1255
  def hats_blobs=(value); end
1256
1256
 
1257
- sig { returns(T.nilable(T.untyped)) }
1257
+ sig { returns(T.untyped) }
1258
1258
  def school; end
1259
1259
 
1260
1260
  sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
@@ -1266,10 +1266,10 @@ module Wizard::GeneratedAssociationMethods
1266
1266
  sig { params(args: T.untyped, block: T.nilable(T.proc.params(object: T.untyped).void)).returns(T.untyped) }
1267
1267
  def create_school!(*args, &block); end
1268
1268
 
1269
- sig { params(value: T.nilable(T.untyped)).void }
1269
+ sig { params(value: T.untyped).void }
1270
1270
  def school=(value); end
1271
1271
 
1272
- sig { returns(T.nilable(T.untyped)) }
1272
+ sig { returns(T.untyped) }
1273
1273
  def reload_school; end
1274
1274
 
1275
1275
  sig { returns(T.nilable(::ActiveStorage::Attachment)) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.27
4
+ version: 0.7.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chan Zuckerberg Initiative