Merge branch 'dev'
This commit is contained in:
commit
162a85c14a
29 changed files with 285 additions and 277 deletions
1
Gemfile
1
Gemfile
|
@ -164,6 +164,7 @@ group :development do
|
||||||
gem 'rubocop-rspec-focused', require: false
|
gem 'rubocop-rspec-focused', require: false
|
||||||
gem 'haml-lint'
|
gem 'haml-lint'
|
||||||
gem 'scss_lint', require: false
|
gem 'scss_lint', require: false
|
||||||
|
gem 'letter_opener_web'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|
|
@ -459,6 +459,12 @@ GEM
|
||||||
leaflet-markercluster-rails (0.7.0)
|
leaflet-markercluster-rails (0.7.0)
|
||||||
railties (>= 3.1)
|
railties (>= 3.1)
|
||||||
leaflet-rails (0.7.7)
|
leaflet-rails (0.7.7)
|
||||||
|
letter_opener (1.6.0)
|
||||||
|
launchy (~> 2.2)
|
||||||
|
letter_opener_web (1.3.4)
|
||||||
|
actionmailer (>= 3.2)
|
||||||
|
letter_opener (~> 1.0)
|
||||||
|
railties (>= 3.2)
|
||||||
listen (3.1.5)
|
listen (3.1.5)
|
||||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||||
rb-inotify (~> 0.9, >= 0.9.7)
|
rb-inotify (~> 0.9, >= 0.9.7)
|
||||||
|
@ -855,6 +861,7 @@ DEPENDENCIES
|
||||||
leaflet-draw-rails
|
leaflet-draw-rails
|
||||||
leaflet-markercluster-rails (~> 0.7.0)
|
leaflet-markercluster-rails (~> 0.7.0)
|
||||||
leaflet-rails
|
leaflet-rails
|
||||||
|
letter_opener_web
|
||||||
lograge
|
lograge
|
||||||
logstash-event
|
logstash-event
|
||||||
mailjet
|
mailjet
|
||||||
|
@ -906,4 +913,4 @@ DEPENDENCIES
|
||||||
zxcvbn-ruby
|
zxcvbn-ruby
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.4
|
1.16.5
|
||||||
|
|
1
Procfile
1
Procfile
|
@ -1,3 +1,2 @@
|
||||||
server: bin/rails server
|
server: bin/rails server
|
||||||
jobs: bin/delayed_job run
|
jobs: bin/delayed_job run
|
||||||
mails: mailcatcher -f
|
|
||||||
|
|
|
@ -77,7 +77,3 @@
|
||||||
padding-right: $default-spacer;
|
padding-right: $default-spacer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dossiers-table-empty {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
|
@ -45,3 +45,7 @@
|
||||||
margin: auto;
|
margin: auto;
|
||||||
max-width: $page-width / 2;
|
max-width: $page-width / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.blank-tab {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.highlighted {
|
.highlighted {
|
||||||
background: $orange-bg;
|
background: $orange-bg;
|
||||||
color: $black;
|
color: $black;
|
||||||
|
|
|
@ -67,10 +67,11 @@ module NewGestionnaire
|
||||||
@archived_dossiers
|
@archived_dossiers
|
||||||
end
|
end
|
||||||
|
|
||||||
sorted_ids = DossierFieldService.sorted_ids(@dossiers, procedure_presentation, current_gestionnaire)
|
dossier_field_service = DossierFieldService.new
|
||||||
|
sorted_ids = dossier_field_service.sorted_ids(@dossiers, procedure_presentation, current_gestionnaire)
|
||||||
|
|
||||||
if @current_filters.count > 0
|
if @current_filters.count > 0
|
||||||
filtered_ids = DossierFieldService.filtered_ids(@dossiers, current_filters)
|
filtered_ids = dossier_field_service.filtered_ids(@dossiers, current_filters)
|
||||||
filtered_sorted_ids = sorted_ids.select { |id| filtered_ids.include?(id) }
|
filtered_sorted_ids = sorted_ids.select { |id| filtered_ids.include?(id) }
|
||||||
else
|
else
|
||||||
filtered_sorted_ids = sorted_ids
|
filtered_sorted_ids = sorted_ids
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class ApiEntreprise::Adapter
|
class ApiEntreprise::Adapter
|
||||||
|
UNAVAILABLE = 'Donnée indisponible'
|
||||||
|
|
||||||
def initialize(siret, procedure_id)
|
def initialize(siret, procedure_id)
|
||||||
@siret = siret
|
@siret = siret
|
||||||
@procedure_id = procedure_id
|
@procedure_id = procedure_id
|
||||||
|
@ -17,4 +19,8 @@ class ApiEntreprise::Adapter
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def valid_params?(params)
|
||||||
|
!params.has_value?(UNAVAILABLE)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,10 +34,7 @@ class ApiEntreprise::API
|
||||||
params: params,
|
params: params,
|
||||||
timeout: TIMEOUT)
|
timeout: TIMEOUT)
|
||||||
|
|
||||||
# Responses with a 206 codes are sometimes not useable,
|
if response.success?
|
||||||
# as the RNA calls often return a 206 with an error message,
|
|
||||||
# not a partial response
|
|
||||||
if response.success? && response.code != 206
|
|
||||||
JSON.parse(response.body, symbolize_names: true)
|
JSON.parse(response.body, symbolize_names: true)
|
||||||
else
|
else
|
||||||
raise RestClient::ResourceNotFound
|
raise RestClient::ResourceNotFound
|
||||||
|
|
|
@ -8,8 +8,13 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
params = data_source[:entreprise].slice(*attr_to_fetch)
|
params = data_source[:entreprise].slice(*attr_to_fetch)
|
||||||
|
|
||||||
|
if valid_params?(params)
|
||||||
params[:date_creation] = Time.at(params[:date_creation]).to_datetime
|
params[:date_creation] = Time.at(params[:date_creation]).to_datetime
|
||||||
params.transform_keys { |k| :"entreprise_#{k}" }
|
params.transform_keys { |k| :"entreprise_#{k}" }
|
||||||
|
else
|
||||||
|
{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attr_to_fetch
|
def attr_to_fetch
|
||||||
|
|
|
@ -7,10 +7,15 @@ class ApiEntreprise::EtablissementAdapter < ApiEntreprise::Adapter
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
params = data_source[:etablissement].slice(*attr_to_fetch)
|
params = data_source[:etablissement].slice(*attr_to_fetch)
|
||||||
|
|
||||||
|
if valid_params?(params)
|
||||||
adresse_line = params[:adresse].slice(*address_lines_to_fetch).values.compact.join("\r\n")
|
adresse_line = params[:adresse].slice(*address_lines_to_fetch).values.compact.join("\r\n")
|
||||||
params.merge!(params[:adresse].slice(*address_attr_to_fetch))
|
params.merge!(params[:adresse].slice(*address_attr_to_fetch))
|
||||||
params[:adresse] = adresse_line
|
params[:adresse] = adresse_line
|
||||||
params
|
params
|
||||||
|
else
|
||||||
|
{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attr_to_fetch
|
def attr_to_fetch
|
||||||
|
|
|
@ -10,7 +10,11 @@ class ApiEntreprise::ExercicesAdapter < ApiEntreprise::Adapter
|
||||||
exercice.slice(*attr_to_fetch)
|
exercice.slice(*attr_to_fetch)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if exercices_array.all? { |params| valid_params?(params) }
|
||||||
{ exercices_attributes: exercices_array }
|
{ exercices_attributes: exercices_array }
|
||||||
|
else
|
||||||
|
{}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attr_to_fetch
|
def attr_to_fetch
|
||||||
|
|
|
@ -6,14 +6,25 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_params
|
def process_params
|
||||||
if data_source[:association][:id].present?
|
# Sometimes the associations endpoints responses with a 206,
|
||||||
|
# and these response are often useable as the they only
|
||||||
|
# contain an error message.
|
||||||
|
# Therefore here we make sure that our response seems valid
|
||||||
|
# by checking that there is an association attribute.
|
||||||
|
if !data_source.key?(:association)
|
||||||
|
{}
|
||||||
|
else
|
||||||
|
association_id = data_source[:association][:id]
|
||||||
params = data_source[:association].slice(*attr_to_fetch)
|
params = data_source[:association].slice(*attr_to_fetch)
|
||||||
params[:rna] = data_source[:association][:id]
|
|
||||||
|
if association_id.present? && valid_params?(params)
|
||||||
|
params[:rna] = association_id
|
||||||
params.transform_keys { |k| :"association_#{k}" }
|
params.transform_keys { |k| :"association_#{k}" }
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def attr_to_fetch
|
def attr_to_fetch
|
||||||
[
|
[
|
||||||
|
|
|
@ -223,10 +223,6 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_value(table, column)
|
|
||||||
DossierFieldService.get_value(self, table, column)
|
|
||||||
end
|
|
||||||
|
|
||||||
def owner_name
|
def owner_name
|
||||||
if etablissement.present?
|
if etablissement.present?
|
||||||
etablissement.entreprise_raison_sociale
|
etablissement.entreprise_raison_sociale
|
||||||
|
|
|
@ -293,7 +293,7 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def fields
|
def fields
|
||||||
DossierFieldService.fields(self)
|
DossierFieldService.new.fields(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fields_for_select
|
def fields_for_select
|
||||||
|
|
|
@ -16,7 +16,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
displayed_fields.each do |field|
|
displayed_fields.each do |field|
|
||||||
table = field['table']
|
table = field['table']
|
||||||
column = field['column']
|
column = field['column']
|
||||||
if !DossierFieldService.valid_column?(procedure, table, column)
|
if !dossier_field_service.valid_column?(procedure, table, column)
|
||||||
errors.add(:filters, "#{table}.#{column} n’est pas une colonne permise")
|
errors.add(:filters, "#{table}.#{column} n’est pas une colonne permise")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
columns.each do |column|
|
columns.each do |column|
|
||||||
table = column['table']
|
table = column['table']
|
||||||
column = column['column']
|
column = column['column']
|
||||||
if !DossierFieldService.valid_column?(procedure, table, column)
|
if !dossier_field_service.valid_column?(procedure, table, column)
|
||||||
errors.add(:filters, "#{table}.#{column} n’est pas une colonne permise")
|
errors.add(:filters, "#{table}.#{column} n’est pas une colonne permise")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -44,7 +44,11 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def dossier_field_service
|
||||||
|
@dossier_field_service ||= DossierFieldService.new
|
||||||
|
end
|
||||||
|
|
||||||
def valid_sort_column?(procedure, table, column)
|
def valid_sort_column?(procedure, table, column)
|
||||||
DossierFieldService.valid_column?(procedure, table, column) || EXTRA_SORT_COLUMNS[table]&.include?(column)
|
dossier_field_service.valid_column?(procedure, table, column) || EXTRA_SORT_COLUMNS[table]&.include?(column)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
class DossierFieldService
|
class DossierFieldService
|
||||||
@@column_whitelist = {}
|
def initialize
|
||||||
|
@column_whitelist = {}
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
|
||||||
def fields(procedure)
|
def fields(procedure)
|
||||||
fields = [
|
fields = [
|
||||||
field_hash('Créé le', 'self', 'created_at'),
|
field_hash('Créé le', 'self', 'created_at'),
|
||||||
|
@ -137,14 +138,14 @@ class DossierFieldService
|
||||||
private
|
private
|
||||||
|
|
||||||
def valid_columns_for_table(procedure, table)
|
def valid_columns_for_table(procedure, table)
|
||||||
if !@@column_whitelist.key?(procedure.id)
|
if !@column_whitelist.key?(procedure.id)
|
||||||
@@column_whitelist[procedure.id] = fields(procedure)
|
@column_whitelist[procedure.id] = fields(procedure)
|
||||||
.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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@column_whitelist[procedure.id][table] || []
|
@column_whitelist[procedure.id][table] || []
|
||||||
end
|
end
|
||||||
|
|
||||||
def sanitized_column(field)
|
def sanitized_column(field)
|
||||||
|
@ -168,5 +169,4 @@ class DossierFieldService
|
||||||
'column' => column
|
'column' => column
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
.send-wrapper
|
.send-wrapper
|
||||||
= f.submit 'Envoyer votre avis', class: 'button send'
|
= f.submit 'Envoyer votre avis', class: 'button send'
|
||||||
|
|
||||||
|
- if !@dossier.termine?
|
||||||
= render partial: "new_gestionnaire/shared/avis/form", locals: { url: avis_gestionnaire_avis_path(@avis), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis }
|
= render partial: "new_gestionnaire/shared/avis/form", locals: { url: avis_gestionnaire_avis_path(@avis), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis }
|
||||||
|
|
||||||
|
- if @dossier.avis_for(current_gestionnaire).present?
|
||||||
= render partial: 'new_gestionnaire/shared/avis/list', locals: { avis: @dossier.avis_for(current_gestionnaire), avis_seen_at: nil }
|
= render partial: 'new_gestionnaire/shared/avis/list', locals: { avis: @dossier.avis_for(current_gestionnaire), avis_seen_at: nil }
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
= render partial: "header", locals: { dossier: @dossier }
|
= render partial: "header", locals: { dossier: @dossier }
|
||||||
|
|
||||||
.container
|
.container
|
||||||
|
- if !@dossier.termine?
|
||||||
= render partial: "new_gestionnaire/shared/avis/form", locals: { url: avis_gestionnaire_dossier_path(@dossier.procedure, @dossier), must_be_confidentiel: false, avis: @avis }
|
= render partial: "new_gestionnaire/shared/avis/form", locals: { url: avis_gestionnaire_dossier_path(@dossier.procedure, @dossier), must_be_confidentiel: false, avis: @avis }
|
||||||
|
|
||||||
|
- if @dossier.avis.present?
|
||||||
= render partial: 'new_gestionnaire/shared/avis/list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at }
|
= render partial: 'new_gestionnaire/shared/avis/list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at }
|
||||||
|
|
||||||
|
- if @dossier.termine? && !@dossier.avis.present?
|
||||||
|
.blank-tab
|
||||||
|
%h2.empty-text Aucun avis.
|
||||||
|
%p.empty-text-details Aucun avis n'a été demandé sur ce dossier.
|
||||||
|
|
|
@ -92,6 +92,7 @@
|
||||||
= submit_tag "Enregistrer", class: 'button'
|
= submit_tag "Enregistrer", class: 'button'
|
||||||
|
|
||||||
%tbody
|
%tbody
|
||||||
|
- dossier_field_service = DossierFieldService.new
|
||||||
- @dossiers.each do |dossier|
|
- @dossiers.each do |dossier|
|
||||||
%tr
|
%tr
|
||||||
%td.folder-col
|
%td.folder-col
|
||||||
|
@ -107,7 +108,7 @@
|
||||||
- @displayed_fields.each do |field|
|
- @displayed_fields.each do |field|
|
||||||
%td
|
%td
|
||||||
= link_to(gestionnaire_dossier_path(@procedure, dossier), class: 'cell-link') do
|
= link_to(gestionnaire_dossier_path(@procedure, dossier), class: 'cell-link') do
|
||||||
= dossier.get_value(field['table'], field['column'])
|
= dossier_field_service.get_value(dossier, field['table'], field['column'])
|
||||||
|
|
||||||
%td.status-col
|
%td.status-col
|
||||||
= link_to(gestionnaire_dossier_path(@procedure, dossier), class: 'cell-link') do
|
= link_to(gestionnaire_dossier_path(@procedure, dossier), class: 'cell-link') do
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
- if avis.present?
|
%section.list-avis
|
||||||
%section.list-avis
|
|
||||||
%h1.tab-title
|
%h1.tab-title
|
||||||
Avis des invités
|
Avis des invités
|
||||||
%span.count= avis.count
|
%span.count= avis.count
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
%span.icon.smile
|
%span.icon.smile
|
||||||
|
|
||||||
- else
|
- else
|
||||||
.dossiers-table-empty
|
.blank-tab
|
||||||
%h2.empty-text Aucun dossier.
|
%h2.empty-text Aucun dossier.
|
||||||
%p.empty-text-details Vous n’avez pas encore commencé de démarche.
|
%p.empty-text-details Vous n’avez pas encore commencé de démarche.
|
||||||
= link_to "Commencer une nouvelle démarche", demarches_url, class: "button primary"
|
= link_to "Commencer une nouvelle démarche", demarches_url, class: "button primary"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
- if id.present?
|
- if id.present?
|
||||||
- dossier = current_user&.dossiers&.find_by(id: id)
|
- dossier = Dossier.find_by(id: id)
|
||||||
- dossier ||= current_gestionnaire&.dossiers&.find_by(id: id)
|
|
||||||
- dossier ||= current_administrateur&.dossiers&.find_by(id: id)
|
|
||||||
- if dossier.blank?
|
- if dossier.blank?
|
||||||
%p.text-warning
|
%p.text-warning
|
||||||
Ce dossier est inconnu
|
Ce dossier est inconnu
|
||||||
|
|
|
@ -13,9 +13,6 @@ chdir APP_ROOT do
|
||||||
# This script is a starting point to setup your application.
|
# This script is a starting point to setup your application.
|
||||||
# Add necessary setup steps to this file.
|
# Add necessary setup steps to this file.
|
||||||
|
|
||||||
puts '== Installing global tools =='
|
|
||||||
system! 'gem install mailcatcher --conservative'
|
|
||||||
|
|
||||||
puts "\n== Installing dependencies =="
|
puts "\n== Installing dependencies =="
|
||||||
system! 'gem install bundler --conservative'
|
system! 'gem install bundler --conservative'
|
||||||
system('bundle check') || system!('bundle install')
|
system('bundle check') || system!('bundle install')
|
||||||
|
|
|
@ -104,16 +104,6 @@ namespace :yarn do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :rails do
|
|
||||||
desc "Run deploy tasks."
|
|
||||||
task :after_party do
|
|
||||||
queue %{
|
|
||||||
echo "-----> Running deploy tasks"
|
|
||||||
#{echo_cmd %[bundle exec rake after_party:run]}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Deploys the current version to the server."
|
desc "Deploys the current version to the server."
|
||||||
task :deploy => :environment do
|
task :deploy => :environment do
|
||||||
queue 'export PATH=$PATH:/usr/local/rbenv/bin:/usr/local/rbenv/shims'
|
queue 'export PATH=$PATH:/usr/local/rbenv/bin:/usr/local/rbenv/shims'
|
||||||
|
@ -126,7 +116,7 @@ task :deploy => :environment do
|
||||||
invoke :'bundle:install'
|
invoke :'bundle:install'
|
||||||
invoke :'yarn:install'
|
invoke :'yarn:install'
|
||||||
invoke :'rails:db_migrate'
|
invoke :'rails:db_migrate'
|
||||||
invoke :'rails:after_party'
|
invoke :'rake[after_party:run]'
|
||||||
invoke :'rails:assets_precompile:force'
|
invoke :'rails:assets_precompile:force'
|
||||||
|
|
||||||
to :launch do
|
to :launch do
|
||||||
|
|
|
@ -45,17 +45,11 @@ Rails.application.configure do
|
||||||
config.assets.raise_runtime_errors = true
|
config.assets.raise_runtime_errors = true
|
||||||
|
|
||||||
# Action Mailer settings
|
# Action Mailer settings
|
||||||
config.action_mailer.delivery_method = :smtp
|
config.action_mailer.delivery_method = :letter_opener_web
|
||||||
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
|
||||||
# Config for mailcatcher https://mailcatcher.me/
|
|
||||||
config.action_mailer.smtp_settings = {
|
|
||||||
address: 'localhost',
|
|
||||||
port: 1025,
|
|
||||||
locale: 'fr'
|
|
||||||
}
|
|
||||||
|
|
||||||
Rails.application.routes.default_url_options = {
|
Rails.application.routes.default_url_options = {
|
||||||
host: 'localhost:3000'
|
host: 'localhost',
|
||||||
|
port: 3000
|
||||||
}
|
}
|
||||||
|
|
||||||
# Raises error for missing translations
|
# Raises error for missing translations
|
||||||
|
|
|
@ -45,6 +45,14 @@ Rails.application.routes.draw do
|
||||||
root to: "administrateurs#index"
|
root to: "administrateurs#index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Letter Opener
|
||||||
|
#
|
||||||
|
|
||||||
|
if Rails.env.development?
|
||||||
|
mount LetterOpenerWeb::Engine, at: "/letter_opener"
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Monitoring
|
# Monitoring
|
||||||
#
|
#
|
||||||
|
|
|
@ -732,29 +732,6 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#get_value" do
|
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
FranceConnectInformation.create(france_connect_particulier_id: 123, user: user, gender: 'male')
|
|
||||||
|
|
||||||
@champ_public = dossier.champs.first
|
|
||||||
@champ_public.value = "kiwi"
|
|
||||||
@champ_public.save
|
|
||||||
|
|
||||||
@champ_private = dossier.champs_private.first
|
|
||||||
@champ_private.value = "banane"
|
|
||||||
@champ_private.save
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect(dossier.get_value('self', 'created_at')).to eq(dossier.created_at) }
|
|
||||||
it { expect(dossier.get_value('user', 'email')).to eq(user.email) }
|
|
||||||
it { expect(dossier.get_value('etablissement', 'entreprise_siren')).to eq(dossier.etablissement.entreprise_siren) }
|
|
||||||
it { expect(dossier.get_value('etablissement', 'siret')).to eq(dossier.etablissement.siret) }
|
|
||||||
it { expect(dossier.get_value('type_de_champ', @champ_public.type_de_champ.id.to_s)).to eq(dossier.champs.first.value) }
|
|
||||||
it { expect(dossier.get_value('type_de_champ_private', @champ_private.type_de_champ.id.to_s)).to eq(dossier.champs_private.first.value) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'updated_at' do
|
describe 'updated_at' do
|
||||||
let!(:dossier) { create(:dossier) }
|
let!(:dossier) { create(:dossier) }
|
||||||
let(:modif_date) { DateTime.parse('01/01/2100') }
|
let(:modif_date) { DateTime.parse('01/01/2100') }
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe DossierFieldService do
|
||||||
type_de_champ.champ.create(dossier: discarded_dossier, value: 'discard me')
|
type_de_champ.champ.create(dossier: discarded_dossier, value: 'discard me')
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.filtered_ids(procedure.dossiers, [{ 'table' => 'type_de_champ', 'column' => type_de_champ.id, 'value' => 'keep' }]) }
|
subject { described_class.new.filtered_ids(procedure.dossiers, [{ 'table' => 'type_de_champ', 'column' => type_de_champ.id, 'value' => 'keep' }]) }
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||||
end
|
end
|
||||||
|
@ -29,7 +29,7 @@ describe DossierFieldService do
|
||||||
type_de_champ_private.champ.create(dossier: discarded_dossier, value: 'discard me')
|
type_de_champ_private.champ.create(dossier: discarded_dossier, value: 'discard me')
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { described_class.filtered_ids(procedure.dossiers, [{ 'table' => 'type_de_champ_private', 'column' => type_de_champ_private.id, 'value' => 'keep' }]) }
|
subject { described_class.new.filtered_ids(procedure.dossiers, [{ 'table' => 'type_de_champ_private', 'column' => type_de_champ_private.id, 'value' => 'keep' }]) }
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||||
end
|
end
|
||||||
|
@ -39,7 +39,7 @@ describe DossierFieldService do
|
||||||
let!(:kept_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, entreprise_date_creation: DateTime.new(2018, 6, 21))) }
|
let!(:kept_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, entreprise_date_creation: DateTime.new(2018, 6, 21))) }
|
||||||
let!(:discarded_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, entreprise_date_creation: DateTime.new(2008, 6, 21))) }
|
let!(:discarded_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, entreprise_date_creation: DateTime.new(2008, 6, 21))) }
|
||||||
|
|
||||||
subject { described_class.filtered_ids(procedure.dossiers, [{ 'table' => 'etablissement', 'column' => 'entreprise_date_creation', 'value' => '21/6/2018' }]) }
|
subject { described_class.new.filtered_ids(procedure.dossiers, [{ 'table' => 'etablissement', 'column' => 'entreprise_date_creation', 'value' => '21/6/2018' }]) }
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||||
end
|
end
|
||||||
|
@ -50,7 +50,7 @@ describe DossierFieldService do
|
||||||
let!(:kept_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, code_postal: '75017')) }
|
let!(:kept_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, code_postal: '75017')) }
|
||||||
let!(:discarded_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, code_postal: '25000')) }
|
let!(:discarded_dossier) { create(:dossier, procedure: procedure, etablissement: create(:etablissement, code_postal: '25000')) }
|
||||||
|
|
||||||
subject { described_class.filtered_ids(procedure.dossiers, [{ 'table' => 'etablissement', 'column' => 'code_postal', 'value' => '75017' }]) }
|
subject { described_class.new.filtered_ids(procedure.dossiers, [{ 'table' => 'etablissement', 'column' => 'code_postal', 'value' => '75017' }]) }
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||||
end
|
end
|
||||||
|
@ -60,7 +60,7 @@ describe DossierFieldService do
|
||||||
let!(:kept_dossier) { create(:dossier, procedure: procedure, user: create(:user, email: 'me@keepmail.com')) }
|
let!(:kept_dossier) { create(:dossier, procedure: procedure, user: create(:user, email: 'me@keepmail.com')) }
|
||||||
let!(:discarded_dossier) { create(:dossier, procedure: procedure, user: create(:user, email: 'me@discard.com')) }
|
let!(:discarded_dossier) { create(:dossier, procedure: procedure, user: create(:user, email: 'me@discard.com')) }
|
||||||
|
|
||||||
subject { described_class.filtered_ids(procedure.dossiers, [{ 'table' => 'user', 'column' => 'email', 'value' => 'keepmail' }]) }
|
subject { described_class.new.filtered_ids(procedure.dossiers, [{ 'table' => 'user', 'column' => 'email', 'value' => 'keepmail' }]) }
|
||||||
|
|
||||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||||
end
|
end
|
||||||
|
@ -72,7 +72,7 @@ describe DossierFieldService do
|
||||||
let(:sort) { { 'table' => table, 'column' => column, 'order' => order } }
|
let(:sort) { { 'table' => table, 'column' => column, 'order' => order } }
|
||||||
let(:procedure_presentation) { ProcedurePresentation.create(assign_to: assign_to, sort: sort) }
|
let(:procedure_presentation) { ProcedurePresentation.create(assign_to: assign_to, sort: sort) }
|
||||||
|
|
||||||
subject { DossierFieldService.sorted_ids(procedure.dossiers, procedure_presentation, gestionnaire) }
|
subject { described_class.new.sorted_ids(procedure.dossiers, procedure_presentation, gestionnaire) }
|
||||||
|
|
||||||
context 'for notifications table' do
|
context 'for notifications table' do
|
||||||
let(:table) { 'notifications' }
|
let(:table) { 'notifications' }
|
||||||
|
@ -164,7 +164,7 @@ describe DossierFieldService do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#get_value' do
|
describe '#get_value' do
|
||||||
subject { DossierFieldService.get_value(dossier, table, column) }
|
subject { described_class.new.get_value(dossier, table, column) }
|
||||||
|
|
||||||
context 'for self table' do
|
context 'for self table' do
|
||||||
let(:table) { 'self' }
|
let(:table) { 'self' }
|
||||||
|
|
Loading…
Reference in a new issue