Merge pull request #3181 from betagouv/cleanup

Cleanup
This commit is contained in:
Paul Chavard 2018-12-19 09:58:08 +01:00 committed by GitHub
commit 766f0401db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 11 deletions

View file

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

View file

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

View file

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

View file

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

View file

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