tech(Sorbet): prepare usage of sorbet to avoid defensive programming style [casting date to datetime]

This commit is contained in:
Martin 2022-04-02 09:04:09 +02:00 committed by mfo
parent ec78340c06
commit d6d9db9721
5 changed files with 23 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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 })

3
sorbet/config Normal file
View file

@ -0,0 +1,3 @@
--dir
.
--ignore=/vendor/bundle

View file

@ -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