diff --git a/Gemfile b/Gemfile index e210be466..37f48fab8 100644 --- a/Gemfile +++ b/Gemfile @@ -120,6 +120,8 @@ group :development do end group :development, :test do + gem 'sorbet' + gem 'sorbet-runtime' gem 'graphql-schema_comparator' gem 'mina', require: false # Deploy gem 'pry-byebug' # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index b91f5e62a..5737b95dc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -677,6 +677,18 @@ GEM tilt (~> 2.0) skylight (5.0.1) activesupport (>= 5.2.0) + sorbet (0.5.9827) + sorbet-static (= 0.5.9827) + sorbet-runtime (0.5.9827) + sorbet-static (0.5.9827-universal-darwin-14) + sorbet-static (0.5.9827-universal-darwin-15) + sorbet-static (0.5.9827-universal-darwin-16) + sorbet-static (0.5.9827-universal-darwin-17) + sorbet-static (0.5.9827-universal-darwin-18) + sorbet-static (0.5.9827-universal-darwin-19) + sorbet-static (0.5.9827-universal-darwin-20) + sorbet-static (0.5.9827-universal-darwin-21) + sorbet-static (0.5.9827-x86_64-linux) spreadsheet_architect (4.1.0) axlsx_styler (>= 1.0.0, < 2) caxlsx (>= 2.0.2, < 4) @@ -874,6 +886,8 @@ DEPENDENCIES sib-api-v3-sdk simple_xlsx_reader skylight + sorbet + sorbet-runtime spreadsheet_architect spring spring-commands-rspec diff --git a/app/models/dossier.rb b/app/models/dossier.rb index fbef6d1a3..f5991efc0 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1,3 +1,4 @@ +# typed: true # == Schema Information # # Table name: dossiers @@ -38,6 +39,7 @@ # user_id :integer # class Dossier < ApplicationRecord + extend T::Sig self.ignored_columns = [:en_construction_conservation_extension] include DossierFilteringConcern include DossierRebaseConcern @@ -233,8 +235,8 @@ class Dossier < ApplicationRecord scope :en_instruction, -> { not_archived.state_en_instruction } scope :termine, -> { not_archived.state_termine } + sig { params(args: DateTime).returns(T.untyped) } scope :processed_in_month, -> (date) do - date = date.to_datetime state_termine .joins(:traitements) .where(traitements: { processed_at: date.beginning_of_month..date.end_of_month }) diff --git a/sorbet/config b/sorbet/config new file mode 100644 index 000000000..534118e61 --- /dev/null +++ b/sorbet/config @@ -0,0 +1,3 @@ +--dir +. +--ignore=/vendor/bundle diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b58e5553d..e52754382 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -13,6 +13,7 @@ require 'rspec/rails' require 'axe-rspec' require 'devise' require 'shoulda-matchers' +require 'sorbet-runtime' # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are