diff --git a/.rubocop.yml b/.rubocop.yml
index 7abe2b071..afb11910f 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -14,7 +14,7 @@ Bundler/InsecureProtocolSource:
Enabled: true
Bundler/OrderedGems:
- Enabled: false
+ Enabled: true
Gemspec/DuplicatedAssignment:
Enabled: true
@@ -58,7 +58,7 @@ Layout/CommentIndentation:
Enabled: true
Layout/ConditionPosition:
- Enabled: false
+ Enabled: true
Layout/DefEndAlignment:
Enabled: false
@@ -200,7 +200,7 @@ Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
- Enabled: false
+ Enabled: true
Layout/SpaceAfterMethodName:
Enabled: true
@@ -224,7 +224,7 @@ Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeBlockBraces:
- Enabled: false
+ Enabled: true
Layout/SpaceBeforeComma:
Enabled: true
@@ -252,7 +252,8 @@ Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Layout/SpaceInsideArrayLiteralBrackets:
- Enabled: false
+ Enabled: true
+ EnforcedStyle: no_space
Layout/SpaceInsideParens:
Enabled: true
@@ -339,40 +340,40 @@ Lint/EnsureReturn:
Enabled: false
Lint/FloatOutOfRange:
- Enabled: false
+ Enabled: true
Lint/FormatParameterMismatch:
- Enabled: false
+ Enabled: true
Lint/HandleExceptions:
Enabled: false
Lint/ImplicitStringConcatenation:
- Enabled: false
+ Enabled: true
Lint/IneffectiveAccessModifier:
Enabled: false
Lint/InheritException:
- Enabled: false
+ Enabled: true
Lint/InterpolationCheck:
Enabled: true
Lint/LiteralAsCondition:
- Enabled: false
+ Enabled: true
Lint/LiteralInInterpolation:
- Enabled: false
+ Enabled: true
Lint/Loop:
- Enabled: false
+ Enabled: true
Lint/MissingCopEnableDirective:
Enabled: true
Lint/MultipleCompare:
- Enabled: false
+ Enabled: true
Lint/NestedMethodDefinition:
Enabled: false
@@ -381,7 +382,7 @@ Lint/NestedPercentLiteral:
Enabled: true
Lint/NextWithoutAccumulator:
- Enabled: false
+ Enabled: true
Lint/NonLocalExitFromIterator:
Enabled: false
@@ -393,7 +394,9 @@ Lint/OrderedMagicComments:
Enabled: true
Lint/ParenthesesAsGroupedExpression:
- Enabled: false
+ Enabled: true
+ Exclude:
+ - "spec/**/*"
Lint/PercentStringArray:
Enabled: false
@@ -417,16 +420,16 @@ Lint/RequireParentheses:
Enabled: false
Lint/RescueException:
- Enabled: false
+ Enabled: true
Lint/RescueType:
- Enabled: false
+ Enabled: true
Lint/ReturnInVoidContext:
Enabled: false
Lint/SafeNavigationChain:
- Enabled: false
+ Enabled: true
Lint/ScriptPermission:
Enabled: false
@@ -435,25 +438,25 @@ Lint/ShadowedArgument:
Enabled: true
Lint/ShadowedException:
- Enabled: false
+ Enabled: true
Lint/ShadowingOuterLocalVariable:
Enabled: false
Lint/StringConversionInInterpolation:
- Enabled: false
+ Enabled: true
Lint/Syntax:
Enabled: true
Lint/UnderscorePrefixedVariableName:
- Enabled: false
+ Enabled: true
Lint/UnifiedInteger:
- Enabled: false
+ Enabled: true
Lint/UnneededCopDisableDirective:
- Enabled: false
+ Enabled: true
Lint/UnneededCopEnableDirective:
Enabled: true
@@ -465,10 +468,10 @@ Lint/UnneededSplatExpansion:
Enabled: false
Lint/UnreachableCode:
- Enabled: false
+ Enabled: true
Lint/UnusedBlockArgument:
- Enabled: false
+ Enabled: true
Lint/UnusedMethodArgument:
Enabled: false
@@ -483,19 +486,21 @@ Lint/UselessAccessModifier:
Enabled: false
Lint/UselessAssignment:
- Enabled: false
+ Enabled: true
+ Exclude:
+ - "spec/**/*"
Lint/UselessComparison:
- Enabled: false
+ Enabled: true
Lint/UselessElseWithoutRescue:
- Enabled: false
+ Enabled: true
Lint/UselessSetterCall:
- Enabled: false
+ Enabled: true
Lint/Void:
- Enabled: false
+ Enabled: true
Metrics/AbcSize:
Enabled: false
diff --git a/Gemfile b/Gemfile
index a278dcf11..1fabe7f8a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,181 +1,104 @@
source 'https://rubygems.org'
-# dotenv should always be loaded before rails
-gem 'dotenv-rails', require: 'dotenv/rails-now'
-gem 'rails'
-
-# Use SCSS for stylesheets
-gem 'sassc-rails'
-
-# Use jquery as the JavaScript library
-gem 'jquery-rails'
-# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
-gem 'turbolinks'
-
-# Enable deep clone of active record models
-gem 'deep_cloneable'
-
-gem 'warden'
-
-# Use Puma as the app server
-gem 'puma'
-
-# serializer
+gem 'aasm'
+gem 'active_link_to' # Automatically set a class on active links
gem 'active_model_serializers'
-
-# haml
-gem 'haml-rails'
-
-# bootstrap saas
+gem 'activestorage-openstack', git: 'https://github.com/fredZen/activestorage-openstack.git', branch: 'frederic/fix_upload_signature'
+gem 'administrate'
+gem 'after_party'
+gem 'axlsx', '~> 3.0.0.pre' # https://github.com/randym/axlsx/issues/501#issuecomment-373640365
+gem 'bcrypt'
gem 'bootstrap-sass', '~> 3.3.5'
-
-# Automatically set a class on active links
-gem 'active_link_to'
-
-# Pagination
-gem 'kaminari'
-
-# Decorators
-gem 'draper'
-
-# Gestion des comptes utilisateurs
-gem 'devise'
-gem 'devise-async'
-gem 'openid_connect'
-gem 'omniauth-github'
-
-# Locales par défaut
-gem 'rails-i18n'
-
-gem 'rest-client'
-gem 'typhoeus'
-
-gem 'clamav-client', require: 'clamav/client'
-
+gem 'bootstrap-wysihtml5-rails', '~> 0.3.3.8'
+gem 'browser'
gem 'carrierwave'
gem 'carrierwave-i18n'
-gem 'copy_carrierwave_file'
-gem 'fog-openstack'
-gem 'activestorage-openstack', git: 'https://github.com/fredZen/activestorage-openstack.git', branch: 'frederic/fix_upload_signature'
-
-gem 'pg'
-
-gem 'rbnacl-libsodium'
-gem 'bcrypt'
-
-gem 'rgeo-geojson'
-
gem 'chartkick'
-
+gem 'chunky_png'
+gem 'clamav-client', require: 'clamav/client'
+gem 'copy_carrierwave_file'
+gem 'daemons'
+gem 'deep_cloneable' # Enable deep clone of active record models
+gem 'delayed_cron_job' # Cron jobs
+gem 'delayed_job_active_record'
+gem 'delayed_job_web'
+gem 'devise' # Gestion des comptes utilisateurs
+gem 'devise-async'
+gem 'dotenv-rails', require: 'dotenv/rails-now' # dotenv should always be loaded before rails
+gem 'flipflop'
+gem 'fog-openstack'
+gem 'font-awesome-rails'
+gem 'groupdate'
+gem 'haml-rails'
+gem 'hashie'
+gem 'jquery-rails' # Use jquery as the JavaScript library
+gem 'kaminari' # Pagination
gem 'lograge'
gem 'logstash-event'
-
-gem 'font-awesome-rails'
-
-gem 'hashie'
-
gem 'mailjet'
-
-gem "premailer-rails"
-
-gem 'smart_listing'
-
-gem 'groupdate'
-
-gem 'bootstrap-wysihtml5-rails', '~> 0.3.3.8'
-
-gem 'spreadsheet_architect'
-gem 'axlsx', '~> 3.0.0.pre' # https://github.com/randym/axlsx/issues/501#issuecomment-373640365
-
+gem 'omniauth-github'
+gem 'openid_connect'
gem 'openstack'
-
-gem 'browser'
-
-gem 'simple_form'
-
-gem 'skylight'
-
-gem 'scenic'
-
+gem 'pg'
+gem 'prawn' # PDF Generation
+gem 'prawn_rails'
+gem 'premailer-rails'
+gem 'puma' # Use Puma as the app server
+gem 'rack-mini-profiler'
+gem 'rails'
+gem 'rails-i18n' # Locales par défaut
+gem 'rake-progressbar', require: false
+gem 'rest-client'
+gem 'rgeo-geojson'
gem 'sanitize-url'
-
-gem 'flipflop'
-
-gem 'aasm'
-
+gem 'sassc-rails' # Use SCSS for stylesheets
+gem 'scenic'
+gem 'select2-rails'
+gem 'sentry-raven'
+gem 'simple_form'
+gem 'skylight'
+gem 'smart_listing'
+gem 'spreadsheet_architect'
+gem 'turbolinks' # Turbolinks makes following links in your web application faster
+gem 'typhoeus'
+gem 'warden'
gem 'webpacker', '>= 4.0.x'
-
-gem 'after_party'
-
gem 'zxcvbn-ruby', require: 'zxcvbn'
-# Cron jobs
-gem 'delayed_job_active_record'
-gem "daemons"
-gem 'delayed_cron_job'
-gem "delayed_job_web"
-gem 'select2-rails'
-
-# PDF Generation
-gem 'prawn'
-gem 'prawn_rails'
-
-gem 'chunky_png'
-gem 'sentry-raven'
-
-gem "administrate"
-
-gem 'rack-mini-profiler'
-
-gem 'rake-progressbar', require: false
-
group :test do
- gem 'launchy'
- gem 'factory_bot'
+ gem 'capybara' # Integration testing
+ gem 'capybara-email' # Access emails during integration tests
+ gem 'capybara-screenshot' # Save a dump of the page when an integration test fails
+ gem 'capybara-selenium'
gem 'database_cleaner'
- gem 'webmock'
+ gem 'factory_bot'
+ gem 'guard'
+ gem 'guard-livereload', require: false
+ gem 'guard-rspec', require: false
+ gem 'launchy'
+ gem 'rails-controller-testing'
gem 'shoulda-matchers', require: false
gem 'timecop'
- gem 'guard'
- gem 'guard-rspec', require: false
- gem 'guard-livereload', require: false
gem 'vcr'
- gem 'rails-controller-testing'
-
- # Integration testing
- gem 'capybara'
- gem 'capybara-selenium'
- # Save a dump of the page when an integration test fails
- gem 'capybara-screenshot'
- # Access emails during integration tests
- gem 'capybara-email'
+ gem 'webmock'
end
group :development do
gem 'brakeman', require: false
- # Access an IRB console on exception pages or by using <%= console %> in views
- gem 'web-console'
- gem 'rack-handlers'
- gem 'xray-rails'
+ gem 'haml-lint'
+ gem 'letter_opener_web'
gem 'rubocop', require: false
gem 'rubocop-rspec-focused', require: false
- gem 'haml-lint'
gem 'scss_lint', require: false
- gem 'letter_opener_web'
+ gem 'xray-rails'
end
group :development, :test do
- # Call 'byebug' anywhere in the code to stop execution and get a debugger console
- gem 'byebug'
+ gem 'byebug' # Call 'byebug' anywhere in the code to stop execution and get a debugger console
+ gem 'mina', git: 'https://github.com/mina-deploy/mina.git', require: false # Deploy
gem 'pry-byebug'
-
- # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
- gem 'spring'
- gem 'spring-commands-rspec'
gem 'rspec-rails'
-
- # Deploy
- gem 'mina', git: 'https://github.com/mina-deploy/mina.git', require: false
-
gem 'rspec_junit_formatter'
+ gem 'spring' # Spring speeds up development by keeping your application running in the background
+ gem 'spring-commands-rspec'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 51aa0b745..1337f9a9f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -58,10 +58,6 @@ GEM
globalid (>= 0.3.6)
activemodel (5.2.2)
activesupport (= 5.2.2)
- activemodel-serializers-xml (1.0.2)
- activemodel (> 5.x)
- activesupport (> 5.x)
- builder (~> 3.1)
activerecord (5.2.2)
activemodel (= 5.2.2)
activesupport (= 5.2.2)
@@ -93,7 +89,7 @@ GEM
arel (9.0.0)
ast (2.4.0)
attr_required (1.0.1)
- autoprefixer-rails (9.4.1)
+ autoprefixer-rails (9.4.4)
execjs
axlsx (3.0.0.pre)
htmlentities (~> 4.3, >= 4.3.4)
@@ -105,7 +101,6 @@ GEM
axlsx (>= 2.0, < 4)
bcrypt (3.1.12)
bindata (2.4.4)
- bindex (0.5.0)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
@@ -132,14 +127,14 @@ GEM
capybara-selenium (0.0.6)
capybara
selenium-webdriver
- carrierwave (1.2.3)
+ carrierwave (1.3.1)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
carrierwave-i18n (0.2.0)
case_transform (0.2)
activesupport
- chartkick (3.0.1)
+ chartkick (3.0.2)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chunky_png (1.3.11)
@@ -152,7 +147,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
- concurrent-ruby (1.1.3)
+ concurrent-ruby (1.1.4)
copy_carrierwave_file (1.3.0)
carrierwave (>= 0.9)
crack (0.4.3)
@@ -160,7 +155,7 @@ GEM
crass (1.0.4)
css_parser (1.6.0)
addressable
- daemons (1.2.6)
+ daemons (1.3.1)
database_cleaner (1.7.0)
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)
@@ -194,16 +189,10 @@ GEM
dotenv-rails (2.5.0)
dotenv (= 2.5.0)
railties (>= 3.2, < 6.0)
- draper (3.0.1)
- actionpack (~> 5.0)
- activemodel (~> 5.0)
- activemodel-serializers-xml (~> 1.0)
- activesupport (~> 5.0)
- request_store (~> 1.0)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
- erubi (1.7.1)
+ erubi (1.8.0)
erubis (2.7.0)
ethon (0.11.0)
ffi (>= 1.3.0)
@@ -212,7 +201,7 @@ GEM
execjs (2.7.0)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
- faraday (0.12.2)
+ faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffi (1.9.25)
flipflop (2.4.0)
@@ -234,7 +223,7 @@ GEM
formatador (0.2.5)
globalid (0.4.1)
activesupport (>= 4.2.0)
- groupdate (4.1.0)
+ groupdate (4.1.1)
activesupport (>= 4.2)
guard (2.15.0)
formatador (>= 0.2.4)
@@ -272,8 +261,8 @@ GEM
rake (>= 10, < 13)
rubocop (>= 0.50.0)
sysexits (~> 1.1)
- hashdiff (0.3.7)
- hashie (3.5.7)
+ hashdiff (0.3.8)
+ hashie (3.6.0)
html2haml (2.2.0)
erubis (~> 2.7.0)
haml (>= 4.0, < 6)
@@ -284,21 +273,21 @@ GEM
domain_name (~> 0.5)
http_parser.rb (0.6.0)
httpclient (2.8.3)
- i18n (1.1.1)
+ i18n (1.4.0)
concurrent-ruby (~> 1.0)
ipaddress (0.8.3)
- jaro_winkler (1.5.1)
+ jaro_winkler (1.5.2)
jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.1.0)
- json-jwt (1.9.4)
- activesupport
+ json-jwt (1.10.0)
+ activesupport (>= 4.2)
aes_key_wrap
bindata
jsonapi-renderer (0.2.0)
- jwt (1.5.6)
+ jwt (2.1.0)
kaminari (1.1.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
@@ -313,7 +302,7 @@ GEM
kaminari-core (1.1.1)
launchy (2.4.3)
addressable (~> 2.3)
- letter_opener (1.6.0)
+ letter_opener (1.7.0)
launchy (~> 2.2)
letter_opener_web (1.3.4)
actionmailer (>= 3.2)
@@ -345,9 +334,9 @@ GEM
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
- mimemagic (0.3.2)
+ mimemagic (0.3.3)
mini_mime (1.0.1)
- mini_portile2 (2.3.0)
+ mini_portile2 (2.4.0)
minitest (5.11.3)
momentjs-rails (2.20.1)
railties (>= 3.1)
@@ -358,26 +347,26 @@ GEM
nenv (0.3.0)
netrc (0.11.0)
nio4r (2.3.1)
- nokogiri (1.8.5)
- mini_portile2 (~> 2.3.0)
+ nokogiri (1.10.0)
+ mini_portile2 (~> 2.4.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
- oauth2 (1.4.0)
- faraday (>= 0.8, < 0.13)
- jwt (~> 1.0)
+ oauth2 (1.4.1)
+ faraday (>= 0.8, < 0.16.0)
+ jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
- omniauth (1.8.1)
- hashie (>= 3.4.6, < 3.6.0)
+ omniauth (1.9.0)
+ hashie (>= 3.4.6, < 3.7.0)
rack (>= 1.6.2, < 3)
omniauth-github (1.3.0)
omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0, < 2.0)
- omniauth-oauth2 (1.5.0)
+ omniauth-oauth2 (1.6.0)
oauth2 (~> 1.1)
- omniauth (~> 1.2)
+ omniauth (~> 1.9)
open4 (1.3.4)
openid_connect (1.1.6)
activemodel
@@ -420,9 +409,7 @@ GEM
public_suffix (3.0.3)
puma (3.12.0)
rack (2.0.6)
- rack-handlers (0.7.3)
- rack
- rack-mini-profiler (1.0.0)
+ rack-mini-profiler (1.0.1)
rack (>= 1.2.0)
rack-oauth2 (1.9.3)
activesupport
@@ -430,7 +417,7 @@ GEM
httpclient
json-jwt (>= 1.9.0)
rack
- rack-protection (2.0.4)
+ rack-protection (2.0.5)
rack
rack-proxy (0.6.5)
rack
@@ -449,7 +436,7 @@ GEM
bundler (>= 1.3.0)
railties (= 5.2.2)
sprockets-rails (>= 2.0.0)
- rails-controller-testing (1.0.3)
+ rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
actionview (>= 5.0.1.x)
activesupport (>= 5.0.1.x)
@@ -468,15 +455,11 @@ GEM
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rainbow (3.0.0)
- rake (12.3.1)
+ rake (12.3.2)
rake-progressbar (0.0.5)
rb-fsevent (0.10.3)
- rb-inotify (0.9.10)
- ffi (>= 0.5.0, < 2)
- rbnacl (5.0.0)
- ffi
- rbnacl-libsodium (1.0.16)
- rbnacl (>= 3.0.1)
+ rb-inotify (0.10.0)
+ ffi (~> 1.0)
regexp_parser (1.3.0)
request_store (1.4.1)
rack (>= 1.4)
@@ -517,7 +500,7 @@ GEM
rspec-support (3.8.0)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
- rubocop (0.61.1)
+ rubocop (0.62.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
@@ -529,12 +512,12 @@ GEM
rubocop (>= 0.51)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
- ruby_parser (3.11.0)
+ ruby_parser (3.12.0)
sexp_processor (~> 4.9)
rubyzip (1.2.2)
safe_yaml (1.0.4)
sanitize-url (0.1.4)
- sass (3.7.2)
+ sass (3.7.3)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
@@ -548,7 +531,7 @@ GEM
sassc (2.0.0)
ffi (~> 1.9.6)
rake
- sassc-rails (2.0.0)
+ sassc-rails (2.1.0)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
@@ -575,10 +558,10 @@ GEM
simple_form (4.1.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
- sinatra (2.0.4)
+ sinatra (2.0.5)
mustermann (~> 1.0)
rack (~> 2.0)
- rack-protection (= 2.0.4)
+ rack-protection (= 2.0.5)
tilt (~> 2.0)
skylight (3.1.2)
skylight-core (= 3.1.2)
@@ -625,7 +608,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
- unicode-display_width (1.4.0)
+ unicode-display_width (1.4.1)
validate_email (0.1.6)
activemodel (>= 3.0)
mail (>= 2.2.5)
@@ -635,19 +618,14 @@ GEM
vcr (4.0.0)
warden (1.2.8)
rack (>= 2.0.6)
- web-console (3.7.0)
- actionview (>= 5.0)
- activemodel (>= 5.0)
- bindex (>= 0.4.0)
- railties (>= 5.0)
webfinger (1.1.0)
activesupport
httpclient (>= 2.4)
- webmock (3.4.2)
+ webmock (3.5.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
- webpacker (4.0.0.pre.3)
+ webpacker (4.0.0.rc.2)
activesupport (>= 4.2)
rack-proxy (>= 0.6.1)
railties (>= 4.2)
@@ -696,7 +674,6 @@ DEPENDENCIES
devise
devise-async
dotenv-rails
- draper
factory_bot
flipflop
fog-openstack
@@ -725,13 +702,11 @@ DEPENDENCIES
premailer-rails
pry-byebug
puma
- rack-handlers
rack-mini-profiler
rails
rails-controller-testing
rails-i18n
rake-progressbar
- rbnacl-libsodium
rest-client
rgeo-geojson
rspec-rails
@@ -756,7 +731,6 @@ DEPENDENCIES
typhoeus
vcr
warden
- web-console
webmock
webpacker (>= 4.0.x)
xray-rails
diff --git a/Guardfile b/Guardfile
index acfab00d5..24a9eca3b 100644
--- a/Guardfile
+++ b/Guardfile
@@ -35,8 +35,7 @@ guard 'livereload' do
png: :png,
gif: :gif,
jpg: :jpg,
- jpeg: :jpeg,
- # less: :less, # uncomment if you want LESS stylesheets done in browser
+ jpeg: :jpeg
}
rails_view_exts = ['erb', 'haml', 'slim']
diff --git a/README.md b/README.md
index 0918d2786..996958ed5 100644
--- a/README.md
+++ b/README.md
@@ -104,7 +104,7 @@ Une fois `overmind` lancé, et un breakpoint `byebug` inséré dans le code, il
### Linting
-Le projet utilise plusieurs linters pour vérifier la lisibilité et la qualité code.
+Le projet utilise plusieurs linters pour vérifier la lisibilité et la qualité du code.
- Faire tourner tous les linters : `bin/rake lint`
- [AccessLint](http://accesslint.com/) tourne automatiquement sur les PRs
@@ -121,16 +121,10 @@ Le projet utilise plusieurs linters pour vérifier la lisibilité et la qualité
## Tâches courantes
-### Tâches Super Admin
+### Tâches de gestion des comptes super-admin
-- ajouter un compte super admin :
- `bin/rake admin:create_admin[email-du-compte-github@exemple.com]`
-
-- lister les comptes super admin :
- `bin/rake admin:list`
-
-- supprimer un compte super admin :
- `bin/rake admin:delete_admin[email-du-compte-github@exemple.com]`
+Des tâches de gestion des comptes super-admin sont prévues dans le namespace `superadmin`.
+Pour les lister : `bin/rake -D superadmin:`.
### Tâches d’aide au support
diff --git a/app/assets/stylesheets/new_design/auth.scss b/app/assets/stylesheets/new_design/auth.scss
index d1221bcd3..9196f0fa1 100644
--- a/app/assets/stylesheets/new_design/auth.scss
+++ b/app/assets/stylesheets/new_design/auth.scss
@@ -3,75 +3,16 @@
@import "placeholders";
@import "mixins";
-$auth-breakpoint: $two-columns-breakpoint;
-
-.preview {
- font-size: 24px;
-
- .paperless-logo {
- width: 100%;
- margin-bottom: 60px;
-
- @media (max-width: $auth-breakpoint) {
- display: none;
- }
- }
-
- h3 {
- color: $blue;
- font-weight: bold;
- }
-
- .close-procedure {
- font-size: 12px;
- }
-
- .procedure-title {
- font-size: 30px;
- margin: 20px 0 0;
-
- @media (min-width: $auth-breakpoint) {
- margin: 50px 0 32px;
- }
- }
-
- .procedure-description {
- font-size: 14px;
-
- p {
- margin-bottom: 2 * $default-spacer;
- }
-
- @media (max-width: $auth-breakpoint) {
- display: none; // TO FIX : make this description available for small devices
- }
- }
-
- .procedure-logos {
- display: flex;
- justify-content: space-around;
-
- img {
- max-height: 50px;
- max-width: 100%;
- margin: 0 10px;
-
- @media (min-width: $auth-breakpoint) {
- max-height: 130px;
- max-width: 500px;
- }
- }
- }
-}
-
.auth-form {
- .reset-password {
- margin-top: - 3 * $default-spacer;
- margin-bottom: $default-spacer;
+ .auth-options {
+ display: flex;
+ justify-content: space-between;
+ margin-bottom: 4 * $default-spacer;
}
.remember-me {
display: inline-block;
+ margin-bottom: 0;
}
.separation {
@@ -120,10 +61,12 @@ $auth-breakpoint: $two-columns-breakpoint;
}
}
-.identity-form {
- @media (max-width: $two-columns-breakpoint) {
- input[type=submit] {
- margin-bottom: 2 * $default-padding;
- }
+.sign-in-form .form {
+ input[type="password"] {
+ margin-bottom: $default-spacer;
+ }
+
+ input[type="checkbox"] {
+ margin-bottom: 0;
}
}
diff --git a/app/assets/stylesheets/new_design/flex.scss b/app/assets/stylesheets/new_design/flex.scss
index a204355e1..e61a57611 100644
--- a/app/assets/stylesheets/new_design/flex.scss
+++ b/app/assets/stylesheets/new_design/flex.scss
@@ -24,4 +24,8 @@
&.justify-start {
justify-content: flex-start;
}
+
+ &.wrap {
+ flex-wrap: wrap;
+ }
}
diff --git a/app/assets/stylesheets/new_design/merci.scss b/app/assets/stylesheets/new_design/merci.scss
index f3ccd7bcd..b9986c443 100644
--- a/app/assets/stylesheets/new_design/merci.scss
+++ b/app/assets/stylesheets/new_design/merci.scss
@@ -4,6 +4,7 @@
.merci {
text-align: center;
+ margin-bottom: 60px;
img {
margin-top: 4 * $default-padding;
diff --git a/app/assets/stylesheets/new_design/procedure_context.scss b/app/assets/stylesheets/new_design/procedure_context.scss
new file mode 100644
index 000000000..f0772825f
--- /dev/null
+++ b/app/assets/stylesheets/new_design/procedure_context.scss
@@ -0,0 +1,71 @@
+@import "colors";
+@import "constants";
+
+$procedure-context-breakpoint: $two-columns-breakpoint;
+
+.procedure-preview {
+ font-size: 24px;
+
+ .paperless-logo {
+ width: 100%;
+ margin-bottom: 60px;
+
+ @media (max-width: $procedure-context-breakpoint) {
+ display: none;
+ }
+ }
+
+ h3 {
+ color: $blue;
+ font-weight: bold;
+ }
+
+ .close-procedure {
+ font-size: 12px;
+ }
+
+ .procedure-title {
+ font-size: 30px;
+ margin: 20px 0 0;
+
+ @media (min-width: $procedure-context-breakpoint) {
+ margin: 50px 0 32px;
+ }
+ }
+
+ .procedure-description {
+ font-size: 14px;
+
+ p {
+ margin-bottom: 2 * $default-spacer;
+ }
+
+ @media (max-width: $procedure-context-breakpoint) {
+ display: none; // TO FIX : make this description available for small devices
+ }
+ }
+
+ .procedure-logos {
+ display: flex;
+ justify-content: space-around;
+
+ img {
+ max-height: 50px;
+ max-width: 100%;
+ margin: 0 10px;
+
+ @media (min-width: $procedure-context-breakpoint) {
+ max-height: 130px;
+ max-width: 500px;
+ }
+ }
+ }
+}
+
+.procedure-context-content {
+ @media (max-width: $procedure-context-breakpoint) {
+ input[type=submit] {
+ margin-bottom: 2 * $default-padding;
+ }
+ }
+}
diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb
index 0f954bde3..e1d2e7e3f 100644
--- a/app/controllers/admin/procedures_controller.rb
+++ b/app/controllers/admin/procedures_controller.rb
@@ -5,12 +5,16 @@ class Admin::ProceduresController < AdminController
before_action :retrieve_procedure, only: [:show, :edit, :delete_logo, :delete_deliberation, :delete_notice]
def index
- @procedures = smart_listing_create :procedures,
- current_administrateur.procedures.publiees.order(published_at: :desc),
- partial: "admin/procedures/list",
- array: true
+ if current_administrateur.procedures.count != 0
+ @procedures = smart_listing_create :procedures,
+ current_administrateur.procedures.publiees.order(published_at: :desc),
+ partial: "admin/procedures/list",
+ array: true
- active_class
+ active_class
+ else
+ redirect_to new_from_existing_admin_procedures_path
+ end
end
def archived
@@ -71,6 +75,10 @@ class Admin::ProceduresController < AdminController
render 'new'
else
flash.notice = 'Démarche enregistrée.'
+ gestionnaire = Gestionnaire.find_by(email: current_administrateur.email)
+ if gestionnaire
+ gestionnaire.assign_to_procedure(@procedure)
+ end
redirect_to admin_procedure_types_de_champ_path(procedure_id: @procedure.id)
end
end
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 235ef781f..926bb0ff4 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -1,8 +1,10 @@
class AdminController < ApplicationController
+ layout 'application_old'
+
before_action :authenticate_administrateur!
def index
- redirect_to (admin_procedures_path)
+ redirect_to(admin_procedures_path)
end
def retrieve_procedure
diff --git a/app/controllers/administrateurs/activate_controller.rb b/app/controllers/administrateurs/activate_controller.rb
index 5d2654587..dc2347e8b 100644
--- a/app/controllers/administrateurs/activate_controller.rb
+++ b/app/controllers/administrateurs/activate_controller.rb
@@ -3,8 +3,6 @@ require 'zxcvbn'
class Administrateurs::ActivateController < ApplicationController
include TrustedDeviceConcern
- layout "new_application"
-
def new
@administrateur = Administrateur.find_inactive_by_token(params[:token])
diff --git a/app/controllers/administrateurs/sessions_controller.rb b/app/controllers/administrateurs/sessions_controller.rb
index 432ff9f25..dfaab02f8 100644
--- a/app/controllers/administrateurs/sessions_controller.rb
+++ b/app/controllers/administrateurs/sessions_controller.rb
@@ -1,6 +1,4 @@
class Administrateurs::SessionsController < Sessions::SessionsController
- layout "new_application"
-
def new
redirect_to new_user_session_path
end
diff --git a/app/controllers/administrations/sessions_controller.rb b/app/controllers/administrations/sessions_controller.rb
index 78de713c8..90ed081b1 100644
--- a/app/controllers/administrations/sessions_controller.rb
+++ b/app/controllers/administrations/sessions_controller.rb
@@ -1,6 +1,4 @@
class Administrations::SessionsController < ApplicationController
- layout "new_application"
-
def new
end
diff --git a/app/controllers/api/v1/dossiers_controller.rb b/app/controllers/api/v1/dossiers_controller.rb
index b522e3aca..68cc51c41 100644
--- a/app/controllers/api/v1/dossiers_controller.rb
+++ b/app/controllers/api/v1/dossiers_controller.rb
@@ -6,7 +6,7 @@ class API::V1::DossiersController < APIController
def index
dossiers = @dossiers.page(params[:page]).per(per_page)
- render json: { dossiers: dossiers.map{ |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200
+ render json: { dossiers: dossiers.map { |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200
rescue ActiveRecord::RecordNotFound
render json: {}, status: 404
end
diff --git a/app/controllers/demandes_controller.rb b/app/controllers/demandes_controller.rb
index 571233896..5aac0b6b7 100644
--- a/app/controllers/demandes_controller.rb
+++ b/app/controllers/demandes_controller.rb
@@ -1,6 +1,4 @@
class DemandesController < ApplicationController
- layout "new_application"
-
def new
end
diff --git a/app/controllers/gestionnaires/activate_controller.rb b/app/controllers/gestionnaires/activate_controller.rb
index 12fdae36a..02a855bb2 100644
--- a/app/controllers/gestionnaires/activate_controller.rb
+++ b/app/controllers/gestionnaires/activate_controller.rb
@@ -1,8 +1,6 @@
class Gestionnaires::ActivateController < ApplicationController
include TrustedDeviceConcern
- layout "new_application"
-
def new
@gestionnaire = Gestionnaire.with_reset_password_token(params[:token])
diff --git a/app/controllers/gestionnaires/sessions_controller.rb b/app/controllers/gestionnaires/sessions_controller.rb
index ed49b6185..d098d4058 100644
--- a/app/controllers/gestionnaires/sessions_controller.rb
+++ b/app/controllers/gestionnaires/sessions_controller.rb
@@ -1,6 +1,4 @@
class Gestionnaires::SessionsController < Sessions::SessionsController
- layout "new_application"
-
def new
redirect_to new_user_session_path
end
diff --git a/app/controllers/new_administrateur/administrateur_controller.rb b/app/controllers/new_administrateur/administrateur_controller.rb
index ebf306f67..ebab217f2 100644
--- a/app/controllers/new_administrateur/administrateur_controller.rb
+++ b/app/controllers/new_administrateur/administrateur_controller.rb
@@ -1,7 +1,5 @@
module NewAdministrateur
class AdministrateurController < ApplicationController
- layout 'new_application'
-
before_action :authenticate_administrateur!
end
end
diff --git a/app/controllers/new_gestionnaire/avis_controller.rb b/app/controllers/new_gestionnaire/avis_controller.rb
index 7cb207e7a..7ff6bfec6 100644
--- a/app/controllers/new_gestionnaire/avis_controller.rb
+++ b/app/controllers/new_gestionnaire/avis_controller.rb
@@ -76,7 +76,7 @@ module NewGestionnaire
@email = params[:email]
@dossier = Avis.includes(:dossier).find(params[:id]).dossier
- render layout: 'new_application'
+ render
end
def create_gestionnaire
diff --git a/app/controllers/new_gestionnaire/gestionnaire_controller.rb b/app/controllers/new_gestionnaire/gestionnaire_controller.rb
index 2ffe8ae50..cd23783b7 100644
--- a/app/controllers/new_gestionnaire/gestionnaire_controller.rb
+++ b/app/controllers/new_gestionnaire/gestionnaire_controller.rb
@@ -1,7 +1,5 @@
module NewGestionnaire
class GestionnaireController < ApplicationController
- layout "new_application"
-
before_action :authenticate_gestionnaire!
def nav_bar_profile
diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb
index b9f1d3fdd..fb4c01ddf 100644
--- a/app/controllers/new_user/dossiers_controller.rb
+++ b/app/controllers/new_user/dossiers_controller.rb
@@ -2,6 +2,8 @@ module NewUser
class DossiersController < UserController
include DossierHelper
+ layout 'procedure_context', only: [:identite, :update_identite, :siret, :update_siret]
+
SESSION_USER_RETURN_LOCATION = 'user_return_to'
ACTIONS_ALLOWED_TO_ANY_USER = [:index, :recherche, :new]
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire, :purge_champ_piece_justificative]
diff --git a/app/controllers/new_user/user_controller.rb b/app/controllers/new_user/user_controller.rb
index dc74e3d12..35519a3f0 100644
--- a/app/controllers/new_user/user_controller.rb
+++ b/app/controllers/new_user/user_controller.rb
@@ -1,7 +1,5 @@
module NewUser
class UserController < ApplicationController
- layout "new_application"
-
before_action :authenticate_user!
def nav_bar_profile
diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb
index fee41a2fb..c44b7a224 100644
--- a/app/controllers/root_controller.rb
+++ b/app/controllers/root_controller.rb
@@ -1,6 +1,4 @@
class RootController < ApplicationController
- layout 'new_application'
-
def index
if administrateur_signed_in?
return redirect_to admin_procedures_path
diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb
index d37af55f4..73d68e8be 100644
--- a/app/controllers/stats_controller.rb
+++ b/app/controllers/stats_controller.rb
@@ -1,6 +1,4 @@
class StatsController < ApplicationController
- layout "new_application"
-
before_action :authenticate_administration!, only: [:download]
MEAN_NUMBER_OF_CHAMPS_IN_A_FORM = 24.0
@@ -165,10 +163,15 @@ class StatsController < ApplicationController
end
def contact_percentage
- from = Date.new(2017, 10)
+ from = Date.new(2018, 1)
to = Date.today.prev_month
- Helpscout::UserConversationsAdapter.new(from, to)
+ adapter = Helpscout::UserConversationsAdapter.new(from, to)
+ if !adapter.can_fetch_reports?
+ return nil
+ end
+
+ adapter
.reports
.map do |monthly_report|
start_date = monthly_report[:start_date].to_time.localtime
@@ -211,7 +214,7 @@ class StatsController < ApplicationController
association
.where(date_attribute => min_date..max_date)
- .group("DATE_TRUNC('month', #{date_attribute.to_s})")
+ .group("DATE_TRUNC('month', #{date_attribute})")
.count
.to_a
.sort_by { |a| a[0] }
@@ -221,8 +224,8 @@ class StatsController < ApplicationController
def cumulative_hash(association, date_attribute)
sum = 0
association
- .where("#{date_attribute.to_s} < ?", max_date)
- .group("DATE_TRUNC('month', #{date_attribute.to_s})")
+ .where("#{date_attribute} < ?", max_date)
+ .group("DATE_TRUNC('month', #{date_attribute})")
.count
.to_a
.sort_by { |a| a[0] }
@@ -271,7 +274,7 @@ class StatsController < ApplicationController
dossiers_grouped_by_procedure = value.group_by { |dossier| dossier[0] }
# Compute the mean time for this procedure
- procedure_processing_times = dossiers_grouped_by_procedure.map do |procedure_id, procedure_dossiers|
+ procedure_processing_times = dossiers_grouped_by_procedure.map do |_procedure_id, procedure_dossiers|
procedure_dossiers_processing_time = procedure_dossiers.map do |dossier|
(dossier[2] - dossier[1]).to_f / (3600 * 24)
end
diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb
index 330100091..034ba0a0e 100644
--- a/app/controllers/support_controller.rb
+++ b/app/controllers/support_controller.rb
@@ -1,6 +1,4 @@
class SupportController < ApplicationController
- layout "new_application"
-
def index
setup_context
end
diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb
index b60e2deeb..a93ac5600 100644
--- a/app/controllers/users/confirmations_controller.rb
+++ b/app/controllers/users/confirmations_controller.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true
class Users::ConfirmationsController < Devise::ConfirmationsController
- layout "new_application"
-
# GET /resource/confirmation/new
def new
# Allow displaying the user email in the message
diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb
index b679af447..f65b71202 100644
--- a/app/controllers/users/passwords_controller.rb
+++ b/app/controllers/users/passwords_controller.rb
@@ -1,6 +1,4 @@
class Users::PasswordsController < Devise::PasswordsController
- layout "new_application"
-
after_action :try_to_authenticate_gestionnaire, only: [:update]
after_action :try_to_authenticate_administrateur, only: [:update]
diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb
index 980740240..27af0703f 100644
--- a/app/controllers/users/registrations_controller.rb
+++ b/app/controllers/users/registrations_controller.rb
@@ -1,6 +1,4 @@
class Users::RegistrationsController < Devise::RegistrationsController
- layout "new_application"
-
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb
index 87f312d51..a74588b5e 100644
--- a/app/controllers/users/sessions_controller.rb
+++ b/app/controllers/users/sessions_controller.rb
@@ -2,8 +2,6 @@ class Users::SessionsController < Sessions::SessionsController
include TrustedDeviceConcern
include ActionView::Helpers::DateHelper
- layout "new_application"
-
# GET /resource/sign_in
def new
if user_return_to_procedure_id.present? # WTF ?
diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb
deleted file mode 100644
index ef50412f2..000000000
--- a/app/decorators/champ_decorator.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class ChampDecorator < Draper::Decorator
- delegate_all
-
- def value
- if type_champ == TypeDeChamp.type_champs.fetch(:date) && object.value.present?
- Date.parse(object.value).strftime("%d/%m/%Y")
- elsif type_champ.in? [TypeDeChamp.type_champs.fetch(:checkbox), TypeDeChamp.type_champs.fetch(:engagement)]
- object.value == 'on' ? 'Oui' : 'Non'
- elsif type_champ == TypeDeChamp.type_champs.fetch(:yes_no)
- if object.value == 'true'
- 'Oui'
- elsif object.value == 'false'
- 'Non'
- end
- elsif type_champ == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) && object.value.present?
- JSON.parse(object.value).join(', ')
- else
- object.value
- end
- end
-end
diff --git a/app/decorators/dossier_decorator.rb b/app/decorators/dossier_decorator.rb
deleted file mode 100644
index 4f283e3c5..000000000
--- a/app/decorators/dossier_decorator.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class DossierDecorator < Draper::Decorator
- delegate :current_page, :limit_value, :total_pages
- delegate_all
-
- def first_creation
- created_at.strftime('%d/%m/%Y %H:%M')
- end
-
- def last_update
- updated_at.strftime('%d/%m/%Y %H:%M')
- end
-end
diff --git a/app/decorators/dossiers_decorator.rb b/app/decorators/dossiers_decorator.rb
deleted file mode 100644
index 98a24e2bd..000000000
--- a/app/decorators/dossiers_decorator.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class DossiersDecorator < Draper::CollectionDecorator
- delegate :current_page, :limit_value, :total_pages
-end
diff --git a/app/decorators/france_connect_information_decorator.rb b/app/decorators/france_connect_information_decorator.rb
deleted file mode 100644
index 503caee5b..000000000
--- a/app/decorators/france_connect_information_decorator.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class FranceConnectInformationDecorator < Draper::Decorator
- delegate_all
-
- def gender_fr
- gender == 'female' ? 'Mme' : 'M.'
- end
-end
diff --git a/app/decorators/procedure_decorator.rb b/app/decorators/procedure_decorator.rb
deleted file mode 100644
index e4933fbea..000000000
--- a/app/decorators/procedure_decorator.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-class ProcedureDecorator < Draper::Decorator
- delegate_all
-
- def created_at_fr
- created_at.strftime('%d/%m/%Y %H:%M')
- end
-
- def published_at_fr
- if published_at.present?
- published_at.strftime('%d/%m/%Y %H:%M')
- end
- end
-
- def logo_img
- if logo.blank?
- h.image_url("marianne.svg")
- else
- if Flipflop.remote_storage?
- (RemoteDownloader.new logo.filename).url
- else
- (LocalDownloader.new logo.path, 'logo').url
- end
- end
- end
-end
diff --git a/app/decorators/procedures_decorator.rb b/app/decorators/procedures_decorator.rb
deleted file mode 100644
index c31731230..000000000
--- a/app/decorators/procedures_decorator.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class ProceduresDecorator < Draper::CollectionDecorator
- delegate :current_page, :limit_value, :total_pages
-end
diff --git a/app/decorators/type_de_champ_decorator.rb b/app/decorators/type_de_champ_decorator.rb
deleted file mode 100644
index 8e3bc8118..000000000
--- a/app/decorators/type_de_champ_decorator.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-class TypeDeChampDecorator < Draper::Decorator
- delegate_all
-
- def button_up(params)
- h.link_to '', params[:url], class: up_classes,
- id: "btn_up_#{params[:index]}",
- remote: true,
- method: :post,
- style: display_up_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;'
- end
-
- def button_down(params)
- h.link_to '', params[:url], class: down_classes,
- id: "btn_down_#{params[:index]}",
- remote: true,
- method: :post,
- style: display_down_button?(params[:index], params[:private]) ? '' : 'visibility: hidden;'
- end
-
- private
-
- def up_classes
- base_classes << 'fa-chevron-up'
- end
-
- def down_classes
- base_classes << 'fa-chevron-down'
- end
-
- def base_classes
- ['btn', 'btn-default', 'form-control', 'fa']
- end
-
- def display_up_button?(index, private)
- !(index == 0 || count_type_de_champ(private) < 2)
- end
-
- def display_down_button?(index, private)
- (index + 1) < count_type_de_champ(private)
- end
-
- def count_type_de_champ(private)
- if private
- @count_type_de_champ ||= procedure.types_de_champ_private.count
- else
- @count_type_de_champ ||= procedure.types_de_champ.count
- end
- end
-end
diff --git a/app/decorators/type_de_piece_justificative_decorator.rb b/app/decorators/type_de_piece_justificative_decorator.rb
deleted file mode 100644
index 906e61864..000000000
--- a/app/decorators/type_de_piece_justificative_decorator.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-class TypeDePieceJustificativeDecorator < Draper::Decorator
- delegate_all
- def button_up(params)
- if display_up_button?(params[:index])
- h.link_to '', params[:url], class: up_classes, id: "btn_up_#{params[:index]}", remote: true, method: :post
- end
- end
-
- def button_down(params)
- if display_down_button?(params[:index])
- h.link_to '', params[:url], class: down_classes, id: "btn_down_#{params[:index]}", remote: true, method: :post
- end
- end
-
- private
-
- def up_classes
- base_classes << 'fa-chevron-up'
- end
-
- def down_classes
- base_classes << 'fa-chevron-down'
- end
-
- def base_classes
- ['btn', 'btn-default', 'form-control', 'fa']
- end
-
- def display_up_button?(index)
- !(index == 0 || count_type_de_piece_justificative < 2)
- end
-
- def display_down_button?(index)
- (index + 1) < count_type_de_piece_justificative
- end
-
- def count_type_de_piece_justificative
- @count_type_de_piece_justificative ||= procedure.types_de_piece_justificative.count
- end
-end
diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb
deleted file mode 100644
index 2ec79a39a..000000000
--- a/app/decorators/user_decorator.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class UserDecorator < Draper::Decorator
- delegate_all
-
- def gender_fr
- case gender
- when 'male'
- 'M.'
- when 'female'
- 'Mme'
- end
- end
-end
diff --git a/app/helpers/admin_formulaire_helper.rb b/app/helpers/admin_formulaire_helper.rb
new file mode 100644
index 000000000..1b0dd9a53
--- /dev/null
+++ b/app/helpers/admin_formulaire_helper.rb
@@ -0,0 +1,55 @@
+module AdminFormulaireHelper
+ BASE_CLASSES = ['btn', 'btn-default', 'form-control', 'fa']
+
+ def button_up(procedure, kind, index, url)
+ if display_up_button?(index, procedure, kind)
+ button(up_classes, "btn_up_#{index}", url)
+ end
+ end
+
+ def button_down(procedure, kind, index, url)
+ if display_down_button?(index, procedure, kind)
+ button(down_classes, "btn_down_#{index}", url)
+ end
+ end
+
+ private
+
+ def button(classes, id, url)
+ link_to(
+ '',
+ url,
+ class: classes,
+ id: id,
+ remote: true,
+ method: :post
+ )
+ end
+
+ def up_classes
+ BASE_CLASSES + ['fa-chevron-up']
+ end
+
+ def down_classes
+ BASE_CLASSES + ['fa-chevron-down']
+ end
+
+ def display_up_button?(index, procedure, kind)
+ index != 0 && count_type_de_champ(procedure, kind) > 1
+ end
+
+ def display_down_button?(index, procedure, kind)
+ (index + 1) < count_type_de_champ(procedure, kind)
+ end
+
+ def count_type_de_champ(procedure, kind)
+ case kind
+ when "public"
+ @count_type_de_champ_public ||= procedure.types_de_champ.count
+ when "private"
+ @count_type_de_champ_private ||= procedure.types_de_champ_private.count
+ when "piece_justificative"
+ @count_type_de_piece_justificative ||= procedure.types_de_piece_justificative.count
+ end
+ end
+end
diff --git a/app/helpers/champ_helper.rb b/app/helpers/champ_helper.rb
index 573a8defe..693eb8bc3 100644
--- a/app/helpers/champ_helper.rb
+++ b/app/helpers/champ_helper.rb
@@ -9,4 +9,25 @@ module ChampHelper
raw(champ.to_render_data.to_json)
# rubocop:enable Rails/OutputSafety
end
+
+ def formatted_value(champ)
+ value = champ.value
+ type = champ.type_champ
+
+ if type == TypeDeChamp.type_champs.fetch(:date) && value.present?
+ Date.parse(value).strftime("%d/%m/%Y")
+ elsif type.in? [TypeDeChamp.type_champs.fetch(:checkbox), TypeDeChamp.type_champs.fetch(:engagement)]
+ value == 'on' ? 'Oui' : 'Non'
+ elsif type == TypeDeChamp.type_champs.fetch(:yes_no)
+ if value == 'true'
+ 'Oui'
+ elsif value == 'false'
+ 'Non'
+ end
+ elsif type == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) && value.present?
+ JSON.parse(value).join(', ')
+ else
+ value
+ end
+ end
end
diff --git a/app/helpers/procedure_helper.rb b/app/helpers/procedure_helper.rb
index 4305b05e5..62ff0f9ee 100644
--- a/app/helpers/procedure_helper.rb
+++ b/app/helpers/procedure_helper.rb
@@ -19,4 +19,18 @@ module ProcedureHelper
action = procedure.archivee? ? :reopen : :publish
t(action, scope: [:modal, :publish, key])
end
+
+ def logo_img(procedure)
+ logo = procedure.logo
+
+ if logo.blank?
+ ActionController::Base.helpers.image_url("marianne.svg")
+ else
+ if Flipflop.remote_storage?
+ RemoteDownloader.new(logo.filename).url
+ else
+ LocalDownloader.new(logo.path, 'logo').url
+ end
+ end
+ end
end
diff --git a/app/jobs/auto_receive_dossiers_for_procedure_job.rb b/app/jobs/auto_receive_dossiers_for_procedure_job.rb
index 6ff7fa117..f55de439f 100644
--- a/app/jobs/auto_receive_dossiers_for_procedure_job.rb
+++ b/app/jobs/auto_receive_dossiers_for_procedure_job.rb
@@ -1,7 +1,7 @@
class AutoReceiveDossiersForProcedureJob < ApplicationJob
queue_as :cron
- def perform(procedure_id, state, gestionnaire_id = nil)
+ def perform(procedure_id, state)
procedure = Procedure.find(procedure_id)
gestionnaire = procedure.gestionnaire_for_cron_job
diff --git a/app/lib/helpscout/api.rb b/app/lib/helpscout/api.rb
index 1b321b166..e7cdbc2db 100644
--- a/app/lib/helpscout/api.rb
+++ b/app/lib/helpscout/api.rb
@@ -7,6 +7,15 @@ class Helpscout::API
PHONES = 'phones'
OAUTH2_TOKEN = 'oauth2/token'
+ def ready?
+ required_secrets = [
+ Rails.application.secrets.helpscout[:mailbox_id],
+ Rails.application.secrets.helpscout[:client_id],
+ Rails.application.secrets.helpscout[:client_secret]
+ ]
+ required_secrets.all?(&:present?)
+ end
+
def add_tags(conversation_id, tags)
call_api(:put, "#{CONVERSATIONS}/#{conversation_id}/#{TAGS}", {
tags: tags
@@ -69,7 +78,7 @@ class Helpscout::API
response = call_api(:get, 'reports/conversations?' + params.to_query)
if !response.success?
- raise StandardError, "Error while fetching conversation report: #{response.status} '#{response.body}'"
+ raise StandardError, "Error while fetching conversation report: #{response.response_code} '#{response.body}'"
end
parse_response_body(response)
diff --git a/app/lib/helpscout/user_conversations_adapter.rb b/app/lib/helpscout/user_conversations_adapter.rb
index 6b265e13e..f62662a0d 100644
--- a/app/lib/helpscout/user_conversations_adapter.rb
+++ b/app/lib/helpscout/user_conversations_adapter.rb
@@ -7,6 +7,10 @@ class Helpscout::UserConversationsAdapter
@to = to
end
+ def can_fetch_reports?
+ api_client.ready?
+ end
+
# Return an array of monthly reports
def reports
@reports ||= (@from..@to)
@@ -35,15 +39,17 @@ class Helpscout::UserConversationsAdapter
}
end
+ def api_client
+ @api_client ||= Helpscout::API.new
+ end
+
def fetch_conversations_report(year, month)
if year == Date.today.year && month == Date.today.month
raise ArgumentError, 'The report for the current month will change in the future, and cannot be cached.'
end
- @helpscout_api ||= Helpscout::API.new
-
Rails.cache.fetch("helpscout-conversation-report-#{year}-#{month}") do
- @helpscout_api.conversations_report(year, month)
+ api_client.conversations_report(year, month)
end
end
end
diff --git a/app/models/champ.rb b/app/models/champ.rb
index 7771007c6..1a9a98241 100644
--- a/app/models/champ.rb
+++ b/app/models/champ.rb
@@ -36,7 +36,7 @@ class Champ < ApplicationRecord
end
def search_terms
- [ to_s ]
+ [to_s]
end
def to_s
diff --git a/app/models/champs/checkbox_champ.rb b/app/models/champs/checkbox_champ.rb
index 9202ca635..8261743f3 100644
--- a/app/models/champs/checkbox_champ.rb
+++ b/app/models/champs/checkbox_champ.rb
@@ -1,7 +1,7 @@
class Champs::CheckboxChamp < Champ
def search_terms
if value == 'on'
- [ libelle ]
+ [libelle]
end
end
diff --git a/app/models/champs/datetime_champ.rb b/app/models/champs/datetime_champ.rb
index 43d59e26f..3995b39e2 100644
--- a/app/models/champs/datetime_champ.rb
+++ b/app/models/champs/datetime_champ.rb
@@ -12,7 +12,7 @@ class Champs::DatetimeChamp < Champ
self.value =
begin
hash_date = YAML.safe_load(value.gsub('=>', ': '))
- year, month, day, hour, minute = hash_date.values_at(1,2,3,4,5)
+ year, month, day, hour, minute = hash_date.values_at(1, 2, 3, 4, 5)
Time.zone.local(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M")
rescue
nil
diff --git a/app/models/champs/engagement_champ.rb b/app/models/champs/engagement_champ.rb
index efd968c5e..c3173e69e 100644
--- a/app/models/champs/engagement_champ.rb
+++ b/app/models/champs/engagement_champ.rb
@@ -1,7 +1,7 @@
class Champs::EngagementChamp < Champs::CheckboxChamp
def search_terms
if value == 'on'
- [ libelle ]
+ [libelle]
end
end
end
diff --git a/app/models/champs/linked_drop_down_list_champ.rb b/app/models/champs/linked_drop_down_list_champ.rb
index f965a472c..db12156a0 100644
--- a/app/models/champs/linked_drop_down_list_champ.rb
+++ b/app/models/champs/linked_drop_down_list_champ.rb
@@ -38,7 +38,7 @@ class Champs::LinkedDropDownListChamp < Champ
end
def search_terms
- [ primary_value, secondary_value ]
+ [primary_value, secondary_value]
end
private
@@ -52,6 +52,6 @@ class Champs::LinkedDropDownListChamp < Champ
end
def pack_value(primary, secondary)
- self.value = JSON.generate([ primary, secondary ])
+ self.value = JSON.generate([primary, secondary])
end
end
diff --git a/app/models/champs/piece_justificative_champ.rb b/app/models/champs/piece_justificative_champ.rb
index 6aa1c39aa..315cc1988 100644
--- a/app/models/champs/piece_justificative_champ.rb
+++ b/app/models/champs/piece_justificative_champ.rb
@@ -31,11 +31,11 @@ class Champs::PieceJustificativeChamp < Champ
if piece_justificative_file.attached? && piece_justificative_file.previous_changes.present?
if piece_justificative_file.blob.byte_size > PIECE_JUSTIFICATIVE_FILE_MAX_SIZE
- errors << "Le fichier #{piece_justificative_file.filename.to_s} est trop lourd, il doit faire au plus #{PIECE_JUSTIFICATIVE_FILE_MAX_SIZE.to_s(:human_size, precision: 2)}"
+ errors << "Le fichier #{piece_justificative_file.filename} est trop lourd, il doit faire au plus #{PIECE_JUSTIFICATIVE_FILE_MAX_SIZE.to_s(:human_size, precision: 2)}"
end
if !piece_justificative_file.blob.content_type.in?(PIECE_JUSTIFICATIVE_FILE_ACCEPTED_FORMATS)
- errors << "Le fichier #{piece_justificative_file.filename.to_s} est dans un format que nous n'acceptons pas"
+ errors << "Le fichier #{piece_justificative_file.filename} est dans un format que nous n'acceptons pas"
end
# FIXME: add Clamav check
diff --git a/app/models/champs/siret_champ.rb b/app/models/champs/siret_champ.rb
index b36e3c1ba..c2eb139b5 100644
--- a/app/models/champs/siret_champ.rb
+++ b/app/models/champs/siret_champ.rb
@@ -40,6 +40,6 @@ class Champs::SiretChamp < Champ
accepts_nested_attributes_for :etablissement, allow_destroy: true, update_only: true
def search_terms
- etablissement.present? ? etablissement.search_terms : [ value ]
+ etablissement.present? ? etablissement.search_terms : [value]
end
end
diff --git a/app/models/champs/yes_no_champ.rb b/app/models/champs/yes_no_champ.rb
index 27ead824a..7c29930fb 100644
--- a/app/models/champs/yes_no_champ.rb
+++ b/app/models/champs/yes_no_champ.rb
@@ -1,7 +1,7 @@
class Champs::YesNoChamp < Champs::CheckboxChamp
def search_terms
if value == 'true'
- [ libelle ]
+ [libelle]
end
end
diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb
index 7bacea4d8..5b15236d1 100644
--- a/app/models/concerns/tags_substitution_concern.rb
+++ b/app/models/concerns/tags_substitution_concern.rb
@@ -133,7 +133,7 @@ module TagsSubstitutionConcern
end
def external_link(url)
- link_to(url, url, target: '_blank')
+ link_to(url, url, target: '_blank', rel: 'noopener')
end
def dossier_tags
diff --git a/app/models/drop_down_list.rb b/app/models/drop_down_list.rb
index cc91f8611..5c3f2757c 100644
--- a/app/models/drop_down_list.rb
+++ b/app/models/drop_down_list.rb
@@ -7,11 +7,7 @@ class DropDownList < ApplicationRecord
end
def disabled_options
- options.select{ |v| (v =~ /^--.*--$/).present? }
- end
-
- def selected_options(champ)
- champ.object.value.blank? ? [] : multiple ? JSON.parse(champ.object.value) : [champ.object.value]
+ options.select { |v| (v =~ /^--.*--$/).present? }
end
def selected_options_without_decorator(champ)
diff --git a/app/models/etablissement.rb b/app/models/etablissement.rb
index 4741a5334..44e5142e9 100644
--- a/app/models/etablissement.rb
+++ b/app/models/etablissement.rb
@@ -91,6 +91,6 @@ class Etablissement < ApplicationRecord
def message_for_signature
JSON.pretty_generate(as_json(include: {
exercices: { only: [:ca, :date_fin_exercice, :date_fin_exercice_timestamp] }
- }).delete_if { |k,v| v.blank? })
+ }).delete_if { |_k, v| v.blank? })
end
end
diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb
index dab20d0ac..9b6a8ece8 100644
--- a/app/models/gestionnaire.rb
+++ b/app/models/gestionnaire.rb
@@ -3,6 +3,8 @@ class Gestionnaire < ApplicationRecord
include EmailSanitizableConcern
include ActiveRecord::SecureToken
+ LOGIN_TOKEN_VALIDITY = 30.minutes
+
devise :database_authenticatable, :registerable, :async,
:recoverable, :rememberable, :trackable, :validatable
@@ -141,7 +143,7 @@ class Gestionnaire < ApplicationRecord
def login_token_valid?(login_token)
BCrypt::Password.new(encrypted_login_token) == login_token &&
- 30.minutes.ago < login_token_created_at
+ LOGIN_TOKEN_VALIDITY.ago < login_token_created_at
rescue BCrypt::Errors::InvalidHash
false
end
diff --git a/app/models/procedure.rb b/app/models/procedure.rb
index d1458181f..0205654a6 100644
--- a/app/models/procedure.rb
+++ b/app/models/procedure.rb
@@ -176,6 +176,7 @@ class Procedure < ApplicationRecord
else
list[index_of_first_element].update(order_place: index_of_first_element + 1)
list[index_of_first_element + 1].update(order_place: index_of_first_element)
+ reload
true
end
diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb
index 1798ece76..abcda68bf 100644
--- a/app/models/procedure_presentation.rb
+++ b/app/models/procedure_presentation.rb
@@ -46,7 +46,7 @@ class ProcedurePresentation < ApplicationRecord
)
end
- explanatory_types_de_champ = [:header_section, :explication].map{ |k| TypeDeChamp.type_champs.fetch(k) }
+ explanatory_types_de_champ = [:header_section, :explication].map { |k| TypeDeChamp.type_champs.fetch(k) }
fields.concat procedure.types_de_champ
.reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) }
@@ -215,7 +215,7 @@ class ProcedurePresentation < ApplicationRecord
def valid_columns_for_table(table)
@column_whitelist ||= fields
.group_by { |field| field['table'] }
- .map { |table, fields| [table, Set.new(fields.map { |field| field['column'] }) ] }
+ .map { |table, fields| [table, Set.new(fields.map { |field| field['column'] })] }
.to_h
@column_whitelist[table] || []
diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb
index b9ef0f767..6a68a0d7b 100644
--- a/app/services/pieces_justificatives_service.rb
+++ b/app/services/pieces_justificatives_service.rb
@@ -10,7 +10,7 @@ class PiecesJustificativesService
errors = with_virus
.map { |_, content| "#{content.original_filename} : virus détecté" }
- errors += without_virus
+ errors + without_virus
.map { |tpj, content| save_pj(content, dossier, tpj, user) }
.compact()
end
diff --git a/app/services/procedure_export_service.rb b/app/services/procedure_export_service.rb
index a025c4ee4..98263e9b7 100644
--- a/app/services/procedure_export_service.rb
+++ b/app/services/procedure_export_service.rb
@@ -212,7 +212,8 @@ class ProcedureExportService
etablissement.champ.dossier_id,
label_for_export(etablissement.champ.libelle).to_s
]
- data += etablissement_data(etablissement)
+
+ data + etablissement_data(etablissement)
end
end
diff --git a/app/services/render_partial_service.rb b/app/services/render_partial_service.rb
index 82ef25a54..9bfb61445 100644
--- a/app/services/render_partial_service.rb
+++ b/app/services/render_partial_service.rb
@@ -17,7 +17,7 @@ class RenderPartialService
def self.left_panel_exist?(left_panel_url)
file = left_panel_url.split('/').last
- File.exist?(Rails.root.join('app','views', 'layouts', 'left_panels', "_#{file}.html.haml"))
+ File.exist?(Rails.root.join('app', 'views', 'layouts', 'left_panels', "_#{file}.html.haml"))
end
private
@@ -31,6 +31,6 @@ class RenderPartialService
end
def retrieve_name
- "#{controller.to_s.parameterize.underscore}_#{method.to_s}"
+ "#{controller.to_s.parameterize.underscore}_#{method}"
end
end
diff --git a/app/services/signature_service.rb b/app/services/signature_service.rb
index 716813aa9..4fafd51b2 100644
--- a/app/services/signature_service.rb
+++ b/app/services/signature_service.rb
@@ -1,28 +1,22 @@
class SignatureService
class << self
- def generate
- RbNaCl::Util.bin2hex(RbNaCl::SigningKey.generate)
- end
-
def verify(signature, message)
- message = Base64.urlsafe_encode64(message)
begin
- signing_key.verify_key
- .verify(RbNaCl::Util.hex2bin(signature), message)
- rescue RbNaCl::BadSignatureError, RbNaCl::LengthError
+ decoded_message = verifier.verify(signature)
+ return message == decoded_message
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
return false
end
end
def sign(message)
- message = Base64.urlsafe_encode64(message)
- RbNaCl::Util.bin2hex(signing_key.sign(message))
+ verifier.generate(message)
end
private
- def signing_key
- @@signing_key ||= RbNaCl::SigningKey.new(RbNaCl::Util.hex2bin(Rails.application.secrets.signing_key))
+ def verifier
+ @@verifier ||= ActiveSupport::MessageVerifier.new(Rails.application.secrets.signing_key)
end
end
end
diff --git a/app/services/types_de_champ_service.rb b/app/services/types_de_champ_service.rb
index afc531349..288e30f59 100644
--- a/app/services/types_de_champ_service.rb
+++ b/app/services/types_de_champ_service.rb
@@ -36,11 +36,11 @@ class TypesDeChampService
end
def types_de_champ
- private? ? @procedure.types_de_champ_private.decorate : @procedure.types_de_champ.decorate
+ private? ? @procedure.types_de_champ_private : @procedure.types_de_champ
end
def new_type_de_champ
- TypeDeChamp.new(private: private?).decorate
+ TypeDeChamp.new(private: private?)
end
def fields_for_var
diff --git a/app/uploaders/commentaire_file_uploader.rb b/app/uploaders/commentaire_file_uploader.rb
index eaa738b14..1249c94c5 100644
--- a/app/uploaders/commentaire_file_uploader.rb
+++ b/app/uploaders/commentaire_file_uploader.rb
@@ -18,6 +18,6 @@ class CommentaireFileUploader < BaseUploader
end
def accept_extension_list
- extension_white_list.map{ |e| ".#{e}" }.join(",")
+ extension_white_list.map { |e| ".#{e}" }.join(",")
end
end
diff --git a/app/views/admin/instructeurs/show.html.haml b/app/views/admin/instructeurs/show.html.haml
index 83effd8c4..3f0c6a2d3 100644
--- a/app/views/admin/instructeurs/show.html.haml
+++ b/app/views/admin/instructeurs/show.html.haml
@@ -18,9 +18,6 @@
%br
%br
= f.submit 'Valider', class: 'btn btn-info', style: 'float: left;', id: 'add-gestionnaire-email'
- %br
- .alert.alert-info
- Astuce : ajoutez votre adresse email pour tester la partie instructeur.
.col-xs-6
%h3.text-success Affectés
= smart_listing_render :instructeurs_assign
diff --git a/app/views/admin/pieces_justificatives/_fields.html.haml b/app/views/admin/pieces_justificatives/_fields.html.haml
index 27294bbf2..8343e84af 100644
--- a/app/views/admin/pieces_justificatives/_fields.html.haml
+++ b/app/views/admin/pieces_justificatives/_fields.html.haml
@@ -20,8 +20,8 @@
- if ff.object.id.present?
.form-group
%br
- = ff.object.button_up(index: ff.index, url: move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index))
- = ff.object.button_down(index: ff.index, url: move_down_admin_procedure_pieces_justificatives_path(@procedure, ff.index))
+ = button_up(@procedure, "piece_justificative", ff.index, move_up_admin_procedure_pieces_justificatives_path(@procedure, ff.index))
+ = button_down(@procedure, "piece_justificative", ff.index, move_down_admin_procedure_pieces_justificatives_path(@procedure, ff.index))
.form-group
%h4 Obligatoire ?
diff --git a/app/views/admin/pieces_justificatives/_form.html.haml b/app/views/admin/pieces_justificatives/_form.html.haml
index 2499b7cad..e48f4077d 100644
--- a/app/views/admin/pieces_justificatives/_form.html.haml
+++ b/app/views/admin/pieces_justificatives/_form.html.haml
@@ -1,7 +1,7 @@
= form_for [:admin, @procedure], url: admin_procedure_pieces_justificatives_path(@procedure), remote: true do |f|
#liste_piece_justificative
- = render partial: 'fields', locals: { types_de_piece_justificative: @procedure.types_de_piece_justificative.decorate, f: f }
+ = render partial: 'fields', locals: { types_de_piece_justificative: @procedure.types_de_piece_justificative, f: f }
= f.submit "Enregistrer", class: 'btn btn-success', id: :save
%hr
#new_type_de_piece_justificative
- = render partial: 'fields', locals: { types_de_piece_justificative: TypeDePieceJustificative.new.decorate, f: f }
+ = render partial: 'fields', locals: { types_de_piece_justificative: TypeDePieceJustificative.new, f: f }
diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml
index bad8e62ed..460f04211 100644
--- a/app/views/admin/procedures/_informations.html.haml
+++ b/app/views/admin/procedures/_informations.html.haml
@@ -101,7 +101,7 @@
.col-md-6
%h4 Logo de la démarche
- if @procedure.logo.present?
- = image_tag @procedure.decorate.logo_img, { style: 'height: 40px; display: inline; margin-right: 6px;', id: 'preview_procedure_logo' }
+ = image_tag logo_img(@procedure), { style: 'height: 40px; display: inline; margin-right: 6px;', id: 'preview_procedure_logo' }
\-
- if @procedure.persisted?
diff --git a/app/views/admin/procedures/_list.html.haml b/app/views/admin/procedures/_list.html.haml
index d1691b639..8fcb04aee 100644
--- a/app/views/admin/procedures/_list.html.haml
+++ b/app/views/admin/procedures/_list.html.haml
@@ -12,7 +12,7 @@
%th Actions
- @procedures.each do |procedure|
- - procedure = procedure.decorate
+ - procedure = procedure
- admin_procedure_href = admin_procedure_path(procedure)
%tr{ id: "tr_dossier_#{procedure.id}", data: { href: admin_procedure_href } }
%td= link_to(procedure.id, admin_procedure_href)
@@ -20,9 +20,9 @@
- if procedure.publiee?
%td.procedure-lien= link_to(procedure_lien(procedure), procedure_lien(procedure))
- if procedure.publiee_ou_archivee?
- %td= link_to(procedure.published_at_fr, admin_procedure_href)
+ %td= link_to(procedure.published_at.present? ? procedure.published_at.strftime('%d/%m/%Y %H:%M') : "", admin_procedure_href)
- else
- %td= link_to(procedure.created_at_fr, admin_procedure_href)
+ %td= link_to(procedure.created_at.strftime('%d/%m/%Y %H:%M'), admin_procedure_href)
%td
= link_to('Cloner', admin_procedure_clone_path(procedure.id), data: { method: :put }, class: 'btn-sm btn-primary clone-btn')
- if !procedure.publiee_ou_archivee?
diff --git a/app/views/admin/procedures/new_from_existing.html.haml b/app/views/admin/procedures/new_from_existing.html.haml
index 92d2ad1e6..2eb000c3a 100644
--- a/app/views/admin/procedures/new_from_existing.html.haml
+++ b/app/views/admin/procedures/new_from_existing.html.haml
@@ -1,9 +1,13 @@
-.row.white-back
- %a#from-scratch{ href: new_admin_procedure_path, class: 'btn-sm btn-primary' }
+- if current_administrateur.procedures.brouillons.count == 0
+ %h4{ style: 'padding: 20px; margin: 20px !important;' }
+ Bienvenue, vous allez pouvoir créer une première démarche de test. Celle-ci sera visible uniquement par vous et ne sera publiée nulle part, alors pas de crainte à avoir.
+
+.row{ style: 'padding: 20px; margin: 20px !important;' }
+ %a#from-scratch{ href: new_admin_procedure_path, class: 'btn-lg btn-primary' }
Créer une nouvelle démarche de zéro
.row.white-back
- %h2
+ %h3
Créer une nouvelle démarche à partir d'une démarche existante
.section.section-label
diff --git a/app/views/admin/types_de_champ/_fields.html.haml b/app/views/admin/types_de_champ/_fields.html.haml
index 9acfa02a2..8d6ca418a 100644
--- a/app/views/admin/types_de_champ/_fields.html.haml
+++ b/app/views/admin/types_de_champ/_fields.html.haml
@@ -1,5 +1,5 @@
= f.fields_for type_de_champ_service.fields_for_var, types_de_champ, remote: true do |ff|
- - type_champ = ff.object.object.type_champ
+ - type_champ = ff.object.type_champ
.form-inline{ class: (type_champ == TypeDeChamp.type_champs.fetch(:header_section) ? 'header-section' : nil) }
.form-group.libelle
@@ -16,14 +16,14 @@
.form-group.drop-down-list{ class: (%w(drop_down_list multiple_drop_down_list linked_drop_down_list).include?(type_champ) ? 'show-inline' : nil), style: 'margin-right: 5px;' }
%h4 Liste déroulante
- = ff.fields_for :drop_down_list_attributes, ff.object.object.drop_down_list do |fff|
+ = ff.fields_for :drop_down_list_attributes, ff.object.drop_down_list do |fff|
~ fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne et --valeur-- pour un séparateur.", rows: 3, cols: 30
= fff.hidden_field :id
.form-group.pj-template{ class: (type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)) ? 'show-inline' : nil }
%h4 Modèle
- if type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)
- - template = ff.object.object.piece_justificative_template
+ - template = ff.object.piece_justificative_template
- if !template.attached?
= ff.file_field :piece_justificative_template,
@@ -52,7 +52,7 @@
= ff.check_box :parcelles_agricoles
Parcelles Agricoles
- - hide_mandatory = (ff.object.object.private? || type_champ == TypeDeChamp.type_champs.fetch(:explication))
+ - hide_mandatory = (ff.object.private? || type_champ == TypeDeChamp.type_champs.fetch(:explication))
.form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : nil }
%h4 Obligatoire ?
.center
@@ -65,8 +65,9 @@
- if ff.object.id.present?
.form-group
%br
- = ff.object.button_up(index: ff.index, url: type_de_champ_service.move_up_url(ff), private: type_de_champ_service.private?)
- = ff.object.button_down(index: ff.index, url: type_de_champ_service.move_down_url(ff), private: type_de_champ_service.private?)
+ - kind = type_de_champ_service.private? ? "private" : "public"
+ = button_up(@procedure, kind, ff.index, type_de_champ_service.move_up_url(ff))
+ = button_down(@procedure, kind, ff.index, type_de_champ_service.move_down_url(ff))
.form-group
%h4 position
diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml
index 4b2da6288..616ade33b 100644
--- a/app/views/layouts/_new_header.haml
+++ b/app/views/layouts/_new_header.haml
@@ -85,7 +85,9 @@
= link_to destroy_user_session_path, method: :delete, class: "menu-item menu-link" do
= image_tag "icons/sign-out.svg"
Se déconnecter
-
- elsif request.path != new_user_session_path
+ - if request.path == new_user_registration_path
+ %li
+ Vous avez déjà un compte ?
%li
= link_to "Connexion", new_user_session_path, class: "button secondary"
diff --git a/app/views/layouts/_sendinblue.html.haml b/app/views/layouts/_sendinblue.html.haml
new file mode 100644
index 000000000..0ddd0f2f9
--- /dev/null
+++ b/app/views/layouts/_sendinblue.html.haml
@@ -0,0 +1,26 @@
+:javascript
+ (function() {
+ window.sib = { equeue: [], client_key: "pcxtf4lpkka986pf4l1kt" };
+ /* OPTIONAL: email for identify request*/
+ window.sib.email_id = '#{current_administrateur.email}';
+ window.sendinblue = {}; for (var j = ['track', 'identify', 'trackLink', 'page'], i = 0; i < j.length; i++) { (function(k) { window.sendinblue[k] = function() { var arg = Array.prototype.slice.call(arguments); (window.sib[k] || function() { var t = {}; t[k] = arg; window.sib.equeue.push(t);})(arg[0], arg[1], arg[2]);};})(j[i]);}var n = document.createElement("script"),i = document.getElementsByTagName("script")[0]; n.type = "text/javascript", n.id = "sendinblue-js", n.async = !0, n.src = "https://sibautomation.com/sa.js?key=" + window.sib.client_key, i.parentNode.insertBefore(n, i), window.sendinblue.page();
+ })();
+
+ sendinblue.identify('#{current_administrateur.email}', {
+ 'nb_demarches_brouillons': '#{current_administrateur.procedures.brouillons.count}',
+ 'nb_demarches_actives': '#{current_administrateur.procedures.publiees.count}',
+ 'nb_demarches_archivees': '#{current_administrateur.procedures.archivees.count}',
+ 'sign_in_count' : '#{current_administrateur.sign_in_count}',
+ 'created_at' : '#{current_administrateur.created_at}',
+ 'active' : '#{current_administrateur.active}'
+ // Dans l'ideal :
+ // 'nom' : //pour personnaliser les emails
+ // 'prenom' : //pour personnaliser les emails
+ // 'nb_demarches_prod' : // Avec plus de 20 dossiers
+ // 'nb_demarches_test' : // Avec entre 1 et 20 dossiers
+ // 'nb_services' : //combien de service ?
+ // 'nb_instructeurs' : //combien d'instructeur en tout ?
+ // 'nb_dossiers' : //combien de dossier en tout ?
+ });
+
+
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 5b1b9cb21..033ec625c 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -1,20 +1,25 @@
-%html
+!!! 5
+%html{ lang: "fr" }
%head
- %meta{ :content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type" }/
+ %meta{ "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" }
+ %meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" }
%meta{ name: "turbolinks-cache-control", content: "no-cache" }
+ %meta{ name: "viewport", content: "width=device-width, initial-scale=1" }
+ = csrf_meta_tags
+
%title
- = t('dynamics.page_title')
- %meta{ 'http-equiv' => "X-UA-Compatible", :content => "IE=edge" }
+ = content_for?(:title) ? "#{yield(:title)} · demarches-simplifiees.fr" : "demarches-simplifiees.fr"
= favicon_link_tag(image_url("favicons/16x16.png"), type: "image/png", sizes: "16x16")
= favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32")
= favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96")
- = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': "reload"
- = stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
- = javascript_pack_tag 'application-old', defer: true, 'data-turbolinks-track': 'reload'
- = javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
- = csrf_meta_tags
+ = javascript_pack_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
+ = stylesheet_link_tag 'new_design/new_application', media: 'all', 'data-turbolinks-track': 'reload'
+ = stylesheet_link_tag 'new_design/print', media: 'print', 'data-turbolinks-track': 'reload'
+
+ - if Rails.env.development?
+ = stylesheet_link_tag :xray
= render partial: "layouts/matomo"
@@ -24,29 +29,21 @@
}];
%body{ class: browser.platform.ios? ? 'ios' : nil }
- = render partial: 'layouts/outdated_browser_banner'
- = render partial: 'layouts/pre_maintenance'
- - if staging?
- #beta
- Env Test
+ .page-wrapper
+ = render partial: "layouts/outdated_browser_banner"
+ = render partial: 'layouts/pre_maintenance'
+ - if staging?
+ #beta
+ Env Test
- #wrap
- .row
- #header.navbar
- = render partial: "layouts/navbar"
- .row.no-margin
- - if RenderPartialService.left_panel_exist? @left_pannel_url
- .col-xs-2#left-panel
- = render partial: @left_pannel_url
- - main_container_size = 10
- - else
- - main_container_size = 12
+ = render partial: "layouts/new_header"
+ = render partial: "layouts/flash_messages"
+ = content_for?(:content) ? yield(:content) : yield
- = render partial: 'layouts/main_container', locals: { main_container_size: main_container_size }
- #mask-search
- %h1
- %i.fa.fa-times{ style: 'position: fixed; top: 10; right: 30; color: white;' }
+ - if content_for?(:footer)
+ = content_for(:footer)
- = render partial: 'layouts/switch_devise_profile_module'
+ - if Rails.env.development?
+ = javascript_include_tag :xray
- = render partial: 'layouts/footer', locals: { main_container_size: main_container_size }
+ = yield :charts_js
diff --git a/app/views/layouts/application_old.html.haml b/app/views/layouts/application_old.html.haml
new file mode 100644
index 000000000..a5a6a67b8
--- /dev/null
+++ b/app/views/layouts/application_old.html.haml
@@ -0,0 +1,53 @@
+%html
+ %head
+ %meta{ :content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type" }/
+ %meta{ name: "turbolinks-cache-control", content: "no-cache" }
+ %title
+ = t('dynamics.page_title')
+ %meta{ 'http-equiv' => "X-UA-Compatible", :content => "IE=edge" }
+
+ = favicon_link_tag(image_url("favicons/16x16.png"), type: "image/png", sizes: "16x16")
+ = favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32")
+ = favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96")
+
+ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': "reload"
+ = stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
+ = javascript_pack_tag 'application-old', defer: true, 'data-turbolinks-track': 'reload'
+ = javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
+ = csrf_meta_tags
+
+ = render partial: "layouts/matomo"
+ = render partial: "layouts/sendinblue"
+
+ :javascript
+ DATA = [{
+ sentry: #{raw(sentry_config)}
+ }];
+
+ %body{ class: browser.platform.ios? ? 'ios' : nil }
+ = render partial: 'layouts/outdated_browser_banner'
+ = render partial: 'layouts/pre_maintenance'
+ - if staging?
+ #beta
+ Env Test
+
+ #wrap
+ .row
+ #header.navbar
+ = render partial: "layouts/navbar"
+ .row.no-margin
+ - if RenderPartialService.left_panel_exist? @left_pannel_url
+ .col-xs-2#left-panel
+ = render partial: @left_pannel_url
+ - main_container_size = 10
+ - else
+ - main_container_size = 12
+
+ = render partial: 'layouts/main_container', locals: { main_container_size: main_container_size }
+ #mask-search
+ %h1
+ %i.fa.fa-times{ style: 'position: fixed; top: 10; right: 30; color: white;' }
+
+ = render partial: 'layouts/switch_devise_profile_module'
+
+ = render partial: 'layouts/footer', locals: { main_container_size: main_container_size }
diff --git a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml
index 560f960b9..b1aa98f6f 100644
--- a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml
+++ b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml
@@ -1,7 +1,7 @@
#first-block
.en-cours
- if @procedure.logo.present?
- = image_tag @procedure.decorate.logo_img, style: 'width: 30px;'
+ = image_tag logo_img(@procedure), style: 'width: 30px;'
%b
= @procedure.libelle
@@ -14,6 +14,10 @@
.procedure-list-element{ class: ('active' if active == 'Informations') }
Publication
+ %a#onglet-description{ href: url_for(edit_admin_procedure_path(@procedure)) }
+ .procedure-list-element{ class: ('active' if active == 'Description') }
+ Description
+
%a#onglet-services{ href: current_administrateur.services.present? ? url_for(services_path(procedure_id: @procedure.id)) : url_for(new_service_path(procedure_id: @procedure.id)) }
.procedure-list-element
Services
@@ -22,10 +26,6 @@
.procedure-list-element{ class: ('active' if active == 'Instructeurs') }
Instructeurs
- %a#onglet-description{ href: url_for(edit_admin_procedure_path(@procedure)) }
- .procedure-list-element{ class: ('active' if active == 'Description') }
- Description
-
- if !@procedure.locked?
%a#onglet-champs{ href: url_for(admin_procedure_types_de_champ_path(@procedure)) }
.procedure-list-element{ class: ('active' if active == 'Champs') }
@@ -41,16 +41,17 @@
.procedure-list-element{ class: ('active' if active == 'Annotations privées') }
Annotations privées
- %a#onglet-inemailsfos{ href: url_for(admin_procedure_mail_templates_path(@procedure)) }
- .procedure-list-element{ class: ('active' if active == 'E-mails') }
- E-mails
-
%a#onglet-preview{ href: url_for(apercu_procedure_path(@procedure)), target: "_blank" }
.procedure-list-element{ class: ('active' if active == 'Prévisualisation') }
Prévisualisation
+ %a#onglet-inemailsfos{ href: url_for(admin_procedure_mail_templates_path(@procedure)) }
+ .procedure-list-element{ class: ('active' if active == 'E-mails') }
+ E-mails
+
%a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) }
- .procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation
+ .procedure-list-element{ class: ('active' if active == 'Attestation') }
+ Attestation
.split-hr-left
diff --git a/app/views/layouts/new_application.html.haml b/app/views/layouts/new_application.html.haml
deleted file mode 100644
index 142e5262c..000000000
--- a/app/views/layouts/new_application.html.haml
+++ /dev/null
@@ -1,49 +0,0 @@
-!!! 5
-%html{ lang: "fr" }
- %head
- %meta{ "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" }
- %meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" }
- %meta{ name: "turbolinks-cache-control", content: "no-cache" }
- %meta{ name: "viewport", content: "width=device-width, initial-scale=1" }
- = csrf_meta_tags
-
- %title
- = content_for?(:title) ? "#{yield(:title)} · demarches-simplifiees.fr" : "demarches-simplifiees.fr"
-
- = favicon_link_tag(image_url("favicons/16x16.png"), type: "image/png", sizes: "16x16")
- = favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32")
- = favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96")
-
- = javascript_pack_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
- = stylesheet_link_tag 'new_design/new_application', media: 'all', 'data-turbolinks-track': 'reload'
- = stylesheet_link_tag 'new_design/print', media: 'print', 'data-turbolinks-track': 'reload'
-
- - if Rails.env.development?
- = stylesheet_link_tag :xray
-
- = render partial: "layouts/matomo"
-
- :javascript
- DATA = [{
- sentry: #{raw(sentry_config)}
- }];
-
- %body{ class: browser.platform.ios? ? 'ios' : nil }
- .page-wrapper
- = render partial: "layouts/outdated_browser_banner"
- = render partial: 'layouts/pre_maintenance'
- - if staging?
- #beta
- Env Test
-
- = render partial: "layouts/new_header"
- = render partial: "layouts/flash_messages"
- = yield
-
- - if content_for?(:footer)
- = content_for(:footer)
-
- - if Rails.env.development?
- = javascript_include_tag :xray
-
- = yield :charts_js
diff --git a/app/views/layouts/procedure_context.html.haml b/app/views/layouts/procedure_context.html.haml
new file mode 100644
index 000000000..223bff4c2
--- /dev/null
+++ b/app/views/layouts/procedure_context.html.haml
@@ -0,0 +1,22 @@
+- content_for :content do
+ .two-columns.procedure-context
+ .columns-container
+
+ .column.procedure-preview
+ - procedure = @dossier.procedure
+ .procedure-logos
+ = image_tag logo_img(procedure)
+ - if procedure.euro_flag
+ = image_tag "flag_of_europe.svg"
+ %h2.procedure-title
+ = procedure.libelle
+ .procedure-description
+ = h string_to_html(procedure.description)
+
+ .column.procedure-context-content
+ = yield
+
+- content_for :footer do
+ = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier }
+
+= render template: 'layouts/application'
diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml
index 052b569c3..b35489857 100644
--- a/app/views/new_gestionnaire/dossiers/print.html.haml
+++ b/app/views/new_gestionnaire/dossiers/print.html.haml
@@ -13,7 +13,7 @@
%h2 Formulaire
-- champs = @dossier.champs.decorate
+- champs = @dossier.champs
- if champs.any?
= render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' }
diff --git a/app/views/new_user/dossiers/_demarche_overview.html.haml b/app/views/new_user/dossiers/_demarche_overview.html.haml
deleted file mode 100644
index e0a451247..000000000
--- a/app/views/new_user/dossiers/_demarche_overview.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-.procedure-logos
- = image_tag procedure.decorate.logo_img
- - if procedure.euro_flag
- = image_tag "flag_of_europe.svg"
-
-%h2.procedure-title
- = procedure.libelle
-.procedure-description
- = h string_to_html(procedure.description)
diff --git a/app/views/new_user/dossiers/identite.html.haml b/app/views/new_user/dossiers/identite.html.haml
index 8a6de338b..28d4466b4 100644
--- a/app/views/new_user/dossiers/identite.html.haml
+++ b/app/views/new_user/dossiers/identite.html.haml
@@ -1,39 +1,30 @@
- content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})")
-- content_for :footer do
- = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier }
+= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
-.two-columns
- .columns-container
- .column.preview
- = render partial: "new_user/dossiers/demarche_overview", locals: { procedure: @dossier.procedure }
+- if !dossier_submission_is_closed?(@dossier)
+ = form_for @dossier.individual, url: update_identite_dossier_path(@dossier), html: { class: "form" } do |f|
+ %h1 Données d'identité
- .column.identity-form
- = render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
+ %p.mb-1 Merci de remplir vos informations personnelles pour accéder à la démarche.
- - if !dossier_submission_is_closed?(@dossier)
- = form_for @dossier.individual, url: update_identite_dossier_path(@dossier), html: { class: "form" } do |f|
- %h1 Données d'identité
+ %label
+ %span.mandatory *
+ champs requis
- %p.mb-1 Merci de remplir vos informations personnelles pour accéder à la démarche.
+ = f.label :gender, class: "required"
+ = f.select :gender, ['M.', 'Mme'], {}, class: "small"
- %label
- %span.mandatory *
- champs requis
+ .flex
+ .inline-champ
+ = f.label :prenom, class: "required"
+ = f.text_field :prenom, class: "small", required: true
+ .inline-champ
+ = f.label :nom, class: "required"
+ = f.text_field :nom, class: "small", required: true
- = f.label :gender, class: "required"
- = f.select :gender, ['M.', 'Mme'], {}, class: "small"
+ - if @dossier.procedure.ask_birthday?
+ = f.label :birthdate, class: "required"
+ = f.date_field :birthdate, value: @dossier.individual.birthdate, placeholder: 'format : AAAA-MM-JJ', required: true, class: "small"
- .flex
- .inline-champ
- = f.label :prenom, class: "required"
- = f.text_field :prenom, class: "small", required: true
- .inline-champ
- = f.label :nom, class: "required"
- = f.text_field :nom, class: "small", required: true
-
- - if @dossier.procedure.ask_birthday?
- = f.label :birthdate, class: "required"
- = f.date_field :birthdate, value: @dossier.individual.birthdate, placeholder: 'format : AAAA-MM-JJ', required: true, class: "small"
-
- = f.submit "Continuer", class: "button large primary expand"
+ = f.submit "Continuer", class: "button large primary expand"
diff --git a/app/views/new_user/dossiers/siret.html.haml b/app/views/new_user/dossiers/siret.html.haml
index ec049a242..4f0f25283 100644
--- a/app/views/new_user/dossiers/siret.html.haml
+++ b/app/views/new_user/dossiers/siret.html.haml
@@ -1,25 +1,14 @@
- content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})")
-- content_for :footer do
- = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier }
+- if !dossier_submission_is_closed?(@dossier)
+ = form_for current_user, url: siret_dossier_path(@dossier), html: { class: 'form', method: 'post' } do |f|
+ %h1 Identifier votre établissement
-.two-columns
- .columns-container
- .column.preview
- = render partial: "new_user/dossiers/demarche_overview", locals: { procedure: @dossier.procedure }
+ %p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche.
- .column.identity-form
- = render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
+ = f.label :siret, style: "display: none"
+ = f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true
- - if !dossier_submission_is_closed?(@dossier)
- = form_for current_user, url: siret_dossier_path(@dossier), html: { class: 'form', method: 'post' } do |f|
- %h1 Identifier votre établissement
+ = f.hidden_field :dossier_id, value: @dossier.id
- %p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche.
-
- = f.label :siret, style: "display: none"
- = f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true
-
- = f.hidden_field :dossier_id, value: @dossier.id
-
- = f.submit "Valider", class: "button large primary expand", data: { disable_with: "Récupération des informations…" }
+ = f.submit "Valider", class: "button large primary expand", data: { disable_with: "Récupération des informations…" }
diff --git a/app/views/shared/dossiers/_champs.html.haml b/app/views/shared/dossiers/_champs.html.haml
index 928efe27c..bab7a4e51 100644
--- a/app/views/shared/dossiers/_champs.html.haml
+++ b/app/views/shared/dossiers/_champs.html.haml
@@ -2,6 +2,7 @@
%tbody
- champs.reject(&:exclude_from_view?).each do |c|
%tr
+ - value = formatted_value(c)
- case c.type_champ
- when TypeDeChamp.type_champs.fetch(:header_section)
%th.header-section{ colspan: 3 }
@@ -10,9 +11,9 @@
%th.libelle
= "#{c.libelle} :"
%td.rich-text
- - if c.value.present?
+ - if value.present?
%ul
- - c.value.split(", ").each do |item|
+ - value.split(", ").each do |item|
%li
= item
- when TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
@@ -23,7 +24,7 @@
%th.libelle
= "#{c.libelle} :"
%td.rich-text
- - dossier = Dossier.includes(:procedure).find_by(id: c.value)
+ - dossier = Dossier.includes(:procedure).find_by(id: value)
- if dossier
- path = dossier_linked_path(current_gestionnaire, dossier)
- if path.present?
@@ -48,7 +49,7 @@
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
- = simple_format(c.value)
+ = simple_format(value)
- when TypeDeChamp.type_champs.fetch(:siret)
%th.libelle
= "#{c.libelle} :"
@@ -61,14 +62,14 @@
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
- - if c.value.present?
+ - if value.present?
= render partial: "shared/champs/carte/show", locals: { champ: c }
- else
%th.libelle
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
- = sanitize(c.value)
+ = sanitize(value)
- if c.type_champ != TypeDeChamp.type_champs.fetch(:header_section)
%td.updated-at
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
diff --git a/app/views/shared/dossiers/_demande.html.haml b/app/views/shared/dossiers/_demande.html.haml
index 140c5c27b..3d9ba3de8 100644
--- a/app/views/shared/dossiers/_demande.html.haml
+++ b/app/views/shared/dossiers/_demande.html.haml
@@ -10,7 +10,7 @@
= render partial: "shared/dossiers/identite_individual", locals: { individual: dossier.individual }
.tab-title Formulaire
- - champs = dossier.champs.includes(:type_de_champ).decorate
+ - champs = dossier.champs.includes(:type_de_champ)
- if champs.any?
.card
= render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at, profile: profile }
diff --git a/app/views/shared/dossiers/messages/_form.html.haml b/app/views/shared/dossiers/messages/_form.html.haml
index 6cc26c2bf..e6dbb38ee 100644
--- a/app/views/shared/dossiers/messages/_form.html.haml
+++ b/app/views/shared/dossiers/messages/_form.html.haml
@@ -1,6 +1,6 @@
= form_for(commentaire, url: form_url, html: { class: 'form' }) do |f|
= f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true, class: 'message-textarea'
- .flex.justify-between
+ .flex.justify-between.wrap
%div
= f.file_field :file, id: :file, accept: commentaire.file.accept_extension_list
%label{ for: :file }
@@ -8,4 +8,4 @@
(taille max : 20 Mo)
%div
- = f.submit 'Envoyer', class: 'button primary send', data: { disable: true }
+ = f.submit 'Envoyer le message', class: 'button primary send', data: { disable: true }
diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml
index 2a11db8ea..07a5af48c 100644
--- a/app/views/users/registrations/new.html.haml
+++ b/app/views/users/registrations/new.html.haml
@@ -1,6 +1,6 @@
.two-columns.auth
.columns-container
- .column.preview
+ .column.procedure-preview
= image_tag "landing/hero/dematerialiser.svg", class: "paperless-logo"
.baseline.center
%h3 Un outil simple
@@ -9,7 +9,7 @@
%br
administratifs dématérialisés.
- .column.auth-form
+ .column.procedure-context-content.auth-form
= devise_error_messages!
= form_for resource, url: user_registration_path, html: { class: "form" } do |f|
%h1 Créez-vous un compte
diff --git a/app/views/users/sessions/_resume_procedure.html.haml b/app/views/users/sessions/_resume_procedure.html.haml
index 9df51d63b..895730eef 100644
--- a/app/views/users/sessions/_resume_procedure.html.haml
+++ b/app/views/users/sessions/_resume_procedure.html.haml
@@ -8,7 +8,7 @@
= image_tag('drapeau_europe.png')
#logo_procedure.flag
- = image_tag( @dossier.procedure.decorate.logo_img )
+ = image_tag(logo_img(dossier.procedure))
%h2#titre-procedure.text-info
= @dossier.procedure.libelle
diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml
index d231b6ac9..b3f6bd9bb 100644
--- a/app/views/users/sessions/new.html.haml
+++ b/app/views/users/sessions/new.html.haml
@@ -1,6 +1,6 @@
.two-columns.auth
.columns-container
- .column.preview
+ .column.procedure-preview
- if !@dossier
= image_tag "landing/hero/dematerialiser.svg", class: "paperless-logo"
.baseline.center
@@ -13,7 +13,7 @@
.text-right
= link_to "Fermer", users_no_procedure_url, class: "link close-procedure"
.procedure-logos
- = image_tag @dossier.procedure.decorate.logo_img
+ = image_tag logo_img(@dossier.procedure)
- if @dossier.procedure.euro_flag
= image_tag "flag_of_europe.svg"
@@ -22,7 +22,7 @@
.procedure-description
= h simple_format(@dossier.procedure.description)
- .column.auth-form
+ .column.procedure-context-content.auth-form.sign-in-form
- if resource_name == :user
%p.register
%span
@@ -40,13 +40,15 @@
= f.label :password, "Mot de passe"
= f.password_field :password, value: @user.password, placeholder: "8 caractères minimum"
- - if [:user, :gestionnaire].include?(resource_name)
- .reset-password.text-right
- = link_to "Mot de passe oublié ?", new_password_path(resource_name), class: "link"
+ .auth-options
+ - if devise_mapping.rememberable?
+ %div
+ = f.check_box :remember_me, as: :boolean
+ = f.label :remember_me, "Se souvenir de moi", class: 'remember-me'
- - if devise_mapping.rememberable?
- = f.check_box :remember_me, as: :boolean
- = f.label :remember_me, "Se souvenir de moi", class: 'remember-me'
+ - if [:user, :gestionnaire].include?(resource_name)
+ .text-right
+ = link_to "Mot de passe oublié ?", new_password_path(resource_name), class: "link"
= f.submit "Se connecter", class: "button large primary expand"
@@ -58,4 +60,4 @@
= link_to "", france_connect_particulier_path, class: "login-with-fc"
.center
- = link_to "Qu’est-ce que FranceConnect ?", "https://app.franceconnect.gouv.fr/en-savoir-plus", target: "_blank", class: "link"
+ = link_to "Qu’est-ce que FranceConnect ?", "https://franceconnect.gouv.fr/", target: "_blank", class: "link"
diff --git a/config/initializers/active_job_log_subscriber.rb b/config/initializers/active_job_log_subscriber.rb
index 202820450..8929602f5 100644
--- a/config/initializers/active_job_log_subscriber.rb
+++ b/config/initializers/active_job_log_subscriber.rb
@@ -32,12 +32,19 @@ class ActiveJobLogSubscriber < ::ActiveJob::Logging::LogSubscriber
def process_event(event, type)
data = extract_metadata(event)
- data.merge! extract_exception(event)
- data.merge! extract_scheduled_at(event) if type == 'enqueue_at'
- data.merge! extract_duration(event) if type == 'perform'
+ data.merge!(extract_exception(event))
+
+ case type
+ when 'enqueue_at'
+ data.merge!(extract_scheduled_at(event))
+ when 'perform'
+ data.merge!(extract_duration(event))
+ end
tags = ['job', type]
- tags.push('exception') if data[:exception]
+ if data[:exception]
+ tags.push('exception')
+ end
data[:tags] = tags
data[:type] = 'tps'
data[:source] = ENV['SOURCE']
diff --git a/config/initializers/after_party.rb b/config/initializers/after_party.rb
index 66c8b1071..e9ef95728 100644
--- a/config/initializers/after_party.rb
+++ b/config/initializers/after_party.rb
@@ -1,3 +1,3 @@
-AfterParty.setup do |config|
+AfterParty.setup do |_config|
require "after_party/active_record.rb"
end
diff --git a/config/initializers/env_vars.rb b/config/initializers/env_vars.rb
index 9046a8c80..a3a7cd20b 100644
--- a/config/initializers/env_vars.rb
+++ b/config/initializers/env_vars.rb
@@ -5,7 +5,7 @@
if ENV['RAILS_ENV'] != 'test' && File.basename($0) != 'rake'
reference_env_file = File.join('config', 'env.example')
- Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, value|
+ Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, _value|
if !ENV.key?(key.to_s)
raise "Configuration error: `#{key}` is not present in the process’ environment variables (declared in `#{reference_env_file}`)"
end
diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb
index cee0b7bd8..5a63f1051 100644
--- a/config/initializers/lograge.rb
+++ b/config/initializers/lograge.rb
@@ -30,7 +30,7 @@ Rails.application.configure do
end
config.lograge.keep_original_rails_log = true
- config.lograge.logger = ActiveSupport::Logger.new Rails.root.join('log', "logstash_#{Rails.env}.log")
+ config.lograge.logger = ActiveSupport::Logger.new(Rails.root.join('log', "logstash_#{Rails.env}.log"))
if config.lograge.enabled
ActiveJobLogSubscriber.attach_to(:active_job)
diff --git a/config/initializers/smart_listing.rb b/config/initializers/smart_listing.rb
index e19f098e6..81435de26 100644
--- a/config/initializers/smart_listing.rb
+++ b/config/initializers/smart_listing.rb
@@ -10,7 +10,7 @@ SmartListing.configure do |config|
# :unlimited_per_page => false, # allow infinite page size
# :paginate => true, # allow pagination
# :memorize_per_page => false, # save per page settings in the cookie
- :page_sizes => [10, 20, 50, 100], # set available page sizes array
+ :page_sizes => [10, 20, 50, 100] # set available page sizes array
# :kaminari_options => {:theme => "smart_listing"}, # Kaminari's paginate helper options
})
diff --git a/db/migrate/20170215102943_remove_duplicate_email_received.rb b/db/migrate/20170215102943_remove_duplicate_email_received.rb
index 93f052b10..af2c6badd 100644
--- a/db/migrate/20170215102943_remove_duplicate_email_received.rb
+++ b/db/migrate/20170215102943_remove_duplicate_email_received.rb
@@ -2,7 +2,7 @@ class RemoveDuplicateEmailReceived < ActiveRecord::Migration[5.0]
def change
all_mails = MailReceived.all
groupped = all_mails.group_by(&:procedure_id)
- filtered = groupped.reject { |k, v| v.length < 2 }
+ filtered = groupped.reject { |_k, v| v.length < 2 }
filtered.each_value do |duplicate_mails|
duplicate_mails.pop
duplicate_mails.each(&:destroy)
diff --git a/db/migrate/20180130180754_create_active_storage_tables.active_storage.rb b/db/migrate/20180130180754_create_active_storage_tables.active_storage.rb
index 360e0d1b7..a3b996c1e 100644
--- a/db/migrate/20180130180754_create_active_storage_tables.active_storage.rb
+++ b/db/migrate/20180130180754_create_active_storage_tables.active_storage.rb
@@ -10,7 +10,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
t.string :checksum, null: false
t.datetime :created_at, null: false
- t.index [ :key ], unique: true
+ t.index [:key], unique: true
end
create_table :active_storage_attachments do |t|
@@ -20,7 +20,7 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
t.datetime :created_at, null: false
- t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
+ t.index [:record_type, :record_id, :name, :blob_id], name: "index_active_storage_attachments_uniqueness", unique: true
end
end
end
diff --git a/db/migrate/20181221103901_drop_rna_informations.rb b/db/migrate/20181221103901_drop_rna_informations.rb
new file mode 100644
index 000000000..39bd0d75c
--- /dev/null
+++ b/db/migrate/20181221103901_drop_rna_informations.rb
@@ -0,0 +1,5 @@
+class DropRNAInformations < ActiveRecord::Migration[5.2]
+ def change
+ drop_table :rna_informations
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2a8ec1ccc..3e9f70e72 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2018_12_18_204707) do
+ActiveRecord::Schema.define(version: 2018_12_21_103901) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -497,19 +497,6 @@ ActiveRecord::Schema.define(version: 2018_12_18_204707) do
t.index ["procedure_id"], name: "index_refused_mails_on_procedure_id"
end
- create_table "rna_informations", id: :serial, force: :cascade do |t|
- t.string "association_id"
- t.string "titre"
- t.text "objet"
- t.date "date_creation"
- t.date "date_declaration"
- t.date "date_publication"
- t.integer "entreprise_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.index ["entreprise_id"], name: "index_rna_informations_on_entreprise_id"
- end
-
create_table "services", force: :cascade do |t|
t.string "type_organisme", null: false
t.string "nom", null: false
diff --git a/db/views/searches_v01.sql b/db/views/searches_v01.sql
deleted file mode 100644
index e5f2cfd71..000000000
--- a/db/views/searches_v01.sql
+++ /dev/null
@@ -1,59 +0,0 @@
--- this version allows to search for a single term within many tables,
--- but behaves badly with multiple terms scattered in multiple tables.
-
-SELECT dossiers.id AS dossier_id,
- dossiers.id::text || ' ' ||
- COALESCE(users.email, '') AS term
- FROM dossiers
- INNER JOIN users ON users.id = dossiers.user_id
-
-UNION SELECT cerfas.dossier_id,
- COALESCE(cerfas.content, '') AS term
- FROM cerfas
-
-UNION SELECT champs.dossier_id,
- COALESCE(champs.value, '') || ' ' ||
- COALESCE(drop_down_lists.value, '') AS term
- FROM champs
- INNER JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id
-
-UNION SELECT entreprises.dossier_id,
- COALESCE(entreprises.siren, '') || ' ' ||
- COALESCE(entreprises.numero_tva_intracommunautaire, '') || ' ' ||
- COALESCE(entreprises.forme_juridique, '') || ' ' ||
- COALESCE(entreprises.forme_juridique_code, '') || ' ' ||
- COALESCE(entreprises.nom_commercial, '') || ' ' ||
- COALESCE(entreprises.raison_sociale, '') || ' ' ||
- COALESCE(entreprises.siret_siege_social, '') || ' ' ||
- COALESCE(entreprises.nom, '') || ' ' ||
- COALESCE(entreprises.prenom, '') || ' ' ||
- COALESCE(rna_informations.association_id, '') || ' ' ||
- COALESCE(rna_informations.titre, '') || ' ' ||
- COALESCE(rna_informations.objet, '') AS term
- FROM entreprises
- LEFT JOIN rna_informations ON rna_informations.entreprise_id = entreprises.id
-
-UNION SELECT etablissements.dossier_id,
- COALESCE(etablissements.siret, '') || ' ' ||
- COALESCE(etablissements.naf, '') || ' ' ||
- COALESCE(etablissements.libelle_naf, '') || ' ' ||
- COALESCE(etablissements.adresse, '') || ' ' ||
- COALESCE(etablissements.code_postal, '') || ' ' ||
- COALESCE(etablissements.localite, '') || ' ' ||
- COALESCE(etablissements.code_insee_localite, '') AS term
- FROM etablissements
-
-UNION SELECT individuals.dossier_id,
- COALESCE(individuals.nom, '') || ' ' ||
- COALESCE(individuals.prenom, '') AS term
- FROM individuals
-
-UNION SELECT pieces_justificatives.dossier_id,
- COALESCE(pieces_justificatives.content, '') AS term
- FROM pieces_justificatives
-
-UNION SELECT dossiers.id,
- COALESCE(france_connect_informations.given_name, '') || ' ' ||
- COALESCE(france_connect_informations.family_name, '') AS term
- FROM france_connect_informations
- INNER JOIN dossiers ON dossiers.user_id = france_connect_informations.user_id
diff --git a/db/views/searches_v02.sql b/db/views/searches_v02.sql
deleted file mode 100644
index 8a168f465..000000000
--- a/db/views/searches_v02.sql
+++ /dev/null
@@ -1,43 +0,0 @@
--- this version merges all possible search terms together, complicating the
--- view, but enables searching for multiple terms from multiple tables at once.
-
-SELECT dossiers.id AS dossier_id,
- COALESCE(users.email, '') || ' ' ||
- COALESCE(france_connect_informations.given_name, '') || ' ' ||
- COALESCE(france_connect_informations.family_name, '') || ' ' ||
- COALESCE(cerfas.content, '') || ' ' ||
- COALESCE(champs.value, '') || ' ' ||
- COALESCE(drop_down_lists.value, '') || ' ' ||
- COALESCE(entreprises.siren, '') || ' ' ||
- COALESCE(entreprises.numero_tva_intracommunautaire, '') || ' ' ||
- COALESCE(entreprises.forme_juridique, '') || ' ' ||
- COALESCE(entreprises.forme_juridique_code, '') || ' ' ||
- COALESCE(entreprises.nom_commercial, '') || ' ' ||
- COALESCE(entreprises.raison_sociale, '') || ' ' ||
- COALESCE(entreprises.siret_siege_social, '') || ' ' ||
- COALESCE(entreprises.nom, '') || ' ' ||
- COALESCE(entreprises.prenom, '') || ' ' ||
- COALESCE(rna_informations.association_id, '') || ' ' ||
- COALESCE(rna_informations.titre, '') || ' ' ||
- COALESCE(rna_informations.objet, '') || ' ' ||
- COALESCE(etablissements.siret, '') || ' ' ||
- COALESCE(etablissements.naf, '') || ' ' ||
- COALESCE(etablissements.libelle_naf, '') || ' ' ||
- COALESCE(etablissements.adresse, '') || ' ' ||
- COALESCE(etablissements.code_postal, '') || ' ' ||
- COALESCE(etablissements.localite, '') || ' ' ||
- COALESCE(etablissements.code_insee_localite, '') || ' ' ||
- COALESCE(individuals.nom, '') || ' ' ||
- COALESCE(individuals.prenom, '') || ' ' ||
- COALESCE(pieces_justificatives.content, '') AS term
-FROM dossiers
-INNER JOIN users ON users.id = dossiers.user_id
-LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id
-LEFT JOIN cerfas ON cerfas.dossier_id = dossiers.id
-LEFT JOIN champs ON champs.dossier_id = dossiers.id
-LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id
-LEFT JOIN entreprises ON entreprises.dossier_id = dossiers.id
-LEFT JOIN rna_informations ON rna_informations.entreprise_id = entreprises.id
-LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id
-LEFT JOIN individuals ON individuals.dossier_id = dossiers.id
-LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id
diff --git a/db/views/searches_v03.sql b/db/views/searches_v03.sql
deleted file mode 100644
index f847fc13f..000000000
--- a/db/views/searches_v03.sql
+++ /dev/null
@@ -1,41 +0,0 @@
--- this version merges all possible search terms together, complicating the
--- view, but enables searching for multiple terms from multiple tables at once.
-
-SELECT dossiers.id AS dossier_id,
- COALESCE(users.email, '') || ' ' ||
- COALESCE(france_connect_informations.given_name, '') || ' ' ||
- COALESCE(france_connect_informations.family_name, '') || ' ' ||
- COALESCE(cerfas.content, '') || ' ' ||
- COALESCE(champs.value, '') || ' ' ||
- COALESCE(drop_down_lists.value, '') || ' ' ||
- COALESCE(etablissements.entreprise_siren, '') || ' ' ||
- COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, '') || ' ' ||
- COALESCE(etablissements.entreprise_forme_juridique, '') || ' ' ||
- COALESCE(etablissements.entreprise_forme_juridique_code, '') || ' ' ||
- COALESCE(etablissements.entreprise_nom_commercial, '') || ' ' ||
- COALESCE(etablissements.entreprise_raison_sociale, '') || ' ' ||
- COALESCE(etablissements.entreprise_siret_siege_social, '') || ' ' ||
- COALESCE(etablissements.entreprise_nom, '') || ' ' ||
- COALESCE(etablissements.entreprise_prenom, '') || ' ' ||
- COALESCE(etablissements.association_rna, '') || ' ' ||
- COALESCE(etablissements.association_titre, '') || ' ' ||
- COALESCE(etablissements.association_objet, '') || ' ' ||
- COALESCE(etablissements.siret, '') || ' ' ||
- COALESCE(etablissements.naf, '') || ' ' ||
- COALESCE(etablissements.libelle_naf, '') || ' ' ||
- COALESCE(etablissements.adresse, '') || ' ' ||
- COALESCE(etablissements.code_postal, '') || ' ' ||
- COALESCE(etablissements.localite, '') || ' ' ||
- COALESCE(etablissements.code_insee_localite, '') || ' ' ||
- COALESCE(individuals.nom, '') || ' ' ||
- COALESCE(individuals.prenom, '') || ' ' ||
- COALESCE(pieces_justificatives.content, '') AS term
-FROM dossiers
-INNER JOIN users ON users.id = dossiers.user_id
-LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id
-LEFT JOIN cerfas ON cerfas.dossier_id = dossiers.id
-LEFT JOIN champs ON champs.dossier_id = dossiers.id
-LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id
-LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id
-LEFT JOIN individuals ON individuals.dossier_id = dossiers.id
-LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id
diff --git a/db/views/searches_v04.sql b/db/views/searches_v04.sql
deleted file mode 100644
index f628d2f20..000000000
--- a/db/views/searches_v04.sql
+++ /dev/null
@@ -1,39 +0,0 @@
--- this version merges all possible search terms together, complicating the
--- view, but enables searching for multiple terms from multiple tables at once.
-
-SELECT dossiers.id AS dossier_id,
- COALESCE(users.email, '') || ' ' ||
- COALESCE(france_connect_informations.given_name, '') || ' ' ||
- COALESCE(france_connect_informations.family_name, '') || ' ' ||
- COALESCE(champs.value, '') || ' ' ||
- COALESCE(drop_down_lists.value, '') || ' ' ||
- COALESCE(etablissements.entreprise_siren, '') || ' ' ||
- COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, '') || ' ' ||
- COALESCE(etablissements.entreprise_forme_juridique, '') || ' ' ||
- COALESCE(etablissements.entreprise_forme_juridique_code, '') || ' ' ||
- COALESCE(etablissements.entreprise_nom_commercial, '') || ' ' ||
- COALESCE(etablissements.entreprise_raison_sociale, '') || ' ' ||
- COALESCE(etablissements.entreprise_siret_siege_social, '') || ' ' ||
- COALESCE(etablissements.entreprise_nom, '') || ' ' ||
- COALESCE(etablissements.entreprise_prenom, '') || ' ' ||
- COALESCE(etablissements.association_rna, '') || ' ' ||
- COALESCE(etablissements.association_titre, '') || ' ' ||
- COALESCE(etablissements.association_objet, '') || ' ' ||
- COALESCE(etablissements.siret, '') || ' ' ||
- COALESCE(etablissements.naf, '') || ' ' ||
- COALESCE(etablissements.libelle_naf, '') || ' ' ||
- COALESCE(etablissements.adresse, '') || ' ' ||
- COALESCE(etablissements.code_postal, '') || ' ' ||
- COALESCE(etablissements.localite, '') || ' ' ||
- COALESCE(etablissements.code_insee_localite, '') || ' ' ||
- COALESCE(individuals.nom, '') || ' ' ||
- COALESCE(individuals.prenom, '') || ' ' ||
- COALESCE(pieces_justificatives.content, '') AS term
-FROM dossiers
-INNER JOIN users ON users.id = dossiers.user_id
-LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id
-LEFT JOIN champs ON champs.dossier_id = dossiers.id
-LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id
-LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id
-LEFT JOIN individuals ON individuals.dossier_id = dossiers.id
-LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id
diff --git a/lib/tasks/2017_07_18_clean_followed_dossiers.rake b/lib/tasks/2017_07_18_clean_followed_dossiers.rake
index 89058da02..2c9a5f4ce 100644
--- a/lib/tasks/2017_07_18_clean_followed_dossiers.rake
+++ b/lib/tasks/2017_07_18_clean_followed_dossiers.rake
@@ -3,7 +3,7 @@ namespace :'2017_07_18_clean_followed_dossiers' do
Follow.where(gestionnaire_id: nil).destroy_all
Follow.where(dossier_id: nil).destroy_all
- duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select{ |_gestionnaire_id_dossier_id, count| count > 1 }.keys
+ duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select { |_gestionnaire_id_dossier_id, count| count > 1 }.keys
duplicate_ids = duplicate_follows.map { |gestionnaire_id, dossier_id| Follow.where(gestionnaire_id: gestionnaire_id, dossier_id: dossier_id).pluck(:id) }
diff --git a/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake b/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake
index 659d37633..caa4c674f 100644
--- a/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake
+++ b/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake
@@ -3,7 +3,7 @@ require Rails.root.join("lib", "tasks", "task_helper")
namespace :'2017_07_26_clean_birthdate_on_individual' do
task clean: :environment do
# remove duplicates
- duplicate_individuals = Individual.group("dossier_id").count.select{ |_dossier_id, count| count > 1 }.keys
+ duplicate_individuals = Individual.group("dossier_id").count.select { |_dossier_id, count| count > 1 }.keys
duplicate_individuals.each { |dossier_id| Individual.where(dossier_id: dossier_id, nom: nil).delete_all }
# Match "" => nil
diff --git a/lib/tasks/2017_08_01_clean_assign_to.rake b/lib/tasks/2017_08_01_clean_assign_to.rake
index fd407a956..bbc2d86dd 100644
--- a/lib/tasks/2017_08_01_clean_assign_to.rake
+++ b/lib/tasks/2017_08_01_clean_assign_to.rake
@@ -1,6 +1,6 @@
namespace :'2017_08_01_clean_assign_to' do
task clean: :environment do
- duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select{ |_gestionnaire_id_procedure_id, count| count > 1 }.keys
+ duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select { |_gestionnaire_id_procedure_id, count| count > 1 }.keys
duplicate_ids = duplicates.map { |gestionnaire_id, procedure_id| AssignTo.where(gestionnaire_id: gestionnaire_id, procedure_id: procedure_id).pluck(:id) }
diff --git a/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake b/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake
index 660f24df3..6a721ed00 100644
--- a/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake
+++ b/lib/tasks/2017_10_30_copy_commentaire_piece_justificative_to_file.rake
@@ -22,7 +22,7 @@ namespace :'2017_10_30_copy_commentaire_piece_justificative_to_file' do
end
def sanitize_name(name) # from https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/sanitized_file.rb#L323
- name = name.gsub(/[^[:word:]\.\-\+]/,"_")
+ name = name.gsub(/[^[:word:]\.\-\+]/, "_")
name = "_#{name}" if name.match?(/\A\.+\z/)
name = "unnamed" if name.empty?
return name.mb_chars.to_s
diff --git a/lib/tasks/2018_01_18_clean_datetime_in_champs.rake b/lib/tasks/2018_01_18_clean_datetime_in_champs.rake
index 004685b7b..a5f5bb627 100644
--- a/lib/tasks/2018_01_18_clean_datetime_in_champs.rake
+++ b/lib/tasks/2018_01_18_clean_datetime_in_champs.rake
@@ -19,11 +19,11 @@ namespace :'2018_01_18_clean_datetime_in_champs' do
# Match "ddmmYYYY HH:MM" => "YYYY-mm-dd HH:MM"
datetime_champs.select { |c| /^\d{8}\s\d{2}:\d{2}$/ =~ c.value }.each do |c|
- day = c.value[0,2]
- month = c.value[2,2]
- year = c.value[4,4]
- hours = c.value[9,2]
- minutes = c.value[12,2]
+ day = c.value[0, 2]
+ month = c.value[2, 2]
+ year = c.value[4, 4]
+ hours = c.value[9, 2]
+ minutes = c.value[12, 2]
formated_date = "#{year}-#{month}-#{day} #{hours}:#{minutes}"
rake_puts "cleaning #{c.value} => #{formated_date}"
c.update_columns(value: formated_date)
diff --git a/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake b/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake
index dc3c581bc..6106ae5ab 100644
--- a/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake
+++ b/lib/tasks/2018_02_28_clean_gestionnaire_emails.rake
@@ -1,10 +1,10 @@
namespace :'2018_02_28_clean_invalid_emails_accounts' do
task clean: :environment do
- Gestionnaire.pluck(:email, :id).select { |e, id| e.include?(" ") }.each do |email, id|
+ Gestionnaire.pluck(:email, :id).select { |e, _id| e.include?(" ") }.each do |_email, id|
Gestionnaire.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used
end
- User.pluck(:email, :id).select { |e, id| e.include?(" ") }.each do |email, id|
+ User.pluck(:email, :id).select { |e, _id| e.include?(" ") }.each do |_email, id|
User.find_by(id: id, current_sign_in_at: nil)&.destroy # ensure account was never used
end
end
diff --git a/lib/tasks/2018_09_12_fix_templates.rake b/lib/tasks/2018_09_12_fix_templates.rake
index 8ca36b559..cb4535304 100644
--- a/lib/tasks/2018_09_12_fix_templates.rake
+++ b/lib/tasks/2018_09_12_fix_templates.rake
@@ -2,7 +2,7 @@ namespace :'2018_09_12_fix_templates' do
task run: :environment do
dossiers_with_invalid_attestations = find_dossiers_with_sent_and_invalid_attestations
fix_templates
- fixed_attestations = delete_then_regenerate_attestations(dossiers_with_invalid_attestations)
+ delete_then_regenerate_attestations(dossiers_with_invalid_attestations)
send_regenerated_attestations(dossiers_with_invalid_attestations)
end
@@ -46,7 +46,7 @@ namespace :'2018_09_12_fix_templates' do
.each do |instance|
instance.update(body: instance.body.gsub("--libellé procédure--", "--libellé démarche--"))
- rake_puts "Body mis-à-jour pour #{klass.to_s}##{instance.id}"
+ rake_puts "Body mis-à-jour pour #{klass}##{instance.id}"
end
end
end
diff --git a/lib/tasks/deployment/20181120133842_remove_footer_from_email_templates.rake b/lib/tasks/deployment/20181120133842_remove_footer_from_email_templates.rake
index c411ced10..c42d3f6ed 100644
--- a/lib/tasks/deployment/20181120133842_remove_footer_from_email_templates.rake
+++ b/lib/tasks/deployment/20181120133842_remove_footer_from_email_templates.rake
@@ -47,7 +47,7 @@ namespace :after_party do
def remove_footer(template)
matches = template.body.match(FOOTER_REGEXP)
if matches && FOOTER_EXCEPTIONS.none? { |exception| matches[0].include?(exception) }
- rake_puts "#{template.model_name.to_s} \##{template.id}: removing footer"
+ rake_puts "#{template.model_name} \##{template.id}: removing footer"
template.update(body: matches.pre_match)
end
end
diff --git a/lib/tasks/deployment/20181219122438_fix_email_templates_subjects.rake b/lib/tasks/deployment/20181219122438_fix_email_templates_subjects.rake
index f0f9a2704..fb3677251 100644
--- a/lib/tasks/deployment/20181219122438_fix_email_templates_subjects.rake
+++ b/lib/tasks/deployment/20181219122438_fix_email_templates_subjects.rake
@@ -17,7 +17,7 @@ namespace :after_party do
.each do |instance|
instance.update(subject: instance.subject.gsub("--libellé procédure--", "--libellé démarche--"))
- rake_puts "Subject mis-à-jour pour #{klass.to_s}##{instance.id}"
+ rake_puts "Subject mis-à-jour pour #{klass}##{instance.id}"
end
end
diff --git a/lib/tasks/admin.rake b/lib/tasks/superadmin.rake
similarity index 52%
rename from lib/tasks/admin.rake
rename to lib/tasks/superadmin.rake
index 60155feb1..67c2dabbf 100644
--- a/lib/tasks/admin.rake
+++ b/lib/tasks/superadmin.rake
@@ -1,23 +1,34 @@
-namespace :admin do
- task :create_admin, [:email] => :environment do |t, args|
- email = args[:email]
- puts "Creating Administration for #{email}"
- a = Administration.new(email: email, password: Devise.friendly_token[0,20])
- if a.save
- puts "#{a.email} created"
- else
- puts "An error occured : #{a.errors.full_messages}"
- end
- end
-
+namespace :superadmin do
+ desc <<~EOD
+ List all super-admins
+ EOD
task list: :environment do
- puts "All Administrations :"
+ puts "All Administrations:"
Administration.all.pluck(:email).each do |a|
puts a
end
end
- task :delete_admin, [:email] => :environment do |t, args|
+ desc <<~EOD
+ Create a new super-admin account with the #EMAIL email address.
+ EOD
+ task :create, [:email] => :environment do |_t, args|
+ email = args[:email]
+
+ puts "Creating Administration for #{email}"
+ a = Administration.new(email: email, password: Devise.friendly_token[0, 20])
+
+ if a.save
+ puts "#{a.email} created"
+ else
+ puts "An error occured: #{a.errors.full_messages}"
+ end
+ end
+
+ desc <<~EOD
+ Delete the #EMAIL super-admin account
+ EOD
+ task :delete, [:email] => :environment do |_t, args|
email = args[:email]
puts "Deleting Administration for #{email}"
a = Administration.find_by(email: email)
diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb
index 6db8cde08..6ff5e02f4 100644
--- a/spec/controllers/admin/procedures_controller_spec.rb
+++ b/spec/controllers/admin/procedures_controller_spec.rb
@@ -39,6 +39,10 @@ describe Admin::ProceduresController, type: :controller do
end
describe 'GET #index with sorting and pagination' do
+ before do
+ admin.procedures << create(:procedure, administrateur: admin)
+ end
+
subject {
get :index, params: {
'procedures_smart_listing[page]': 1,
@@ -130,7 +134,7 @@ describe Admin::ProceduresController, type: :controller do
subject { delete :destroy, params: { id: procedure_not_owned.id } }
- it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) }
+ it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
end
end
@@ -197,6 +201,19 @@ describe Admin::ProceduresController, type: :controller do
it { expect(flash[:notice]).to be_present }
end
+
+ context 'when procedure is correctly saved' do
+ let!(:gestionnaire) { create(:gestionnaire, email: admin.email) }
+
+ before do
+ post :create, params: { procedure: procedure_params }
+ end
+
+ describe "admin can also instruct the procedure as a gestionnaire" do
+ subject { Procedure.last }
+ it { expect(subject.gestionnaires).to include(gestionnaire) }
+ end
+ end
end
context 'when many attributs are not valid' do
@@ -494,7 +511,7 @@ describe Admin::ProceduresController, type: :controller do
subject { get :new_from_existing }
let(:grouped_procedures) { subject; assigns(:grouped_procedures) }
- let(:response_procedures) { grouped_procedures.map{ |o, procedures| procedures }.flatten }
+ let(:response_procedures) { grouped_procedures.map { |_o, procedures| procedures }.flatten }
describe 'selecting' do
let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) }
@@ -525,8 +542,8 @@ describe Admin::ProceduresController, type: :controller do
it 'groups procedures with services as well as procedures with organisations' do
expect(grouped_procedures.length).to eq 2
- expect(grouped_procedures.find{ |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1)
- expect(grouped_procedures.find{ |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service)
+ expect(grouped_procedures.find { |o, _p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1)
+ expect(grouped_procedures.find { |o, _p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service)
end
end
end
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 0fc0ec700..0545d786b 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -5,7 +5,7 @@ describe ApplicationController, type: :controller do
it 'is present' do
before_actions = ApplicationController
._process_action_callbacks
- .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
+ .find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
.map(&:filter)
expect(before_actions).to include(:set_raven_context)
diff --git a/spec/controllers/manager/administrateurs_controller_spec.rb b/spec/controllers/manager/administrateurs_controller_spec.rb
index 432aa9daa..fb72fb129 100644
--- a/spec/controllers/manager/administrateurs_controller_spec.rb
+++ b/spec/controllers/manager/administrateurs_controller_spec.rb
@@ -1,5 +1,5 @@
describe Manager::AdministrateursController, type: :controller do
- let(:administration){ create(:administration) }
+ let(:administration) { create(:administration) }
describe 'POST #create' do
let(:email) { 'plop@plop.com' }
diff --git a/spec/controllers/new_administrateur/administrateur_controller_spec.rb b/spec/controllers/new_administrateur/administrateur_controller_spec.rb
index 81ac03e93..6dbd65ffd 100644
--- a/spec/controllers/new_administrateur/administrateur_controller_spec.rb
+++ b/spec/controllers/new_administrateur/administrateur_controller_spec.rb
@@ -3,7 +3,7 @@ describe NewAdministrateur::AdministrateurController, type: :controller do
it 'is present' do
before_actions = NewAdministrateur::AdministrateurController
._process_action_callbacks
- .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
+ .find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
.map(&:filter)
expect(before_actions).to include(:authenticate_administrateur!)
diff --git a/spec/controllers/new_administrateur/services_controller_spec.rb b/spec/controllers/new_administrateur/services_controller_spec.rb
index bddd7f679..081603342 100644
--- a/spec/controllers/new_administrateur/services_controller_spec.rb
+++ b/spec/controllers/new_administrateur/services_controller_spec.rb
@@ -118,7 +118,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
delete :destroy, params: { id: service.id, procedure_id: 12 }
end
- it { expect{ service.reload }.to raise_error(ActiveRecord::RecordNotFound) }
+ it { expect { service.reload }.to raise_error(ActiveRecord::RecordNotFound) }
it { expect(flash.alert).to be_nil }
it { expect(flash.notice).to eq("#{service.nom} est supprimé") }
it { expect(response).to redirect_to(services_path(procedure_id: 12)) }
diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb
index 8221c6491..39c9137b5 100644
--- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb
+++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb
@@ -412,7 +412,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
subject { delete :purge_champ_piece_justificative, params: { procedure_id: champ.dossier.procedure.id, dossier_id: champ.dossier.id, champ_id: champ.id }, format: :js }
context 'when gestionnaire can process dossier' do
- let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
+ let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
it { is_expected.to have_http_status(200) }
@@ -422,7 +422,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
end
context 'but champ is not linked to this dossier' do
- let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier), private: true) }
+ let(:champ) { create(:champ_piece_justificative, dossier: create(:dossier), private: true) }
it { is_expected.to redirect_to(root_path) }
@@ -434,8 +434,8 @@ describe NewGestionnaire::DossiersController, type: :controller do
end
context 'when gestionnaire cannot process dossier' do
- let(:dossier){ create(:dossier, procedure: create(:procedure)) }
- let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
+ let(:dossier) { create(:dossier, procedure: create(:procedure)) }
+ let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id, private: true) }
it { is_expected.to redirect_to(root_path) }
diff --git a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb
index 83c189582..36a31b204 100644
--- a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb
+++ b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb
@@ -5,7 +5,7 @@ describe NewGestionnaire::GestionnaireController, type: :controller do
it 'is present' do
before_actions = NewGestionnaire::GestionnaireController
._process_action_callbacks
- .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
+ .find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
.map(&:filter)
expect(before_actions).to include(:authenticate_gestionnaire!)
diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb
index d89d73871..772a9bcff 100644
--- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb
+++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb
@@ -5,7 +5,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
it "is present" do
before_actions = NewGestionnaire::ProceduresController
._process_action_callbacks
- .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
+ .find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
.map(&:filter)
expect(before_actions).to include(:ensure_ownership!)
@@ -46,7 +46,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
it "is present" do
before_actions = NewGestionnaire::ProceduresController
._process_action_callbacks
- .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
+ .find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
.map(&:filter)
expect(before_actions).to include(:redirect_to_avis_if_needed)
@@ -253,10 +253,10 @@ describe NewGestionnaire::ProceduresController, type: :controller do
end
describe 'statut' do
- let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
- let!(:new_followed_dossier) { Timecop.freeze(2.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
- let!(:termine_dossier) { Timecop.freeze(3.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } }
- let!(:archived_dossier) { Timecop.freeze(4.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } }
+ let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
+ let!(:new_followed_dossier) { Timecop.freeze(2.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
+ let!(:termine_dossier) { Timecop.freeze(3.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } }
+ let!(:archived_dossier) { Timecop.freeze(4.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } }
before do
gestionnaire.followed_dossiers << new_followed_dossier
diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb
index d404218fc..d2e42693d 100644
--- a/spec/controllers/new_user/dossiers_controller_spec.rb
+++ b/spec/controllers/new_user/dossiers_controller_spec.rb
@@ -7,7 +7,7 @@ describe NewUser::DossiersController, type: :controller do
it 'are present' do
before_actions = NewUser::DossiersController
._process_action_callbacks
- .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
+ .find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
.map(&:filter)
expect(before_actions).to include(:ensure_ownership!, :ensure_ownership_or_invitation!, :forbid_invite_submission!)
@@ -913,8 +913,8 @@ describe NewUser::DossiersController, type: :controller do
subject { delete :purge_champ_piece_justificative, params: { id: champ.dossier.id, champ_id: champ.id }, format: :js }
context 'when dossier is owned by user' do
- let(:dossier){ create(:dossier, user: user) }
- let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) }
+ let(:dossier) { create(:dossier, user: user) }
+ let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) }
it { is_expected.to have_http_status(200) }
@@ -924,7 +924,7 @@ describe NewUser::DossiersController, type: :controller do
end
context 'but champ is not linked to this dossier' do
- let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier)) }
+ let(:champ) { create(:champ_piece_justificative, dossier: create(:dossier)) }
it { is_expected.to redirect_to(root_path) }
@@ -936,8 +936,8 @@ describe NewUser::DossiersController, type: :controller do
end
context 'when dossier is not owned by user' do
- let(:dossier){ create(:dossier, user: create(:user)) }
- let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) }
+ let(:dossier) { create(:dossier, user: create(:user)) }
+ let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) }
it { is_expected.to redirect_to(root_path) }
diff --git a/spec/controllers/new_user/user_controller_spec.rb b/spec/controllers/new_user/user_controller_spec.rb
index b4e93c10c..82908835d 100644
--- a/spec/controllers/new_user/user_controller_spec.rb
+++ b/spec/controllers/new_user/user_controller_spec.rb
@@ -5,7 +5,7 @@ describe NewUser::UserController, type: :controller do
it 'is present' do
before_actions = NewUser::UserController
._process_action_callbacks
- .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
+ .find_all { |process_action_callbacks| process_action_callbacks.kind == :before }
.map(&:filter)
expect(before_actions).to include(:authenticate_user!)
diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb
index 4f2632724..6fd3f5c2c 100644
--- a/spec/controllers/stats_controller_spec.rb
+++ b/spec/controllers/stats_controller_spec.rb
@@ -116,7 +116,7 @@ describe StatsController, type: :controller do
create(:procedure, published_at: Time.zone.now, administrateur: administrateur_4)
end
- let(:association){ Procedure.all }
+ let(:association) { Procedure.all }
subject { StatsController.new.send(:procedures_count_per_administrateur, association) }
diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb
index d34e3f280..2047a9cf7 100644
--- a/spec/controllers/users/sessions_controller_spec.rb
+++ b/spec/controllers/users/sessions_controller_spec.rb
@@ -253,13 +253,15 @@ describe Users::SessionsController, type: :controller do
describe '#sign_in_by_link' do
context 'when the gestionnaire has non other account' do
let(:gestionnaire) { create(:gestionnaire) }
+ let!(:good_jeton) { gestionnaire.login_token! }
+
before do
allow(controller).to receive(:trust_device)
post :sign_in_by_link, params: { id: gestionnaire.id, jeton: jeton }
end
context 'when the token is valid' do
- let(:jeton) { gestionnaire.login_token! }
+ let(:jeton) { good_jeton }
# TODO when the gestionnaire has no other account, and the token is valid, and the user signing in was not starting a demarche,
# redirect to root_path, then redirect to gestionnaire_procedures_path (see root_controller)
diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb
deleted file mode 100644
index 3c8f4fe96..000000000
--- a/spec/decorators/dossier_decorator_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require 'spec_helper'
-
-describe DossierDecorator do
- let(:dossier) do
- dossier = create(:dossier, created_at: Time.zone.local(2015, 12, 24, 14, 10))
- dossier.update_column('updated_at', Time.zone.local(2015, 12, 24, 14, 10))
- dossier
- end
-
- subject { dossier.decorate }
-
- describe 'first_creation' do
- subject { super().first_creation }
- it { is_expected.to eq('24/12/2015 14:10') }
- end
-
- describe 'last_update' do
- subject { super().last_update }
- it { is_expected.to eq('24/12/2015 14:10') }
- end
-end
diff --git a/spec/decorators/france_connect_inforation_decorator_spec.rb b/spec/decorators/france_connect_inforation_decorator_spec.rb
deleted file mode 100644
index d6d642fc3..000000000
--- a/spec/decorators/france_connect_inforation_decorator_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require 'spec_helper'
-
-describe FranceConnectInformationDecorator do
- let(:gender) { 'female' }
- let(:france_connect_information) { create :france_connect_information, gender: gender }
-
- subject { france_connect_information.decorate.gender_fr }
-
- context 'when france connect user is a male' do
- let(:gender) { 'male' }
- it { is_expected.to eq 'M.' }
- end
-
- context 'when france connect user is a female' do
- it { is_expected.to eq 'Mme' }
- end
-end
diff --git a/spec/decorators/procedure_decorator_spec.rb b/spec/decorators/procedure_decorator_spec.rb
deleted file mode 100644
index 2c7972076..000000000
--- a/spec/decorators/procedure_decorator_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'spec_helper'
-
-describe ProcedureDecorator do
- let(:published_at) { Time.zone.local(2017, 12, 24, 14, 12) }
- let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.zone.local(2015, 12, 24, 14, 10)) }
-
- subject { procedure.decorate }
-
- describe 'created_at_fr' do
- subject { super().created_at_fr }
- it { is_expected.to eq('24/12/2015 14:10') }
- end
-
- describe 'published_at_fr' do
- subject { super().published_at_fr }
- it { is_expected.to eq('24/12/2017 14:12') }
-
- context 'published_at is nil' do
- let(:published_at) { nil }
- it { is_expected.to eq(nil) }
- end
- end
-
- describe 'logo_img' do
- subject { super().logo_img }
- it { is_expected.to match(/http.*#{ActionController::Base.helpers.image_url("marianne.svg")}/) }
- end
-end
diff --git a/spec/decorators/procedures_decorator_spec.rb b/spec/decorators/procedures_decorator_spec.rb
deleted file mode 100644
index 92f63c91e..000000000
--- a/spec/decorators/procedures_decorator_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'spec_helper'
-
-describe ProceduresDecorator do
- before do
- create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
- create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
- create(:procedure, :published, created_at: Time.zone.local(2015, 12, 24, 14, 10))
- end
-
- let(:procedure) { Procedure.all.page(1) }
-
- subject { procedure.decorate }
-
- it { expect(subject.current_page).not_to be_nil }
- it { expect(subject.limit_value).not_to be_nil }
- it { expect(subject.count).to eq(3) }
- it { expect(subject.total_pages).not_to be_nil }
-end
diff --git a/spec/decorators/type_de_champ_decorator_spec.rb b/spec/decorators/type_de_champ_decorator_spec.rb
deleted file mode 100644
index 7a490aefc..000000000
--- a/spec/decorators/type_de_champ_decorator_spec.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require 'spec_helper'
-
-describe TypeDeChampDecorator do
- let(:procedure) { create(:procedure) }
- let(:url) { 'http://localhost' }
- let(:params) { { url: url, index: index } }
- let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
- let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) }
- let!(:type_de_champ_2) { create(:type_de_champ, procedure: procedure, order_place: 2) }
-
- describe '#button_up' do
- describe 'with first piece justificative' do
- let(:index) { 0 }
- subject { type_de_champ_0.decorate }
- let(:button_up) { type_de_champ_.decorate }
-
- it 'hide a button up' do
- expect(subject.button_up(params)).to include('visibility: hidden')
- end
- it 'returns a button down' do
- expect(subject.button_down(params)).to match(/fa-chevron-down/)
- end
- end
-
- describe 'with second out of three piece justificative' do
- let(:index) { 1 }
- subject { type_de_champ_1.decorate }
- let(:button_up) { type_de_champ_1.decorate }
-
- it 'returns a button up' do
- expect(subject.button_up(params)).to match(/fa-chevron-up/)
- end
- it 'returns a button down' do
- expect(subject.button_down(params)).to match(/fa-chevron-down/)
- end
- end
-
- describe 'with last piece justificative' do
- let(:index) { 2 }
- subject { type_de_champ_2.decorate }
- let(:button_up) { type_de_champ_1.decorate }
-
- it 'returns a button up' do
- expect(subject.button_up(params)).to match(/fa-chevron-up/)
- end
-
- it 'hide a button down' do
- expect(subject.button_down(params)).to include('visibility: hidden')
- end
- end
- end
-end
diff --git a/spec/factories/administrateur.rb b/spec/factories/administrateur.rb
index abcb8dad2..676ce1359 100644
--- a/spec/factories/administrateur.rb
+++ b/spec/factories/administrateur.rb
@@ -10,4 +10,10 @@ FactoryBot.define do
admin.renew_api_token
end
end
+
+ trait :with_procedure do
+ after(:create) do |admin|
+ admin.procedures << create(:simple_procedure, administrateur: admin)
+ end
+ end
end
diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb
index 20d04628d..c1cb471e7 100644
--- a/spec/factories/champ.rb
+++ b/spec/factories/champ.rb
@@ -23,7 +23,7 @@ FactoryBot.define do
end
trait :with_piece_justificative_file do
- after(:create) do |champ, evaluator|
+ after(:create) do |champ, _evaluator|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
end
end
@@ -147,7 +147,7 @@ FactoryBot.define do
factory :champ_piece_justificative, class: 'Champs::PieceJustificativeChamp' do
type_de_champ { create(:type_de_champ_piece_justificative) }
- after(:create) do |champ, evaluator|
+ after(:create) do |champ, _evaluator|
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
end
end
@@ -161,7 +161,7 @@ FactoryBot.define do
association :etablissement, factory: [:etablissement]
value { '44011762001530' }
- after(:build) do |champ, evaluator|
+ after(:build) do |champ, _evaluator|
champ.etablissement.signature = champ.etablissement.sign
end
end
diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb
index c26c4b7ce..0e6d44c41 100644
--- a/spec/factories/procedure.rb
+++ b/spec/factories/procedure.rb
@@ -10,14 +10,15 @@ FactoryBot.define do
administrateur { create(:administrateur) }
duree_conservation_dossiers_dans_ds { 3 }
duree_conservation_dossiers_hors_ds { 6 }
+ ask_birthday { false }
factory :procedure_with_dossiers do
transient do
dossiers_count { 1 }
end
- after(:build) do |procedure, _evaluator|
- procedure.dossiers << create_list(:dossier, _evaluator.dossiers_count, procedure: procedure)
+ after(:build) do |procedure, evaluator|
+ procedure.dossiers << create_list(:dossier, evaluator.dossiers_count, procedure: procedure)
end
end
diff --git a/spec/features/admin/connection_spec.rb b/spec/features/admin/connection_spec.rb
index 1647e5bb7..c9e4a06e8 100644
--- a/spec/features/admin/connection_spec.rb
+++ b/spec/features/admin/connection_spec.rb
@@ -5,7 +5,7 @@ feature 'Administrator connection' do
let(:email) { 'admin1@admin.com' }
let(:password) { 'mon chien aime les bananes' }
- let!(:admin) { create(:administrateur, email: email, password: password) }
+ let!(:admin) { create(:administrateur, :with_procedure, email: email, password: password) }
let!(:gestionnaire) { create(:gestionnaire, :with_trusted_device, email: email, password: password) }
before do
diff --git a/spec/features/admin/procedure_cloning_spec.rb b/spec/features/admin/procedure_cloning_spec.rb
index 5f1528d43..9546cda29 100644
--- a/spec/features/admin/procedure_cloning_spec.rb
+++ b/spec/features/admin/procedure_cloning_spec.rb
@@ -9,12 +9,11 @@ feature 'As an administrateur I wanna clone a procedure', js: true do
before do
Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true)
login_as administrateur, scope: :administrateur
- visit root_path
+ visit new_from_existing_admin_procedures_path
end
context 'Cloning procedure' do
before 'Create procedure' do
- page.find_by_id('new-procedure').click
page.find_by_id('from-scratch').click
fill_in_dummy_procedure_details
page.find_by_id('save-procedure').click
diff --git a/spec/features/admin/procedure_creation_spec.rb b/spec/features/admin/procedure_creation_spec.rb
index 9b762f726..8389fe1f2 100644
--- a/spec/features/admin/procedure_creation_spec.rb
+++ b/spec/features/admin/procedure_creation_spec.rb
@@ -4,7 +4,7 @@ require 'features/admin/procedure_spec_helper'
feature 'As an administrateur I wanna create a new procedure', js: true do
include ProcedureSpecHelper
- let(:administrateur) { create(:administrateur) }
+ let(:administrateur) { create(:administrateur, :with_procedure) }
before do
Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true)
diff --git a/spec/features/new_gestionnaire/gestionnaire_spec.rb b/spec/features/new_gestionnaire/gestionnaire_spec.rb
index 220d28d93..dd0aab750 100644
--- a/spec/features/new_gestionnaire/gestionnaire_spec.rb
+++ b/spec/features/new_gestionnaire/gestionnaire_spec.rb
@@ -105,7 +105,7 @@ feature 'The gestionnaire part' do
avis = dossier.avis.first
test_mail(expert_email, sign_up_gestionnaire_avis_path(avis, expert_email))
- avis_sign_up(avis, expert_email, 'a good password')
+ avis_sign_up(avis, expert_email)
expect(page).to have_current_path(gestionnaire_avis_index_path)
expect(page).to have_text('avis à donner 1')
@@ -225,7 +225,7 @@ feature 'The gestionnaire part' do
texts.each { |text| expect(page).to have_text(text) }
end
- def avis_sign_up(avis, email, password)
+ def avis_sign_up(avis, email)
visit sign_up_gestionnaire_avis_path(avis, email)
fill_in 'gestionnaire_password', with: 'a good password'
click_on 'Créer un compte'
diff --git a/spec/features/new_user/dossier_creation_spec.rb b/spec/features/new_user/dossier_creation_spec.rb
index 23785d9cb..a45af4ba0 100644
--- a/spec/features/new_user/dossier_creation_spec.rb
+++ b/spec/features/new_user/dossier_creation_spec.rb
@@ -11,12 +11,17 @@ feature 'Creating a new dossier:' do
end
context 'when the procedure has identification by individual' do
- let(:procedure) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative, ask_birthday: ask_birthday) }
+ let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_type_de_champ, :with_two_type_de_piece_justificative, ask_birthday: ask_birthday) }
let(:ask_birthday) { false }
let(:expected_birthday) { nil }
before do
visit commencer_path(path: procedure.path)
+
+ expect(page).to have_content(procedure.libelle)
+ expect(page).to have_content(procedure.description)
+ expect(page).to have_content(procedure.service.email)
+
fill_in 'individual_nom', with: 'Nom'
fill_in 'individual_prenom', with: 'Prenom'
end
@@ -58,7 +63,7 @@ feature 'Creating a new dossier:' do
end
context 'when identifying through SIRET' do
- let(:procedure) { create(:procedure, :published, :with_type_de_champ, :with_two_type_de_piece_justificative) }
+ let(:procedure) { create(:procedure, :published, :with_service, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let(:dossier) { procedure.dossiers.last }
before do
@@ -74,7 +79,11 @@ feature 'Creating a new dossier:' do
scenario 'the user can enter the SIRET of its etablissement and create a new draft', vcr: { cassette_name: 'api_adresse_search_paris_3' }, js: true do
visit commencer_path(path: procedure.path)
+
expect(page).to have_current_path(siret_dossier_path(dossier))
+ expect(page).to have_content(procedure.libelle)
+ expect(page).to have_content(procedure.description)
+ expect(page).to have_content(procedure.service.email)
fill_in 'Numéro SIRET', with: siret
click_on 'Valider'
diff --git a/spec/features/new_user/dossier_shared_examples.rb b/spec/features/new_user/dossier_shared_examples.rb
index 7ff2b8c4e..d9c36a73b 100644
--- a/spec/features/new_user/dossier_shared_examples.rb
+++ b/spec/features/new_user/dossier_shared_examples.rb
@@ -31,7 +31,7 @@ RSpec.shared_examples 'the user can send messages to the instructeur' do
expect(page).to have_content(commentaire.body)
fill_in 'commentaire_body', with: message_body
- click_on 'Envoyer'
+ click_on 'Envoyer le message'
expect(page).to have_current_path(messagerie_dossier_path(dossier))
expect(page).to have_content('Message envoyé')
diff --git a/spec/decorators/type_de_piece_justificative_decorator_spec.rb b/spec/helpers/admin_formulaire_helper.rb
similarity index 51%
rename from spec/decorators/type_de_piece_justificative_decorator_spec.rb
rename to spec/helpers/admin_formulaire_helper.rb
index 5503b68a0..7f0804497 100644
--- a/spec/decorators/type_de_piece_justificative_decorator_spec.rb
+++ b/spec/helpers/admin_formulaire_helper.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require 'rails_helper'
-describe TypeDePieceJustificativeDecorator do
+RSpec.describe AdminFormulaireHelper, type: :helper do
let(:procedure) { create(:procedure) }
+ let(:kind) { 'piece_justificative' }
let(:url) { 'http://localhost' }
- let(:params) { { url: url, index: index } }
let!(:type_de_piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) }
let!(:type_de_piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) }
let!(:type_de_piece_justificative_2) { create(:type_de_piece_justificative, procedure: procedure, order_place: 2) }
@@ -11,40 +11,51 @@ describe TypeDePieceJustificativeDecorator do
describe '#button_up' do
describe 'with first piece justificative' do
let(:index) { 0 }
- subject { type_de_piece_justificative_0.decorate }
- let(:button_up) { type_de_piece_justificative_.decorate }
it 'returns a button up' do
- expect(subject.button_up(params)).to be(nil)
- end
- it 'returns a button down' do
- expect(subject.button_down(params)).to match(/fa-chevron-down/)
+ expect(button_up(procedure, kind, index, url)).to be(nil)
end
end
describe 'with second out of three piece justificative' do
let(:index) { 1 }
- subject { type_de_piece_justificative_1.decorate }
- let(:button_up) { type_de_piece_justificative_1.decorate }
it 'returns a button up' do
- expect(subject.button_up(params)).to match(/fa-chevron-up/)
- end
- it 'returns a button down' do
- expect(subject.button_down(params)).to match(/fa-chevron-down/)
+ expect(button_up(procedure, kind, index, url)).to match(/fa-chevron-up/)
end
end
describe 'with last piece justificative' do
let(:index) { 2 }
- subject { type_de_piece_justificative_2.decorate }
- let(:button_up) { type_de_piece_justificative_1.decorate }
it 'returns a button up' do
- expect(subject.button_up(params)).to match(/fa-chevron-up/)
+ expect(button_up(procedure, kind, index, url)).to match(/fa-chevron-up/)
end
+ end
+ end
+
+ describe '#button_down' do
+ describe 'with first piece justificative' do
+ let(:index) { 0 }
+
it 'returns a button down' do
- expect(subject.button_down(params)).to be(nil)
+ expect(button_down(procedure, kind, index, url)).to match(/fa-chevron-down/)
+ end
+ end
+
+ describe 'with second out of three piece justificative' do
+ let(:index) { 1 }
+
+ it 'returns a button down' do
+ expect(button_down(procedure, kind, index, url)).to match(/fa-chevron-down/)
+ end
+ end
+
+ describe 'with last piece justificative' do
+ let(:index) { 2 }
+
+ it 'returns nil' do
+ expect(button_down(procedure, kind, index, url)).to be(nil)
end
end
end
diff --git a/spec/decorators/champ_decorator_spec.rb b/spec/helpers/champ_helper_spec.rb
similarity index 91%
rename from spec/decorators/champ_decorator_spec.rb
rename to spec/helpers/champ_helper_spec.rb
index 9d9fde006..9f61990f9 100644
--- a/spec/decorators/champ_decorator_spec.rb
+++ b/spec/helpers/champ_helper_spec.rb
@@ -1,12 +1,11 @@
-require 'spec_helper'
+require 'rails_helper'
-describe ChampDecorator do
+RSpec.describe ChampHelper, type: :helper do
let(:type_de_champ) { create(:type_de_champ) }
let(:champ) { type_de_champ.champ.create }
- let(:decorator) { champ.decorate }
- describe 'value' do
- subject { decorator.value }
+ describe '.formatted_value' do
+ subject { formatted_value(champ) }
describe 'for a checkbox' do
let(:type_de_champ) { create(:type_de_champ_checkbox) }
diff --git a/spec/helpers/conservation_de_donnees_helper_spec.rb b/spec/helpers/conservation_de_donnees_helper_spec.rb
index e15a59e56..8edacefe9 100644
--- a/spec/helpers/conservation_de_donnees_helper_spec.rb
+++ b/spec/helpers/conservation_de_donnees_helper_spec.rb
@@ -10,21 +10,21 @@ RSpec.describe ConservationDeDonneesHelper, type: :helper do
let(:dans_ds) { 3 }
let(:hors_ds) { 6 }
- it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois", "Par l’administration : 6 mois" ]) }
+ it { is_expected.to eq(["Dans demarches-simplifiees.fr : 3 mois", "Par l’administration : 6 mois"]) }
end
context "when only in-app retention time is set" do
let(:dans_ds) { 3 }
let(:hors_ds) { nil }
- it { is_expected.to eq([ "Dans demarches-simplifiees.fr : 3 mois" ]) }
+ it { is_expected.to eq(["Dans demarches-simplifiees.fr : 3 mois"]) }
end
context "when only out of app retention time is set" do
let(:dans_ds) { nil }
let(:hors_ds) { 6 }
- it { is_expected.to eq([ "Par l’administration : 6 mois" ]) }
+ it { is_expected.to eq(["Par l’administration : 6 mois"]) }
end
context "when the retention time is not set" do
diff --git a/spec/helpers/procedure_helper_spec.rb b/spec/helpers/procedure_helper_spec.rb
new file mode 100644
index 000000000..838e05e1f
--- /dev/null
+++ b/spec/helpers/procedure_helper_spec.rb
@@ -0,0 +1,9 @@
+RSpec.describe ProcedureHelper, type: :helper do
+ let(:procedure) { create(:procedure) }
+
+ describe ".logo_img" do
+ subject { logo_img(procedure) }
+
+ it { is_expected.to match(/#{ActionController::Base.helpers.image_url("marianne.svg")}/) }
+ end
+end
diff --git a/spec/lib/helpscout/user_conversations_adapter_spec.rb b/spec/lib/helpscout/user_conversations_adapter_spec.rb
index 126b92590..7978bbb54 100644
--- a/spec/lib/helpscout/user_conversations_adapter_spec.rb
+++ b/spec/lib/helpscout/user_conversations_adapter_spec.rb
@@ -1,10 +1,30 @@
require 'spec_helper'
describe Helpscout::UserConversationsAdapter do
- describe '#reports', vcr: { cassette_name: 'helpscout_conversations_reports' } do
- let(:from) { Date.new(2017, 11) }
- let(:to) { Date.new(2017, 12) }
+ let(:from) { Date.new(2017, 11) }
+ let(:to) { Date.new(2017, 12) }
+ describe '#can_fetch_reports?' do
+ context 'when a required secret is missing' do
+ before do
+ Rails.application.secrets.helpscout[:mailbox_id] = nil
+ end
+
+ it { expect(described_class.new(from, to).can_fetch_reports?).to be false }
+ end
+
+ context 'when all required secrets are present' do
+ before do
+ Rails.application.secrets.helpscout[:mailbox_id] = '9999'
+ Rails.application.secrets.helpscout[:client_id] = '1234'
+ Rails.application.secrets.helpscout[:client_secret] = '5678'
+ end
+
+ it { expect(described_class.new(from, to).can_fetch_reports?).to be true }
+ end
+ end
+
+ describe '#reports', vcr: { cassette_name: 'helpscout_conversations_reports' } do
before { Rails.cache.clear }
subject { described_class.new(from, to) }
diff --git a/spec/models/avis_spec.rb b/spec/models/avis_spec.rb
index c692f0d60..d55b4afd0 100644
--- a/spec/models/avis_spec.rb
+++ b/spec/models/avis_spec.rb
@@ -14,21 +14,21 @@ RSpec.describe Avis, type: :model do
subject { avis.email_to_display }
context 'when gestionnaire is not known' do
- it{ is_expected.to eq(invited_email) }
+ it { is_expected.to eq(invited_email) }
end
context 'when gestionnaire is known' do
let!(:avis) { create(:avis, email: nil, gestionnaire: create(:gestionnaire), dossier: create(:dossier)) }
- it{ is_expected.to eq(avis.gestionnaire.email) }
+ it { is_expected.to eq(avis.gestionnaire.email) }
end
end
describe '.by_latest' do
context 'with 3 avis' do
- let!(:avis){ create(:avis) }
- let!(:avis2){ create(:avis, updated_at: 4.hours.ago) }
- let!(:avis3){ create(:avis, updated_at: 3.hours.ago) }
+ let!(:avis) { create(:avis) }
+ let!(:avis2) { create(:avis, updated_at: 4.hours.ago) }
+ let!(:avis3) { create(:avis, updated_at: 3.hours.ago) }
subject { Avis.by_latest }
@@ -37,13 +37,13 @@ RSpec.describe Avis, type: :model do
end
describe ".link_avis_to_gestionnaire" do
- let(:gestionnaire){ create(:gestionnaire) }
+ let(:gestionnaire) { create(:gestionnaire) }
- subject{ Avis.link_avis_to_gestionnaire(gestionnaire) }
+ subject { Avis.link_avis_to_gestionnaire(gestionnaire) }
context 'when there are 2 avis linked by email to a gestionnaire' do
- let!(:avis){ create(:avis, email: gestionnaire.email, gestionnaire: nil) }
- let!(:avis2){ create(:avis, email: gestionnaire.email, gestionnaire: nil) }
+ let!(:avis) { create(:avis, email: gestionnaire.email, gestionnaire: nil) }
+ let!(:avis2) { create(:avis, email: gestionnaire.email, gestionnaire: nil) }
before do
subject
diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb
index a47d82206..e2c80d524 100644
--- a/spec/models/champ_spec.rb
+++ b/spec/models/champ_spec.rb
@@ -128,7 +128,7 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_address) }
let(:value) { "10 rue du Pinson qui Piaille" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for checkbox champ' do
@@ -138,7 +138,7 @@ describe Champ do
context 'when the box is checked' do
let(:value) { 'on' }
- it { is_expected.to eq([ libelle ]) }
+ it { is_expected.to eq([libelle]) }
end
context 'when the box is unchecked' do
@@ -152,7 +152,7 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_civilite) }
let(:value) { "M." }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for date champ' do
@@ -173,28 +173,28 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_departements) }
let(:value) { "69 - Rhône" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for dossier link champ' do
let(:type_de_champ) { build(:type_de_champ_dossier_link) }
let(:value) { "9103132886" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for drop down list champ' do
let(:type_de_champ) { build(:type_de_champ_dossier_link) }
let(:value) { "HLM" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for email champ' do
let(:type_de_champ) { build(:type_de_champ_email) }
let(:value) { "machin@example.com" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for engagement champ' do
@@ -204,7 +204,7 @@ describe Champ do
context 'when the box is checked' do
let(:value) { 'on' }
- it { is_expected.to eq([ libelle ]) }
+ it { is_expected.to eq([libelle]) }
end
context 'when the box is unchecked' do
@@ -239,7 +239,7 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list) }
context 'when there are multiple values selected' do
- let(:value) { JSON.generate([ 'goodbye', 'cruel', 'world' ]) }
+ let(:value) { JSON.generate(['goodbye', 'cruel', 'world']) }
it { is_expected.to eq(["goodbye", "cruel", "world"]) }
end
@@ -255,21 +255,21 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_number) }
let(:value) { "1234" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for pays champ' do
let(:type_de_champ) { build(:type_de_champ_pays) }
let(:value) { "FRANCE" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for phone champ' do
let(:type_de_champ) { build(:type_de_champ_phone) }
let(:value) { "0606060606" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for pièce justificative champ' do
@@ -283,7 +283,7 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_regions) }
let(:value) { "Île-de-France" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for siret champ' do
@@ -325,14 +325,14 @@ describe Champ do
end
let(:champ) { type_de_champ.champ.build(value: etablissement.siret, etablissement: etablissement) }
- it { is_expected.to eq([ etablissement.entreprise_siren, etablissement.entreprise_numero_tva_intracommunautaire, etablissement.entreprise_forme_juridique, etablissement.entreprise_forme_juridique_code, etablissement.entreprise_nom_commercial, etablissement.entreprise_raison_sociale, etablissement.entreprise_siret_siege_social, etablissement.entreprise_nom, etablissement.entreprise_prenom, etablissement.association_rna, etablissement.association_titre, etablissement.association_objet, etablissement.siret, etablissement.naf, etablissement.libelle_naf, etablissement.adresse, etablissement.code_postal, etablissement.localite, etablissement.code_insee_localite ]) }
+ it { is_expected.to eq([etablissement.entreprise_siren, etablissement.entreprise_numero_tva_intracommunautaire, etablissement.entreprise_forme_juridique, etablissement.entreprise_forme_juridique_code, etablissement.entreprise_nom_commercial, etablissement.entreprise_raison_sociale, etablissement.entreprise_siret_siege_social, etablissement.entreprise_nom, etablissement.entreprise_prenom, etablissement.association_rna, etablissement.association_titre, etablissement.association_objet, etablissement.siret, etablissement.naf, etablissement.libelle_naf, etablissement.adresse, etablissement.code_postal, etablissement.localite, etablissement.code_insee_localite]) }
end
context 'when there is no etablissement' do
let(:siret) { "35130347400024" }
let(:champ) { type_de_champ.champ.build(value: siret) }
- it { is_expected.to eq([ siret ]) }
+ it { is_expected.to eq([siret]) }
end
end
@@ -340,14 +340,14 @@ describe Champ do
let(:type_de_champ) { build(:type_de_champ_text) }
let(:value) { "Blah" }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for text area champ' do
let(:type_de_champ) { build(:type_de_champ_textarea) }
let(:value) { "Bla\nBlah de bla." }
- it { is_expected.to eq([ value ]) }
+ it { is_expected.to eq([value]) }
end
context 'for yes/no champ' do
@@ -357,7 +357,7 @@ describe Champ do
context 'when the box is checked' do
let(:value) { "true" }
- it { is_expected.to eq([ libelle ]) }
+ it { is_expected.to eq([libelle]) }
end
context 'when the box is unchecked' do
@@ -385,18 +385,18 @@ describe Champ do
context 'and there is a blob' do
before { champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain") }
- it { expect{ champ.save }.to change(VirusScan, :count).by(1) }
+ it { expect { champ.save }.to change(VirusScan, :count).by(1) }
end
context 'and there is no blob' do
- it { expect{ champ.save }.to_not change(VirusScan, :count) }
+ it { expect { champ.save }.to_not change(VirusScan, :count) }
end
end
context 'when type_champ is not type_de_champ_piece_justificative' do
let(:type_de_champ) { create(:type_de_champ_textarea) }
- it { expect{ champ.save }.to_not change(VirusScan, :count) }
+ it { expect { champ.save }.to_not change(VirusScan, :count) }
end
end
diff --git a/spec/models/concern/mail_template_concern_spec.rb b/spec/models/concern/mail_template_concern_spec.rb
index 04e4e428c..54c1ca63a 100644
--- a/spec/models/concern/mail_template_concern_spec.rb
+++ b/spec/models/concern/mail_template_concern_spec.rb
@@ -26,7 +26,7 @@ describe MailTemplateConcern do
it do
expected =
"[demarches-simplifiees.fr] #{dossier.id} #{dossier.procedure.libelle} " +
- "http://localhost:3000/dossiers/#{dossier.id}"
+ "http://localhost:3000/dossiers/#{dossier.id}"
is_expected.to eq(expected)
end
@@ -77,7 +77,7 @@ describe MailTemplateConcern do
describe "in closed mail" do
let(:mail) { create(:closed_mail, procedure: procedure) }
- it { is_expected.to eq("http://localhost:3000/dossiers/#{dossier.id}/attestation") }
+ it { is_expected.to eq("http://localhost:3000/dossiers/#{dossier.id}/attestation") }
end
describe "in refuse mail" do
diff --git a/spec/models/drop_down_list_spec.rb b/spec/models/drop_down_list_spec.rb
index e4ce2adf2..7af28b927 100644
--- a/spec/models/drop_down_list_spec.rb
+++ b/spec/models/drop_down_list_spec.rb
@@ -40,24 +40,4 @@ describe DropDownList do
it { expect(dropdownlist.disabled_options).to match(['--top--', '--troupt--']) }
end
-
- describe 'selected_options' do
- let(:dropdownlist) do
- create(:drop_down_list, type_de_champ: type_de_champ)
- end
-
- context 'when multiple' do
- let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list) }
- let(:champ) { type_de_champ.champ.build(value: '["1","2"]').decorate }
-
- it { expect(dropdownlist.selected_options(champ)).to match(['1', '2']) }
- end
-
- context 'when simple' do
- let(:type_de_champ) { build(:type_de_champ_drop_down_list) }
- let(:champ) { type_de_champ.champ.build(value: '1').decorate }
-
- it { expect(dropdownlist.selected_options(champ)).to match(['1']) }
- end
- end
end
diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb
index e24b6d353..adf65f7b6 100644
--- a/spec/models/gestionnaire_spec.rb
+++ b/spec/models/gestionnaire_spec.rb
@@ -95,14 +95,14 @@ describe Gestionnaire, type: :model do
let(:procedure_to_assign) { procedure_3 }
it { is_expected.to be_truthy }
- it { expect{ subject }.to change(gestionnaire.procedures, :count) }
+ it { expect { subject }.to change(gestionnaire.procedures, :count) }
end
context "with an already assigned procedure" do
let(:procedure_to_assign) { procedure }
it { is_expected.to be_falsey }
- it { expect{ subject }.not_to change(gestionnaire.procedures, :count) }
+ it { expect { subject }.not_to change(gestionnaire.procedures, :count) }
end
end
@@ -393,6 +393,26 @@ describe Gestionnaire, type: :model do
end
end
+ describe '#login_token_valid?' do
+ let!(:gestionnaire) { create(:gestionnaire) }
+ let!(:good_token) { gestionnaire.login_token! }
+
+ it { expect(gestionnaire.login_token_valid?(good_token)).to be true }
+ it { expect(gestionnaire.login_token_valid?('bad_token')).to be false }
+
+ context 'when the token as expired' do
+ before { gestionnaire.update(login_token_created_at: (Gestionnaire::LOGIN_TOKEN_VALIDITY + 1.minute).ago) }
+
+ it { expect(gestionnaire.login_token_valid?(good_token)).to be false }
+ end
+
+ context 'when the gestionnaire does not have a token' do
+ before { gestionnaire.update(encrypted_login_token: nil) }
+
+ it { expect(gestionnaire.login_token_valid?(nil)).to be false }
+ end
+ end
+
private
def assign(procedure_to_assign)
diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb
index 66eb762b6..1b3929b91 100644
--- a/spec/models/invite_spec.rb
+++ b/spec/models/invite_spec.rb
@@ -13,7 +13,7 @@ describe Invite do
create(:invite, email: email1, dossier: dossier2)
end
- it { expect{ subject }.to change(Invite, :count).by(2) }
+ it { expect { subject }.to change(Invite, :count).by(2) }
end
context 'when an email is invite twice on a dossier' do
@@ -22,7 +22,7 @@ describe Invite do
create(:invite, email: email1, dossier: dossier1)
end
- it { expect{ subject }.to raise_error ActiveRecord::RecordInvalid }
+ it { expect { subject }.to raise_error ActiveRecord::RecordInvalid }
end
context "email validation" do
diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb
index f62afab48..9ed0e79a0 100644
--- a/spec/models/procedure_presentation_spec.rb
+++ b/spec/models/procedure_presentation_spec.rb
@@ -11,7 +11,7 @@ describe ProcedurePresentation do
{ "label" => "test1", "table" => "user", "column" => "email" },
{ "label" => "test2", "table" => "type_de_champ", "column" => first_type_de_champ_id }
],
- sort: { "table" => "user","column" => "email","order" => "asc" },
+ sort: { "table" => "user", "column" => "email", "order" => "asc" },
filters: { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] }
).id
}
@@ -22,7 +22,7 @@ describe ProcedurePresentation do
end
describe "#sort" do
- it { expect(procedure_presentation.sort).to eq({ "table" => "user","column" => "email","order" => "asc" }) }
+ it { expect(procedure_presentation.sort).to eq({ "table" => "user", "column" => "email", "order" => "asc" }) }
end
describe "#filters" do
@@ -78,10 +78,10 @@ describe ProcedurePresentation do
}
before do
- procedure.types_de_champ[2].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:header_section))
- procedure.types_de_champ[3].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:explication))
- procedure.types_de_champ_private[2].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:header_section))
- procedure.types_de_champ_private[3].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:explication))
+ procedure.types_de_champ[2].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:header_section))
+ procedure.types_de_champ[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication))
+ procedure.types_de_champ_private[2].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:header_section))
+ procedure.types_de_champ_private[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication))
end
subject { create(:procedure_presentation, assign_to: create(:assign_to, procedure: procedure)) }
diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb
index f4c2df6d7..bc3b90b39 100644
--- a/spec/models/procedure_spec.rb
+++ b/spec/models/procedure_spec.rb
@@ -264,26 +264,32 @@ describe Procedure do
describe '#switch_types_de_champ' do
let(:procedure) { create(:procedure) }
let(:index) { 0 }
- subject { procedure.switch_types_de_champ index }
+ subject { procedure.switch_types_de_champ(index) }
- context 'when procedure have no types_de_champ' do
+ context 'when procedure has no types_de_champ' do
it { expect(subject).to eq(false) }
end
- context 'when procedure have 2 types de champ' do
+ context 'when procedure has 3 types de champ' do
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) }
+ let!(:type_de_champ_2) { create(:type_de_champ, procedure: procedure, order_place: 2) }
context 'when index is not the last element' do
it { expect(subject).to eq(true) }
- it 'switch order place' do
- procedure.switch_types_de_champ index
- type_de_champ_0.reload
- type_de_champ_1.reload
- expect(type_de_champ_0.order_place).to eq(1)
- expect(type_de_champ_1.order_place).to eq(0)
+ it 'switches the position of the champ N and N+1' do
+ subject
+ expect(procedure.types_de_champ[0]).to eq(type_de_champ_1)
+ expect(procedure.types_de_champ[0].order_place).to eq(0)
+ expect(procedure.types_de_champ[1]).to eq(type_de_champ_0)
+ expect(procedure.types_de_champ[1].order_place).to eq(1)
+ end
+ it 'doesn’t move other types de champ' do
+ subject
+ expect(procedure.types_de_champ[2]).to eq(type_de_champ_2)
+ expect(procedure.types_de_champ[2].order_place).to eq(2)
end
end
context 'when index is the last element' do
- let(:index) { 1 }
+ let(:index) { 2 }
it { expect(subject).to eq(false) }
end
end
@@ -537,7 +543,7 @@ describe Procedure do
end
describe '#default_path' do
- let(:procedure){ create(:procedure, libelle: 'A long libelle with àccênts, blabla coucou hello un deux trois voila') }
+ let(:procedure) { create(:procedure, libelle: 'A long libelle with àccênts, blabla coucou hello un deux trois voila') }
subject { procedure.default_path }
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index adf6baefb..2a24cc89f 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -44,7 +44,7 @@ describe Service, type: :model do
context 'of type_organisme' do
it 'should belong to the enum' do
- expect{ Service.new(params.merge(type_organisme: 'choucroute')) }.to raise_error(ArgumentError)
+ expect { Service.new(params.merge(type_organisme: 'choucroute')) }.to raise_error(ArgumentError)
end
end
end
diff --git a/spec/models/types_de_champ/linked_drop_down_list_type_de_champ_spec.rb b/spec/models/types_de_champ/linked_drop_down_list_type_de_champ_spec.rb
index b7ee29bdf..18c551bd4 100644
--- a/spec/models/types_de_champ/linked_drop_down_list_type_de_champ_spec.rb
+++ b/spec/models/types_de_champ/linked_drop_down_list_type_de_champ_spec.rb
@@ -96,13 +96,13 @@ describe TypesDeChamp::LinkedDropDownListTypeDeChamp do
expect(subject.secondary_options).to eq(
{
'' => [],
- 'Primary 1' => [ '', 'secondary 1.1', 'secondary 1.2'],
- 'Primary 2' => [ '', 'secondary 2.1', 'secondary 2.2', 'secondary 2.3']
+ 'Primary 1' => ['', 'secondary 1.1', 'secondary 1.2'],
+ 'Primary 2' => ['', 'secondary 2.1', 'secondary 2.2', 'secondary 2.3']
}
)
end
- it { expect(subject.primary_options).to eq([ '', 'Primary 1', 'Primary 2' ]) }
+ it { expect(subject.primary_options).to eq(['', 'Primary 1', 'Primary 2']) }
end
end
end
diff --git a/spec/services/render_partial_service_spec.rb b/spec/services/render_partial_service_spec.rb
index 9f0e30533..fa5306e61 100644
--- a/spec/services/render_partial_service_spec.rb
+++ b/spec/services/render_partial_service_spec.rb
@@ -8,12 +8,12 @@ describe RenderPartialService do
describe 'navbar' do
subject { service.navbar }
- it { is_expected.to eq "layouts/navbars/navbar_#{controller.to_s.parameterize}_#{method.to_s}" }
+ it { is_expected.to eq "layouts/navbars/navbar_#{controller.to_s.parameterize}_#{method}" }
end
describe 'left_panel' do
subject { service.left_panel }
- it { is_expected.to eq "layouts/left_panels/left_panel_#{controller.to_s.parameterize}_#{method.to_s}" }
+ it { is_expected.to eq "layouts/left_panels/left_panel_#{controller.to_s.parameterize}_#{method}" }
end
end
diff --git a/spec/services/signature_service_spec.rb b/spec/services/signature_service_spec.rb
index c10f38cf9..14a160f69 100644
--- a/spec/services/signature_service_spec.rb
+++ b/spec/services/signature_service_spec.rb
@@ -3,14 +3,22 @@ require 'spec_helper'
describe SignatureService do
let(:service) { SignatureService }
let(:message) { { hello: 'World!' }.to_json }
- let(:message2) { { hello: 'World' }.to_json }
+ let(:tampered_message) { { hello: 'Tampered' }.to_json }
- it "sign and verify" do
+ it 'sign and verify' do
signature = service.sign(message)
- signature2 = service.sign(message2)
-
expect(service.verify(signature, message)).to eq(true)
- expect(service.verify(signature2, message)).to eq(false)
- expect(service.verify(signature, message2)).to eq(false)
+ end
+
+ it 'fails the verification if the message changed' do
+ signature = service.sign(message)
+ expect(service.verify(signature, tampered_message)).to eq(false)
+ end
+
+ it 'fails the verification if the signature changed' do
+ other_signature = service.sign(tampered_message)
+ expect(service.verify(nil, message)).to eq(false)
+ expect(service.verify('', message)).to eq(false)
+ expect(service.verify(other_signature, message)).to eq(false)
end
end
diff --git a/spec/views/admin/types_de_champ/show.html.haml_spec.rb b/spec/views/admin/types_de_champ/show.html.haml_spec.rb
index 9cb1e32c9..ad15d570f 100644
--- a/spec/views/admin/types_de_champ/show.html.haml_spec.rb
+++ b/spec/views/admin/types_de_champ/show.html.haml_spec.rb
@@ -36,18 +36,18 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
end
context 'when there is only one field in database' do
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
- it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') }
- it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
+ it { expect(subject).not_to have_css('#btn_down_0') }
+ it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).not_to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') }
end
context 'when there are 2 fields in database' do
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) }
+ it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).to have_css('#btn_down_0') }
- it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
it { expect(subject).to have_css('#btn_up_1') }
- it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') }
+ it { expect(subject).not_to have_css('#btn_down_1') }
end
end
end
diff --git a/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb b/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb
index 074cd31b7..8f80aa9c6 100644
--- a/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb
+++ b/spec/views/admin/types_de_champ_private/show.html.haml_spec.rb
@@ -44,8 +44,8 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
end
context 'when there is only one field in database' do
let!(:type_de_champ_0) { create(:type_de_champ, :private, procedure: procedure, order_place: 0) }
- it { expect(subject).to have_css('#btn_down_0[style*="visibility: hidden"]') }
- it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
+ it { expect(subject).not_to have_css('#btn_down_0') }
+ it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).not_to have_css('#btn_up_1') }
it { expect(subject).not_to have_css('#btn_down_1') }
end
@@ -53,9 +53,9 @@ describe 'admin/types_de_champ/show.html.haml', type: :view do
let!(:type_de_champ_0) { create(:type_de_champ, :private, procedure: procedure, order_place: 0) }
let!(:type_de_champ_1) { create(:type_de_champ, :private, procedure: procedure, order_place: 1) }
it { expect(subject).to have_css('#btn_down_0') }
- it { expect(subject).to have_css('#btn_up_0[style*="visibility: hidden"]') }
+ it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).to have_css('#btn_up_1') }
- it { expect(subject).to have_css('#btn_down_1[style*="visibility: hidden"]') }
+ it { expect(subject).not_to have_css('#btn_down_1') }
end
end
end
diff --git a/spec/views/layouts/procedure_context.html.haml_spec.rb b/spec/views/layouts/procedure_context.html.haml_spec.rb
new file mode 100644
index 000000000..2c9e51856
--- /dev/null
+++ b/spec/views/layouts/procedure_context.html.haml_spec.rb
@@ -0,0 +1,28 @@
+require 'rails_helper'
+
+describe 'layouts/procedure_context.html.haml', type: :view do
+ let(:procedure) { create(:simple_procedure, :with_service) }
+ let(:dossier) { create(:dossier, procedure: procedure) }
+
+ before do
+ assign(:dossier, dossier)
+ end
+
+ subject do
+ render html: 'Column content', layout: 'layouts/procedure_context.html.haml'
+ end
+
+ it 'renders a description of the procedure' do
+ expect(subject).to have_text(dossier.procedure.libelle)
+ expect(subject).to have_text(dossier.procedure.description)
+ end
+
+ it 'renders the inner content' do
+ expect(subject).to have_text('Column content')
+ end
+
+ it 'renders the dossier footer' do
+ expect(subject).to have_text(dossier.procedure.service.nom)
+ expect(subject).to have_text(dossier.procedure.service.email)
+ end
+end
diff --git a/spec/views/new_user/dossiers/identite.html.haml_spec.rb b/spec/views/new_user/dossiers/identite.html.haml_spec.rb
index c9db3953e..38b6e709f 100644
--- a/spec/views/new_user/dossiers/identite.html.haml_spec.rb
+++ b/spec/views/new_user/dossiers/identite.html.haml_spec.rb
@@ -1,25 +1,26 @@
require 'spec_helper'
describe 'new_user/dossiers/identite.html.haml', type: :view do
- let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: create(:procedure, :with_two_type_de_piece_justificative, for_individual: true)) }
- let(:footer) { view.content_for(:footer) }
+ let(:procedure) { create(:simple_procedure, for_individual: true) }
+ let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
before do
sign_in dossier.user
assign(:dossier, dossier)
end
- context 'test de composition de la page' do
- before do
- render
- end
+ subject! { render }
- it 'affiche les informations de la démarche' do
- expect(rendered).to have_text(dossier.procedure.libelle)
- end
+ it 'has identity fields' do
+ expect(rendered).to have_field('Prénom')
+ expect(rendered).to have_field('Nom')
+ end
- it 'prépare le footer' do
- expect(footer).to have_selector('footer')
+ context 'when the demarche asks for the birthdate' do
+ let(:procedure) { create(:simple_procedure, for_individual: true, ask_birthday: true) }
+
+ it 'has a birthday field' do
+ expect(rendered).to have_field('Date de naissance')
end
end
end
diff --git a/spec/views/new_user/dossiers/siret.html.haml_spec.rb b/spec/views/new_user/dossiers/siret.html.haml_spec.rb
index 4b003ba33..318542e05 100644
--- a/spec/views/new_user/dossiers/siret.html.haml_spec.rb
+++ b/spec/views/new_user/dossiers/siret.html.haml_spec.rb
@@ -2,7 +2,6 @@ require 'spec_helper'
describe 'new_user/dossiers/siret.html.haml', type: :view do
let(:dossier) { create(:dossier) }
- let(:footer) { view.content_for(:footer) }
before do
sign_in dossier.user
@@ -11,15 +10,7 @@ describe 'new_user/dossiers/siret.html.haml', type: :view do
subject! { render }
- it 'affiche les informations de la démarche' do
- expect(rendered).to have_text(dossier.procedure.libelle)
- end
-
it 'affiche le formulaire de SIRET' do
expect(rendered).to have_field('Numéro SIRET')
end
-
- it 'prépare le footer' do
- expect(footer).to have_selector('footer')
- end
end