commit
90e95d7db5
47 changed files with 3293 additions and 3831 deletions
70
.babelrc
70
.babelrc
|
@ -1,28 +1,54 @@
|
||||||
{
|
{
|
||||||
"presets": [
|
"presets": [
|
||||||
["env", {
|
[
|
||||||
"modules": false,
|
"@babel/env",
|
||||||
"targets": {
|
{
|
||||||
// See config/browser.rb
|
"modules": false,
|
||||||
"browsers": [
|
"targets": {
|
||||||
"> 1%",
|
"browsers": [
|
||||||
"Chrome >= 50",
|
"> 1%",
|
||||||
"IE >= 11",
|
"Chrome >= 50",
|
||||||
"Edge >= 14",
|
"IE >= 11",
|
||||||
"Firefox >= 50",
|
"Edge >= 14",
|
||||||
"Opera >= 40",
|
"Firefox >= 50",
|
||||||
"Safari >= 8",
|
"Opera >= 40",
|
||||||
"iOS >= 8"
|
"Safari >= 8",
|
||||||
],
|
"iOS >= 8"
|
||||||
"uglify": true
|
],
|
||||||
},
|
"uglify": true
|
||||||
"useBuiltIns": true
|
},
|
||||||
}]
|
"forceAllTransforms": true,
|
||||||
|
"useBuiltIns": "entry"
|
||||||
|
}
|
||||||
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"syntax-dynamic-import",
|
"@babel/plugin-transform-destructuring",
|
||||||
"transform-object-rest-spread",
|
"@babel/plugin-syntax-dynamic-import",
|
||||||
["transform-class-properties", { "spec": true }]
|
[
|
||||||
|
"@babel/plugin-proposal-object-rest-spread",
|
||||||
|
{
|
||||||
|
"useBuiltIns": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"@babel/plugin-transform-runtime",
|
||||||
|
{
|
||||||
|
"helpers": false,
|
||||||
|
"regenerator": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"@babel/plugin-transform-regenerator",
|
||||||
|
{
|
||||||
|
"async": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"@babel/plugin-proposal-class-properties",
|
||||||
|
{
|
||||||
|
"loose": true
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -5,7 +5,7 @@ gem 'dotenv-rails', require: 'dotenv/rails-now'
|
||||||
gem 'rails'
|
gem 'rails'
|
||||||
|
|
||||||
# Use SCSS for stylesheets
|
# Use SCSS for stylesheets
|
||||||
gem 'sass-rails'
|
gem 'sassc-rails'
|
||||||
|
|
||||||
# Use jquery as the JavaScript library
|
# Use jquery as the JavaScript library
|
||||||
gem 'jquery-rails'
|
gem 'jquery-rails'
|
||||||
|
|
67
Gemfile.lock
67
Gemfile.lock
|
@ -93,7 +93,7 @@ GEM
|
||||||
arel (9.0.0)
|
arel (9.0.0)
|
||||||
ast (2.4.0)
|
ast (2.4.0)
|
||||||
attr_required (1.0.1)
|
attr_required (1.0.1)
|
||||||
autoprefixer-rails (9.2.0)
|
autoprefixer-rails (9.4.1)
|
||||||
execjs
|
execjs
|
||||||
axlsx (3.0.0.pre)
|
axlsx (3.0.0.pre)
|
||||||
htmlentities (~> 4.3, >= 4.3.4)
|
htmlentities (~> 4.3, >= 4.3.4)
|
||||||
|
@ -104,7 +104,7 @@ GEM
|
||||||
activesupport (>= 3.1)
|
activesupport (>= 3.1)
|
||||||
axlsx (>= 2.0, < 4)
|
axlsx (>= 2.0, < 4)
|
||||||
bcrypt (3.1.12)
|
bcrypt (3.1.12)
|
||||||
bindata (2.4.3)
|
bindata (2.4.4)
|
||||||
bindex (0.5.0)
|
bindex (0.5.0)
|
||||||
bootstrap-sass (3.3.7)
|
bootstrap-sass (3.3.7)
|
||||||
autoprefixer-rails (>= 5.2.1)
|
autoprefixer-rails (>= 5.2.1)
|
||||||
|
@ -115,7 +115,7 @@ GEM
|
||||||
browser (2.5.3)
|
browser (2.5.3)
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
byebug (10.0.2)
|
byebug (10.0.2)
|
||||||
capybara (3.11.0)
|
capybara (3.12.0)
|
||||||
addressable
|
addressable
|
||||||
mini_mime (>= 0.1.3)
|
mini_mime (>= 0.1.3)
|
||||||
nokogiri (~> 1.8)
|
nokogiri (~> 1.8)
|
||||||
|
@ -140,9 +140,9 @@ GEM
|
||||||
case_transform (0.2)
|
case_transform (0.2)
|
||||||
activesupport
|
activesupport
|
||||||
chartkick (3.0.1)
|
chartkick (3.0.1)
|
||||||
childprocess (0.8.0)
|
childprocess (0.9.0)
|
||||||
ffi (~> 1.0, >= 1.0.11)
|
ffi (~> 1.0, >= 1.0.11)
|
||||||
chunky_png (1.3.10)
|
chunky_png (1.3.11)
|
||||||
clamav-client (3.1.0)
|
clamav-client (3.1.0)
|
||||||
coderay (1.1.2)
|
coderay (1.1.2)
|
||||||
coffee-rails (4.2.2)
|
coffee-rails (4.2.2)
|
||||||
|
@ -188,7 +188,7 @@ GEM
|
||||||
activejob (>= 5.0)
|
activejob (>= 5.0)
|
||||||
devise (>= 4.0)
|
devise (>= 4.0)
|
||||||
diff-lcs (1.3)
|
diff-lcs (1.3)
|
||||||
domain_name (0.5.20170404)
|
domain_name (0.5.20180417)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
dotenv (2.5.0)
|
dotenv (2.5.0)
|
||||||
dotenv-rails (2.5.0)
|
dotenv-rails (2.5.0)
|
||||||
|
@ -266,7 +266,7 @@ GEM
|
||||||
haml (>= 4.0.6, < 6.0)
|
haml (>= 4.0.6, < 6.0)
|
||||||
html2haml (>= 1.0.1)
|
html2haml (>= 1.0.1)
|
||||||
railties (>= 4.0.1)
|
railties (>= 4.0.1)
|
||||||
haml_lint (0.27.0)
|
haml_lint (0.28.0)
|
||||||
haml (>= 4.0, < 5.1)
|
haml (>= 4.0, < 5.1)
|
||||||
rainbow
|
rainbow
|
||||||
rake (>= 10, < 13)
|
rake (>= 10, < 13)
|
||||||
|
@ -354,7 +354,7 @@ GEM
|
||||||
multi_json (1.13.1)
|
multi_json (1.13.1)
|
||||||
multi_xml (0.6.0)
|
multi_xml (0.6.0)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
mustermann (1.0.2)
|
mustermann (1.0.3)
|
||||||
nenv (0.3.0)
|
nenv (0.3.0)
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nio4r (2.3.1)
|
nio4r (2.3.1)
|
||||||
|
@ -424,13 +424,13 @@ GEM
|
||||||
rack
|
rack
|
||||||
rack-mini-profiler (1.0.0)
|
rack-mini-profiler (1.0.0)
|
||||||
rack (>= 1.2.0)
|
rack (>= 1.2.0)
|
||||||
rack-oauth2 (1.9.2)
|
rack-oauth2 (1.9.3)
|
||||||
activesupport
|
activesupport
|
||||||
attr_required
|
attr_required
|
||||||
httpclient
|
httpclient
|
||||||
json-jwt (>= 1.9.0)
|
json-jwt (>= 1.9.0)
|
||||||
rack
|
rack
|
||||||
rack-protection (2.0.3)
|
rack-protection (2.0.4)
|
||||||
rack
|
rack
|
||||||
rack-proxy (0.6.5)
|
rack-proxy (0.6.5)
|
||||||
rack
|
rack
|
||||||
|
@ -449,10 +449,10 @@ GEM
|
||||||
bundler (>= 1.3.0)
|
bundler (>= 1.3.0)
|
||||||
railties (= 5.2.1.1)
|
railties (= 5.2.1.1)
|
||||||
sprockets-rails (>= 2.0.0)
|
sprockets-rails (>= 2.0.0)
|
||||||
rails-controller-testing (1.0.2)
|
rails-controller-testing (1.0.3)
|
||||||
actionpack (~> 5.x, >= 5.0.1)
|
actionpack (>= 5.0.1.x)
|
||||||
actionview (~> 5.x, >= 5.0.1)
|
actionview (>= 5.0.1.x)
|
||||||
activesupport (~> 5.x)
|
activesupport (>= 5.0.1.x)
|
||||||
rails-dom-testing (2.0.3)
|
rails-dom-testing (2.0.3)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
nokogiri (>= 1.6)
|
nokogiri (>= 1.6)
|
||||||
|
@ -487,9 +487,9 @@ GEM
|
||||||
http-cookie (>= 1.0.2, < 2.0)
|
http-cookie (>= 1.0.2, < 2.0)
|
||||||
mime-types (>= 1.16, < 4.0)
|
mime-types (>= 1.16, < 4.0)
|
||||||
netrc (~> 0.8)
|
netrc (~> 0.8)
|
||||||
rgeo (1.0.0)
|
rgeo (2.0.0)
|
||||||
rgeo-geojson (2.0.0)
|
rgeo-geojson (2.1.1)
|
||||||
rgeo (~> 1.0)
|
rgeo (>= 1.0.0)
|
||||||
rodf (1.0.0)
|
rodf (1.0.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
builder (>= 3.0)
|
builder (>= 3.0)
|
||||||
|
@ -534,7 +534,7 @@ GEM
|
||||||
rubyzip (1.2.2)
|
rubyzip (1.2.2)
|
||||||
safe_yaml (1.0.4)
|
safe_yaml (1.0.4)
|
||||||
sanitize-url (0.1.4)
|
sanitize-url (0.1.4)
|
||||||
sass (3.6.0)
|
sass (3.7.2)
|
||||||
sass-listen (~> 4.0.0)
|
sass-listen (~> 4.0.0)
|
||||||
sass-listen (4.0.0)
|
sass-listen (4.0.0)
|
||||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||||
|
@ -545,6 +545,15 @@ GEM
|
||||||
sprockets (>= 2.8, < 4.0)
|
sprockets (>= 2.8, < 4.0)
|
||||||
sprockets-rails (>= 2.0, < 4.0)
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
tilt (>= 1.1, < 3)
|
tilt (>= 1.1, < 3)
|
||||||
|
sassc (2.0.0)
|
||||||
|
ffi (~> 1.9.6)
|
||||||
|
rake
|
||||||
|
sassc-rails (2.0.0)
|
||||||
|
railties (>= 4.0.0)
|
||||||
|
sassc (>= 2.0)
|
||||||
|
sprockets (> 3.0)
|
||||||
|
sprockets-rails
|
||||||
|
tilt
|
||||||
scenic (1.4.1)
|
scenic (1.4.1)
|
||||||
activerecord (>= 4.0.0)
|
activerecord (>= 4.0.0)
|
||||||
railties (>= 4.0.0)
|
railties (>= 4.0.0)
|
||||||
|
@ -553,27 +562,27 @@ GEM
|
||||||
sass (~> 3.5, >= 3.5.5)
|
sass (~> 3.5, >= 3.5.5)
|
||||||
select2-rails (4.0.3)
|
select2-rails (4.0.3)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
selectize-rails (0.12.5)
|
selectize-rails (0.12.6)
|
||||||
selenium-webdriver (3.8.0)
|
selenium-webdriver (3.141.0)
|
||||||
childprocess (~> 0.5)
|
childprocess (~> 0.5)
|
||||||
rubyzip (~> 1.0)
|
rubyzip (~> 1.2, >= 1.2.2)
|
||||||
sentry-raven (2.7.4)
|
sentry-raven (2.7.4)
|
||||||
faraday (>= 0.7.6, < 1.0)
|
faraday (>= 0.7.6, < 1.0)
|
||||||
sexp_processor (4.11.0)
|
sexp_processor (4.11.0)
|
||||||
shellany (0.0.1)
|
shellany (0.0.1)
|
||||||
shoulda-matchers (3.1.2)
|
shoulda-matchers (3.1.2)
|
||||||
activesupport (>= 4.0.0)
|
activesupport (>= 4.0.0)
|
||||||
simple_form (4.0.1)
|
simple_form (4.1.0)
|
||||||
actionpack (>= 5.0)
|
actionpack (>= 5.0)
|
||||||
activemodel (>= 5.0)
|
activemodel (>= 5.0)
|
||||||
sinatra (2.0.3)
|
sinatra (2.0.4)
|
||||||
mustermann (~> 1.0)
|
mustermann (~> 1.0)
|
||||||
rack (~> 2.0)
|
rack (~> 2.0)
|
||||||
rack-protection (= 2.0.3)
|
rack-protection (= 2.0.4)
|
||||||
tilt (~> 2.0)
|
tilt (~> 2.0)
|
||||||
skylight (3.1.1)
|
skylight (3.1.2)
|
||||||
skylight-core (= 3.1.1)
|
skylight-core (= 3.1.2)
|
||||||
skylight-core (3.1.1)
|
skylight-core (3.1.2)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
smart_listing (1.2.2)
|
smart_listing (1.2.2)
|
||||||
coffee-rails
|
coffee-rails
|
||||||
|
@ -603,7 +612,7 @@ GEM
|
||||||
temple (0.8.0)
|
temple (0.8.0)
|
||||||
thor (0.20.3)
|
thor (0.20.3)
|
||||||
thread_safe (0.3.6)
|
thread_safe (0.3.6)
|
||||||
tilt (2.0.8)
|
tilt (2.0.9)
|
||||||
timecop (0.9.1)
|
timecop (0.9.1)
|
||||||
ttfunk (1.5.1)
|
ttfunk (1.5.1)
|
||||||
turbolinks (5.2.0)
|
turbolinks (5.2.0)
|
||||||
|
@ -730,7 +739,7 @@ DEPENDENCIES
|
||||||
rubocop
|
rubocop
|
||||||
rubocop-rspec-focused
|
rubocop-rspec-focused
|
||||||
sanitize-url
|
sanitize-url
|
||||||
sass-rails
|
sassc-rails
|
||||||
scenic
|
scenic
|
||||||
scss_lint
|
scss_lint
|
||||||
select2-rails
|
select2-rails
|
||||||
|
|
|
@ -50,7 +50,7 @@ module NewGestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_commentaire
|
def create_commentaire
|
||||||
@commentaire = Commentaire.new(commentaire_params.merge(email: current_gestionnaire.email, dossier: avis.dossier))
|
@commentaire = CommentaireService.build(current_gestionnaire, avis.dossier, commentaire_params)
|
||||||
|
|
||||||
if @commentaire.save
|
if @commentaire.save
|
||||||
flash.notice = "Message envoyé"
|
flash.notice = "Message envoyé"
|
||||||
|
|
|
@ -106,7 +106,7 @@ module NewGestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_commentaire
|
def create_commentaire
|
||||||
@commentaire = CommentaireService.create(current_gestionnaire, dossier, commentaire_params)
|
@commentaire = CommentaireService.build(current_gestionnaire, dossier, commentaire_params)
|
||||||
|
|
||||||
if @commentaire.save
|
if @commentaire.save
|
||||||
current_gestionnaire.follow(dossier)
|
current_gestionnaire.follow(dossier)
|
||||||
|
|
|
@ -174,13 +174,21 @@ module NewGestionnaire
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_dossiers
|
def download_dossiers
|
||||||
export = procedure.generate_export
|
options = params.permit(:limit, :since, tables: [])
|
||||||
filename = procedure.export_filename
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.csv { send_data(SpreadsheetArchitect.to_csv(data: export[:data], headers: export[:headers]), filename: "#{filename}.csv") }
|
format.csv do
|
||||||
format.xlsx { send_data(SpreadsheetArchitect.to_xlsx(data: export[:data], headers: export[:headers]), filename: "#{filename}.xlsx") }
|
send_data(procedure.to_csv(options),
|
||||||
format.ods { send_data(SpreadsheetArchitect.to_ods(data: export[:data], headers: export[:headers]), filename: "#{filename}.ods") }
|
filename: procedure.export_filename(:csv))
|
||||||
|
end
|
||||||
|
format.xlsx do
|
||||||
|
send_data(procedure.to_xlsx(options),
|
||||||
|
filename: procedure.export_filename(:xlsx))
|
||||||
|
end
|
||||||
|
format.ods do
|
||||||
|
send_data(procedure.to_ods(options),
|
||||||
|
filename: procedure.export_filename(:ods))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ module NewUser
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_commentaire
|
def create_commentaire
|
||||||
@commentaire = CommentaireService.create(current_user, dossier, commentaire_params)
|
@commentaire = CommentaireService.build(current_user, dossier, commentaire_params)
|
||||||
|
|
||||||
if @commentaire.save
|
if @commentaire.save
|
||||||
flash.notice = "Votre message a bien été envoyé à l’instructeur en charge de votre dossier."
|
flash.notice = "Votre message a bien été envoyé à l’instructeur en charge de votre dossier."
|
||||||
|
|
|
@ -62,11 +62,12 @@ class SupportController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_commentaire
|
def create_commentaire
|
||||||
dossier.commentaires.create(
|
params = {
|
||||||
email: email,
|
|
||||||
file: params[:file],
|
file: params[:file],
|
||||||
body: "[#{params[:subject]}]<br><br>#{params[:text]}"
|
body: "[#{params[:subject]}]<br><br>#{params[:text]}"
|
||||||
)
|
}
|
||||||
|
commentaire = CommentaireService.build_with_email(email, dossier, params)
|
||||||
|
commentaire.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import '../shared/polyfills';
|
import '../shared/polyfills';
|
||||||
import Turbolinks from 'turbolinks';
|
import Turbolinks from 'turbolinks';
|
||||||
import Rails from 'rails-ujs';
|
import Rails from 'rails-ujs';
|
||||||
import ActiveStorage from '../shared/activestorage/ujs';
|
import * as ActiveStorage from 'activestorage';
|
||||||
import jQuery from 'jquery';
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
|
import '../shared/activestorage/progress';
|
||||||
import '../shared/sentry';
|
import '../shared/sentry';
|
||||||
import '../shared/rails-ujs-fix';
|
import '../shared/rails-ujs-fix';
|
||||||
import '../shared/safari-11-file-xhr-workaround';
|
import '../shared/safari-11-file-xhr-workaround';
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import '../shared/polyfills';
|
import '../shared/polyfills';
|
||||||
import Turbolinks from 'turbolinks';
|
import Turbolinks from 'turbolinks';
|
||||||
import Rails from 'rails-ujs';
|
import Rails from 'rails-ujs';
|
||||||
import ActiveStorage from '../shared/activestorage/ujs';
|
import * as ActiveStorage from 'activestorage';
|
||||||
import Chartkick from 'chartkick';
|
import Chartkick from 'chartkick';
|
||||||
import Highcharts from 'highcharts';
|
import Highcharts from 'highcharts';
|
||||||
|
|
||||||
|
import '../shared/activestorage/progress';
|
||||||
import '../shared/sentry';
|
import '../shared/sentry';
|
||||||
import '../shared/rails-ujs-fix';
|
import '../shared/rails-ujs-fix';
|
||||||
import '../shared/safari-11-file-xhr-workaround';
|
import '../shared/safari-11-file-xhr-workaround';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Include runtime-polyfills for older browsers.
|
// Include runtime-polyfills for older browsers.
|
||||||
// Due to .babelrc's 'useBuiltIns', only polyfills actually
|
// Due to .babelrc's 'useBuiltIns', only polyfills actually
|
||||||
// required by the browsers we support will be included.
|
// required by the browsers we support will be included.
|
||||||
import 'babel-polyfill';
|
import '@babel/polyfill';
|
||||||
|
|
||||||
// This file is copied from mailjet. We serve here a copy of it ourselves
|
// This file is copied from mailjet. We serve here a copy of it ourselves
|
||||||
// to avoid loading javascript files from other domains on the frontpage.
|
// to avoid loading javascript files from other domains on the frontpage.
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
import { DirectUploadsController } from 'activestorage/src/direct_uploads_controller';
|
|
||||||
import { findElement } from 'activestorage/src/helpers';
|
|
||||||
import './progress';
|
|
||||||
|
|
||||||
// This is a patched copy of https://github.com/rails/rails/blob/master/activestorage/app/javascript/activestorage/ujs.js
|
|
||||||
// It fixes support for multiple input/button elements on direct upload forms
|
|
||||||
|
|
||||||
const processingAttribute = 'data-direct-uploads-processing';
|
|
||||||
let started = false;
|
|
||||||
|
|
||||||
export function start() {
|
|
||||||
if (!started) {
|
|
||||||
started = true;
|
|
||||||
document.addEventListener('submit', didSubmitForm);
|
|
||||||
document.addEventListener('click', didSubmitFormElement);
|
|
||||||
document.addEventListener('ajax:before', didSubmitRemoteElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default { start };
|
|
||||||
|
|
||||||
function didSubmitForm(event) {
|
|
||||||
handleFormSubmissionEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
function didSubmitFormElement(event) {
|
|
||||||
const { target } = event;
|
|
||||||
if (isSubmitElement(target)) {
|
|
||||||
handleFormSubmissionEvent(formSubmitEvent(event), target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function didSubmitRemoteElement(event) {
|
|
||||||
if (event.target.tagName == 'FORM') {
|
|
||||||
handleFormSubmissionEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function formSubmitEvent(event) {
|
|
||||||
return {
|
|
||||||
target: event.target.form,
|
|
||||||
preventDefault() {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function isSubmitElement({ tagName, type, form }) {
|
|
||||||
if (form && (tagName === 'BUTTON' || tagName === 'INPUT')) {
|
|
||||||
return type === 'submit';
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleFormSubmissionEvent(event, button) {
|
|
||||||
const form = event.target;
|
|
||||||
|
|
||||||
if (form.hasAttribute(processingAttribute)) {
|
|
||||||
event.preventDefault();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const controller = new DirectUploadsController(form);
|
|
||||||
const { inputs } = controller;
|
|
||||||
|
|
||||||
if (inputs.length) {
|
|
||||||
event.preventDefault();
|
|
||||||
form.setAttribute(processingAttribute, '');
|
|
||||||
inputs.forEach(disable);
|
|
||||||
controller.start(error => {
|
|
||||||
form.removeAttribute(processingAttribute);
|
|
||||||
if (error) {
|
|
||||||
inputs.forEach(enable);
|
|
||||||
} else {
|
|
||||||
submitForm(form, button);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitForm(form, button) {
|
|
||||||
button = button || findElement(form, 'input[type=submit]');
|
|
||||||
if (button) {
|
|
||||||
const { disabled } = button;
|
|
||||||
button.disabled = false;
|
|
||||||
button.focus();
|
|
||||||
button.click();
|
|
||||||
button.disabled = disabled;
|
|
||||||
} else {
|
|
||||||
button = document.createElement('input');
|
|
||||||
button.type = 'submit';
|
|
||||||
button.style.display = 'none';
|
|
||||||
form.appendChild(button);
|
|
||||||
button.click();
|
|
||||||
form.removeChild(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function disable(input) {
|
|
||||||
input.disabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function enable(input) {
|
|
||||||
input.disabled = false;
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Include runtime-polyfills for older browsers.
|
// Include runtime-polyfills for older browsers.
|
||||||
// Due to .babelrc's 'useBuiltIns', only polyfills actually
|
// Due to .babelrc's 'useBuiltIns', only polyfills actually
|
||||||
// required by the browsers we support will be included.
|
// required by the browsers we support will be included.
|
||||||
import 'babel-polyfill';
|
import '@babel/polyfill';
|
||||||
import 'dom4';
|
import 'dom4';
|
||||||
|
|
|
@ -46,10 +46,8 @@ class NotificationMailer < ApplicationMailer
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_commentaire_for_notification(dossier, subject, body)
|
def create_commentaire_for_notification(dossier, subject, body)
|
||||||
Commentaire.create(
|
params = { body: ["[#{subject}]", body].join("<br><br>") }
|
||||||
dossier: dossier,
|
commentaire = CommentaireService.build_with_email(CONTACT_EMAIL, dossier, params)
|
||||||
email: CONTACT_EMAIL,
|
commentaire.save!
|
||||||
body: ["[#{subject}]", body].join("<br><br>")
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,9 @@ class Commentaire < ApplicationRecord
|
||||||
belongs_to :dossier, touch: true
|
belongs_to :dossier, touch: true
|
||||||
belongs_to :piece_justificative
|
belongs_to :piece_justificative
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :gestionnaire
|
||||||
|
|
||||||
mount_uploader :file, CommentaireFileUploader
|
mount_uploader :file, CommentaireFileUploader
|
||||||
validates :file, file_size: { maximum: 20.megabytes, message: "La taille du fichier doit être inférieure à 20 Mo" }
|
validates :file, file_size: { maximum: 20.megabytes, message: "La taille du fichier doit être inférieure à 20 Mo" }
|
||||||
validate :is_virus_free?
|
validate :is_virus_free?
|
||||||
|
@ -16,6 +19,16 @@ class Commentaire < ApplicationRecord
|
||||||
super.reject { |c| c.name == "champ" }
|
super.reject { |c| c.name == "champ" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def email
|
||||||
|
if user
|
||||||
|
user.email
|
||||||
|
elsif gestionnaire
|
||||||
|
gestionnaire.email
|
||||||
|
else
|
||||||
|
read_attribute(:email)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def header
|
def header
|
||||||
"#{sender}, #{I18n.l(created_at, format: '%d %b %Y %H:%M')}"
|
"#{sender}, #{I18n.l(created_at, format: '%d %b %Y %H:%M')}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,13 +52,13 @@ class Dossier < ApplicationRecord
|
||||||
scope :en_construction, -> { not_archived.state_en_construction }
|
scope :en_construction, -> { not_archived.state_en_construction }
|
||||||
scope :en_instruction, -> { not_archived.state_en_instruction }
|
scope :en_instruction, -> { not_archived.state_en_instruction }
|
||||||
scope :termine, -> { not_archived.state_termine }
|
scope :termine, -> { not_archived.state_termine }
|
||||||
scope :downloadable_sorted, -> { state_not_brouillon.includes(:etablissement, :champs, :champs_private, :user, :individual, :followers_gestionnaires).order(en_construction_at: 'asc') }
|
scope :downloadable_sorted, -> { state_not_brouillon.includes(:etablissement, :user, :individual, :followers_gestionnaires, champs: { etablissement: [], type_de_champ: :drop_down_list }, champs_private: { etablissement: [], type_de_champ: :drop_down_list }).order(en_construction_at: 'asc') }
|
||||||
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction }
|
scope :en_cours, -> { not_archived.state_en_construction_ou_instruction }
|
||||||
scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) }
|
scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) }
|
||||||
scope :followed_by, -> (gestionnaire) { joins(:follows).where(follows: { gestionnaire: gestionnaire }) }
|
scope :followed_by, -> (gestionnaire) { joins(:follows).where(follows: { gestionnaire: gestionnaire }) }
|
||||||
scope :with_champs, -> { includes(champs: :type_de_champ) }
|
scope :with_champs, -> { includes(champs: :type_de_champ) }
|
||||||
scope :nearing_end_of_retention, -> (duration = '1 month') { joins(:procedure).where("en_instruction_at + (duree_conservation_dossiers_dans_ds * interval '1 month') - now() < interval ?", duration) }
|
scope :nearing_end_of_retention, -> (duration = '1 month') { joins(:procedure).where("en_instruction_at + (duree_conservation_dossiers_dans_ds * interval '1 month') - now() < interval ?", duration) }
|
||||||
|
scope :since, -> (since) { where('dossiers.en_construction_at >= ?', since) }
|
||||||
scope :for_api, -> {
|
scope :for_api, -> {
|
||||||
includes(commentaires: [],
|
includes(commentaires: [],
|
||||||
champs: [
|
champs: [
|
||||||
|
@ -146,21 +146,6 @@ class Dossier < ApplicationRecord
|
||||||
INSTRUCTION_COMMENCEE.include?(state)
|
INSTRUCTION_COMMENCEE.include?(state)
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_headers
|
|
||||||
serialized_dossier = DossierTableExportSerializer.new(self)
|
|
||||||
headers = serialized_dossier.attributes.keys
|
|
||||||
headers += procedure.types_de_champ.order(:order_place).map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
|
|
||||||
headers += procedure.types_de_champ_private.order(:order_place).map { |types_de_champ| types_de_champ.libelle.parameterize.underscore.to_sym }
|
|
||||||
headers += export_etablissement_data.keys
|
|
||||||
headers
|
|
||||||
end
|
|
||||||
|
|
||||||
def export_values
|
|
||||||
sorted_values.map do |value|
|
|
||||||
serialize_value_for_export(value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def reset!
|
def reset!
|
||||||
etablissement.destroy
|
etablissement.destroy
|
||||||
|
|
||||||
|
@ -361,36 +346,6 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize_value_for_export(value)
|
|
||||||
value.nil? || value.kind_of?(Time) ? value : value.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
def convert_specific_hash_values_to_string(hash_to_convert)
|
|
||||||
hash_to_convert.transform_values do |value|
|
|
||||||
serialize_value_for_export(value)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def export_etablissement_data
|
|
||||||
if etablissement.present?
|
|
||||||
etablissement_attr = EtablissementCsvSerializer.new(etablissement).attributes.transform_keys { |k| "etablissement.#{k}".parameterize.underscore.to_sym }
|
|
||||||
entreprise_attr = EntrepriseSerializer.new(etablissement.entreprise).attributes.transform_keys { |k| "entreprise.#{k}".parameterize.underscore.to_sym }
|
|
||||||
else
|
|
||||||
etablissement_attr = EtablissementSerializer.new(Etablissement.new).attributes.transform_keys { |k| "etablissement.#{k}".parameterize.underscore.to_sym }
|
|
||||||
entreprise_attr = EntrepriseSerializer.new(Entreprise.new).attributes.transform_keys { |k| "entreprise.#{k}".parameterize.underscore.to_sym }
|
|
||||||
end
|
|
||||||
convert_specific_hash_values_to_string(etablissement_attr.merge(entreprise_attr))
|
|
||||||
end
|
|
||||||
|
|
||||||
def sorted_values
|
|
||||||
serialized_dossier = DossierTableExportSerializer.new(self)
|
|
||||||
values = serialized_dossier.attributes.values
|
|
||||||
values += champs.map(&:for_export)
|
|
||||||
values += champs_private.map(&:for_export)
|
|
||||||
values += export_etablissement_data.values
|
|
||||||
values
|
|
||||||
end
|
|
||||||
|
|
||||||
def send_dossier_received
|
def send_dossier_received
|
||||||
if saved_change_to_state? && en_instruction?
|
if saved_change_to_state? && en_instruction?
|
||||||
NotificationMailer.send_dossier_received(self).deliver_later
|
NotificationMailer.send_dossier_received(self).deliver_later
|
||||||
|
|
|
@ -19,11 +19,7 @@ class Gestionnaire < ApplicationRecord
|
||||||
has_many :dossiers_from_avis, through: :avis, source: :dossier
|
has_many :dossiers_from_avis, through: :avis, source: :dossier
|
||||||
|
|
||||||
def visible_procedures
|
def visible_procedures
|
||||||
if Flipflop.publish_draft?
|
procedures.merge(Procedure.avec_lien.or(Procedure.archivees))
|
||||||
procedures.avec_lien
|
|
||||||
else
|
|
||||||
procedures.publiees_ou_archivees
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_view_dossier?(dossier_id)
|
def can_view_dossier?(dossier_id)
|
||||||
|
|
|
@ -242,21 +242,25 @@ class Procedure < ApplicationRecord
|
||||||
self.dossiers.state_not_brouillon.size
|
self.dossiers.state_not_brouillon.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_filename
|
def export_filename(format)
|
||||||
procedure_identifier = path || "procedure-#{id}"
|
procedure_identifier = path || "procedure-#{id}"
|
||||||
"dossiers_#{procedure_identifier}_#{Time.zone.now.strftime('%Y-%m-%d_%H-%M')}"
|
"dossiers_#{procedure_identifier}_#{Time.zone.now.strftime('%Y-%m-%d_%H-%M')}.#{format}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_export
|
def export(options = {})
|
||||||
exportable_dossiers = dossiers.downloadable_sorted
|
ProcedureExportService.new(self, **options.to_h.symbolize_keys)
|
||||||
|
end
|
||||||
|
|
||||||
headers = exportable_dossiers&.first&.export_headers || []
|
def to_csv(options = {})
|
||||||
data = exportable_dossiers.any? ? exportable_dossiers.map(&:export_values) : [[]]
|
export(options).to_csv
|
||||||
|
end
|
||||||
|
|
||||||
{
|
def to_xlsx(options = {})
|
||||||
headers: headers,
|
export(options).to_xlsx
|
||||||
data: data
|
end
|
||||||
}
|
|
||||||
|
def to_ods(options = {})
|
||||||
|
export(options).to_ods
|
||||||
end
|
end
|
||||||
|
|
||||||
def procedure_overview(start_date)
|
def procedure_overview(start_date)
|
||||||
|
|
|
@ -12,7 +12,7 @@ class ChampSerializer < ActiveModel::Serializer
|
||||||
def value
|
def value
|
||||||
case object
|
case object
|
||||||
when GeoArea
|
when GeoArea
|
||||||
object.geometry.to_json
|
object.geometry
|
||||||
when Champs::CarteChamp
|
when Champs::CarteChamp
|
||||||
if object.geo_json.present?
|
if object.geo_json.present?
|
||||||
object.geo_json.to_json
|
object.geo_json.to_json
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
class DossierTableExportSerializer < ActiveModel::Serializer
|
|
||||||
include DossierHelper
|
|
||||||
|
|
||||||
attributes :id,
|
|
||||||
:created_at,
|
|
||||||
:updated_at,
|
|
||||||
:archived,
|
|
||||||
:email,
|
|
||||||
:state,
|
|
||||||
:initiated_at,
|
|
||||||
:received_at,
|
|
||||||
:processed_at,
|
|
||||||
:motivation
|
|
||||||
|
|
||||||
attribute :emails_instructeurs
|
|
||||||
|
|
||||||
attributes :individual_gender,
|
|
||||||
:individual_prenom,
|
|
||||||
:individual_nom,
|
|
||||||
:individual_birthdate
|
|
||||||
|
|
||||||
def email
|
|
||||||
object.user&.email
|
|
||||||
end
|
|
||||||
|
|
||||||
def state
|
|
||||||
dossier_legacy_state(object)
|
|
||||||
end
|
|
||||||
|
|
||||||
def initiated_at
|
|
||||||
object.en_construction_at
|
|
||||||
end
|
|
||||||
|
|
||||||
def received_at
|
|
||||||
object.en_instruction_at
|
|
||||||
end
|
|
||||||
|
|
||||||
def individual_prenom
|
|
||||||
object.individual&.prenom
|
|
||||||
end
|
|
||||||
|
|
||||||
def individual_nom
|
|
||||||
object.individual&.nom
|
|
||||||
end
|
|
||||||
|
|
||||||
def individual_birthdate
|
|
||||||
object.individual&.birthdate
|
|
||||||
end
|
|
||||||
|
|
||||||
def individual_gender
|
|
||||||
object.individual&.gender
|
|
||||||
end
|
|
||||||
|
|
||||||
def emails_instructeurs
|
|
||||||
object.followers_gestionnaires.pluck(:email).join(' ')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
class EtablissementCsvSerializer < EtablissementSerializer
|
|
||||||
def adresse
|
|
||||||
object.adresse.chomp.gsub("\r\n", ' ').delete("\r")
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,16 +1,18 @@
|
||||||
class CommentaireService
|
class CommentaireService
|
||||||
class << self
|
class << self
|
||||||
def create(sender, dossier, params)
|
def build(sender, dossier, params)
|
||||||
attributes = params.merge(email: sender.email, dossier: dossier)
|
case sender
|
||||||
|
when User
|
||||||
# If the user submits a empty message, simple_format will replace '' by '<p></p>',
|
params[:user] = sender
|
||||||
# and thus bypass the not-empty constraint on commentaire's body.
|
when Gestionnaire
|
||||||
#
|
params[:gestionnaire] = sender
|
||||||
# To avoid this, format the message only if a body is present in the first place.
|
|
||||||
if attributes[:body].present?
|
|
||||||
attributes[:body] = ActionController::Base.helpers.simple_format(attributes[:body])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
build_with_email(sender.email, dossier, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_with_email(email, dossier, params)
|
||||||
|
attributes = params.merge(email: email, dossier: dossier)
|
||||||
Commentaire.new(attributes)
|
Commentaire.new(attributes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
261
app/services/procedure_export_service.rb
Normal file
261
app/services/procedure_export_service.rb
Normal file
|
@ -0,0 +1,261 @@
|
||||||
|
class ProcedureExportService
|
||||||
|
include DossierHelper
|
||||||
|
|
||||||
|
ATTRIBUTES = [
|
||||||
|
:id,
|
||||||
|
:created_at,
|
||||||
|
:updated_at,
|
||||||
|
:archived,
|
||||||
|
:email,
|
||||||
|
:state,
|
||||||
|
:initiated_at,
|
||||||
|
:received_at,
|
||||||
|
:processed_at,
|
||||||
|
:motivation,
|
||||||
|
:emails_instructeurs,
|
||||||
|
:individual_gender,
|
||||||
|
:individual_prenom,
|
||||||
|
:individual_nom,
|
||||||
|
:individual_birthdate
|
||||||
|
]
|
||||||
|
|
||||||
|
ETABLISSEMENT_ATTRIBUTES = [
|
||||||
|
:siret,
|
||||||
|
:siege_social,
|
||||||
|
:naf,
|
||||||
|
:libelle_naf,
|
||||||
|
:adresse,
|
||||||
|
:numero_voie,
|
||||||
|
:type_voie,
|
||||||
|
:nom_voie,
|
||||||
|
:complement_adresse,
|
||||||
|
:code_postal,
|
||||||
|
:localite,
|
||||||
|
:code_insee_localite
|
||||||
|
]
|
||||||
|
|
||||||
|
ENTREPRISE_ATTRIBUTES = [
|
||||||
|
:siren,
|
||||||
|
:capital_social,
|
||||||
|
:numero_tva_intracommunautaire,
|
||||||
|
:forme_juridique,
|
||||||
|
:forme_juridique_code,
|
||||||
|
:nom_commercial,
|
||||||
|
:raison_sociale,
|
||||||
|
:siret_siege_social,
|
||||||
|
:code_effectif_entreprise,
|
||||||
|
:date_creation,
|
||||||
|
:nom,
|
||||||
|
:prenom
|
||||||
|
]
|
||||||
|
|
||||||
|
def initialize(procedure, tables: [], ids: nil, since: nil, limit: nil)
|
||||||
|
@procedure = procedure
|
||||||
|
@dossiers = procedure.dossiers.downloadable_sorted
|
||||||
|
if ids
|
||||||
|
@dossiers = @dossiers.where(id: ids)
|
||||||
|
end
|
||||||
|
if since
|
||||||
|
@dossiers = @dossiers.since(since)
|
||||||
|
end
|
||||||
|
if limit
|
||||||
|
@dossiers = @dossiers.limit(limit)
|
||||||
|
end
|
||||||
|
@dossiers = @dossiers.to_a
|
||||||
|
@tables = tables.map(&:to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_csv
|
||||||
|
SpreadsheetArchitect.to_csv(to_data(:dossiers))
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_xlsx
|
||||||
|
package = SpreadsheetArchitect.to_axlsx_package(to_data(:dossiers))
|
||||||
|
|
||||||
|
# Next we recursively build multi page spreadsheet
|
||||||
|
@tables.reduce(package) do |package, table|
|
||||||
|
SpreadsheetArchitect.to_axlsx_package(to_data(table), package)
|
||||||
|
end.to_stream.read
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_ods
|
||||||
|
spreadsheet = SpreadsheetArchitect.to_rodf_spreadsheet(to_data(:dossiers))
|
||||||
|
|
||||||
|
# Next we recursively build multi page spreadsheet
|
||||||
|
@tables.reduce(spreadsheet) do |spreadsheet, table|
|
||||||
|
SpreadsheetArchitect.to_rodf_spreadsheet(to_data(table), spreadsheet)
|
||||||
|
end.bytes
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_data(table)
|
||||||
|
case table
|
||||||
|
when :dossiers
|
||||||
|
dossiers_table_data
|
||||||
|
when :etablissements
|
||||||
|
etablissements_table_data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def empty_table_data(sheet_name, headers = [])
|
||||||
|
{
|
||||||
|
sheet_name: sheet_name,
|
||||||
|
headers: headers,
|
||||||
|
data: [[]]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def dossiers_table_data
|
||||||
|
if @dossiers.any?
|
||||||
|
{
|
||||||
|
sheet_name: 'Dossiers',
|
||||||
|
headers: dossiers_headers,
|
||||||
|
data: dossiers_data
|
||||||
|
}
|
||||||
|
else
|
||||||
|
empty_table_data('Dossiers', dossiers_headers)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def etablissements_table_data
|
||||||
|
@etablissements = @dossiers.flat_map do |dossier|
|
||||||
|
dossier.champs.select do |champ|
|
||||||
|
champ.is_a?(Champs::SiretChamp)
|
||||||
|
end + dossier.champs_private.select do |champ|
|
||||||
|
champ.is_a?(Champs::SiretChamp)
|
||||||
|
end
|
||||||
|
end.map(&:etablissement).compact
|
||||||
|
|
||||||
|
if @etablissements.any?
|
||||||
|
{
|
||||||
|
sheet_name: 'Etablissements',
|
||||||
|
headers: etablissements_headers,
|
||||||
|
data: etablissements_data
|
||||||
|
}
|
||||||
|
else
|
||||||
|
empty_table_data('Etablissements', etablissements_headers)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dossiers_headers
|
||||||
|
headers = ATTRIBUTES.map do |key|
|
||||||
|
label_for_export(key.to_s)
|
||||||
|
end
|
||||||
|
headers += @procedure.types_de_champ.map do |champ|
|
||||||
|
label_for_export(champ.libelle)
|
||||||
|
end
|
||||||
|
headers += @procedure.types_de_champ_private.map do |champ|
|
||||||
|
label_for_export(champ.libelle)
|
||||||
|
end
|
||||||
|
headers += ETABLISSEMENT_ATTRIBUTES.map do |key|
|
||||||
|
label_for_export("etablissement.#{key}")
|
||||||
|
end
|
||||||
|
headers += ENTREPRISE_ATTRIBUTES.map do |key|
|
||||||
|
label_for_export("entreprise.#{key}")
|
||||||
|
end
|
||||||
|
headers
|
||||||
|
end
|
||||||
|
|
||||||
|
def dossiers_data
|
||||||
|
@dossiers.map do |dossier|
|
||||||
|
values = ATTRIBUTES.map do |key|
|
||||||
|
case key
|
||||||
|
when :email
|
||||||
|
dossier.user.email
|
||||||
|
when :state
|
||||||
|
dossier_legacy_state(dossier)
|
||||||
|
when :initiated_at
|
||||||
|
dossier.en_construction_at
|
||||||
|
when :received_at
|
||||||
|
dossier.en_instruction_at
|
||||||
|
when :individual_prenom
|
||||||
|
dossier.individual&.prenom
|
||||||
|
when :individual_nom
|
||||||
|
dossier.individual&.nom
|
||||||
|
when :individual_birthdate
|
||||||
|
dossier.individual&.birthdate
|
||||||
|
when :individual_gender
|
||||||
|
dossier.individual&.gender
|
||||||
|
when :emails_instructeurs
|
||||||
|
dossier.followers_gestionnaires.map(&:email).join(' ')
|
||||||
|
else
|
||||||
|
dossier.read_attribute(key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
values = normalize_values(values)
|
||||||
|
values += dossier.champs.map do |champ|
|
||||||
|
value_for_export(champ)
|
||||||
|
end
|
||||||
|
values += dossier.champs_private.map do |champ|
|
||||||
|
value_for_export(champ)
|
||||||
|
end
|
||||||
|
values += etablissement_data(dossier.etablissement)
|
||||||
|
values
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def etablissements_headers
|
||||||
|
headers = [:dossier_id, :libelle]
|
||||||
|
headers += ETABLISSEMENT_ATTRIBUTES.map do |key|
|
||||||
|
label_for_export("etablissement.#{key}")
|
||||||
|
end
|
||||||
|
headers += ENTREPRISE_ATTRIBUTES.map do |key|
|
||||||
|
label_for_export("entreprise.#{key}")
|
||||||
|
end
|
||||||
|
headers
|
||||||
|
end
|
||||||
|
|
||||||
|
def etablissements_data
|
||||||
|
@etablissements.map do |etablissement|
|
||||||
|
data = [
|
||||||
|
etablissement.champ.dossier_id,
|
||||||
|
label_for_export(etablissement.champ.libelle).to_s
|
||||||
|
]
|
||||||
|
data += etablissement_data(etablissement)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def etablissement_data(etablissement)
|
||||||
|
data = ETABLISSEMENT_ATTRIBUTES.map do |key|
|
||||||
|
if etablissement.present?
|
||||||
|
case key
|
||||||
|
when :adresse
|
||||||
|
etablissement.adresse&.chomp&.gsub("\r\n", ' ')&.delete("\r")
|
||||||
|
else
|
||||||
|
etablissement.read_attribute(key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
data += ENTREPRISE_ATTRIBUTES.map do |key|
|
||||||
|
if etablissement.present?
|
||||||
|
case key
|
||||||
|
when :date_creation
|
||||||
|
etablissement.entreprise_date_creation&.to_datetime
|
||||||
|
else
|
||||||
|
etablissement.read_attribute(:"entreprise_#{key}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
normalize_values(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def label_for_export(label)
|
||||||
|
label.parameterize.underscore.to_sym
|
||||||
|
end
|
||||||
|
|
||||||
|
def value_for_export(champ)
|
||||||
|
champ.for_export
|
||||||
|
end
|
||||||
|
|
||||||
|
def normalize_values(values)
|
||||||
|
values.map do |value|
|
||||||
|
case value
|
||||||
|
when TrueClass, FalseClass
|
||||||
|
value.to_s
|
||||||
|
else
|
||||||
|
value.blank? ? nil : value.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,6 +7,6 @@
|
||||||
%li
|
%li
|
||||||
= link_to "Au format .csv", download_dossiers_gestionnaire_procedure_path(format: :csv, procedure_id: procedure.id), target: "_blank"
|
= link_to "Au format .csv", download_dossiers_gestionnaire_procedure_path(format: :csv, procedure_id: procedure.id), target: "_blank"
|
||||||
%li
|
%li
|
||||||
= link_to "Au format .xlsx", download_dossiers_gestionnaire_procedure_path(format: :xlsx, procedure_id: procedure.id), target: "_blank"
|
= link_to "Au format .xlsx", download_dossiers_gestionnaire_procedure_path(format: :xlsx, procedure_id: procedure.id, tables: [:etablissements]), target: "_blank"
|
||||||
%li
|
%li
|
||||||
= link_to "Au format .ods", download_dossiers_gestionnaire_procedure_path(format: :ods, procedure_id: procedure.id), target: "_blank"
|
= link_to "Au format .ods", download_dossiers_gestionnaire_procedure_path(format: :ods, procedure_id: procedure.id, tables: [:etablissements]), target: "_blank"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
%span.guest Invité
|
%span.guest Invité
|
||||||
%span.date{ class: highlight_if_unseen_class(messagerie_seen_at, commentaire.created_at) }
|
%span.date{ class: highlight_if_unseen_class(messagerie_seen_at, commentaire.created_at) }
|
||||||
= commentaire_date(commentaire)
|
= commentaire_date(commentaire)
|
||||||
.rich-text= sanitize(commentaire.body)
|
.rich-text= sanitize(simple_format(commentaire.body))
|
||||||
|
|
||||||
- if commentaire.piece_justificative
|
- if commentaire.piece_justificative
|
||||||
.attachment-link
|
.attachment-link
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace :after_party do
|
||||||
desc "Run after_party tasks."
|
desc "Run after_party tasks."
|
||||||
task :run do
|
task :run do
|
||||||
command %{
|
command %{
|
||||||
echo "-----> Running deploy tasks"
|
echo "-----> Running after_party"
|
||||||
#{echo_cmd %[bundle exec rake after_party:run]}
|
#{echo_cmd %[bundle exec rake after_party:run]}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -103,7 +103,6 @@ task :deploy do
|
||||||
invoke :'bundle:install'
|
invoke :'bundle:install'
|
||||||
invoke :'yarn:install'
|
invoke :'yarn:install'
|
||||||
invoke :'rails:db_migrate'
|
invoke :'rails:db_migrate'
|
||||||
# invoke :'after_party:run'
|
|
||||||
invoke :'rails:assets_precompile'
|
invoke :'rails:assets_precompile'
|
||||||
|
|
||||||
on :launch do
|
on :launch do
|
||||||
|
@ -114,3 +113,11 @@ task :deploy do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :post_deploy do
|
||||||
|
command 'export PATH=$PATH:/home/ds/.rbenv/bin:/home/ds/.rbenv/shims'
|
||||||
|
command 'source /home/ds/.profile'
|
||||||
|
command 'cd /home/ds/current'
|
||||||
|
|
||||||
|
invoke :'after_party:run'
|
||||||
|
end
|
||||||
|
|
|
@ -1,20 +1,6 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { environment } = require('@rails/webpacker');
|
const { environment } = require('@rails/webpacker');
|
||||||
|
|
||||||
// By default don't transpile JS files in ./node_modules – except for some specific modules.
|
|
||||||
const babelLoader = environment.loaders.get('babel');
|
|
||||||
babelLoader.exclude = function(modulePath) {
|
|
||||||
let forcedModules = [
|
|
||||||
'activestorage' // ActiveStorage uses 'class', which is not supported by IE 11 and older Safari version
|
|
||||||
];
|
|
||||||
return (
|
|
||||||
modulePath.includes('node_modules') &&
|
|
||||||
forcedModules.every(
|
|
||||||
forcedModule => !modulePath.includes('node_modules/' + forcedModule)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const resolve = {
|
const resolve = {
|
||||||
alias: {
|
alias: {
|
||||||
'@utils': path.resolve(__dirname, '..', '..', 'app/javascript/shared/utils')
|
'@utils': path.resolve(__dirname, '..', '..', 'app/javascript/shared/utils')
|
||||||
|
|
9
db/migrate/20181204125101_add_user_id_to_commentaires.rb
Normal file
9
db/migrate/20181204125101_add_user_id_to_commentaires.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class AddUserIdToCommentaires < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :commentaires, :user_id, :bigint
|
||||||
|
add_column :commentaires, :gestionnaire_id, :bigint
|
||||||
|
|
||||||
|
add_index :commentaires, :user_id
|
||||||
|
add_index :commentaires, :gestionnaire_id
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_11_23_195208) do
|
ActiveRecord::Schema.define(version: 2018_12_04_125101) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -189,7 +189,11 @@ ActiveRecord::Schema.define(version: 2018_11_23_195208) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "piece_justificative_id"
|
t.integer "piece_justificative_id"
|
||||||
t.string "file"
|
t.string "file"
|
||||||
|
t.bigint "user_id"
|
||||||
|
t.bigint "gestionnaire_id"
|
||||||
t.index ["dossier_id"], name: "index_commentaires_on_dossier_id"
|
t.index ["dossier_id"], name: "index_commentaires_on_dossier_id"
|
||||||
|
t.index ["gestionnaire_id"], name: "index_commentaires_on_gestionnaire_id"
|
||||||
|
t.index ["user_id"], name: "index_commentaires_on_user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "delayed_jobs", id: :serial, force: :cascade do |t|
|
create_table "delayed_jobs", id: :serial, force: :cascade do |t|
|
||||||
|
|
|
@ -107,6 +107,15 @@ module Cellar
|
||||||
response.is_a?(Net::HTTPSuccess)
|
response.is_a?(Net::HTTPSuccess)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def last_modified(key)
|
||||||
|
request = Net::HTTP::Head.new("/#{key}")
|
||||||
|
@signer.sign(request, key)
|
||||||
|
response = @http.request(request)
|
||||||
|
if response.is_a?(Net::HTTPSuccess)
|
||||||
|
Time.zone.parse(response['Last-Modified'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_range_header(request, range)
|
def add_range_header(request, range)
|
||||||
|
|
183
lib/tasks/2018_12_03_finish_piece_jointe_transfer.rake
Normal file
183
lib/tasks/2018_12_03_finish_piece_jointe_transfer.rake
Normal file
|
@ -0,0 +1,183 @@
|
||||||
|
namespace :'2018_12_03_finish_piece_jointe_transfer' do
|
||||||
|
task run: :environment do
|
||||||
|
Class.new do
|
||||||
|
def run
|
||||||
|
notify_dry_run
|
||||||
|
refresh_outdated_files
|
||||||
|
fix_openstack_mime_types
|
||||||
|
remove_unused_openstack_objects
|
||||||
|
notify_dry_run
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify_dry_run
|
||||||
|
if !force?
|
||||||
|
rake_puts "Dry run, run with FORCE=1 to actually perform changes"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def force?
|
||||||
|
if !defined? @force
|
||||||
|
@force = (ENV['FORCE'].presence || '0').to_i != 0
|
||||||
|
end
|
||||||
|
|
||||||
|
@force
|
||||||
|
end
|
||||||
|
|
||||||
|
def verbose?
|
||||||
|
if !defined? @verbose
|
||||||
|
@verbose = (ENV['VERBOSE'].presence || '0').to_i != 0
|
||||||
|
end
|
||||||
|
|
||||||
|
@verbose
|
||||||
|
end
|
||||||
|
|
||||||
|
def old_pj_adapter
|
||||||
|
if !defined? @old_pj_adapter
|
||||||
|
@old_pj_adapter = Cellar::CellarAdapter.new(
|
||||||
|
ENV['CLEVER_CLOUD_ACCESS_KEY_ID'],
|
||||||
|
ENV['CLEVER_CLOUD_SECRET_ACCESS_KEY'],
|
||||||
|
ENV['CLEVER_CLOUD_BUCKET']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
@old_pj_adapter
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_pjs
|
||||||
|
if !defined? @new_pjs
|
||||||
|
fog_credentials = {
|
||||||
|
provider: 'OpenStack',
|
||||||
|
openstack_tenant: Rails.application.secrets.fog[:openstack_tenant],
|
||||||
|
openstack_api_key: Rails.application.secrets.fog[:openstack_api_key],
|
||||||
|
openstack_username: Rails.application.secrets.fog[:openstack_username],
|
||||||
|
openstack_auth_url: Rails.application.secrets.fog[:openstack_auth_url],
|
||||||
|
openstack_region: Rails.application.secrets.fog[:openstack_region],
|
||||||
|
openstack_identity_api_version: Rails.application.secrets.fog[:oopenstack_identity_api_version]
|
||||||
|
}
|
||||||
|
new_pj_storage = Fog::Storage.new(fog_credentials)
|
||||||
|
@new_pjs = new_pj_storage.directories.get(ENV['FOG_ACTIVESTORAGE_DIRECTORY'])
|
||||||
|
end
|
||||||
|
|
||||||
|
@new_pjs
|
||||||
|
end
|
||||||
|
|
||||||
|
# After the initial bulk transfer, but before ActiveStorage is switched to the new storage,
|
||||||
|
# there is a window where new attachments can be added to the old storage.
|
||||||
|
#
|
||||||
|
# This task ports them to the new storage after the switch, while being careful not to
|
||||||
|
# overwrite attachments that may have changed in the new storage after the switch.
|
||||||
|
def refresh_outdated_files
|
||||||
|
rake_puts "Refresh outdated attachments"
|
||||||
|
|
||||||
|
bar = RakeProgressbar.new(ActiveStorage::Blob.count)
|
||||||
|
refreshed_keys = []
|
||||||
|
missing_keys = []
|
||||||
|
old_pj_adapter.session do |old_pjs|
|
||||||
|
ActiveStorage::Blob.find_each do |blob|
|
||||||
|
new_pj_metadata = new_pjs.files.head(blob.key)
|
||||||
|
|
||||||
|
refresh_needed = new_pj_metadata.nil?
|
||||||
|
if !refresh_needed
|
||||||
|
new_pj_last_modified = new_pj_metadata.last_modified.in_time_zone
|
||||||
|
old_pj_last_modified = old_pjs.last_modified(blob.key)
|
||||||
|
if old_pj_last_modified.nil?
|
||||||
|
missing_keys.push(blob.key)
|
||||||
|
else
|
||||||
|
refresh_needed = new_pj_last_modified < old_pj_last_modified
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if refresh_needed
|
||||||
|
refreshed_keys.push(blob.key)
|
||||||
|
if force?
|
||||||
|
file = Tempfile.new(blob.key)
|
||||||
|
file.binmode
|
||||||
|
old_pjs.download(blob.key) do |chunk|
|
||||||
|
file.write(chunk)
|
||||||
|
end
|
||||||
|
file.rewind
|
||||||
|
new_pjs.files.create(
|
||||||
|
:key => blob.key,
|
||||||
|
:body => file,
|
||||||
|
:public => false
|
||||||
|
)
|
||||||
|
file.close
|
||||||
|
file.unlink
|
||||||
|
end
|
||||||
|
end
|
||||||
|
bar.inc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
bar.finished
|
||||||
|
|
||||||
|
if verbose?
|
||||||
|
rake_puts "Refreshed #{refreshed_keys.count} attachments\n#{refreshed_keys.join(', ')}"
|
||||||
|
end
|
||||||
|
if missing_keys.present?
|
||||||
|
rake_puts "Failed to refresh #{missing_keys.count} attachments\n#{missing_keys.join(', ')}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# For OpenStack, the content type cannot be forced dynamically from a direct download URL.
|
||||||
|
#
|
||||||
|
# The ActiveStorage-OpenStack adapter works around this by monkey patching ActiveStorage
|
||||||
|
# to statically set the correct MIME type on each OpenStack object.
|
||||||
|
#
|
||||||
|
# However, for objects that have been migrated from another storage, the content-type might
|
||||||
|
# be wrong, so we manually fix it.
|
||||||
|
def fix_openstack_mime_types
|
||||||
|
if !ActiveStorage::Blob.service.respond_to?(:change_content_type)
|
||||||
|
rake_puts "Not running on openstack, not fixing MIME types"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
rake_puts "Fix MIME types"
|
||||||
|
|
||||||
|
bar = RakeProgressbar.new(ActiveStorage::Blob.count)
|
||||||
|
failed_keys = []
|
||||||
|
updated_keys = []
|
||||||
|
ActiveStorage::Blob.find_each do |blob|
|
||||||
|
if blob.identified? && blob.content_type.present?
|
||||||
|
updated_keys.push(blob.key)
|
||||||
|
if force?
|
||||||
|
if !blob.service.change_content_type(blob.key, blob.content_type)
|
||||||
|
failed_keys.push(blob.key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
bar.inc
|
||||||
|
end
|
||||||
|
bar.finished
|
||||||
|
|
||||||
|
if verbose?
|
||||||
|
rake_puts "Updated MIME Type for #{updated_keys.count} keys\n#{updated_keys.join(', ')}"
|
||||||
|
end
|
||||||
|
if failed_keys.present?
|
||||||
|
rake_puts "failed to update #{failed_keys.count} keys (dangling blob?)\n#{failed_keys.join(', ')}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Garbage collect objects that might have been removed in the meantime
|
||||||
|
def remove_unused_openstack_objects
|
||||||
|
rake_puts "Remove unused files"
|
||||||
|
|
||||||
|
bar = RakeProgressbar.new(new_pjs.count.to_i)
|
||||||
|
removed_keys = []
|
||||||
|
new_pjs.files.each do |file|
|
||||||
|
if !ActiveStorage::Blob.exists?(key: file.key)
|
||||||
|
removed_keys.push(file.key)
|
||||||
|
if force?
|
||||||
|
file.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
bar.inc
|
||||||
|
end
|
||||||
|
bar.finished
|
||||||
|
|
||||||
|
if verbose?
|
||||||
|
rake_puts "Removed #{removed_keys.count} unused objects\n#{removed_keys.join(', ')}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end.new.run
|
||||||
|
end
|
||||||
|
end
|
|
@ -25,3 +25,10 @@ task :deploy do
|
||||||
sh "mina deploy domain=#{domain} branch=#{branch} force_asset_precompile=true"
|
sh "mina deploy domain=#{domain} branch=#{branch} force_asset_precompile=true"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :post_deploy do
|
||||||
|
domains = domains_for_stage(ENV.fetch('STAGE'))
|
||||||
|
branch = ENV.fetch('BRANCH')
|
||||||
|
|
||||||
|
sh "mina post_deploy domain=#{domains.first} branch=#{branch}"
|
||||||
|
end
|
||||||
|
|
12
package.json
12
package.json
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rails/webpacker": "4.0.0-pre.2",
|
"@rails/webpacker": "4.0.0-pre.3",
|
||||||
"@sentry/browser": "^4.0.4",
|
"@sentry/browser": "^4.0.4",
|
||||||
"@turf/area": "^6.0.1",
|
"@turf/area": "^6.0.1",
|
||||||
"activestorage": "^5.2.1",
|
"activestorage": "^5.2.2-rc1",
|
||||||
"autocomplete.js": "^0.31.0",
|
"autocomplete.js": "^0.31.0",
|
||||||
"chartkick": "^3.0.1",
|
"chartkick": "^3.0.1",
|
||||||
"debounce": "^1.2.0",
|
"debounce": "^1.2.0",
|
||||||
|
@ -19,10 +19,10 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eclint": "^2.8.0",
|
"eclint": "^2.8.0",
|
||||||
"eslint": "^5.6.0",
|
"eslint": "^5.9.0",
|
||||||
"eslint-config-prettier": "^3.1.0",
|
"eslint-config-prettier": "^3.3.0",
|
||||||
"eslint-plugin-prettier": "^2.6.2",
|
"eslint-plugin-prettier": "^3.0.0",
|
||||||
"prettier": "^1.14.3",
|
"prettier": "^1.15.3",
|
||||||
"webpack-dev-server": "^3.1.9"
|
"webpack-dev-server": "^3.1.9"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -301,7 +301,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
||||||
|
|
||||||
expect(response).to render_template :messagerie
|
expect(response).to render_template :messagerie
|
||||||
expect(flash.alert).to be_present
|
expect(flash.alert).to be_present
|
||||||
expect(assigns(:commentaire).body).to eq("<p>avant\n<br />apres</p>")
|
expect(assigns(:commentaire).body).to eq("avant\napres")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -307,4 +307,33 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#download_dossiers" do
|
||||||
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
|
let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) }
|
||||||
|
|
||||||
|
context "when logged in" do
|
||||||
|
before do
|
||||||
|
sign_in(gestionnaire)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "csv" do
|
||||||
|
before { get :download_dossiers, params: { procedure_id: procedure.id }, format: 'csv' }
|
||||||
|
|
||||||
|
it { expect(response).to have_http_status(:ok) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "xlsx" do
|
||||||
|
before { get :download_dossiers, params: { procedure_id: procedure.id }, format: 'xlsx' }
|
||||||
|
|
||||||
|
it { expect(response).to have_http_status(:ok) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "ods" do
|
||||||
|
before { get :download_dossiers, params: { procedure_id: procedure.id }, format: 'ods' }
|
||||||
|
|
||||||
|
it { expect(response).to have_http_status(:ok) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -787,7 +787,7 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
|
|
||||||
expect(response).to render_template :messagerie
|
expect(response).to render_template :messagerie
|
||||||
expect(flash.alert).to be_present
|
expect(flash.alert).to be_present
|
||||||
expect(assigns(:commentaire).body).to eq("<p>avant\n<br />apres</p>")
|
expect(assigns(:commentaire).body).to eq("avant\napres")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,8 +29,28 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_integer_number, class: 'Champs::IntegerNumberChamp' do
|
factory :champ_text, class: 'Champs::TextChamp' do
|
||||||
type_de_champ { create(:type_de_champ_integer_number) }
|
type_de_champ { create(:type_de_champ_text) }
|
||||||
|
value { 'text' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_textarea, class: 'Champs::TextareaChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_textarea) }
|
||||||
|
value { 'textarea' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_date, class: 'Champs::DateChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_date) }
|
||||||
|
value { 1.day.ago.iso8601 }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_datetime, class: 'Champs::DatetimeChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_datetime) }
|
||||||
|
value { 1.day.ago.iso8601 }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_number, class: 'Champs::NumberChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_number) }
|
||||||
value { '42' }
|
value { '42' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,23 +59,89 @@ FactoryBot.define do
|
||||||
value { '42.1' }
|
value { '42.1' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :champ_integer_number, class: 'Champs::IntegerNumberChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_integer_number) }
|
||||||
|
value { '42' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_checkbox, class: 'Champs::CheckboxChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_checkbox) }
|
||||||
|
value { 'on' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_civilite, class: 'Champs::CiviliteChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_civilite) }
|
||||||
|
value { 'M.' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_email, class: 'Champs::EmailChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_email) }
|
||||||
|
value { 'yoda@beta.gouv.fr' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_phone, class: 'Champs::PhoneChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_phone) }
|
||||||
|
value { '0666666666' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_address, class: 'Champs::AddressChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_address) }
|
||||||
|
value { '2 rue des Démarches' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_yes_no, class: 'Champs::YesNoChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_yes_no) }
|
||||||
|
value { 'true' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_drop_down_list, class: 'Champs::DropDownListChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_drop_down_list) }
|
||||||
|
value { '' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_multiple_drop_down_list, class: 'Champs::MultipleDropDownListChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_multiple_drop_down_list) }
|
||||||
|
value { '' }
|
||||||
|
end
|
||||||
|
|
||||||
factory :champ_linked_drop_down_list, class: 'Champs::LinkedDropDownListChamp' do
|
factory :champ_linked_drop_down_list, class: 'Champs::LinkedDropDownListChamp' do
|
||||||
type_de_champ { create(:type_de_champ_linked_drop_down_list) }
|
type_de_champ { create(:type_de_champ_linked_drop_down_list) }
|
||||||
value { '{}' }
|
value { '{}' }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_carte, class: 'Champs::CarteChamp' do
|
factory :champ_pays, class: 'Champs::PaysChamp' do
|
||||||
type_de_champ { create(:type_de_champ_carte) }
|
type_de_champ { create(:type_de_champ_pays) }
|
||||||
|
value { 'France' }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_siret, class: 'Champs::SiretChamp' do
|
factory :champ_regions, class: 'Champs::RegionChamp' do
|
||||||
type_de_champ { create(:type_de_champ_siret) }
|
type_de_champ { create(:type_de_champ_regions) }
|
||||||
value { '44011762001530' }
|
value { '' }
|
||||||
etablissement { create(:etablissement) }
|
end
|
||||||
|
|
||||||
before(:create) do |champ, evaluator|
|
factory :champ_departements, class: 'Champs::DepartementChamp' do
|
||||||
champ.etablissement.signature = champ.etablissement.sign
|
type_de_champ { create(:type_de_champ_departements) }
|
||||||
end
|
value { '' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_engagement, class: 'Champs::EngagementChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_engagement) }
|
||||||
|
value { 'true' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_header_section, class: 'Champs::HeaderSectionChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_header_section) }
|
||||||
|
value { 'une section' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_explication, class: 'Champs::ExplicationChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_explication) }
|
||||||
|
value { 'une explication' }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_dossier_link, class: 'Champs::DossierLinkChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_dossier_link) }
|
||||||
|
value { create(:dossier).id }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_piece_justificative, class: 'Champs::PieceJustificativeChamp' do
|
factory :champ_piece_justificative, class: 'Champs::PieceJustificativeChamp' do
|
||||||
|
@ -65,4 +151,18 @@ FactoryBot.define do
|
||||||
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
|
||||||
|
|
||||||
|
factory :champ_carte, class: 'Champs::CarteChamp' do
|
||||||
|
type_de_champ { create(:type_de_champ_carte) }
|
||||||
|
end
|
||||||
|
|
||||||
|
factory :champ_siret, class: 'Champs::SiretChamp' do
|
||||||
|
association :type_de_champ, factory: [:type_de_champ_siret]
|
||||||
|
association :etablissement, factory: [:etablissement]
|
||||||
|
value { '44011762001530' }
|
||||||
|
|
||||||
|
after(:build) do |champ, evaluator|
|
||||||
|
champ.etablissement.signature = champ.etablissement.sign
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -131,5 +131,23 @@ FactoryBot.define do
|
||||||
dossier.attestation = dossier.build_attestation
|
dossier.attestation = dossier.build_attestation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :with_all_champs do
|
||||||
|
after(:create) do |dossier, _evaluator|
|
||||||
|
dossier.champs = dossier.procedure.types_de_champ.map do |type_de_champ|
|
||||||
|
build(:"champ_#{type_de_champ.type_champ}", type_de_champ: type_de_champ)
|
||||||
|
end
|
||||||
|
dossier.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
trait :with_all_annotations do
|
||||||
|
after(:create) do |dossier, _evaluator|
|
||||||
|
dossier.champs = dossier.procedure.types_de_champ.map do |type_de_champ|
|
||||||
|
build(:"champ_#{type_de_champ.type_champ}", type_de_champ: type_de_champ)
|
||||||
|
end
|
||||||
|
dossier.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -134,6 +134,15 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :archived_automatically do
|
||||||
|
# For now the behavior is the same than :archived
|
||||||
|
# (it may be different in the future though)
|
||||||
|
after(:build) do |procedure, _evaluator|
|
||||||
|
procedure.publish!(generate(:published_path))
|
||||||
|
procedure.archive!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
trait :hidden do
|
trait :hidden do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
procedure.publish!(generate(:published_path))
|
procedure.publish!(generate(:published_path))
|
||||||
|
@ -167,28 +176,34 @@ FactoryBot.define do
|
||||||
|
|
||||||
trait :with_all_champs_mandatory do
|
trait :with_all_champs_mandatory do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
tdcs = []
|
procedure.types_de_champ = TypeDeChamp.type_champs.map.with_index do |(libelle, type_champ), index|
|
||||||
tdcs << create(:type_de_champ, mandatory: true, libelle: 'text')
|
if libelle == 'drop_down_list'
|
||||||
tdcs << create(:type_de_champ_textarea, mandatory: true, libelle: 'textarea')
|
libelle = 'simple_drop_down_list'
|
||||||
tdcs << create(:type_de_champ_date, mandatory: true, libelle: 'date')
|
end
|
||||||
tdcs << create(:type_de_champ_datetime, mandatory: true, libelle: 'datetime')
|
build(:"type_de_champ_#{type_champ}", mandatory: true, libelle: libelle, order_place: index)
|
||||||
tdcs << create(:type_de_champ_number, mandatory: true, libelle: 'number')
|
end
|
||||||
tdcs << create(:type_de_champ_checkbox, mandatory: true, libelle: 'checkbox')
|
end
|
||||||
tdcs << create(:type_de_champ_civilite, mandatory: true, libelle: 'civilite')
|
end
|
||||||
tdcs << create(:type_de_champ_email, mandatory: true, libelle: 'email')
|
|
||||||
tdcs << create(:type_de_champ_phone, mandatory: true, libelle: 'phone')
|
trait :with_all_champs do
|
||||||
tdcs << create(:type_de_champ_yes_no, mandatory: true, libelle: 'yes_no')
|
after(:build) do |procedure, _evaluator|
|
||||||
tdcs << create(:type_de_champ_drop_down_list, mandatory: true, libelle: 'simple_drop_down_list')
|
procedure.types_de_champ = TypeDeChamp.type_champs.map.with_index do |(libelle, type_champ), index|
|
||||||
tdcs << create(:type_de_champ_multiple_drop_down_list, mandatory: true, libelle: 'multiple_drop_down_list')
|
if libelle == 'drop_down_list'
|
||||||
tdcs << create(:type_de_champ_pays, mandatory: true, libelle: 'pays')
|
libelle = 'simple_drop_down_list'
|
||||||
tdcs << create(:type_de_champ_regions, mandatory: true, libelle: 'regions')
|
end
|
||||||
tdcs << create(:type_de_champ_departements, mandatory: true, libelle: 'departements')
|
build(:"type_de_champ_#{type_champ}", libelle: libelle, order_place: index)
|
||||||
tdcs << create(:type_de_champ_engagement, mandatory: true, libelle: 'engagement')
|
end
|
||||||
tdcs << create(:type_de_champ_header_section, mandatory: true, libelle: 'header_section')
|
end
|
||||||
tdcs << create(:type_de_champ_explication, mandatory: true, libelle: 'explication')
|
end
|
||||||
tdcs << create(:type_de_champ_dossier_link, mandatory: true, libelle: 'dossier_link')
|
|
||||||
tdcs << create(:type_de_champ_piece_justificative, mandatory: true, libelle: 'piece_justificative')
|
trait :with_all_annotations do
|
||||||
procedure.types_de_champ = tdcs
|
after(:build) do |procedure, _evaluator|
|
||||||
|
procedure.types_de_champ_private = TypeDeChamp.type_champs.map.with_index do |(libelle, type_champ), index|
|
||||||
|
if libelle == 'drop_down_list'
|
||||||
|
libelle = 'simple_drop_down_list'
|
||||||
|
end
|
||||||
|
build(:"type_de_champ_#{type_champ}", private: true, libelle: libelle, order_place: index)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -166,60 +166,6 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#convert_specific_hash_values_to_string(hash_to_convert)' do
|
|
||||||
let(:procedure) { create(:procedure) }
|
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
|
||||||
let(:dossier_serialized_attributes) { DossierSerializer.new(dossier).attributes }
|
|
||||||
|
|
||||||
subject { dossier.send(:convert_specific_hash_values_to_string, dossier_serialized_attributes) }
|
|
||||||
|
|
||||||
it { expect(dossier_serialized_attributes[:id]).to be_an(Integer) }
|
|
||||||
it { expect(dossier_serialized_attributes[:created_at]).to be_a(Time) }
|
|
||||||
it { expect(dossier_serialized_attributes[:updated_at]).to be_a(Time) }
|
|
||||||
it { expect(dossier_serialized_attributes[:archived]).to be_in([true, false]) }
|
|
||||||
it { expect(dossier_serialized_attributes[:state]).to be_a(String) }
|
|
||||||
|
|
||||||
it { expect(subject[:id]).to be_a(String) }
|
|
||||||
it { expect(subject[:created_at]).to be_a(Time) }
|
|
||||||
it { expect(subject[:updated_at]).to be_a(Time) }
|
|
||||||
it { expect(subject[:archived]).to be_a(String) }
|
|
||||||
it { expect(subject[:state]).to be_a(String) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#export_etablissement_data' do
|
|
||||||
let(:procedure) { create(:procedure) }
|
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
|
||||||
|
|
||||||
subject { dossier.send(:export_etablissement_data) }
|
|
||||||
|
|
||||||
it { expect(subject[:etablissement_siret]).to eq('44011762001530') }
|
|
||||||
it { expect(subject[:etablissement_siege_social]).to eq('true') }
|
|
||||||
it { expect(subject[:etablissement_naf]).to eq('4950Z') }
|
|
||||||
it { expect(subject[:etablissement_libelle_naf]).to eq('Transports par conduites') }
|
|
||||||
it { expect(subject[:etablissement_adresse]).to eq('GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES') }
|
|
||||||
it { expect(subject[:etablissement_numero_voie]).to eq('6') }
|
|
||||||
it { expect(subject[:etablissement_type_voie]).to eq('RUE') }
|
|
||||||
it { expect(subject[:etablissement_nom_voie]).to eq('RAOUL NORDLING') }
|
|
||||||
it { expect(subject[:etablissement_complement_adresse]).to eq('IMMEUBLE BORA') }
|
|
||||||
it { expect(subject[:etablissement_code_postal]).to eq('92270') }
|
|
||||||
it { expect(subject[:etablissement_localite]).to eq('BOIS COLOMBES') }
|
|
||||||
it { expect(subject[:etablissement_code_insee_localite]).to eq('92009') }
|
|
||||||
it { expect(subject[:entreprise_siren]).to eq('440117620') }
|
|
||||||
it { expect(subject[:entreprise_capital_social]).to eq('537100000') }
|
|
||||||
it { expect(subject[:entreprise_numero_tva_intracommunautaire]).to eq('FR27440117620') }
|
|
||||||
it { expect(subject[:entreprise_forme_juridique]).to eq("SA à conseil d'administration (s.a.i.)") }
|
|
||||||
it { expect(subject[:entreprise_forme_juridique_code]).to eq('5599') }
|
|
||||||
it { expect(subject[:entreprise_nom_commercial]).to eq('GRTGAZ') }
|
|
||||||
it { expect(subject[:entreprise_raison_sociale]).to eq('GRTGAZ') }
|
|
||||||
it { expect(subject[:entreprise_siret_siege_social]).to eq('44011762001530') }
|
|
||||||
it { expect(subject[:entreprise_code_effectif_entreprise]).to eq('51') }
|
|
||||||
it { expect(subject[:entreprise_date_creation]).to eq('1990-04-24T00:00:00+00:00') }
|
|
||||||
it { expect(subject[:entreprise_nom]).to be_nil }
|
|
||||||
it { expect(subject[:entreprise_prenom]).to be_nil }
|
|
||||||
|
|
||||||
it { expect(subject.count).to eq(EntrepriseSerializer.new(Entreprise.new).as_json.count + EtablissementSerializer.new(Etablissement.new).as_json.count) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when dossier is followed' do
|
context 'when dossier is followed' do
|
||||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
|
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
|
||||||
let(:gestionnaire) { create(:gestionnaire) }
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
|
@ -236,112 +182,6 @@ describe Dossier do
|
||||||
it { expect(subject).to eq [gestionnaire] }
|
it { expect(subject).to eq [gestionnaire] }
|
||||||
it { expect(subject).not_to include(non_following_gestionnaire) }
|
it { expect(subject).not_to include(non_following_gestionnaire) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#export_headers' do
|
|
||||||
subject { dossier.export_headers }
|
|
||||||
|
|
||||||
it { expect(subject).to include(dossier.champs.first.libelle.parameterize.underscore.to_sym) }
|
|
||||||
it { expect(subject).to include(:individual_gender) }
|
|
||||||
it { expect(subject).to include(:individual_nom) }
|
|
||||||
it { expect(subject).to include(:individual_prenom) }
|
|
||||||
it { expect(subject).to include(:individual_birthdate) }
|
|
||||||
it do
|
|
||||||
expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
|
|
||||||
dossier.procedure.types_de_champ.count +
|
|
||||||
dossier.procedure.types_de_champ_private.count +
|
|
||||||
dossier.send(:export_etablissement_data).count)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#sorted_values' do
|
|
||||||
subject { dossier.send(:sorted_values) }
|
|
||||||
|
|
||||||
it { expect(subject[0]).to be_a_kind_of(Integer) }
|
|
||||||
it { expect(subject[1]).to be_a_kind_of(Time) }
|
|
||||||
it { expect(subject[2]).to be_a_kind_of(Time) }
|
|
||||||
it { expect(subject[3]).to be_in([true, false]) }
|
|
||||||
it { expect(subject[4]).to eq(dossier.user.email) }
|
|
||||||
it { expect(subject[5]).to eq(Dossier.states.fetch(:brouillon)) }
|
|
||||||
it { expect(subject[6]).to eq(date1) }
|
|
||||||
it { expect(subject[7]).to eq(date2) }
|
|
||||||
it { expect(subject[8]).to eq(date3) }
|
|
||||||
it { expect(subject[9]).to be_a_kind_of(String) }
|
|
||||||
it { expect(subject[10]).to be_a_kind_of(String) }
|
|
||||||
it { expect(subject[11]).to be_nil }
|
|
||||||
it { expect(subject[12]).to be_nil }
|
|
||||||
it { expect(subject[13]).to be_nil }
|
|
||||||
it { expect(subject[14]).to be_nil }
|
|
||||||
it { expect(subject[15]).to be_nil }
|
|
||||||
it do
|
|
||||||
expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count +
|
|
||||||
dossier.procedure.types_de_champ.count +
|
|
||||||
dossier.procedure.types_de_champ_private.count +
|
|
||||||
dossier.send(:export_etablissement_data).count)
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'dossier for individual' do
|
|
||||||
let(:dossier_with_individual) { create(:dossier, :for_individual, user: user, procedure: procedure) }
|
|
||||||
|
|
||||||
subject { dossier_with_individual.send(:sorted_values) }
|
|
||||||
|
|
||||||
it { expect(subject[11]).to eq(dossier_with_individual.individual.gender) }
|
|
||||||
it { expect(subject[12]).to eq(dossier_with_individual.individual.prenom) }
|
|
||||||
it { expect(subject[13]).to eq(dossier_with_individual.individual.nom) }
|
|
||||||
it { expect(subject[14]).to eq(dossier_with_individual.individual.birthdate) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#full_data_string" do
|
|
||||||
let(:expected_string) {
|
|
||||||
[
|
|
||||||
dossier.id.to_s,
|
|
||||||
dossier.created_at,
|
|
||||||
dossier.updated_at,
|
|
||||||
"false",
|
|
||||||
dossier.user.email,
|
|
||||||
Dossier.states.fetch(:brouillon),
|
|
||||||
dossier.en_construction_at,
|
|
||||||
dossier.en_instruction_at,
|
|
||||||
dossier.processed_at,
|
|
||||||
"Motivation",
|
|
||||||
gestionnaire.email,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
"44011762001530",
|
|
||||||
"true",
|
|
||||||
"4950Z",
|
|
||||||
"Transports par conduites",
|
|
||||||
"GRTGAZ IMMEUBLE BORA 6 RUE RAOUL NORDLING 92270 BOIS COLOMBES",
|
|
||||||
"6",
|
|
||||||
"RUE",
|
|
||||||
"RAOUL NORDLING",
|
|
||||||
"IMMEUBLE BORA",
|
|
||||||
"92270",
|
|
||||||
"BOIS COLOMBES",
|
|
||||||
"92009",
|
|
||||||
"440117620",
|
|
||||||
"537100000",
|
|
||||||
"FR27440117620",
|
|
||||||
"SA à conseil d'administration (s.a.i.)",
|
|
||||||
"5599",
|
|
||||||
"GRTGAZ",
|
|
||||||
"GRTGAZ",
|
|
||||||
"44011762001530",
|
|
||||||
"51",
|
|
||||||
"1990-04-24T00:00:00+00:00",
|
|
||||||
nil,
|
|
||||||
nil
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
subject { dossier }
|
|
||||||
|
|
||||||
it { expect(dossier.export_values).to eq(expected_string) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#reset!' do
|
describe '#reset!' do
|
||||||
|
|
|
@ -6,10 +6,35 @@ describe Gestionnaire, type: :model do
|
||||||
let!(:procedure_2) { create :procedure, :published, administrateur: admin }
|
let!(:procedure_2) { create :procedure, :published, administrateur: admin }
|
||||||
let!(:procedure_3) { create :procedure, :published, administrateur: admin }
|
let!(:procedure_3) { create :procedure, :published, administrateur: admin }
|
||||||
let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] }
|
let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] }
|
||||||
let!(:procedure_assign) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure }
|
let!(:procedure_assign) { assign(procedure) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
|
assign(procedure_2)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#visible_procedures' do
|
||||||
|
let(:procedure_not_assigned) { create :procedure, administrateur: admin }
|
||||||
|
let(:procedure_without_link) { create :procedure, administrateur: admin }
|
||||||
|
let(:procedure_with_link) { create :procedure, :with_path, administrateur: admin }
|
||||||
|
let(:procedure_archived_manually) { create :procedure, :archived, administrateur: admin }
|
||||||
|
let(:procedure_archived_automatically) { create :procedure, :archived_automatically, administrateur: admin }
|
||||||
|
|
||||||
|
before do
|
||||||
|
assign(procedure_without_link)
|
||||||
|
assign(procedure_with_link)
|
||||||
|
assign(procedure_archived_manually)
|
||||||
|
assign(procedure_archived_automatically)
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { gestionnaire.visible_procedures }
|
||||||
|
|
||||||
|
it do
|
||||||
|
expect(subject).not_to include(procedure_not_assigned)
|
||||||
|
expect(subject).not_to include(procedure_without_link)
|
||||||
|
expect(subject).to include(procedure_with_link)
|
||||||
|
expect(subject).to include(procedure_archived_manually)
|
||||||
|
expect(subject).to include(procedure_archived_automatically)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'follow' do
|
describe 'follow' do
|
||||||
|
@ -390,4 +415,10 @@ describe Gestionnaire, type: :model do
|
||||||
it { expect(follow.demande_seen_at).to eq(freeze_date) }
|
it { expect(follow.demande_seen_at).to eq(freeze_date) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def assign(procedure_to_assign)
|
||||||
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_to_assign
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -515,67 +515,6 @@ describe Procedure do
|
||||||
it { is_expected.to eq 2 }
|
it { is_expected.to eq 2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#generate_export' do
|
|
||||||
let(:procedure) { create :procedure }
|
|
||||||
subject { procedure.generate_export }
|
|
||||||
|
|
||||||
shared_examples "export is empty" do
|
|
||||||
it { expect(subject[:data]).to eq([[]]) }
|
|
||||||
it { expect(subject[:headers]).to eq([]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when there are no dossiers' do
|
|
||||||
it_behaves_like "export is empty"
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when there are some dossiers' do
|
|
||||||
let!(:dossier){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
|
||||||
let!(:dossier2){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) }
|
|
||||||
|
|
||||||
it { expect(subject[:data].size).to eq(2) }
|
|
||||||
it { expect(subject[:headers]).to eq(dossier.export_headers) }
|
|
||||||
|
|
||||||
context 'with ordered champs' do
|
|
||||||
let(:tc_2) { create(:type_de_champ, order_place: 2) }
|
|
||||||
let(:tc_1) { create(:type_de_champ, order_place: 1) }
|
|
||||||
let(:tcp_2) { create(:type_de_champ, :private, order_place: 2) }
|
|
||||||
let(:tcp_1) { create(:type_de_champ, :private, order_place: 1) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
procedure.types_de_champ << tc_2 << tc_1
|
|
||||||
procedure.types_de_champ_private << tcp_2 << tcp_1
|
|
||||||
|
|
||||||
dossier.build_default_champs
|
|
||||||
dossier.champs.find_by(type_de_champ: tc_1).update(value: "value 1")
|
|
||||||
dossier.champs.find_by(type_de_champ: tc_2).update(value: "value 2")
|
|
||||||
dossier.champs_private.find_by(type_de_champ: tcp_1).update(value: "private value 1")
|
|
||||||
dossier.champs_private.find_by(type_de_champ: tcp_2).update(value: "private value 2")
|
|
||||||
|
|
||||||
dossier2.build_default_champs
|
|
||||||
dossier2.champs.find_by(type_de_champ: tc_1).update(value: "value 1")
|
|
||||||
dossier2.champs.find_by(type_de_champ: tc_2).update(value: "value 2")
|
|
||||||
dossier2.champs_private.find_by(type_de_champ: tcp_1).update(value: "private value 1")
|
|
||||||
dossier2.champs_private.find_by(type_de_champ: tcp_2).update(value: "private value 2")
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect(subject[:headers].index(tc_1.libelle.parameterize.underscore.to_sym)).to be < subject[:headers].index(tc_2.libelle.parameterize.underscore.to_sym) }
|
|
||||||
it { expect(subject[:headers].index(tcp_1.libelle.parameterize.underscore.to_sym)).to be < subject[:headers].index(tcp_2.libelle.parameterize.underscore.to_sym) }
|
|
||||||
|
|
||||||
it { expect(subject[:data][0].index("value 1")).to be < subject[:data].first.index("value 2") }
|
|
||||||
it { expect(subject[:data][0].index("private value 1")).to be < subject[:data].first.index("private value 2") }
|
|
||||||
|
|
||||||
it { expect(subject[:data][1].index("value 1")).to be < subject[:data].first.index("value 2") }
|
|
||||||
it { expect(subject[:data][1].index("private value 1")).to be < subject[:data].first.index("private value 2") }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when there is a brouillon dossier' do
|
|
||||||
let!(:dossier_not_exportable){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:brouillon)) }
|
|
||||||
|
|
||||||
it_behaves_like "export is empty"
|
|
||||||
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') }
|
||||||
|
|
||||||
|
@ -632,18 +571,18 @@ describe Procedure do
|
||||||
before { Timecop.freeze(Time.zone.local(2018, 1, 2, 23, 11, 14)) }
|
before { Timecop.freeze(Time.zone.local(2018, 1, 2, 23, 11, 14)) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
|
||||||
subject { procedure.export_filename }
|
subject { procedure.export_filename(:csv) }
|
||||||
|
|
||||||
context "with a path" do
|
context "with a path" do
|
||||||
let(:procedure) { create(:procedure, :published) }
|
let(:procedure) { create(:procedure, :published) }
|
||||||
|
|
||||||
it { is_expected.to eq("dossiers_#{procedure.path}_2018-01-02_23-11") }
|
it { is_expected.to eq("dossiers_#{procedure.path}_2018-01-02_23-11.csv") }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "without a path" do
|
context "without a path" do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
|
|
||||||
it { is_expected.to eq("dossiers_procedure-#{procedure.id}_2018-01-02_23-11") }
|
it { is_expected.to eq("dossiers_procedure-#{procedure.id}_2018-01-02_23-11.csv") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ describe ChampSerializer do
|
||||||
let(:serialized_id) { -1 }
|
let(:serialized_id) { -1 }
|
||||||
let(:serialized_description) { "" }
|
let(:serialized_description) { "" }
|
||||||
let(:serialized_order_place) { -1 }
|
let(:serialized_order_place) { -1 }
|
||||||
let(:serialized_value) { geo_json }
|
let(:serialized_value) { parsed_geo_json }
|
||||||
|
|
||||||
context 'and geo_area is selection_utilisateur' do
|
context 'and geo_area is selection_utilisateur' do
|
||||||
context 'value is empty' do
|
context 'value is empty' do
|
||||||
|
@ -102,6 +102,7 @@ describe ChampSerializer do
|
||||||
let(:serialized_order_place) { champ.order_place }
|
let(:serialized_order_place) { champ.order_place }
|
||||||
let(:serialized_libelle) { champ.libelle }
|
let(:serialized_libelle) { champ.libelle }
|
||||||
let(:serialized_type_champ) { champ.type_champ }
|
let(:serialized_type_champ) { champ.type_champ }
|
||||||
|
let(:serialized_value) { geo_json }
|
||||||
|
|
||||||
context 'when value is coordinates' do
|
context 'when value is coordinates' do
|
||||||
let(:value) { coordinates.to_json }
|
let(:value) { coordinates.to_json }
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe DossierTableExportSerializer do
|
|
||||||
describe '#attributes' do
|
|
||||||
subject { DossierTableExportSerializer.new(dossier).serializable_hash }
|
|
||||||
|
|
||||||
context 'when the dossier is en_construction' do
|
|
||||||
let(:dossier) { create(:dossier, :en_construction) }
|
|
||||||
|
|
||||||
it { is_expected.to include(initiated_at: dossier.en_construction_at) }
|
|
||||||
it { is_expected.to include(state: 'initiated') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when the dossier is en instruction' do
|
|
||||||
let(:dossier) { create(:dossier, :en_instruction) }
|
|
||||||
|
|
||||||
it { is_expected.to include(received_at: dossier.en_instruction_at) }
|
|
||||||
it { is_expected.to include(state: 'received') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when the dossier is accepte' do
|
|
||||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:accepte)) }
|
|
||||||
|
|
||||||
it { is_expected.to include(state: 'closed') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when the dossier is refuse' do
|
|
||||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:refuse)) }
|
|
||||||
|
|
||||||
it { is_expected.to include(state: 'refused') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when the dossier is sans_suite' do
|
|
||||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:sans_suite)) }
|
|
||||||
|
|
||||||
it { is_expected.to include(state: 'without_continuation') }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#emails_instructeurs' do
|
|
||||||
let(:gestionnaire){ create(:gestionnaire) }
|
|
||||||
let(:gestionnaire2) { create :gestionnaire }
|
|
||||||
let(:dossier) { create(:dossier) }
|
|
||||||
|
|
||||||
subject { DossierTableExportSerializer.new(dossier).emails_instructeurs }
|
|
||||||
|
|
||||||
context 'when there is no instructeurs' do
|
|
||||||
it { is_expected.to eq('') }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when there one instructeur' do
|
|
||||||
before { gestionnaire.followed_dossiers << dossier }
|
|
||||||
|
|
||||||
it { is_expected.to eq(gestionnaire.email) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when there is 2 followers' do
|
|
||||||
before do
|
|
||||||
gestionnaire.followed_dossiers << dossier
|
|
||||||
gestionnaire2.followed_dossiers << dossier
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to eq "#{gestionnaire.email} #{gestionnaire2.email}" }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -8,7 +8,7 @@ describe CommentaireService do
|
||||||
let(:file) { nil }
|
let(:file) { nil }
|
||||||
let(:scan_result) { true }
|
let(:scan_result) { true }
|
||||||
|
|
||||||
subject(:commentaire) { CommentaireService.create(sender, dossier, { body: body, file: file }) }
|
subject(:commentaire) { CommentaireService.build(sender, dossier, { body: body, file: file }) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(ClamavService).to receive(:safe_file?).and_return(scan_result)
|
allow(ClamavService).to receive(:safe_file?).and_return(scan_result)
|
||||||
|
@ -17,7 +17,7 @@ describe CommentaireService do
|
||||||
it 'creates a new valid commentaire' do
|
it 'creates a new valid commentaire' do
|
||||||
expect(commentaire.email).to eq sender.email
|
expect(commentaire.email).to eq sender.email
|
||||||
expect(commentaire.dossier).to eq dossier
|
expect(commentaire.dossier).to eq dossier
|
||||||
expect(commentaire.body).to eq '<p>Contenu du message.</p>'
|
expect(commentaire.body).to eq 'Contenu du message.'
|
||||||
expect(commentaire.file).to be_blank
|
expect(commentaire.file).to be_blank
|
||||||
expect(commentaire).to be_valid
|
expect(commentaire).to be_valid
|
||||||
end
|
end
|
||||||
|
|
261
spec/services/procedure_export_service_spec.rb
Normal file
261
spec/services/procedure_export_service_spec.rb
Normal file
|
@ -0,0 +1,261 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe ProcedureExportService do
|
||||||
|
describe 'to_data' do
|
||||||
|
let(:procedure) { create(:procedure, :published, :with_all_champs) }
|
||||||
|
let(:table) { :dossiers }
|
||||||
|
subject { ProcedureExportService.new(procedure).to_data(table) }
|
||||||
|
|
||||||
|
let(:headers) { subject[:headers] }
|
||||||
|
let(:data) { subject[:data] }
|
||||||
|
|
||||||
|
context 'dossiers' do
|
||||||
|
it 'should have headers' do
|
||||||
|
expect(headers).to eq([
|
||||||
|
:id,
|
||||||
|
:created_at,
|
||||||
|
:updated_at,
|
||||||
|
:archived,
|
||||||
|
:email,
|
||||||
|
:state,
|
||||||
|
:initiated_at,
|
||||||
|
:received_at,
|
||||||
|
:processed_at,
|
||||||
|
:motivation,
|
||||||
|
:emails_instructeurs,
|
||||||
|
:individual_gender,
|
||||||
|
:individual_prenom,
|
||||||
|
:individual_nom,
|
||||||
|
:individual_birthdate,
|
||||||
|
:text,
|
||||||
|
:textarea,
|
||||||
|
:date,
|
||||||
|
:datetime,
|
||||||
|
:number,
|
||||||
|
:decimal_number,
|
||||||
|
:integer_number,
|
||||||
|
:checkbox,
|
||||||
|
:civilite,
|
||||||
|
:email,
|
||||||
|
:phone,
|
||||||
|
:address,
|
||||||
|
:yes_no,
|
||||||
|
:simple_drop_down_list,
|
||||||
|
:multiple_drop_down_list,
|
||||||
|
:linked_drop_down_list,
|
||||||
|
:pays,
|
||||||
|
:regions,
|
||||||
|
:departements,
|
||||||
|
:engagement,
|
||||||
|
:header_section,
|
||||||
|
:explication,
|
||||||
|
:dossier_link,
|
||||||
|
:piece_justificative,
|
||||||
|
:siret,
|
||||||
|
:carte,
|
||||||
|
:etablissement_siret,
|
||||||
|
:etablissement_siege_social,
|
||||||
|
:etablissement_naf,
|
||||||
|
:etablissement_libelle_naf,
|
||||||
|
:etablissement_adresse,
|
||||||
|
:etablissement_numero_voie,
|
||||||
|
:etablissement_type_voie,
|
||||||
|
:etablissement_nom_voie,
|
||||||
|
:etablissement_complement_adresse,
|
||||||
|
:etablissement_code_postal,
|
||||||
|
:etablissement_localite,
|
||||||
|
:etablissement_code_insee_localite,
|
||||||
|
:entreprise_siren,
|
||||||
|
:entreprise_capital_social,
|
||||||
|
:entreprise_numero_tva_intracommunautaire,
|
||||||
|
:entreprise_forme_juridique,
|
||||||
|
:entreprise_forme_juridique_code,
|
||||||
|
:entreprise_nom_commercial,
|
||||||
|
:entreprise_raison_sociale,
|
||||||
|
:entreprise_siret_siege_social,
|
||||||
|
:entreprise_code_effectif_entreprise,
|
||||||
|
:entreprise_date_creation,
|
||||||
|
:entreprise_nom,
|
||||||
|
:entreprise_prenom
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have empty values' do
|
||||||
|
expect(data).to eq([[]])
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with dossier' do
|
||||||
|
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :for_individual, procedure: procedure) }
|
||||||
|
|
||||||
|
let(:dossier_data) {
|
||||||
|
[
|
||||||
|
dossier.id.to_s,
|
||||||
|
dossier.created_at.to_s,
|
||||||
|
dossier.updated_at.to_s,
|
||||||
|
"false",
|
||||||
|
dossier.user.email,
|
||||||
|
"received",
|
||||||
|
dossier.en_construction_at.to_s,
|
||||||
|
dossier.en_instruction_at.to_s,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil
|
||||||
|
] + individual_data
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:individual_data) {
|
||||||
|
[
|
||||||
|
"M.",
|
||||||
|
"Xavier",
|
||||||
|
"Julien",
|
||||||
|
"1991-11-01"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:champs_data) {
|
||||||
|
dossier.champs.map(&:for_export)
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:etablissement_data) {
|
||||||
|
Array.new(24)
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'should have values' do
|
||||||
|
expect(data.first[0..14]).to eq(dossier_data)
|
||||||
|
expect(data.first[15..40]).to eq(champs_data)
|
||||||
|
expect(data.first[41..64]).to eq(etablissement_data)
|
||||||
|
|
||||||
|
expect(data).to eq([
|
||||||
|
dossier_data + champs_data + etablissement_data
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'and etablissement' do
|
||||||
|
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_entreprise, procedure: procedure) }
|
||||||
|
|
||||||
|
let(:etablissement_data) {
|
||||||
|
[
|
||||||
|
dossier.etablissement.siret,
|
||||||
|
dossier.etablissement.siege_social.to_s,
|
||||||
|
dossier.etablissement.naf,
|
||||||
|
dossier.etablissement.libelle_naf,
|
||||||
|
dossier.etablissement.adresse&.chomp&.gsub("\r\n", ' ')&.delete("\r"),
|
||||||
|
dossier.etablissement.numero_voie,
|
||||||
|
dossier.etablissement.type_voie,
|
||||||
|
dossier.etablissement.nom_voie,
|
||||||
|
dossier.etablissement.complement_adresse,
|
||||||
|
dossier.etablissement.code_postal,
|
||||||
|
dossier.etablissement.localite,
|
||||||
|
dossier.etablissement.code_insee_localite,
|
||||||
|
dossier.etablissement.entreprise_siren,
|
||||||
|
dossier.etablissement.entreprise_capital_social.to_s,
|
||||||
|
dossier.etablissement.entreprise_numero_tva_intracommunautaire,
|
||||||
|
dossier.etablissement.entreprise_forme_juridique,
|
||||||
|
dossier.etablissement.entreprise_forme_juridique_code,
|
||||||
|
dossier.etablissement.entreprise_nom_commercial,
|
||||||
|
dossier.etablissement.entreprise_raison_sociale,
|
||||||
|
dossier.etablissement.entreprise_siret_siege_social,
|
||||||
|
dossier.etablissement.entreprise_code_effectif_entreprise,
|
||||||
|
dossier.etablissement.entreprise_date_creation.to_datetime.to_s,
|
||||||
|
dossier.etablissement.entreprise_nom,
|
||||||
|
dossier.etablissement.entreprise_prenom
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:individual_data) {
|
||||||
|
Array.new(4)
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'should have values' do
|
||||||
|
expect(data.first[0..14]).to eq(dossier_data)
|
||||||
|
expect(data.first[15..40]).to eq(champs_data)
|
||||||
|
expect(data.first[41..64]).to eq(etablissement_data)
|
||||||
|
|
||||||
|
expect(data).to eq([
|
||||||
|
dossier_data + champs_data + etablissement_data
|
||||||
|
])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'etablissements' do
|
||||||
|
let(:table) { :etablissements }
|
||||||
|
|
||||||
|
it 'should have headers' do
|
||||||
|
expect(headers).to eq([
|
||||||
|
:dossier_id,
|
||||||
|
:libelle,
|
||||||
|
:etablissement_siret,
|
||||||
|
:etablissement_siege_social,
|
||||||
|
:etablissement_naf,
|
||||||
|
:etablissement_libelle_naf,
|
||||||
|
:etablissement_adresse,
|
||||||
|
:etablissement_numero_voie,
|
||||||
|
:etablissement_type_voie,
|
||||||
|
:etablissement_nom_voie,
|
||||||
|
:etablissement_complement_adresse,
|
||||||
|
:etablissement_code_postal,
|
||||||
|
:etablissement_localite,
|
||||||
|
:etablissement_code_insee_localite,
|
||||||
|
:entreprise_siren,
|
||||||
|
:entreprise_capital_social,
|
||||||
|
:entreprise_numero_tva_intracommunautaire,
|
||||||
|
:entreprise_forme_juridique,
|
||||||
|
:entreprise_forme_juridique_code,
|
||||||
|
:entreprise_nom_commercial,
|
||||||
|
:entreprise_raison_sociale,
|
||||||
|
:entreprise_siret_siege_social,
|
||||||
|
:entreprise_code_effectif_entreprise,
|
||||||
|
:entreprise_date_creation,
|
||||||
|
:entreprise_nom,
|
||||||
|
:entreprise_prenom
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have empty values' do
|
||||||
|
expect(data).to eq([[]])
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with dossier containing champ siret' do
|
||||||
|
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, procedure: procedure) }
|
||||||
|
let(:etablissement) { dossier.champs.find { |champ| champ.type_champ == 'siret' }.etablissement }
|
||||||
|
|
||||||
|
let(:etablissement_data) {
|
||||||
|
[
|
||||||
|
dossier.id,
|
||||||
|
'siret',
|
||||||
|
etablissement.siret,
|
||||||
|
etablissement.siege_social.to_s,
|
||||||
|
etablissement.naf,
|
||||||
|
etablissement.libelle_naf,
|
||||||
|
etablissement.adresse&.chomp&.gsub("\r\n", ' ')&.delete("\r"),
|
||||||
|
etablissement.numero_voie,
|
||||||
|
etablissement.type_voie,
|
||||||
|
etablissement.nom_voie,
|
||||||
|
etablissement.complement_adresse,
|
||||||
|
etablissement.code_postal,
|
||||||
|
etablissement.localite,
|
||||||
|
etablissement.code_insee_localite,
|
||||||
|
etablissement.entreprise_siren,
|
||||||
|
etablissement.entreprise_capital_social.to_s,
|
||||||
|
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_code_effectif_entreprise,
|
||||||
|
etablissement.entreprise_date_creation.to_datetime.to_s,
|
||||||
|
etablissement.entreprise_nom,
|
||||||
|
etablissement.entreprise_prenom
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'should have values' do
|
||||||
|
expect(data.first).to eq(etablissement_data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue