commit
ae5ecd10c5
60 changed files with 180 additions and 167 deletions
63
.rubocop.yml
63
.rubocop.yml
|
@ -58,7 +58,7 @@ Layout/CommentIndentation:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Layout/ConditionPosition:
|
Layout/ConditionPosition:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Layout/DefEndAlignment:
|
Layout/DefEndAlignment:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -200,7 +200,7 @@ Layout/SpaceAfterColon:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Layout/SpaceAfterComma:
|
Layout/SpaceAfterComma:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Layout/SpaceAfterMethodName:
|
Layout/SpaceAfterMethodName:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
@ -224,7 +224,7 @@ Layout/SpaceAroundOperators:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Layout/SpaceBeforeBlockBraces:
|
Layout/SpaceBeforeBlockBraces:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Layout/SpaceBeforeComma:
|
Layout/SpaceBeforeComma:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
@ -252,7 +252,8 @@ Layout/SpaceInsideHashLiteralBraces:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Layout/SpaceInsideArrayLiteralBrackets:
|
Layout/SpaceInsideArrayLiteralBrackets:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
EnforcedStyle: no_space
|
||||||
|
|
||||||
Layout/SpaceInsideParens:
|
Layout/SpaceInsideParens:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
@ -339,40 +340,40 @@ Lint/EnsureReturn:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/FloatOutOfRange:
|
Lint/FloatOutOfRange:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/FormatParameterMismatch:
|
Lint/FormatParameterMismatch:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/HandleExceptions:
|
Lint/HandleExceptions:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/ImplicitStringConcatenation:
|
Lint/ImplicitStringConcatenation:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/IneffectiveAccessModifier:
|
Lint/IneffectiveAccessModifier:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/InheritException:
|
Lint/InheritException:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/InterpolationCheck:
|
Lint/InterpolationCheck:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Lint/LiteralAsCondition:
|
Lint/LiteralAsCondition:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/LiteralInInterpolation:
|
Lint/LiteralInInterpolation:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/Loop:
|
Lint/Loop:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/MissingCopEnableDirective:
|
Lint/MissingCopEnableDirective:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Lint/MultipleCompare:
|
Lint/MultipleCompare:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/NestedMethodDefinition:
|
Lint/NestedMethodDefinition:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -381,7 +382,7 @@ Lint/NestedPercentLiteral:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Lint/NextWithoutAccumulator:
|
Lint/NextWithoutAccumulator:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/NonLocalExitFromIterator:
|
Lint/NonLocalExitFromIterator:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -393,7 +394,9 @@ Lint/OrderedMagicComments:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Lint/ParenthesesAsGroupedExpression:
|
Lint/ParenthesesAsGroupedExpression:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
Exclude:
|
||||||
|
- "spec/**/*"
|
||||||
|
|
||||||
Lint/PercentStringArray:
|
Lint/PercentStringArray:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -417,16 +420,16 @@ Lint/RequireParentheses:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/RescueException:
|
Lint/RescueException:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/RescueType:
|
Lint/RescueType:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/ReturnInVoidContext:
|
Lint/ReturnInVoidContext:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/SafeNavigationChain:
|
Lint/SafeNavigationChain:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/ScriptPermission:
|
Lint/ScriptPermission:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -435,25 +438,25 @@ Lint/ShadowedArgument:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Lint/ShadowedException:
|
Lint/ShadowedException:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/ShadowingOuterLocalVariable:
|
Lint/ShadowingOuterLocalVariable:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/StringConversionInInterpolation:
|
Lint/StringConversionInInterpolation:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/Syntax:
|
Lint/Syntax:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Lint/UnderscorePrefixedVariableName:
|
Lint/UnderscorePrefixedVariableName:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/UnifiedInteger:
|
Lint/UnifiedInteger:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/UnneededCopDisableDirective:
|
Lint/UnneededCopDisableDirective:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/UnneededCopEnableDirective:
|
Lint/UnneededCopEnableDirective:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
@ -465,10 +468,10 @@ Lint/UnneededSplatExpansion:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/UnreachableCode:
|
Lint/UnreachableCode:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/UnusedBlockArgument:
|
Lint/UnusedBlockArgument:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/UnusedMethodArgument:
|
Lint/UnusedMethodArgument:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
@ -483,19 +486,21 @@ Lint/UselessAccessModifier:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/UselessAssignment:
|
Lint/UselessAssignment:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
Exclude:
|
||||||
|
- "spec/**/*"
|
||||||
|
|
||||||
Lint/UselessComparison:
|
Lint/UselessComparison:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/UselessElseWithoutRescue:
|
Lint/UselessElseWithoutRescue:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/UselessSetterCall:
|
Lint/UselessSetterCall:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Lint/Void:
|
Lint/Void:
|
||||||
Enabled: false
|
Enabled: true
|
||||||
|
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
|
@ -2,7 +2,7 @@ class AdminController < ApplicationController
|
||||||
before_action :authenticate_administrateur!
|
before_action :authenticate_administrateur!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
redirect_to (admin_procedures_path)
|
redirect_to(admin_procedures_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def retrieve_procedure
|
def retrieve_procedure
|
||||||
|
|
|
@ -6,7 +6,7 @@ class API::V1::DossiersController < APIController
|
||||||
def index
|
def index
|
||||||
dossiers = @dossiers.page(params[:page]).per(per_page)
|
dossiers = @dossiers.page(params[:page]).per(per_page)
|
||||||
|
|
||||||
render json: { dossiers: dossiers.map{ |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200
|
render json: { dossiers: dossiers.map { |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render json: {}, status: 404
|
render json: {}, status: 404
|
||||||
end
|
end
|
||||||
|
|
|
@ -211,7 +211,7 @@ class StatsController < ApplicationController
|
||||||
|
|
||||||
association
|
association
|
||||||
.where(date_attribute => min_date..max_date)
|
.where(date_attribute => min_date..max_date)
|
||||||
.group("DATE_TRUNC('month', #{date_attribute.to_s})")
|
.group("DATE_TRUNC('month', #{date_attribute})")
|
||||||
.count
|
.count
|
||||||
.to_a
|
.to_a
|
||||||
.sort_by { |a| a[0] }
|
.sort_by { |a| a[0] }
|
||||||
|
@ -221,8 +221,8 @@ class StatsController < ApplicationController
|
||||||
def cumulative_hash(association, date_attribute)
|
def cumulative_hash(association, date_attribute)
|
||||||
sum = 0
|
sum = 0
|
||||||
association
|
association
|
||||||
.where("#{date_attribute.to_s} < ?", max_date)
|
.where("#{date_attribute} < ?", max_date)
|
||||||
.group("DATE_TRUNC('month', #{date_attribute.to_s})")
|
.group("DATE_TRUNC('month', #{date_attribute})")
|
||||||
.count
|
.count
|
||||||
.to_a
|
.to_a
|
||||||
.sort_by { |a| a[0] }
|
.sort_by { |a| a[0] }
|
||||||
|
@ -271,7 +271,7 @@ class StatsController < ApplicationController
|
||||||
dossiers_grouped_by_procedure = value.group_by { |dossier| dossier[0] }
|
dossiers_grouped_by_procedure = value.group_by { |dossier| dossier[0] }
|
||||||
|
|
||||||
# Compute the mean time for this procedure
|
# Compute the mean time for this procedure
|
||||||
procedure_processing_times = dossiers_grouped_by_procedure.map do |procedure_id, procedure_dossiers|
|
procedure_processing_times = dossiers_grouped_by_procedure.map do |_procedure_id, procedure_dossiers|
|
||||||
procedure_dossiers_processing_time = procedure_dossiers.map do |dossier|
|
procedure_dossiers_processing_time = procedure_dossiers.map do |dossier|
|
||||||
(dossier[2] - dossier[1]).to_f / (3600 * 24)
|
(dossier[2] - dossier[1]).to_f / (3600 * 24)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
||||||
queue_as :cron
|
queue_as :cron
|
||||||
|
|
||||||
def perform(procedure_id, state, gestionnaire_id = nil)
|
def perform(procedure_id, state)
|
||||||
procedure = Procedure.find(procedure_id)
|
procedure = Procedure.find(procedure_id)
|
||||||
gestionnaire = procedure.gestionnaire_for_cron_job
|
gestionnaire = procedure.gestionnaire_for_cron_job
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Champ < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_terms
|
def search_terms
|
||||||
[ to_s ]
|
[to_s]
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Champs::CheckboxChamp < Champ
|
class Champs::CheckboxChamp < Champ
|
||||||
def search_terms
|
def search_terms
|
||||||
if value == 'on'
|
if value == 'on'
|
||||||
[ libelle ]
|
[libelle]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Champs::DatetimeChamp < Champ
|
||||||
self.value =
|
self.value =
|
||||||
begin
|
begin
|
||||||
hash_date = YAML.safe_load(value.gsub('=>', ': '))
|
hash_date = YAML.safe_load(value.gsub('=>', ': '))
|
||||||
year, month, day, hour, minute = hash_date.values_at(1,2,3,4,5)
|
year, month, day, hour, minute = hash_date.values_at(1, 2, 3, 4, 5)
|
||||||
Time.zone.local(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M")
|
Time.zone.local(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M")
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Champs::EngagementChamp < Champs::CheckboxChamp
|
class Champs::EngagementChamp < Champs::CheckboxChamp
|
||||||
def search_terms
|
def search_terms
|
||||||
if value == 'on'
|
if value == 'on'
|
||||||
[ libelle ]
|
[libelle]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Champs::LinkedDropDownListChamp < Champ
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_terms
|
def search_terms
|
||||||
[ primary_value, secondary_value ]
|
[primary_value, secondary_value]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -52,6 +52,6 @@ class Champs::LinkedDropDownListChamp < Champ
|
||||||
end
|
end
|
||||||
|
|
||||||
def pack_value(primary, secondary)
|
def pack_value(primary, secondary)
|
||||||
self.value = JSON.generate([ primary, secondary ])
|
self.value = JSON.generate([primary, secondary])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,11 +31,11 @@ class Champs::PieceJustificativeChamp < Champ
|
||||||
|
|
||||||
if piece_justificative_file.attached? && piece_justificative_file.previous_changes.present?
|
if piece_justificative_file.attached? && piece_justificative_file.previous_changes.present?
|
||||||
if piece_justificative_file.blob.byte_size > PIECE_JUSTIFICATIVE_FILE_MAX_SIZE
|
if piece_justificative_file.blob.byte_size > PIECE_JUSTIFICATIVE_FILE_MAX_SIZE
|
||||||
errors << "Le fichier #{piece_justificative_file.filename.to_s} est trop lourd, il doit faire au plus #{PIECE_JUSTIFICATIVE_FILE_MAX_SIZE.to_s(:human_size, precision: 2)}"
|
errors << "Le fichier #{piece_justificative_file.filename} est trop lourd, il doit faire au plus #{PIECE_JUSTIFICATIVE_FILE_MAX_SIZE.to_s(:human_size, precision: 2)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if !piece_justificative_file.blob.content_type.in?(PIECE_JUSTIFICATIVE_FILE_ACCEPTED_FORMATS)
|
if !piece_justificative_file.blob.content_type.in?(PIECE_JUSTIFICATIVE_FILE_ACCEPTED_FORMATS)
|
||||||
errors << "Le fichier #{piece_justificative_file.filename.to_s} est dans un format que nous n'acceptons pas"
|
errors << "Le fichier #{piece_justificative_file.filename} est dans un format que nous n'acceptons pas"
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: add Clamav check
|
# FIXME: add Clamav check
|
||||||
|
|
|
@ -40,6 +40,6 @@ class Champs::SiretChamp < Champ
|
||||||
accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true
|
accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true
|
||||||
|
|
||||||
def search_terms
|
def search_terms
|
||||||
etablissement.present? ? etablissement.search_terms : [ value ]
|
etablissement.present? ? etablissement.search_terms : [value]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class Champs::YesNoChamp < Champs::CheckboxChamp
|
class Champs::YesNoChamp < Champs::CheckboxChamp
|
||||||
def search_terms
|
def search_terms
|
||||||
if value == 'true'
|
if value == 'true'
|
||||||
[ libelle ]
|
[libelle]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ class DropDownList < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def disabled_options
|
def disabled_options
|
||||||
options.select{ |v| (v =~ /^--.*--$/).present? }
|
options.select { |v| (v =~ /^--.*--$/).present? }
|
||||||
end
|
end
|
||||||
|
|
||||||
def selected_options(champ)
|
def selected_options(champ)
|
||||||
|
|
|
@ -91,6 +91,6 @@ class Etablissement < ApplicationRecord
|
||||||
def message_for_signature
|
def message_for_signature
|
||||||
JSON.pretty_generate(as_json(include: {
|
JSON.pretty_generate(as_json(include: {
|
||||||
exercices: { only: [:ca, :date_fin_exercice, :date_fin_exercice_timestamp] }
|
exercices: { only: [:ca, :date_fin_exercice, :date_fin_exercice_timestamp] }
|
||||||
}).delete_if { |k,v| v.blank? })
|
}).delete_if { |_k, v| v.blank? })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
explanatory_types_de_champ = [:header_section, :explication].map{ |k| TypeDeChamp.type_champs.fetch(k) }
|
explanatory_types_de_champ = [:header_section, :explication].map { |k| TypeDeChamp.type_champs.fetch(k) }
|
||||||
|
|
||||||
fields.concat procedure.types_de_champ
|
fields.concat procedure.types_de_champ
|
||||||
.reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) }
|
.reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) }
|
||||||
|
@ -215,7 +215,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
def valid_columns_for_table(table)
|
def valid_columns_for_table(table)
|
||||||
@column_whitelist ||= fields
|
@column_whitelist ||= fields
|
||||||
.group_by { |field| field['table'] }
|
.group_by { |field| field['table'] }
|
||||||
.map { |table, fields| [table, Set.new(fields.map { |field| field['column'] }) ] }
|
.map { |table, fields| [table, Set.new(fields.map { |field| field['column'] })] }
|
||||||
.to_h
|
.to_h
|
||||||
|
|
||||||
@column_whitelist[table] || []
|
@column_whitelist[table] || []
|
||||||
|
|
|
@ -10,7 +10,7 @@ class PiecesJustificativesService
|
||||||
errors = with_virus
|
errors = with_virus
|
||||||
.map { |_, content| "#{content.original_filename} : virus détecté" }
|
.map { |_, content| "#{content.original_filename} : virus détecté" }
|
||||||
|
|
||||||
errors += without_virus
|
errors + without_virus
|
||||||
.map { |tpj, content| save_pj(content, dossier, tpj, user) }
|
.map { |tpj, content| save_pj(content, dossier, tpj, user) }
|
||||||
.compact()
|
.compact()
|
||||||
end
|
end
|
||||||
|
|
|
@ -212,7 +212,8 @@ class ProcedureExportService
|
||||||
etablissement.champ.dossier_id,
|
etablissement.champ.dossier_id,
|
||||||
label_for_export(etablissement.champ.libelle).to_s
|
label_for_export(etablissement.champ.libelle).to_s
|
||||||
]
|
]
|
||||||
data += etablissement_data(etablissement)
|
|
||||||
|
data + etablissement_data(etablissement)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class RenderPartialService
|
||||||
def self.left_panel_exist?(left_panel_url)
|
def self.left_panel_exist?(left_panel_url)
|
||||||
file = left_panel_url.split('/').last
|
file = left_panel_url.split('/').last
|
||||||
|
|
||||||
File.exist?(Rails.root.join('app','views', 'layouts', 'left_panels', "_#{file}.html.haml"))
|
File.exist?(Rails.root.join('app', 'views', 'layouts', 'left_panels', "_#{file}.html.haml"))
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -31,6 +31,6 @@ class RenderPartialService
|
||||||
end
|
end
|
||||||
|
|
||||||
def retrieve_name
|
def retrieve_name
|
||||||
"#{controller.to_s.parameterize.underscore}_#{method.to_s}"
|
"#{controller.to_s.parameterize.underscore}_#{method}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,6 @@ class CommentaireFileUploader < BaseUploader
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept_extension_list
|
def accept_extension_list
|
||||||
extension_white_list.map{ |e| ".#{e}" }.join(",")
|
extension_white_list.map { |e| ".#{e}" }.join(",")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,12 +32,19 @@ class ActiveJobLogSubscriber < ::ActiveJob::Logging::LogSubscriber
|
||||||
|
|
||||||
def process_event(event, type)
|
def process_event(event, type)
|
||||||
data = extract_metadata(event)
|
data = extract_metadata(event)
|
||||||
data.merge! extract_exception(event)
|
data.merge!(extract_exception(event))
|
||||||
data.merge! extract_scheduled_at(event) if type == 'enqueue_at'
|
|
||||||
data.merge! extract_duration(event) if type == 'perform'
|
case type
|
||||||
|
when 'enqueue_at'
|
||||||
|
data.merge!(extract_scheduled_at(event))
|
||||||
|
when 'perform'
|
||||||
|
data.merge!(extract_duration(event))
|
||||||
|
end
|
||||||
|
|
||||||
tags = ['job', type]
|
tags = ['job', type]
|
||||||
tags.push('exception') if data[:exception]
|
if data[:exception]
|
||||||
|
tags.push('exception')
|
||||||
|
end
|
||||||
data[:tags] = tags
|
data[:tags] = tags
|
||||||
data[:type] = 'tps'
|
data[:type] = 'tps'
|
||||||
data[:source] = ENV['SOURCE']
|
data[:source] = ENV['SOURCE']
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
AfterParty.setup do |config|
|
AfterParty.setup do |_config|
|
||||||
require "after_party/active_record.rb"
|
require "after_party/active_record.rb"
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
if ENV['RAILS_ENV'] != 'test' && File.basename($0) != 'rake'
|
if ENV['RAILS_ENV'] != 'test' && File.basename($0) != 'rake'
|
||||||
reference_env_file = File.join('config', 'env.example')
|
reference_env_file = File.join('config', 'env.example')
|
||||||
Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, value|
|
Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, _value|
|
||||||
if !ENV.key?(key.to_s)
|
if !ENV.key?(key.to_s)
|
||||||
raise "Configuration error: `#{key}` is not present in the process’ environment variables (declared in `#{reference_env_file}`)"
|
raise "Configuration error: `#{key}` is not present in the process’ environment variables (declared in `#{reference_env_file}`)"
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ Rails.application.configure do
|
||||||
end
|
end
|
||||||
|
|
||||||
config.lograge.keep_original_rails_log = true
|
config.lograge.keep_original_rails_log = true
|
||||||
config.lograge.logger = ActiveSupport::Logger.new Rails.root.join('log', "logstash_#{Rails.env}.log")
|
config.lograge.logger = ActiveSupport::Logger.new(Rails.root.join('log', "logstash_#{Rails.env}.log"))
|
||||||
|
|
||||||
if config.lograge.enabled
|
if config.lograge.enabled
|
||||||
ActiveJobLogSubscriber.attach_to(:active_job)
|
ActiveJobLogSubscriber.attach_to(:active_job)
|
||||||
|
|
|
@ -2,7 +2,7 @@ class RemoveDuplicateEmailReceived < ActiveRecord::Migration[5.0]
|
||||||
def change
|
def change
|
||||||
all_mails = MailReceived.all
|
all_mails = MailReceived.all
|
||||||
groupped = all_mails.group_by(&:procedure_id)
|
groupped = all_mails.group_by(&:procedure_id)
|
||||||
filtered = groupped.reject { |k, v| v.length < 2 }
|
filtered = groupped.reject { |_k, v| v.length < 2 }
|
||||||
filtered.each_value do |duplicate_mails|
|
filtered.each_value do |duplicate_mails|
|
||||||
duplicate_mails.pop
|
duplicate_mails.pop
|
||||||
duplicate_mails.each(&:destroy)
|
duplicate_mails.each(&:destroy)
|
||||||
|
|
|
@ -10,7 +10,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
||||||
t.string :checksum, null: false
|
t.string :checksum, null: false
|
||||||
t.datetime :created_at, null: false
|
t.datetime :created_at, null: false
|
||||||
|
|
||||||
t.index [ :key ], unique: true
|
t.index [:key], unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table :active_storage_attachments do |t|
|
create_table :active_storage_attachments do |t|
|
||||||
|
@ -20,7 +20,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
||||||
|
|
||||||
t.datetime :created_at, null: false
|
t.datetime :created_at, null: false
|
||||||
|
|
||||||
t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
|
t.index [:record_type, :record_id, :name, :blob_id], name: "index_active_storage_attachments_uniqueness", unique: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ namespace :'2017_07_18_clean_followed_dossiers' do
|
||||||
Follow.where(gestionnaire_id: nil).destroy_all
|
Follow.where(gestionnaire_id: nil).destroy_all
|
||||||
Follow.where(dossier_id: nil).destroy_all
|
Follow.where(dossier_id: nil).destroy_all
|
||||||
|
|
||||||
duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select{ |_gestionnaire_id_dossier_id, count| count > 1 }.keys
|
duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select { |_gestionnaire_id_dossier_id, count| count > 1 }.keys
|
||||||
|
|
||||||
duplicate_ids = duplicate_follows.map { |gestionnaire_id, dossier_id| Follow.where(gestionnaire_id: gestionnaire_id, dossier_id: dossier_id).pluck(:id) }
|
duplicate_ids = duplicate_follows.map { |gestionnaire_id, dossier_id| Follow.where(gestionnaire_id: gestionnaire_id, dossier_id: dossier_id).pluck(:id) }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ require Rails.root.join("lib", "tasks", "task_helper")
|
||||||
namespace :'2017_07_26_clean_birthdate_on_individual' do
|
namespace :'2017_07_26_clean_birthdate_on_individual' do
|
||||||
task clean: :environment do
|
task clean: :environment do
|
||||||
# remove duplicates
|
# remove duplicates
|
||||||
duplicate_individuals = Individual.group("dossier_id").count.select{ |_dossier_id, count| count > 1 }.keys
|
duplicate_individuals = Individual.group("dossier_id").count.select { |_dossier_id, count| count > 1 }.keys
|
||||||
duplicate_individuals.each { |dossier_id| Individual.where(dossier_id: dossier_id, nom: nil).delete_all }
|
duplicate_individuals.each { |dossier_id| Individual.where(dossier_id: dossier_id, nom: nil).delete_all }
|
||||||
|
|
||||||
# Match "" => nil
|
# Match "" => nil
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace :'2017_08_01_clean_assign_to' do
|
namespace :'2017_08_01_clean_assign_to' do
|
||||||
task clean: :environment do
|
task clean: :environment do
|
||||||
duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select{ |_gestionnaire_id_procedure_id, count| count > 1 }.keys
|
duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select { |_gestionnaire_id_procedure_id, count| count > 1 }.keys
|
||||||
|
|
||||||
duplicate_ids = duplicates.map { |gestionnaire_id, procedure_id| AssignTo.where(gestionnaire_id: gestionnaire_id, procedure_id: procedure_id).pluck(:id) }
|
duplicate_ids = duplicates.map { |gestionnaire_id, procedure_id| AssignTo.where(gestionnaire_id: gestionnaire_id, procedure_id: procedure_id).pluck(:id) }
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace :'2017_10_30_copy_commentaire_piece_justificative_to_file' do
|
||||||
end
|
end
|
||||||
|
|
||||||
def sanitize_name(name) # from https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/sanitized_file.rb#L323
|
def sanitize_name(name) # from https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/sanitized_file.rb#L323
|
||||||
name = name.gsub(/[^[:word:]\.\-\+]/,"_")
|
name = name.gsub(/[^[:word:]\.\-\+]/, "_")
|
||||||
name = "_#{name}" if name.match?(/\A\.+\z/)
|
name = "_#{name}" if name.match?(/\A\.+\z/)
|
||||||
name = "unnamed" if name.empty?
|
name = "unnamed" if name.empty?
|
||||||
return name.mb_chars.to_s
|
return name.mb_chars.to_s
|
||||||
|
|
|
@ -19,11 +19,11 @@ namespace :'2018_01_18_clean_datetime_in_champs' do
|
||||||
|
|
||||||
# Match "ddmmYYYY HH:MM" => "YYYY-mm-dd HH:MM"
|
# Match "ddmmYYYY HH:MM" => "YYYY-mm-dd HH:MM"
|
||||||
datetime_champs.select { |c| /^\d{8}\s\d{2}:\d{2}$/ =~ c.value }.each do |c|
|
datetime_champs.select { |c| /^\d{8}\s\d{2}:\d{2}$/ =~ c.value }.each do |c|
|
||||||
day = c.value[0,2]
|
day = c.value[0, 2]
|
||||||
month = c.value[2,2]
|
month = c.value[2, 2]
|
||||||
year = c.value[4,4]
|
year = c.value[4, 4]
|
||||||
hours = c.value[9,2]
|
hours = c.value[9, 2]
|
||||||
minutes = c.value[12,2]
|
minutes = c.value[12, 2]
|
||||||
formated_date = "#{year}-#{month}-#{day} #{hours}:#{minutes}"
|
formated_date = "#{year}-#{month}-#{day} #{hours}:#{minutes}"
|
||||||
rake_puts "cleaning #{c.value} => #{formated_date}"
|
rake_puts "cleaning #{c.value} => #{formated_date}"
|
||||||
c.update_columns(value: formated_date)
|
c.update_columns(value: formated_date)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
namespace :'2018_02_28_clean_invalid_emails_accounts' do
|
namespace :'2018_02_28_clean_invalid_emails_accounts' do
|
||||||
task clean: :environment do
|
task clean: :environment do
|
||||||
Gestionnaire.pluck(:email, :id).select { |e, id| e.include?(" ") }.each do |email, id|
|
Gestionnaire.pluck(:email, :id).select { |e, _id| e.include?(" ") }.each do |_email, id|
|
||||||
Gestionnaire.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used
|
Gestionnaire.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used
|
||||||
end
|
end
|
||||||
|
|
||||||
User.pluck(:email, :id).select { |e, id| e.include?(" ") }.each do |email, id|
|
User.pluck(:email, :id).select { |e, _id| e.include?(" ") }.each do |_email, id|
|
||||||
User.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used
|
User.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ namespace :'2018_09_12_fix_templates' do
|
||||||
task run: :environment do
|
task run: :environment do
|
||||||
dossiers_with_invalid_attestations = find_dossiers_with_sent_and_invalid_attestations
|
dossiers_with_invalid_attestations = find_dossiers_with_sent_and_invalid_attestations
|
||||||
fix_templates
|
fix_templates
|
||||||
fixed_attestations = delete_then_regenerate_attestations(dossiers_with_invalid_attestations)
|
delete_then_regenerate_attestations(dossiers_with_invalid_attestations)
|
||||||
send_regenerated_attestations(dossiers_with_invalid_attestations)
|
send_regenerated_attestations(dossiers_with_invalid_attestations)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace :'2018_09_12_fix_templates' do
|
||||||
.each do |instance|
|
.each do |instance|
|
||||||
|
|
||||||
instance.update(body: instance.body.gsub("--libellé procédure--", "--libellé démarche--"))
|
instance.update(body: instance.body.gsub("--libellé procédure--", "--libellé démarche--"))
|
||||||
rake_puts "Body mis-à-jour pour #{klass.to_s}##{instance.id}"
|
rake_puts "Body mis-à-jour pour #{klass}##{instance.id}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
task :create_admin, [:email] => :environment do |t, args|
|
task :create_admin, [:email] => :environment do |_t, args|
|
||||||
email = args[:email]
|
email = args[:email]
|
||||||
puts "Creating Administration for #{email}"
|
puts "Creating Administration for #{email}"
|
||||||
a = Administration.new(email: email, password: Devise.friendly_token[0,20])
|
a = Administration.new(email: email, password: Devise.friendly_token[0, 20])
|
||||||
if a.save
|
if a.save
|
||||||
puts "#{a.email} created"
|
puts "#{a.email} created"
|
||||||
else
|
else
|
||||||
|
@ -17,7 +17,7 @@ namespace :admin do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :delete_admin, [:email] => :environment do |t, args|
|
task :delete_admin, [:email] => :environment do |_t, args|
|
||||||
email = args[:email]
|
email = args[:email]
|
||||||
puts "Deleting Administration for #{email}"
|
puts "Deleting Administration for #{email}"
|
||||||
a = Administration.find_by(email: email)
|
a = Administration.find_by(email: email)
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace :after_party do
|
||||||
def remove_footer(template)
|
def remove_footer(template)
|
||||||
matches = template.body.match(FOOTER_REGEXP)
|
matches = template.body.match(FOOTER_REGEXP)
|
||||||
if matches && FOOTER_EXCEPTIONS.none? { |exception| matches[0].include?(exception) }
|
if matches && FOOTER_EXCEPTIONS.none? { |exception| matches[0].include?(exception) }
|
||||||
rake_puts "#{template.model_name.to_s} \##{template.id}: removing footer"
|
rake_puts "#{template.model_name} \##{template.id}: removing footer"
|
||||||
template.update(body: matches.pre_match)
|
template.update(body: matches.pre_match)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace :after_party do
|
||||||
.each do |instance|
|
.each do |instance|
|
||||||
|
|
||||||
instance.update(subject: instance.subject.gsub("--libellé procédure--", "--libellé démarche--"))
|
instance.update(subject: instance.subject.gsub("--libellé procédure--", "--libellé démarche--"))
|
||||||
rake_puts "Subject mis-à-jour pour #{klass.to_s}##{instance.id}"
|
rake_puts "Subject mis-à-jour pour #{klass}##{instance.id}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
subject { delete :destroy, params: { id: procedure_not_owned.id } }
|
subject { delete :destroy, params: { id: procedure_not_owned.id } }
|
||||||
|
|
||||||
it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
subject { get :new_from_existing }
|
subject { get :new_from_existing }
|
||||||
let(:grouped_procedures) { subject; assigns(:grouped_procedures) }
|
let(:grouped_procedures) { subject; assigns(:grouped_procedures) }
|
||||||
let(:response_procedures) { grouped_procedures.map{ |o, procedures| procedures }.flatten }
|
let(:response_procedures) { grouped_procedures.map { |_o, procedures| procedures }.flatten }
|
||||||
|
|
||||||
describe 'selecting' do
|
describe 'selecting' do
|
||||||
let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) }
|
let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) }
|
||||||
|
@ -542,8 +542,8 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
|
|
||||||
it 'groups procedures with services as well as procedures with organisations' do
|
it 'groups procedures with services as well as procedures with organisations' do
|
||||||
expect(grouped_procedures.length).to eq 2
|
expect(grouped_procedures.length).to eq 2
|
||||||
expect(grouped_procedures.find{ |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1)
|
expect(grouped_procedures.find { |o, _p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1)
|
||||||
expect(grouped_procedures.find{ |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service)
|
expect(grouped_procedures.find { |o, _p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe ApplicationController, type: :controller do
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
before_actions = ApplicationController
|
before_actions = ApplicationController
|
||||||
._process_action_callbacks
|
._process_action_callbacks
|
||||||
.find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
|
.find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||||
.map(&:filter)
|
.map(&:filter)
|
||||||
|
|
||||||
expect(before_actions).to include(:set_raven_context)
|
expect(before_actions).to include(:set_raven_context)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
describe Manager::AdministrateursController, type: :controller do
|
describe Manager::AdministrateursController, type: :controller do
|
||||||
let(:administration){ create(:administration) }
|
let(:administration) { create(:administration) }
|
||||||
|
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
let(:email) { 'plop@plop.com' }
|
let(:email) { 'plop@plop.com' }
|
||||||
|
|
|
@ -3,7 +3,7 @@ describe NewAdministrateur::AdministrateurController, type: :controller do
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
before_actions = NewAdministrateur::AdministrateurController
|
before_actions = NewAdministrateur::AdministrateurController
|
||||||
._process_action_callbacks
|
._process_action_callbacks
|
||||||
.find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
|
.find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||||
.map(&:filter)
|
.map(&:filter)
|
||||||
|
|
||||||
expect(before_actions).to include(:authenticate_administrateur!)
|
expect(before_actions).to include(:authenticate_administrateur!)
|
||||||
|
|
|
@ -118,7 +118,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
||||||
delete :destroy, params: { id: service.id, procedure_id: 12 }
|
delete :destroy, params: { id: service.id, procedure_id: 12 }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect{ service.reload }.to raise_error(ActiveRecord::RecordNotFound) }
|
it { expect { service.reload }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||||
it { expect(flash.alert).to be_nil }
|
it { expect(flash.alert).to be_nil }
|
||||||
it { expect(flash.notice).to eq("#{service.nom} est supprimé") }
|
it { expect(flash.notice).to eq("#{service.nom} est supprimé") }
|
||||||
it { expect(response).to redirect_to(services_path(procedure_id: 12)) }
|
it { expect(response).to redirect_to(services_path(procedure_id: 12)) }
|
||||||
|
|
|
@ -412,7 +412,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
subject { delete :purge_champ_piece_justificative, params: { procedure_id: champ.dossier.procedure.id, dossier_id: champ.dossier.id, champ_id: champ.id }, format: :js }
|
subject { delete :purge_champ_piece_justificative, params: { procedure_id: champ.dossier.procedure.id, dossier_id: champ.dossier.id, champ_id: champ.id }, format: :js }
|
||||||
|
|
||||||
context 'when gestionnaire can process dossier' do
|
context 'when gestionnaire can process dossier' do
|
||||||
let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
|
let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
|
||||||
|
|
||||||
it { is_expected.to have_http_status(200) }
|
it { is_expected.to have_http_status(200) }
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'but champ is not linked to this dossier' do
|
context 'but champ is not linked to this dossier' do
|
||||||
let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier), private: true) }
|
let(:champ) { create(:champ_piece_justificative, dossier: create(:dossier), private: true) }
|
||||||
|
|
||||||
it { is_expected.to redirect_to(root_path) }
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
||||||
|
@ -434,8 +434,8 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when gestionnaire cannot process dossier' do
|
context 'when gestionnaire cannot process dossier' do
|
||||||
let(:dossier){ create(:dossier, procedure: create(:procedure)) }
|
let(:dossier) { create(:dossier, procedure: create(:procedure)) }
|
||||||
let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
|
let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
|
||||||
|
|
||||||
it { is_expected.to redirect_to(root_path) }
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe NewGestionnaire::GestionnaireController, type: :controller do
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
before_actions = NewGestionnaire::GestionnaireController
|
before_actions = NewGestionnaire::GestionnaireController
|
||||||
._process_action_callbacks
|
._process_action_callbacks
|
||||||
.find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
|
.find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||||
.map(&:filter)
|
.map(&:filter)
|
||||||
|
|
||||||
expect(before_actions).to include(:authenticate_gestionnaire!)
|
expect(before_actions).to include(:authenticate_gestionnaire!)
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
||||||
it "is present" do
|
it "is present" do
|
||||||
before_actions = NewGestionnaire::ProceduresController
|
before_actions = NewGestionnaire::ProceduresController
|
||||||
._process_action_callbacks
|
._process_action_callbacks
|
||||||
.find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
|
.find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||||
.map(&:filter)
|
.map(&:filter)
|
||||||
|
|
||||||
expect(before_actions).to include(:ensure_ownership!)
|
expect(before_actions).to include(:ensure_ownership!)
|
||||||
|
@ -46,7 +46,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
||||||
it "is present" do
|
it "is present" do
|
||||||
before_actions = NewGestionnaire::ProceduresController
|
before_actions = NewGestionnaire::ProceduresController
|
||||||
._process_action_callbacks
|
._process_action_callbacks
|
||||||
.find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
|
.find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||||
.map(&:filter)
|
.map(&:filter)
|
||||||
|
|
||||||
expect(before_actions).to include(:redirect_to_avis_if_needed)
|
expect(before_actions).to include(:redirect_to_avis_if_needed)
|
||||||
|
@ -253,10 +253,10 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'statut' do
|
describe 'statut' do
|
||||||
let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
|
let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
|
||||||
let!(:new_followed_dossier) { Timecop.freeze(2.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
|
let!(:new_followed_dossier) { Timecop.freeze(2.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
|
||||||
let!(:termine_dossier) { Timecop.freeze(3.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } }
|
let!(:termine_dossier) { Timecop.freeze(3.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } }
|
||||||
let!(:archived_dossier) { Timecop.freeze(4.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } }
|
let!(:archived_dossier) { Timecop.freeze(4.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
gestionnaire.followed_dossiers << new_followed_dossier
|
gestionnaire.followed_dossiers << new_followed_dossier
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
it 'are present' do
|
it 'are present' do
|
||||||
before_actions = NewUser::DossiersController
|
before_actions = NewUser::DossiersController
|
||||||
._process_action_callbacks
|
._process_action_callbacks
|
||||||
.find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
|
.find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||||
.map(&:filter)
|
.map(&:filter)
|
||||||
|
|
||||||
expect(before_actions).to include(:ensure_ownership!, :ensure_ownership_or_invitation!, :forbid_invite_submission!)
|
expect(before_actions).to include(:ensure_ownership!, :ensure_ownership_or_invitation!, :forbid_invite_submission!)
|
||||||
|
@ -913,8 +913,8 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
subject { delete :purge_champ_piece_justificative, params: { id: champ.dossier.id, champ_id: champ.id }, format: :js }
|
subject { delete :purge_champ_piece_justificative, params: { id: champ.dossier.id, champ_id: champ.id }, format: :js }
|
||||||
|
|
||||||
context 'when dossier is owned by user' do
|
context 'when dossier is owned by user' do
|
||||||
let(:dossier){ create(:dossier, user: user) }
|
let(:dossier) { create(:dossier, user: user) }
|
||||||
let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) }
|
let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) }
|
||||||
|
|
||||||
it { is_expected.to have_http_status(200) }
|
it { is_expected.to have_http_status(200) }
|
||||||
|
|
||||||
|
@ -924,7 +924,7 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'but champ is not linked to this dossier' do
|
context 'but champ is not linked to this dossier' do
|
||||||
let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier)) }
|
let(:champ) { create(:champ_piece_justificative, dossier: create(:dossier)) }
|
||||||
|
|
||||||
it { is_expected.to redirect_to(root_path) }
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
||||||
|
@ -936,8 +936,8 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier is not owned by user' do
|
context 'when dossier is not owned by user' do
|
||||||
let(:dossier){ create(:dossier, user: create(:user)) }
|
let(:dossier) { create(:dossier, user: create(:user)) }
|
||||||
let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) }
|
let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) }
|
||||||
|
|
||||||
it { is_expected.to redirect_to(root_path) }
|
it { is_expected.to redirect_to(root_path) }
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe NewUser::UserController, type: :controller do
|
||||||
it 'is present' do
|
it 'is present' do
|
||||||
before_actions = NewUser::UserController
|
before_actions = NewUser::UserController
|
||||||
._process_action_callbacks
|
._process_action_callbacks
|
||||||
.find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
|
.find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||||
.map(&:filter)
|
.map(&:filter)
|
||||||
|
|
||||||
expect(before_actions).to include(:authenticate_user!)
|
expect(before_actions).to include(:authenticate_user!)
|
||||||
|
|
|
@ -116,7 +116,7 @@ describe StatsController, type: :controller do
|
||||||
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_4)
|
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_4)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:association){ Procedure.all }
|
let(:association) { Procedure.all }
|
||||||
|
|
||||||
subject { StatsController.new.send(:procedures_count_per_administrateur, association) }
|
subject { StatsController.new.send(:procedures_count_per_administrateur, association) }
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_piece_justificative_file do
|
trait :with_piece_justificative_file do
|
||||||
after(:create) do |champ, evaluator|
|
after(:create) do |champ, _evaluator|
|
||||||
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -147,7 +147,7 @@ FactoryBot.define do
|
||||||
factory :champ_piece_justificative, class: 'Champs::PieceJustificativeChamp' do
|
factory :champ_piece_justificative, class: 'Champs::PieceJustificativeChamp' do
|
||||||
type_de_champ { create(:type_de_champ_piece_justificative) }
|
type_de_champ { create(:type_de_champ_piece_justificative) }
|
||||||
|
|
||||||
after(:create) do |champ, evaluator|
|
after(:create) do |champ, _evaluator|
|
||||||
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -161,7 +161,7 @@ FactoryBot.define do
|
||||||
association :etablissement, factory: [:etablissement]
|
association :etablissement, factory: [:etablissement]
|
||||||
value { '44011762001530' }
|
value { '44011762001530' }
|
||||||
|
|
||||||
after(:build) do |champ, evaluator|
|
after(:build) do |champ, _evaluator|
|
||||||
champ.etablissement.signature = champ.etablissement.sign
|
champ.etablissement.signature = champ.etablissement.sign
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,8 +16,8 @@ FactoryBot.define do
|
||||||
dossiers_count { 1 }
|
dossiers_count { 1 }
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, evaluator|
|
||||||
procedure.dossiers << create_list(:dossier, _evaluator.dossiers_count, procedure: procedure)
|
procedure.dossiers << create_list(:dossier, evaluator.dossiers_count, procedure: procedure)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ feature 'The gestionnaire part' do
|
||||||
avis = dossier.avis.first
|
avis = dossier.avis.first
|
||||||
test_mail(expert_email, sign_up_gestionnaire_avis_path(avis, expert_email))
|
test_mail(expert_email, sign_up_gestionnaire_avis_path(avis, expert_email))
|
||||||
|
|
||||||
avis_sign_up(avis, expert_email, 'a good password')
|
avis_sign_up(avis, expert_email)
|
||||||
|
|
||||||
expect(page).to have_current_path(gestionnaire_avis_index_path)
|
expect(page).to have_current_path(gestionnaire_avis_index_path)
|
||||||
expect(page).to have_text('avis à donner 1')
|
expect(page).to have_text('avis à donner 1')
|
||||||
|
@ -225,7 +225,7 @@ feature 'The gestionnaire part' do
|
||||||
texts.each { |text| expect(page).to have_text(text) }
|
texts.each { |text| expect(page).to have_text(text) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def avis_sign_up(avis, email, password)
|
def avis_sign_up(avis, email)
|
||||||
visit sign_up_gestionnaire_avis_path(avis, email)
|
visit sign_up_gestionnaire_avis_path(avis, email)
|
||||||
fill_in 'gestionnaire_password', with: 'a good password'
|
fill_in 'gestionnaire_password', with: 'a good password'
|
||||||
click_on 'Créer un compte'
|
click_on 'Créer un compte'
|
||||||
|
|
|
@ -10,21 +10,21 @@ RSpec.describe ConservationDeDonneesHelper, type: :helper do
|
||||||
let(:dans_ds) { 3 }
|
let(:dans_ds) { 3 }
|
||||||
let(:hors_ds) { 6 }
|
let(:hors_ds) { 6 }
|
||||||
|
|
||||||
it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois", "Par l’administration : 6 mois" ]) }
|
it { is_expected.to eq(["Dans demarches-simplifiees.fr : 3 mois", "Par l’administration : 6 mois"]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when only in-app retention time is set" do
|
context "when only in-app retention time is set" do
|
||||||
let(:dans_ds) { 3 }
|
let(:dans_ds) { 3 }
|
||||||
let(:hors_ds) { nil }
|
let(:hors_ds) { nil }
|
||||||
|
|
||||||
it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois" ]) }
|
it { is_expected.to eq(["Dans demarches-simplifiees.fr : 3 mois"]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when only out of app retention time is set" do
|
context "when only out of app retention time is set" do
|
||||||
let(:dans_ds) { nil }
|
let(:dans_ds) { nil }
|
||||||
let(:hors_ds) { 6 }
|
let(:hors_ds) { 6 }
|
||||||
|
|
||||||
it { is_expected.to eq([ "Par l’administration : 6 mois" ]) }
|
it { is_expected.to eq(["Par l’administration : 6 mois"]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the retention time is not set" do
|
context "when the retention time is not set" do
|
||||||
|
|
|
@ -14,21 +14,21 @@ RSpec.describe Avis, type: :model do
|
||||||
subject { avis.email_to_display }
|
subject { avis.email_to_display }
|
||||||
|
|
||||||
context 'when gestionnaire is not known' do
|
context 'when gestionnaire is not known' do
|
||||||
it{ is_expected.to eq(invited_email) }
|
it { is_expected.to eq(invited_email) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when gestionnaire is known' do
|
context 'when gestionnaire is known' do
|
||||||
let!(:avis) { create(:avis, email: nil, gestionnaire: create(:gestionnaire), dossier: create(:dossier)) }
|
let!(:avis) { create(:avis, email: nil, gestionnaire: create(:gestionnaire), dossier: create(:dossier)) }
|
||||||
|
|
||||||
it{ is_expected.to eq(avis.gestionnaire.email) }
|
it { is_expected.to eq(avis.gestionnaire.email) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.by_latest' do
|
describe '.by_latest' do
|
||||||
context 'with 3 avis' do
|
context 'with 3 avis' do
|
||||||
let!(:avis){ create(:avis) }
|
let!(:avis) { create(:avis) }
|
||||||
let!(:avis2){ create(:avis, updated_at: 4.hours.ago) }
|
let!(:avis2) { create(:avis, updated_at: 4.hours.ago) }
|
||||||
let!(:avis3){ create(:avis, updated_at: 3.hours.ago) }
|
let!(:avis3) { create(:avis, updated_at: 3.hours.ago) }
|
||||||
|
|
||||||
subject { Avis.by_latest }
|
subject { Avis.by_latest }
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ RSpec.describe Avis, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".link_avis_to_gestionnaire" do
|
describe ".link_avis_to_gestionnaire" do
|
||||||
let(:gestionnaire){ create(:gestionnaire) }
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
|
|
||||||
subject{ Avis.link_avis_to_gestionnaire(gestionnaire) }
|
subject { Avis.link_avis_to_gestionnaire(gestionnaire) }
|
||||||
|
|
||||||
context 'when there are 2 avis linked by email to a gestionnaire' do
|
context 'when there are 2 avis linked by email to a gestionnaire' do
|
||||||
let!(:avis){ create(:avis, email: gestionnaire.email, gestionnaire: nil) }
|
let!(:avis) { create(:avis, email: gestionnaire.email, gestionnaire: nil) }
|
||||||
let!(:avis2){ create(:avis, email: gestionnaire.email, gestionnaire: nil) }
|
let!(:avis2) { create(:avis, email: gestionnaire.email, gestionnaire: nil) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject
|
subject
|
||||||
|
|
|
@ -128,7 +128,7 @@ describe Champ do
|
||||||
let(:type_de_champ) { build(:type_de_champ_address) }
|
let(:type_de_champ) { build(:type_de_champ_address) }
|
||||||
let(:value) { "10 rue du Pinson qui Piaille" }
|
let(:value) { "10 rue du Pinson qui Piaille" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for checkbox champ' do
|
context 'for checkbox champ' do
|
||||||
|
@ -138,7 +138,7 @@ describe Champ do
|
||||||
context 'when the box is checked' do
|
context 'when the box is checked' do
|
||||||
let(:value) { 'on' }
|
let(:value) { 'on' }
|
||||||
|
|
||||||
it { is_expected.to eq([ libelle ]) }
|
it { is_expected.to eq([libelle]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the box is unchecked' do
|
context 'when the box is unchecked' do
|
||||||
|
@ -152,7 +152,7 @@ describe Champ do
|
||||||
let(:type_de_champ) { build(:type_de_champ_civilite) }
|
let(:type_de_champ) { build(:type_de_champ_civilite) }
|
||||||
let(:value) { "M." }
|
let(:value) { "M." }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for date champ' do
|
context 'for date champ' do
|
||||||
|
@ -173,28 +173,28 @@ describe Champ do
|
||||||
let(:type_de_champ) { build(:type_de_champ_departements) }
|
let(:type_de_champ) { build(:type_de_champ_departements) }
|
||||||
let(:value) { "69 - Rhône" }
|
let(:value) { "69 - Rhône" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for dossier link champ' do
|
context 'for dossier link champ' do
|
||||||
let(:type_de_champ) { build(:type_de_champ_dossier_link) }
|
let(:type_de_champ) { build(:type_de_champ_dossier_link) }
|
||||||
let(:value) { "9103132886" }
|
let(:value) { "9103132886" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for drop down list champ' do
|
context 'for drop down list champ' do
|
||||||
let(:type_de_champ) { build(:type_de_champ_dossier_link) }
|
let(:type_de_champ) { build(:type_de_champ_dossier_link) }
|
||||||
let(:value) { "HLM" }
|
let(:value) { "HLM" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for email champ' do
|
context 'for email champ' do
|
||||||
let(:type_de_champ) { build(:type_de_champ_email) }
|
let(:type_de_champ) { build(:type_de_champ_email) }
|
||||||
let(:value) { "machin@example.com" }
|
let(:value) { "machin@example.com" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for engagement champ' do
|
context 'for engagement champ' do
|
||||||
|
@ -204,7 +204,7 @@ describe Champ do
|
||||||
context 'when the box is checked' do
|
context 'when the box is checked' do
|
||||||
let(:value) { 'on' }
|
let(:value) { 'on' }
|
||||||
|
|
||||||
it { is_expected.to eq([ libelle ]) }
|
it { is_expected.to eq([libelle]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the box is unchecked' do
|
context 'when the box is unchecked' do
|
||||||
|
@ -239,7 +239,7 @@ describe Champ do
|
||||||
let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list) }
|
let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list) }
|
||||||
|
|
||||||
context 'when there are multiple values selected' do
|
context 'when there are multiple values selected' do
|
||||||
let(:value) { JSON.generate([ 'goodbye', 'cruel', 'world' ]) }
|
let(:value) { JSON.generate(['goodbye', 'cruel', 'world']) }
|
||||||
|
|
||||||
it { is_expected.to eq(["goodbye", "cruel", "world"]) }
|
it { is_expected.to eq(["goodbye", "cruel", "world"]) }
|
||||||
end
|
end
|
||||||
|
@ -255,21 +255,21 @@ describe Champ do
|
||||||
let(:type_de_champ) { build(:type_de_champ_number) }
|
let(:type_de_champ) { build(:type_de_champ_number) }
|
||||||
let(:value) { "1234" }
|
let(:value) { "1234" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for pays champ' do
|
context 'for pays champ' do
|
||||||
let(:type_de_champ) { build(:type_de_champ_pays) }
|
let(:type_de_champ) { build(:type_de_champ_pays) }
|
||||||
let(:value) { "FRANCE" }
|
let(:value) { "FRANCE" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for phone champ' do
|
context 'for phone champ' do
|
||||||
let(:type_de_champ) { build(:type_de_champ_phone) }
|
let(:type_de_champ) { build(:type_de_champ_phone) }
|
||||||
let(:value) { "0606060606" }
|
let(:value) { "0606060606" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for pièce justificative champ' do
|
context 'for pièce justificative champ' do
|
||||||
|
@ -283,7 +283,7 @@ describe Champ do
|
||||||
let(:type_de_champ) { build(:type_de_champ_regions) }
|
let(:type_de_champ) { build(:type_de_champ_regions) }
|
||||||
let(:value) { "Île-de-France" }
|
let(:value) { "Île-de-France" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for siret champ' do
|
context 'for siret champ' do
|
||||||
|
@ -325,14 +325,14 @@ describe Champ do
|
||||||
end
|
end
|
||||||
let(:champ) { type_de_champ.champ.build(value: etablissement.siret, etablissement: etablissement) }
|
let(:champ) { type_de_champ.champ.build(value: etablissement.siret, etablissement: etablissement) }
|
||||||
|
|
||||||
it { is_expected.to eq([ etablissement.entreprise_siren, etablissement.entreprise_numero_tva_intracommunautaire, etablissement.entreprise_forme_juridique, etablissement.entreprise_forme_juridique_code, etablissement.entreprise_nom_commercial, etablissement.entreprise_raison_sociale, etablissement.entreprise_siret_siege_social, etablissement.entreprise_nom, etablissement.entreprise_prenom, etablissement.association_rna, etablissement.association_titre, etablissement.association_objet, etablissement.siret, etablissement.naf, etablissement.libelle_naf, etablissement.adresse, etablissement.code_postal, etablissement.localite, etablissement.code_insee_localite ]) }
|
it { is_expected.to eq([etablissement.entreprise_siren, etablissement.entreprise_numero_tva_intracommunautaire, etablissement.entreprise_forme_juridique, etablissement.entreprise_forme_juridique_code, etablissement.entreprise_nom_commercial, etablissement.entreprise_raison_sociale, etablissement.entreprise_siret_siege_social, etablissement.entreprise_nom, etablissement.entreprise_prenom, etablissement.association_rna, etablissement.association_titre, etablissement.association_objet, etablissement.siret, etablissement.naf, etablissement.libelle_naf, etablissement.adresse, etablissement.code_postal, etablissement.localite, etablissement.code_insee_localite]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when there is no etablissement' do
|
context 'when there is no etablissement' do
|
||||||
let(:siret) { "35130347400024" }
|
let(:siret) { "35130347400024" }
|
||||||
let(:champ) { type_de_champ.champ.build(value: siret) }
|
let(:champ) { type_de_champ.champ.build(value: siret) }
|
||||||
|
|
||||||
it { is_expected.to eq([ siret ]) }
|
it { is_expected.to eq([siret]) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -340,14 +340,14 @@ describe Champ do
|
||||||
let(:type_de_champ) { build(:type_de_champ_text) }
|
let(:type_de_champ) { build(:type_de_champ_text) }
|
||||||
let(:value) { "Blah" }
|
let(:value) { "Blah" }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for text area champ' do
|
context 'for text area champ' do
|
||||||
let(:type_de_champ) { build(:type_de_champ_textarea) }
|
let(:type_de_champ) { build(:type_de_champ_textarea) }
|
||||||
let(:value) { "Bla\nBlah de bla." }
|
let(:value) { "Bla\nBlah de bla." }
|
||||||
|
|
||||||
it { is_expected.to eq([ value ]) }
|
it { is_expected.to eq([value]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for yes/no champ' do
|
context 'for yes/no champ' do
|
||||||
|
@ -357,7 +357,7 @@ describe Champ do
|
||||||
context 'when the box is checked' do
|
context 'when the box is checked' do
|
||||||
let(:value) { "true" }
|
let(:value) { "true" }
|
||||||
|
|
||||||
it { is_expected.to eq([ libelle ]) }
|
it { is_expected.to eq([libelle]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the box is unchecked' do
|
context 'when the box is unchecked' do
|
||||||
|
@ -385,18 +385,18 @@ describe Champ do
|
||||||
context 'and there is a blob' do
|
context 'and there is a blob' do
|
||||||
before { champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain") }
|
before { champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain") }
|
||||||
|
|
||||||
it { expect{ champ.save }.to change(VirusScan, :count).by(1) }
|
it { expect { champ.save }.to change(VirusScan, :count).by(1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and there is no blob' do
|
context 'and there is no blob' do
|
||||||
it { expect{ champ.save }.to_not change(VirusScan, :count) }
|
it { expect { champ.save }.to_not change(VirusScan, :count) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when type_champ is not type_de_champ_piece_justificative' do
|
context 'when type_champ is not type_de_champ_piece_justificative' do
|
||||||
let(:type_de_champ) { create(:type_de_champ_textarea) }
|
let(:type_de_champ) { create(:type_de_champ_textarea) }
|
||||||
|
|
||||||
it { expect{ champ.save }.to_not change(VirusScan, :count) }
|
it { expect { champ.save }.to_not change(VirusScan, :count) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -95,14 +95,14 @@ describe Gestionnaire, type: :model do
|
||||||
let(:procedure_to_assign) { procedure_3 }
|
let(:procedure_to_assign) { procedure_3 }
|
||||||
|
|
||||||
it { is_expected.to be_truthy }
|
it { is_expected.to be_truthy }
|
||||||
it { expect{ subject }.to change(gestionnaire.procedures, :count) }
|
it { expect { subject }.to change(gestionnaire.procedures, :count) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with an already assigned procedure" do
|
context "with an already assigned procedure" do
|
||||||
let(:procedure_to_assign) { procedure }
|
let(:procedure_to_assign) { procedure }
|
||||||
|
|
||||||
it { is_expected.to be_falsey }
|
it { is_expected.to be_falsey }
|
||||||
it { expect{ subject }.not_to change(gestionnaire.procedures, :count) }
|
it { expect { subject }.not_to change(gestionnaire.procedures, :count) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe Invite do
|
||||||
create(:invite, email: email1, dossier: dossier2)
|
create(:invite, email: email1, dossier: dossier2)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect{ subject }.to change(Invite, :count).by(2) }
|
it { expect { subject }.to change(Invite, :count).by(2) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when an email is invite twice on a dossier' do
|
context 'when an email is invite twice on a dossier' do
|
||||||
|
@ -22,7 +22,7 @@ describe Invite do
|
||||||
create(:invite, email: email1, dossier: dossier1)
|
create(:invite, email: email1, dossier: dossier1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect{ subject }.to raise_error ActiveRecord::RecordInvalid }
|
it { expect { subject }.to raise_error ActiveRecord::RecordInvalid }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "email validation" do
|
context "email validation" do
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe ProcedurePresentation do
|
||||||
{ "label" => "test1", "table" => "user", "column" => "email" },
|
{ "label" => "test1", "table" => "user", "column" => "email" },
|
||||||
{ "label" => "test2", "table" => "type_de_champ", "column" => first_type_de_champ_id }
|
{ "label" => "test2", "table" => "type_de_champ", "column" => first_type_de_champ_id }
|
||||||
],
|
],
|
||||||
sort: { "table" => "user","column" => "email","order" => "asc" },
|
sort: { "table" => "user", "column" => "email", "order" => "asc" },
|
||||||
filters: { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] }
|
filters: { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] }
|
||||||
).id
|
).id
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ describe ProcedurePresentation do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#sort" do
|
describe "#sort" do
|
||||||
it { expect(procedure_presentation.sort).to eq({ "table" => "user","column" => "email","order" => "asc" }) }
|
it { expect(procedure_presentation.sort).to eq({ "table" => "user", "column" => "email", "order" => "asc" }) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#filters" do
|
describe "#filters" do
|
||||||
|
@ -78,10 +78,10 @@ describe ProcedurePresentation do
|
||||||
}
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
procedure.types_de_champ[2].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:header_section))
|
procedure.types_de_champ[2].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:header_section))
|
||||||
procedure.types_de_champ[3].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:explication))
|
procedure.types_de_champ[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication))
|
||||||
procedure.types_de_champ_private[2].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:header_section))
|
procedure.types_de_champ_private[2].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:header_section))
|
||||||
procedure.types_de_champ_private[3].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:explication))
|
procedure.types_de_champ_private[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication))
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { create(:procedure_presentation, assign_to: create(:assign_to, procedure: procedure)) }
|
subject { create(:procedure_presentation, assign_to: create(:assign_to, procedure: procedure)) }
|
||||||
|
|
|
@ -537,7 +537,7 @@ describe Procedure do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#default_path' do
|
describe '#default_path' do
|
||||||
let(:procedure){ create(:procedure, libelle: 'A long libelle with àccênts, blabla coucou hello un deux trois voila') }
|
let(:procedure) { create(:procedure, libelle: 'A long libelle with àccênts, blabla coucou hello un deux trois voila') }
|
||||||
|
|
||||||
subject { procedure.default_path }
|
subject { procedure.default_path }
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ describe Service, type: :model do
|
||||||
|
|
||||||
context 'of type_organisme' do
|
context 'of type_organisme' do
|
||||||
it 'should belong to the enum' do
|
it 'should belong to the enum' do
|
||||||
expect{ Service.new(params.merge(type_organisme: 'choucroute')) }.to raise_error(ArgumentError)
|
expect { Service.new(params.merge(type_organisme: 'choucroute')) }.to raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -96,13 +96,13 @@ describe TypesDeChamp::LinkedDropDownListTypeDeChamp do
|
||||||
expect(subject.secondary_options).to eq(
|
expect(subject.secondary_options).to eq(
|
||||||
{
|
{
|
||||||
'' => [],
|
'' => [],
|
||||||
'Primary 1' => [ '', 'secondary 1.1', 'secondary 1.2'],
|
'Primary 1' => ['', 'secondary 1.1', 'secondary 1.2'],
|
||||||
'Primary 2' => [ '', 'secondary 2.1', 'secondary 2.2', 'secondary 2.3']
|
'Primary 2' => ['', 'secondary 2.1', 'secondary 2.2', 'secondary 2.3']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject.primary_options).to eq([ '', 'Primary 1', 'Primary 2' ]) }
|
it { expect(subject.primary_options).to eq(['', 'Primary 1', 'Primary 2']) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,12 +8,12 @@ describe RenderPartialService do
|
||||||
describe 'navbar' do
|
describe 'navbar' do
|
||||||
subject { service.navbar }
|
subject { service.navbar }
|
||||||
|
|
||||||
it { is_expected.to eq "layouts/navbars/navbar_#{controller.to_s.parameterize}_#{method.to_s}" }
|
it { is_expected.to eq "layouts/navbars/navbar_#{controller.to_s.parameterize}_#{method}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'left_panel' do
|
describe 'left_panel' do
|
||||||
subject { service.left_panel }
|
subject { service.left_panel }
|
||||||
|
|
||||||
it { is_expected.to eq "layouts/left_panels/left_panel_#{controller.to_s.parameterize}_#{method.to_s}" }
|
it { is_expected.to eq "layouts/left_panels/left_panel_#{controller.to_s.parameterize}_#{method}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue