diff --git a/app/controllers/admin/gestionnaires_controller.rb b/app/controllers/admin/gestionnaires_controller.rb index 51ebf2fac..c0b5c62b0 100644 --- a/app/controllers/admin/gestionnaires_controller.rb +++ b/app/controllers/admin/gestionnaires_controller.rb @@ -61,7 +61,7 @@ class Admin::GestionnairesController < AdminController end def assign_gestionnaire! - if current_administrateur.gestionnaires.include? @gestionnaire + if current_administrateur.gestionnaires.include?(@gestionnaire) flash.alert = 'Instructeur déjà ajouté' else @gestionnaire.administrateurs.push current_administrateur diff --git a/app/lib/file_size_validator.rb b/app/lib/file_size_validator.rb index 8537ce414..eb9f987f0 100644 --- a/app/lib/file_size_validator.rb +++ b/app/lib/file_size_validator.rb @@ -41,7 +41,7 @@ class FileSizeValidator < ActiveModel::EachValidator end def validate_each(record, attribute, value) - if !value.kind_of? CarrierWave::Uploader::Base + if !value.kind_of?(CarrierWave::Uploader::Base) raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") end diff --git a/app/models/user.rb b/app/models/user.rb index d6d55c9f3..7945bf875 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -30,8 +30,9 @@ class User < ApplicationRecord def self.find_for_france_connect(email, siret) user = User.find_by(email: email) + if user.nil? - return User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret) + User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret) else user.update(siret: siret) user diff --git a/app/services/clamav_service.rb b/app/services/clamav_service.rb index 02c559601..5b082d5a9 100644 --- a/app/services/clamav_service.rb +++ b/app/services/clamav_service.rb @@ -1,18 +1,14 @@ class ClamavService def self.safe_file?(file_path) - if Rails.env == 'development' + if Rails.env.development? return true end - FileUtils.chmod 0666, file_path + FileUtils.chmod(0666, file_path) client = ClamAV::Client.new response = client.execute(ClamAV::Commands::ScanCommand.new(file_path)) - if response.first.class == ClamAV::VirusResponse - return false - end - - true + response.first.class != ClamAV::VirusResponse end end diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 52a5d5249..521dd5873 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -17,7 +17,7 @@ class PiecesJustificativesService def self.upload_one!(dossier, user, params) content = params[:piece_justificative][:content] - if ClamavService.safe_file? content.path + if ClamavService.safe_file?(content.path) pj = PieceJustificative.new(content: content, dossier: dossier, type_de_piece_justificative: nil,