Merge branch 'develop' into staging
This commit is contained in:
commit
084716ba46
97 changed files with 2389 additions and 779 deletions
2
Gemfile
2
Gemfile
|
@ -59,6 +59,8 @@ gem 'chartkick'
|
|||
|
||||
gem 'logstasher'
|
||||
|
||||
gem "font-awesome-rails"
|
||||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'factory_girl'
|
||||
|
|
|
@ -114,6 +114,8 @@ GEM
|
|||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.9.6)
|
||||
font-awesome-rails (4.4.0.0)
|
||||
railties (>= 3.2, < 5.0)
|
||||
globalid (0.3.5)
|
||||
activesupport (>= 4.1.0)
|
||||
haml (4.0.6)
|
||||
|
@ -339,6 +341,7 @@ DEPENDENCIES
|
|||
devise
|
||||
draper
|
||||
factory_girl
|
||||
font-awesome-rails
|
||||
haml-rails
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*= require_self
|
||||
*= require bootstrap-datepicker3
|
||||
*= require leaflet
|
||||
*= require font-awesome
|
||||
*/
|
||||
@import "bootstrap-sprockets";
|
||||
@import "bootstrap";
|
||||
|
@ -46,13 +47,7 @@ body {
|
|||
}
|
||||
|
||||
.description {
|
||||
border-color: rgba(200, 200, 200, 0.6);
|
||||
border-style: solid;
|
||||
border-radius: 5px;
|
||||
border-width: 1px;
|
||||
padding: 10px;
|
||||
background-color: rgb(245, 245, 245);
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.btn-file {
|
||||
|
|
9
app/assets/stylesheets/recapiitulatif.scss
Normal file
9
app/assets/stylesheets/recapiitulatif.scss
Normal file
|
@ -0,0 +1,9 @@
|
|||
#infos_dossier{
|
||||
background-color:rgba(248,248,255,0.8);
|
||||
padding-left:13%;
|
||||
padding-right:13%;
|
||||
padding-bottom:20px;
|
||||
padding-top:15px;
|
||||
margin-left:-13%;
|
||||
margin-right:-13%;
|
||||
}
|
|
@ -14,12 +14,17 @@ class Backoffice::DossiersController < ApplicationController
|
|||
|
||||
@dossier = @dossier.decorate
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_start
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: '/backoffice')
|
||||
end
|
||||
|
||||
private
|
||||
def confirme
|
||||
params[:id] = params[:dossier_id]
|
||||
show
|
||||
|
||||
def redirect_start
|
||||
redirect_to url_for(controller: '/start', action: :error_dossier)
|
||||
@dossier.next_step! 'gestionnaire', 'confirme'
|
||||
flash.notice = 'Dossier confirmé avec succès.'
|
||||
|
||||
render 'show'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ class BackofficeController < ApplicationController
|
|||
|
||||
def index
|
||||
redirect_to(controller: '/gestionnaires/sessions', action: :new) unless gestionnaire_signed_in?
|
||||
@dossiers = Dossier.all.decorate
|
||||
@dossiers_a_traiter = Dossier.a_traiter.decorate
|
||||
@dossiers_en_attente = Dossier.en_attente.decorate
|
||||
@dossiers_termine = Dossier.termine.decorate
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ class CarteController < ApplicationController
|
|||
def show
|
||||
@dossier = current_dossier
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
||||
redirect_to url_for(controller: :siret, action: :error_dossier)
|
||||
end
|
||||
|
||||
def save_ref_api_carto
|
||||
|
|
|
@ -1,69 +1,73 @@
|
|||
class DossiersController < ApplicationController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:id])
|
||||
# def show
|
||||
# @dossier = Dossier.find(params[:id])
|
||||
|
||||
@etablissement = @dossier.etablissement
|
||||
@entreprise = @dossier.entreprise.decorate
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
||||
end
|
||||
# @etablissement = @dossier.etablissement
|
||||
# @entreprise = @dossier.entreprise.decorate
|
||||
# rescue ActiveRecord::RecordNotFound
|
||||
# flash.alert = t('errors.messages.dossier_not_found')
|
||||
# redirect_to url_for(controller: :siret)
|
||||
# end
|
||||
|
||||
def create
|
||||
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
||||
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
||||
@dossier = Dossier.create
|
||||
@dossier.draft!
|
||||
# def create
|
||||
# procedure = Procedure.find(params['procedure_id'])
|
||||
# @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
||||
# @entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
||||
# @dossier = Dossier.create
|
||||
# @dossier.draft!
|
||||
|
||||
@dossier.procedure = Procedure.find(params['procedure_id'])
|
||||
@dossier.save
|
||||
# @dossier.procedure = procedure
|
||||
# @dossier.save
|
||||
|
||||
@entreprise.dossier = @dossier
|
||||
@entreprise.save
|
||||
# @entreprise.dossier = @dossier
|
||||
# @entreprise.save
|
||||
|
||||
@etablissement.dossier = @dossier
|
||||
@etablissement.entreprise = @entreprise
|
||||
@etablissement.save
|
||||
# @etablissement.dossier = @dossier
|
||||
# @etablissement.entreprise = @entreprise
|
||||
# @etablissement.save
|
||||
|
||||
redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
|
||||
# redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
|
||||
|
||||
rescue RestClient::ResourceNotFound
|
||||
redirect_to url_for(controller: :start, action: :error_siret, procedure_id: params['procedure_id'])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
||||
end
|
||||
# rescue RestClient::ResourceNotFound
|
||||
# flash.alert = t('errors.messages.invalid_siret')
|
||||
# redirect_to url_for(controller: :siret, procedure_id: params['procedure_id'])
|
||||
# rescue ActiveRecord::RecordNotFound
|
||||
# flash.alert = t('errors.messages.dossier_not_found')
|
||||
# redirect_to url_for(controller: :siret)
|
||||
# end
|
||||
|
||||
def update
|
||||
@dossier = Dossier.find(params[:id])
|
||||
if checked_autorisation_donnees?
|
||||
@dossier.update_attributes(update_params)
|
||||
redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
|
||||
else
|
||||
@etablissement = @dossier.etablissement
|
||||
@entreprise = @dossier.entreprise.decorate
|
||||
flash.now.alert = 'Les conditions sont obligatoires.'
|
||||
render 'show'
|
||||
end
|
||||
end
|
||||
# def update
|
||||
# @dossier = Dossier.find(params[:id])
|
||||
# if checked_autorisation_donnees?
|
||||
# @dossier.update_attributes(update_params)
|
||||
# redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
|
||||
# else
|
||||
# @etablissement = @dossier.etablissement
|
||||
# @entreprise = @dossier.entreprise.decorate
|
||||
# flash.now.alert = 'Les conditions sont obligatoires.'
|
||||
# render 'show'
|
||||
# end
|
||||
# end
|
||||
|
||||
private
|
||||
# private
|
||||
|
||||
def update_params
|
||||
params.require(:dossier).permit(:autorisation_donnees)
|
||||
end
|
||||
# def update_params
|
||||
# params.require(:dossier).permit(:autorisation_donnees)
|
||||
# end
|
||||
|
||||
def dossier_id_is_present?
|
||||
@dossier_id != ''
|
||||
end
|
||||
# def dossier_id_is_present?
|
||||
# @dossier_id != ''
|
||||
# end
|
||||
|
||||
def checked_autorisation_donnees?
|
||||
update_params[:autorisation_donnees] == '1'
|
||||
end
|
||||
# def checked_autorisation_donnees?
|
||||
# update_params[:autorisation_donnees] == '1'
|
||||
# end
|
||||
|
||||
def siret
|
||||
params[:siret]
|
||||
end
|
||||
# def siret
|
||||
# params[:siret]
|
||||
# end
|
||||
|
||||
def siren
|
||||
siret[0..8]
|
||||
end
|
||||
# def siren
|
||||
# siret[0..8]
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
class RecapitulatifController < ApplicationController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier = @dossier.decorate
|
||||
|
||||
# mettre dans le modele
|
||||
@commentaires = @dossier.commentaires.order(created_at: :desc)
|
||||
|
||||
@commentaires = @commentaires.all.decorate
|
||||
|
||||
#TODO load user email
|
||||
@commentaire_email = 'user@email'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
||||
end
|
||||
end
|
|
@ -1,37 +0,0 @@
|
|||
class StartController < ApplicationController
|
||||
def index
|
||||
get_procedure_infos
|
||||
|
||||
if @procedure.nil?
|
||||
error_procedure
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
error_procedure
|
||||
end
|
||||
|
||||
def error_procedure
|
||||
render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
|
||||
end
|
||||
|
||||
def error_siret
|
||||
get_procedure_infos
|
||||
flash.now.alert = 'Ce SIRET n\'est pas valide'
|
||||
render 'index'
|
||||
end
|
||||
|
||||
def error_login
|
||||
flash.now.alert = 'Ce compte n\'existe pas'
|
||||
render 'index'
|
||||
end
|
||||
|
||||
def error_dossier
|
||||
flash.now.alert = 'Ce dossier n\'existe pas'
|
||||
render 'index'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_procedure_infos
|
||||
@procedure = Procedure.find(params['procedure_id'])
|
||||
end
|
||||
end
|
3
app/controllers/users/commentaires_controller.rb
Normal file
3
app/controllers/users/commentaires_controller.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Users::CommentairesController < CommentairesController
|
||||
before_action :authenticate_user!
|
||||
end
|
28
app/controllers/users/confirmations_controller.rb
Normal file
28
app/controllers/users/confirmations_controller.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
# GET /resource/confirmation/new
|
||||
# def new
|
||||
# super
|
||||
# end
|
||||
|
||||
# POST /resource/confirmation
|
||||
# def create
|
||||
# super
|
||||
# end
|
||||
|
||||
# GET /resource/confirmation?confirmation_token=abcdef
|
||||
# def show
|
||||
# super
|
||||
# end
|
||||
|
||||
# protected
|
||||
|
||||
# The path used after resending confirmation instructions.
|
||||
# def after_resending_confirmation_instructions_path_for(resource_name)
|
||||
# super(resource_name)
|
||||
# end
|
||||
|
||||
# The path used after confirmation.
|
||||
# def after_confirmation_path_for(resource_name, resource)
|
||||
# super(resource_name, resource)
|
||||
# end
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
class DescriptionController < ApplicationController
|
||||
class Users::DescriptionController < ApplicationController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier = @dossier.decorate
|
||||
|
@ -6,7 +6,8 @@ class DescriptionController < ApplicationController
|
|||
@procedure = @dossier.procedure
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: :siret)
|
||||
end
|
||||
|
||||
def error
|
||||
|
@ -45,6 +46,7 @@ class DescriptionController < ApplicationController
|
|||
commentaire.save
|
||||
end
|
||||
|
||||
flash.notice = 'Félicitation, votre demande a bien été enregistrée.'
|
||||
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
||||
|
||||
end
|
79
app/controllers/users/dossiers_controller.rb
Normal file
79
app/controllers/users/dossiers_controller.rb
Normal file
|
@ -0,0 +1,79 @@
|
|||
class Users::DossiersController < UsersController
|
||||
before_action :authenticate_user!
|
||||
def index
|
||||
@dossiers = current_user.dossiers.decorate
|
||||
end
|
||||
def show
|
||||
|
||||
@dossier = Dossier.find(params[:id])
|
||||
|
||||
@etablissement = @dossier.etablissement
|
||||
@entreprise = @dossier.entreprise.decorate
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: :siret)
|
||||
end
|
||||
|
||||
def create
|
||||
procedure = Procedure.find(params['procedure_id'])
|
||||
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
||||
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
||||
@dossier = Dossier.create(user: current_user)
|
||||
@dossier.draft!
|
||||
|
||||
@dossier.procedure = procedure
|
||||
@dossier.save
|
||||
|
||||
@entreprise.dossier = @dossier
|
||||
@entreprise.save
|
||||
|
||||
@etablissement.dossier = @dossier
|
||||
@etablissement.entreprise = @entreprise
|
||||
@etablissement.save
|
||||
|
||||
redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
|
||||
|
||||
rescue RestClient::ResourceNotFound
|
||||
flash.alert = t('errors.messages.invalid_siret')
|
||||
redirect_to url_for(controller: :siret, procedure_id: params['procedure_id'])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: :siret)
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@dossier = Dossier.find(params[:id])
|
||||
if checked_autorisation_donnees?
|
||||
@dossier.update_attributes(update_params)
|
||||
redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
|
||||
else
|
||||
@etablissement = @dossier.etablissement
|
||||
@entreprise = @dossier.entreprise.decorate
|
||||
flash.now.alert = 'Les conditions sont obligatoires.'
|
||||
render 'show'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_params
|
||||
params.require(:dossier).permit(:autorisation_donnees)
|
||||
end
|
||||
|
||||
def dossier_id_is_present?
|
||||
@dossier_id != ''
|
||||
end
|
||||
|
||||
def checked_autorisation_donnees?
|
||||
update_params[:autorisation_donnees] == '1'
|
||||
end
|
||||
|
||||
def siret
|
||||
params[:siret]
|
||||
end
|
||||
|
||||
def siren
|
||||
siret[0..8]
|
||||
end
|
||||
end
|
28
app/controllers/users/omniauth_callbacks_controller.rb
Normal file
28
app/controllers/users/omniauth_callbacks_controller.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
# You should configure your model like this:
|
||||
# devise :omniauthable, omniauth_providers: [:twitter]
|
||||
|
||||
# You should also create an action method in this controller like this:
|
||||
# def twitter
|
||||
# end
|
||||
|
||||
# More info at:
|
||||
# https://github.com/plataformatec/devise#omniauth
|
||||
|
||||
# GET|POST /resource/auth/twitter
|
||||
# def passthru
|
||||
# super
|
||||
# end
|
||||
|
||||
# GET|POST /users/auth/twitter/callback
|
||||
# def failure
|
||||
# super
|
||||
# end
|
||||
|
||||
# protected
|
||||
|
||||
# The path used when omniauth fails
|
||||
# def after_omniauth_failure_path_for(scope)
|
||||
# super(scope)
|
||||
# end
|
||||
end
|
32
app/controllers/users/passwords_controller.rb
Normal file
32
app/controllers/users/passwords_controller.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
class Users::PasswordsController < Devise::PasswordsController
|
||||
# GET /resource/password/new
|
||||
# def new
|
||||
# super
|
||||
# end
|
||||
|
||||
# POST /resource/password
|
||||
# def create
|
||||
# super
|
||||
# end
|
||||
|
||||
# GET /resource/password/edit?reset_password_token=abcdef
|
||||
# def edit
|
||||
# super
|
||||
# end
|
||||
|
||||
# PUT /resource/password
|
||||
# def update
|
||||
# super
|
||||
# end
|
||||
|
||||
# protected
|
||||
|
||||
# def after_resetting_password_path_for(resource)
|
||||
# super(resource)
|
||||
# end
|
||||
|
||||
# The path used after sending reset password instructions
|
||||
# def after_sending_reset_password_instructions_path_for(resource_name)
|
||||
# super(resource_name)
|
||||
# end
|
||||
end
|
36
app/controllers/users/recapitulatif_controller.rb
Normal file
36
app/controllers/users/recapitulatif_controller.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
class Users::RecapitulatifController < UsersController
|
||||
def show
|
||||
@dossier = Dossier.find(params[:dossier_id])
|
||||
@dossier = @dossier.decorate
|
||||
@procedure = @dossier.procedure
|
||||
|
||||
# mettre dans le modele
|
||||
@commentaires = @dossier.commentaires.order(created_at: :desc)
|
||||
|
||||
@commentaires = @commentaires.all.decorate
|
||||
|
||||
#TODO load user email
|
||||
@commentaire_email = 'user@email'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: :siret)
|
||||
end
|
||||
|
||||
def propose
|
||||
show
|
||||
|
||||
@dossier.next_step! 'user', 'propose'
|
||||
flash.notice = 'Dossier soumis avec succès.'
|
||||
|
||||
render 'show'
|
||||
end
|
||||
|
||||
def depose
|
||||
show
|
||||
|
||||
@dossier.next_step! 'user', 'depose'
|
||||
flash.notice = 'Dossier déposé avec succès.'
|
||||
|
||||
render 'show'
|
||||
end
|
||||
end
|
60
app/controllers/users/registrations_controller.rb
Normal file
60
app/controllers/users/registrations_controller.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
class Users::RegistrationsController < Devise::RegistrationsController
|
||||
# before_filter :configure_sign_up_params, only: [:create]
|
||||
# before_filter :configure_account_update_params, only: [:update]
|
||||
|
||||
# GET /resource/sign_up
|
||||
# def new
|
||||
# super
|
||||
# end
|
||||
|
||||
# POST /resource
|
||||
# def create
|
||||
# super
|
||||
# end
|
||||
|
||||
# GET /resource/edit
|
||||
# def edit
|
||||
# super
|
||||
# end
|
||||
|
||||
# PUT /resource
|
||||
# def update
|
||||
# super
|
||||
# end
|
||||
|
||||
# DELETE /resource
|
||||
# def destroy
|
||||
# super
|
||||
# end
|
||||
|
||||
# GET /resource/cancel
|
||||
# Forces the session data which is usually expired after sign
|
||||
# in to be expired now. This is useful if the user wants to
|
||||
# cancel oauth signing in/up in the middle of the process,
|
||||
# removing all OAuth session data.
|
||||
# def cancel
|
||||
# super
|
||||
# end
|
||||
|
||||
# protected
|
||||
|
||||
# You can put the params you want to permit in the empty array.
|
||||
# def configure_sign_up_params
|
||||
# devise_parameter_sanitizer.for(:sign_up) << :attribute
|
||||
# end
|
||||
|
||||
# You can put the params you want to permit in the empty array.
|
||||
# def configure_account_update_params
|
||||
# devise_parameter_sanitizer.for(:account_update) << :attribute
|
||||
# end
|
||||
|
||||
# The path used after sign up.
|
||||
# def after_sign_up_path_for(resource)
|
||||
# super(resource)
|
||||
# end
|
||||
|
||||
# The path used after sign up for inactive accounts.
|
||||
# def after_inactive_sign_up_path_for(resource)
|
||||
# super(resource)
|
||||
# end
|
||||
end
|
25
app/controllers/users/sessions_controller.rb
Normal file
25
app/controllers/users/sessions_controller.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
class Users::SessionsController < Devise::SessionsController
|
||||
# before_filter :configure_sign_in_params, only: [:create]
|
||||
|
||||
# GET /resource/sign_in
|
||||
# def new
|
||||
# super
|
||||
# end
|
||||
|
||||
# POST /resource/sign_in
|
||||
# def create
|
||||
# super
|
||||
# end
|
||||
|
||||
# DELETE /resource/sign_out
|
||||
# def destroy
|
||||
# super
|
||||
# end
|
||||
|
||||
# protected
|
||||
|
||||
# You can put the params you want to permit in the empty array.
|
||||
# def configure_sign_in_params
|
||||
# devise_parameter_sanitizer.for(:sign_in) << :attribute
|
||||
# end
|
||||
end
|
11
app/controllers/users/siret_controller.rb
Normal file
11
app/controllers/users/siret_controller.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class Users::SiretController < UsersController
|
||||
def index
|
||||
@procedure = Procedure.find(params['procedure_id'])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
error_procedure
|
||||
end
|
||||
|
||||
def error_procedure
|
||||
render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
|
||||
end
|
||||
end
|
28
app/controllers/users/unlocks_controller.rb
Normal file
28
app/controllers/users/unlocks_controller.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
class Users::UnlocksController < Devise::UnlocksController
|
||||
# GET /resource/unlock/new
|
||||
# def new
|
||||
# super
|
||||
# end
|
||||
|
||||
# POST /resource/unlock
|
||||
# def create
|
||||
# super
|
||||
# end
|
||||
|
||||
# GET /resource/unlock?unlock_token=abcdef
|
||||
# def show
|
||||
# super
|
||||
# end
|
||||
|
||||
# protected
|
||||
|
||||
# The path used after sending unlock password instructions
|
||||
# def after_sending_unlock_instructions_path_for(resource)
|
||||
# super(resource)
|
||||
# end
|
||||
|
||||
# The path used after unlocking the resource
|
||||
# def after_unlock_path_for(resource)
|
||||
# super(resource)
|
||||
# end
|
||||
end
|
3
app/controllers/users_controller.rb
Normal file
3
app/controllers/users_controller.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class UsersController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
end
|
|
@ -10,4 +10,25 @@ class DossierDecorator < Draper::Decorator
|
|||
def last_update
|
||||
updated_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
end
|
||||
|
||||
def state_fr
|
||||
case state
|
||||
when 'draft'
|
||||
'Brouillon'
|
||||
when 'proposed'
|
||||
'Soumis'
|
||||
when 'reply'
|
||||
'Répondu'
|
||||
when 'updated'
|
||||
'Mis à jour'
|
||||
when 'confirmed'
|
||||
'Validé'
|
||||
when 'deposited'
|
||||
'Déposé'
|
||||
when 'processed'
|
||||
'Traité'
|
||||
else
|
||||
fail 'State not valid'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
class Dossier < ActiveRecord::Base
|
||||
enum state: { draft: 'draft',
|
||||
submitted: 'submitted',
|
||||
reply: 'reply',
|
||||
updated: 'updated',
|
||||
confirmed: 'confirmed',
|
||||
filed: 'filed',
|
||||
processed: 'processed' }
|
||||
proposed: 'proposed',
|
||||
reply: 'reply',
|
||||
updated: 'updated',
|
||||
confirmed: 'confirmed',
|
||||
deposited: 'deposited',
|
||||
processed: 'processed' }
|
||||
|
||||
has_one :etablissement
|
||||
has_one :entreprise
|
||||
has_one :cerfa
|
||||
has_many :pieces_justificatives
|
||||
has_one :etablissement, dependent: :destroy
|
||||
has_one :entreprise, dependent: :destroy
|
||||
has_one :cerfa, dependent: :destroy
|
||||
has_many :pieces_justificatives, dependent: :destroy
|
||||
belongs_to :procedure
|
||||
has_many :commentaires
|
||||
belongs_to :user
|
||||
has_many :commentaires, dependent: :destroy
|
||||
|
||||
delegate :siren, to: :entreprise
|
||||
delegate :siret, to: :etablissement
|
||||
|
@ -27,7 +28,7 @@ class Dossier < ActiveRecord::Base
|
|||
validates :montant_projet, presence: true, allow_blank: false, allow_nil: true
|
||||
validates :montant_aide_demande, presence: true, allow_blank: false, allow_nil: true
|
||||
validates :date_previsionnelle, presence: true, allow_blank: false, unless: Proc.new { description.nil? }
|
||||
|
||||
validates :user, presence: true
|
||||
|
||||
def retrieve_piece_justificative_by_type(type)
|
||||
pieces_justificatives.where(type_de_piece_justificative_id: type).last
|
||||
|
@ -47,6 +48,71 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def next_step! role, action
|
||||
unless ['propose', 'reply', 'update', 'comment', 'confirme', 'depose', 'process'].include?(action)
|
||||
fail 'action is not valid'
|
||||
end
|
||||
|
||||
unless ['user', 'gestionnaire'].include?(role)
|
||||
fail 'role is not valid'
|
||||
end
|
||||
|
||||
if role == 'user'
|
||||
case action
|
||||
when 'propose'
|
||||
if draft?
|
||||
proposed!
|
||||
end
|
||||
when 'depose'
|
||||
if confirmed?
|
||||
deposited!
|
||||
end
|
||||
when 'update'
|
||||
if reply?
|
||||
updated!
|
||||
end
|
||||
when 'comment'
|
||||
if reply?
|
||||
updated!
|
||||
end
|
||||
end
|
||||
elsif role == 'gestionnaire'
|
||||
case action
|
||||
when 'comment'
|
||||
if updated?
|
||||
reply!
|
||||
elsif proposed?
|
||||
reply!
|
||||
end
|
||||
when 'confirme'
|
||||
if updated?
|
||||
confirmed!
|
||||
elsif reply?
|
||||
confirmed!
|
||||
elsif proposed?
|
||||
confirmed!
|
||||
end
|
||||
when 'process'
|
||||
if deposited?
|
||||
processed!
|
||||
end
|
||||
end
|
||||
end
|
||||
state
|
||||
end
|
||||
|
||||
def self.a_traiter
|
||||
Dossier.where("state='proposed' OR state='updated' OR state='deposited'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.en_attente
|
||||
Dossier.where("state='reply' OR state='confirmed'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.termine
|
||||
Dossier.where("state='processed'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_default_cerfa
|
||||
|
|
8
app/models/user.rb
Normal file
8
app/models/user.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class User < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
has_many :dossiers
|
||||
end
|
|
@ -1,50 +1,21 @@
|
|||
#backoffice_dossier_show
|
||||
%h1#dossier_id.text-info{ :style => 'text-align:right'}
|
||||
= "Dossier n°#{@dossier.id}"
|
||||
%h1#dossier_id.text-info{ :style => 'text-align:right'}
|
||||
= "Dossier n°#{@dossier.id}"
|
||||
|
||||
%script{type: 'text/javascript'}
|
||||
="url_carte = '#{@dossier.id}/'"
|
||||
="ref_dossier = '#{@dossier.ref_dossier_carto}'"
|
||||
%h3{:class => 'text-success', :style => 'text-align:right'}
|
||||
= @dossier.state_fr
|
||||
|
||||
= render partial: '/dossiers/infos_entreprise'
|
||||
%br
|
||||
= render partial: '/dossiers/infos_dossier'
|
||||
%br
|
||||
%br
|
||||
|
||||
.content.row
|
||||
#map_qp.col-lg-6.col-md-6{style: 'height:500px'}
|
||||
#pieces_justificatives.col-lg-6.col-md-6
|
||||
%h3.text-info Liste des pièces justificatives
|
||||
%br
|
||||
%table.table
|
||||
-if @procedure.lien_demarche != nil
|
||||
%tr{id: "piece_justificative_0"}
|
||||
%th{class:'col-lg-6'}
|
||||
='CERFA'
|
||||
%td.col-lg-4.col-md-4
|
||||
- if !@dossier.cerfa.empty?
|
||||
%a{ href: "#{@dossier.cerfa.content}", target: '_blank' } Consulter
|
||||
- else
|
||||
= 'Pièce non fournie'
|
||||
= render partial: '/dossiers/infos_entreprise'
|
||||
%br
|
||||
= render partial: '/dossiers/infos_dossier'
|
||||
%br
|
||||
%br
|
||||
|
||||
- @dossier.pieces_justificatives.each do |piece_justificative|
|
||||
%tr{ id: "piece_justificative_#{piece_justificative.type}" }
|
||||
%th.col-lg-6
|
||||
= piece_justificative.libelle
|
||||
%td.col-lg-4.col-md-4
|
||||
- if piece_justificative.api_entreprise
|
||||
%a{ href: '' } Récupérer
|
||||
- elsif !piece_justificative.empty?
|
||||
%a{ href: "#{piece_justificative.content}", target: '_blank' } Consulter
|
||||
- else
|
||||
= 'Pièce non fournie'
|
||||
|
||||
= render partial: '/carte/carte_sources_CSS'
|
||||
= render partial: '/carte/carte_sources_JS_backend'
|
||||
%br
|
||||
|
||||
= render partial: '/recapitulatif/commentaires_flux'
|
||||
%br
|
||||
%br
|
||||
= render partial: '/users/recapitulatif/commentaires_flux'
|
||||
%br
|
||||
%br
|
||||
|
||||
-#%script{type: 'text/javascript'}
|
||||
-# ="url_carte = '#{@dossier.id}/'"
|
||||
-# ="ref_dossier = '#{@dossier.ref_dossier_carto}'"
|
||||
|
|
|
@ -1,16 +1,49 @@
|
|||
#backoffice
|
||||
|
||||
|
||||
%h1 Gestion des dossiers
|
||||
%br
|
||||
%h3.text-danger À traiter
|
||||
%table.table
|
||||
%thead
|
||||
%th Procédure
|
||||
%th Dossier
|
||||
%th etat
|
||||
%th Date de mise à jour
|
||||
- @dossiers.each do |dossier|
|
||||
%thead.row
|
||||
%th.col-md-4.col-lg-4 Procédure
|
||||
%th.col-md-4.col-lg-4 Dossier
|
||||
%th.col-md-2.col-lg-2 État
|
||||
%th.col-md-2.col-lg-2 Date de mise à jour
|
||||
- @dossiers_a_traiter.each do |dossier|
|
||||
%tr
|
||||
%td= dossier.procedure.libelle
|
||||
%td
|
||||
= link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}")
|
||||
%td Mise à jour
|
||||
%td= dossier.last_update
|
||||
%td= dossier.state_fr
|
||||
%td= dossier.last_update
|
||||
|
||||
%br
|
||||
%h3.text-info En attente
|
||||
%table.table
|
||||
%thead
|
||||
%th.col-md-4.col-lg-4 Procédure
|
||||
%th.col-md-4.col-lg-4 Dossier
|
||||
%th.col-md-2.col-lg-2 État
|
||||
%th.col-md-2.col-lg-2 Date de mise à jour
|
||||
- @dossiers_en_attente.each do |dossier|
|
||||
%tr
|
||||
%td= dossier.procedure.libelle
|
||||
%td
|
||||
= link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}")
|
||||
%td= dossier.state_fr
|
||||
%td= dossier.last_update
|
||||
|
||||
%br
|
||||
%h3.text-success Terminé
|
||||
%table.table
|
||||
%thead
|
||||
%th.col-md-4.col-lg-4 Procédure
|
||||
%th.col-md-4.col-lg-4 Dossier
|
||||
%th.col-md-2.col-lg-2 État
|
||||
%th.col-md-2.col-lg-2 Date de mise à jour
|
||||
- @dossiers_termine.each do |dossier|
|
||||
%tr
|
||||
%td= dossier.procedure.libelle
|
||||
%td
|
||||
= link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}")
|
||||
%td= dossier.state_fr
|
||||
%td= dossier.last_update
|
||||
|
|
|
@ -1,9 +1,30 @@
|
|||
= javascript_include_tag "https://code.highcharts.com/highcharts.js", "chartkick"
|
||||
.row#infos_dossier
|
||||
.col-md-6
|
||||
%h4.text-info
|
||||
= @dossier.nom_projet
|
||||
%div
|
||||
|
||||
#infos_dossier
|
||||
%div.row
|
||||
.col-lg-6.col-md-6
|
||||
%h3.text-info
|
||||
= @dossier.nom_projet
|
||||
|
||||
%br
|
||||
%div.row
|
||||
.col-lg-6.col-md-6
|
||||
%h4 Montant total
|
||||
%p{style:'margin-left:5%'}
|
||||
=number_to_currency(@dossier.montant_projet.to_f, :unit => " ", :separator => ",", :delimiter => " ")
|
||||
!='€'
|
||||
|
||||
.col-lg-6.col-md-6
|
||||
%h4 Début du projet souhaité
|
||||
%p{style:'margin-left:5%'}
|
||||
= @dossier.date_fr
|
||||
%div.row
|
||||
.col-lg-6.col-md-6
|
||||
%h4 Montant souhaité
|
||||
%p{style:'margin-left:5%'}
|
||||
=number_to_currency(@dossier.montant_aide_demande.to_f, :unit => " ", :separator => ",", :delimiter => " ")
|
||||
!='€'
|
||||
%br
|
||||
.description
|
||||
- begin
|
||||
- @dossier.description.split(/(?:\n\r?|\r\n?')/).each do |line|
|
||||
|
@ -11,28 +32,20 @@
|
|||
%br
|
||||
- rescue
|
||||
=''
|
||||
%br
|
||||
.col-lg-6.col-md-6
|
||||
%h4 Montant total
|
||||
|
||||
%p
|
||||
=number_to_currency(@dossier.montant_projet.to_f, :unit => " ", :separator => ",", :delimiter => " ")
|
||||
!='€'
|
||||
.col-lg-6.col-md-6
|
||||
=render partial: '/dossiers/pieces_justificatives'
|
||||
-#= pie_chart({"Montant à charge #{(100 - @dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => (@dossier.montant_projet.to_f - @dossier.montant_aide_demande.to_f), "Montant souhaité #{(@dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => @dossier.montant_aide_demande})
|
||||
|
||||
.col-lg-6.col-md-6
|
||||
%h4 Début du projet souhaité
|
||||
%p
|
||||
= @dossier.date_fr
|
||||
%div.row{style: 'text-align:right'}
|
||||
-unless gestionnaire_signed_in?
|
||||
-if !@dossier.confirmed? && !@dossier.deposited? && !@dossier.processed?
|
||||
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description?back_url=recapitulatif"}
|
||||
= 'Editer mon dossier'
|
||||
|
||||
|
||||
/ -if !request.url.include?('admin')
|
||||
- unless gestionnaire_signed_in?
|
||||
.col-lg-6.col-md-6
|
||||
%br
|
||||
%br
|
||||
%a#modif_description{href: "/dossiers/#{@dossier.id}/description?back_url=recapitulatif"} Modifier la description
|
||||
|
||||
|
||||
.col-md-6
|
||||
= pie_chart({"Montant à charge #{(100 - @dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => (@dossier.montant_projet.to_f - @dossier.montant_aide_demande.to_f), "Montant souhaité #{(@dossier.montant_aide_demande.to_f/@dossier.montant_projet.to_f*100).round(2)}%" => @dossier.montant_aide_demande})
|
||||
-unless user_signed_in?
|
||||
-if !@dossier.confirmed? && !@dossier.deposited? && !@dossier.processed?
|
||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :confirme, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
%button#action_button.btn.btn-success
|
||||
= 'Valider le dossier'
|
||||
|
||||
|
|
30
app/views/dossiers/_pieces_justificatives.html.haml
Normal file
30
app/views/dossiers/_pieces_justificatives.html.haml
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pieces_justificatives
|
||||
%h3.text-info Liste des pièces justificatives
|
||||
%br
|
||||
%table.table
|
||||
-if @procedure.lien_demarche != nil
|
||||
%tr{id: "piece_justificative_0"}
|
||||
%th{class:'col-lg-6'}
|
||||
='CERFA'
|
||||
-if @procedure.lien_demarche != nil
|
||||
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Lien CERFA
|
||||
%td.col-lg-6.col-md-6
|
||||
- if !@dossier.cerfa.empty?
|
||||
- if user_signed_in?
|
||||
= 'Pièce fournie'
|
||||
- elsif gestionnaire_signed_in?
|
||||
%a{ href: "#{@dossier.cerfa.content}", target: '_blank' } Consulter
|
||||
- else
|
||||
= 'Pièce non fournie'
|
||||
|
||||
- @dossier.pieces_justificatives.each do |piece_justificative|
|
||||
%tr{ id: "piece_justificative_#{piece_justificative.type}" }
|
||||
%th.col-lg-6
|
||||
= piece_justificative.libelle
|
||||
%td.col-lg-6.col-md-6
|
||||
- if piece_justificative.api_entreprise
|
||||
%span.text-success Nous l'avons récupéré pour vous.
|
||||
- elsif !piece_justificative.empty?
|
||||
%a{ href: "#{piece_justificative.content}", target: '_blank' } Consulter
|
||||
- else
|
||||
= 'Pièce non fournie'
|
13
app/views/dossiers/_show.html.haml
Normal file
13
app/views/dossiers/_show.html.haml
Normal file
|
@ -0,0 +1,13 @@
|
|||
.container#recap_info_entreprise
|
||||
%h2 Récapitulatif de vos informations <em id="insee_infogreffe" class='small'>(récupérées auprès de l'INSEE et d'INFOGREFFE)</em>
|
||||
%br
|
||||
|
||||
%div.row
|
||||
= render partial: '/dossiers/infos_entreprise'
|
||||
%br
|
||||
= form_for @dossier, url: { controller: '/users/dossiers', action: :update } do |f|
|
||||
%label{ style:'font-weight:normal' }
|
||||
= f.check_box :autorisation_donnees
|
||||
J'autorise les organismes publics à vérifier les informations de mon entreprise auprès des administrations concernées. Ces informations resteront strictement confidentielles.
|
||||
%br
|
||||
= f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float:right', id: 'etape_suivante'
|
|
@ -1,13 +1 @@
|
|||
.container
|
||||
%h2 Récapitulatif de vos informations <em id="insee_infogreffe" class='small'>(récupérées auprès de l'INSEE et d'INFOGREFFE)</em>
|
||||
%br
|
||||
|
||||
%div.row
|
||||
= render partial: 'infos_entreprise'
|
||||
%br
|
||||
= form_for @dossier do |f|
|
||||
%label{ style:'font-weight:normal' }
|
||||
= f.check_box :autorisation_donnees
|
||||
J'autorise les organismes publics à vérifier les informations de mon entreprise auprès des administrations concernées. Ces informations resteront strictement confidentielles.
|
||||
%br
|
||||
= f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float:right', id: 'etape_suivante'
|
||||
= render partial: 'show'
|
|
@ -1,3 +1,3 @@
|
|||
%div{style: 'float:right'}
|
||||
%a.btn{href: "/dossiers/#{@dossier.id}/recapitulatif"} Retour
|
||||
%a.btn{href: "/users/dossiers/#{@dossier.id}/recapitulatif"} Retour
|
||||
= submit_tag 'Modification terminée', class: %w(btn btn btn-info), id: 'modification_terminee', data: { disable_with: 'Modification terminée', submit: true}, onclick: 'submit_check_draw(event)'
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
%div{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
||||
= current_gestionnaire.email
|
||||
= link_to "Déconnexion", '/gestionnaires/sign_out', method: :delete, :class => 'btn btn-md'
|
||||
- elsif user_signed_in?
|
||||
%div.user{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
||||
%i.fa.fa-user
|
||||
= current_user.email
|
||||
= link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md'
|
||||
|
||||
#flash_message.center
|
||||
- if flash.notice
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
.content#commentaires_flux
|
||||
%h3 Commentaires
|
||||
|
||||
%div{style: 'margin-left:3%; width:80%'}
|
||||
-@commentaires.each do |com|
|
||||
%span.text-info#email_contact{style: 'font-weight:bold'}
|
||||
=com.email
|
||||
%span#created_at
|
||||
\-
|
||||
=com.created_at_fr
|
||||
%br
|
||||
.description#body
|
||||
=com.body
|
||||
%br
|
||||
|
||||
%h4{style: 'margin-bottom:2%'} Nouveau
|
||||
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do
|
||||
%input.form-control{:type => 'text', style: 'width: 30%; margin-bottom:2%', :id => 'email_commentaire', :name => 'email_commentaire', :value => @commentaire_email}
|
||||
%textarea.form-control{:id => 'texte_commentaire', :name => 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255'}
|
||||
%br
|
||||
%input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'}
|
||||
%br
|
||||
%br
|
||||
%br
|
|
@ -1,24 +0,0 @@
|
|||
%h2
|
||||
='Récapitulatif'
|
||||
|
||||
%div{style: 'text-align:center'}
|
||||
-if request.referer != nil
|
||||
-if (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif')
|
||||
%h4.text-success Félicitation, votre demande a bien été enregistrée.
|
||||
|
||||
%h3{style: 'text-align:center; line-height:1.5em'}
|
||||
='Votre dossier est le '
|
||||
%br
|
||||
%span{id: 'dossier_id', style: 'font-weight:bold;', class: 'text-success'}
|
||||
="n°#{@dossier.id}"
|
||||
-else
|
||||
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right'}
|
||||
= "Dossier n°#{@dossier.id}"
|
||||
-else
|
||||
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right'}
|
||||
= "Dossier n°#{@dossier.id}"
|
||||
|
||||
= render partial: '/dossiers/infos_dossier'
|
||||
%br
|
||||
|
||||
= render partial: 'commentaires_flux'
|
|
@ -1,24 +0,0 @@
|
|||
/ %p.lead{id: 'admin_section'}
|
||||
/ %span{class:'text-info', style:'font-weight:bold'}
|
||||
/ -if user_signed_in?
|
||||
/ ='Vous êtes identifié comme une administration'
|
||||
/ -else
|
||||
/ ='Si vous êtes une administration, '
|
||||
|
||||
/ %p.lead
|
||||
/ -if user_signed_in?
|
||||
/ = form_tag(url_for({controller: 'admin/dossier', action: :index}), class: 'form-inline', method: 'GET') do
|
||||
/ .form-group.form-group-lg
|
||||
/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "N° de dossier", :id => "dossier_id", :name => "dossier_id"
|
||||
/ %br
|
||||
/ = submit_tag "Accéder", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Accéder", submit: true}
|
||||
/ -else
|
||||
/ = form_tag(url_for({controller: 'user/sessions', action: :create}), class: 'form-inline', method: 'POST') do
|
||||
/ .form-group.form-group-lg
|
||||
/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "Identifiant", :id => "user_email", :name => "user[email]"
|
||||
/ %br
|
||||
/ = password_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "Mot de passe", :id => "user_password", :name => "user[password]"
|
||||
/ %br
|
||||
/ = text_field_tag :siret, nil, :class => "form-control", :style => 'margin-bottom:10px', :placeholder => "N° de dossier", :id => "dossier_id", :name => "dossier_id"
|
||||
/ %br
|
||||
/ = submit_tag "Accéder", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Accéder", submit: true}
|
16
app/views/users/confirmations/new.html.erb
Normal file
16
app/views/users/confirmations/new.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
<h2>Resend confirmation instructions</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Resend confirmation instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "users/shared/links" %>
|
11
app/views/users/dossiers/index.html.haml
Normal file
11
app/views/users/dossiers/index.html.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
%h1 Vos dossiers :
|
||||
|
||||
%table.table
|
||||
%thead
|
||||
%th Nom du Projet
|
||||
%th Mise à jour
|
||||
- @dossiers.each do |dossier|
|
||||
%tr
|
||||
%td
|
||||
= link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier))
|
||||
%td= dossier.last_update
|
1
app/views/users/dossiers/show.html.haml
Normal file
1
app/views/users/dossiers/show.html.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= render partial: '/dossiers/show'
|
|
@ -0,0 +1,5 @@
|
|||
<p>Welcome <%= @email %>!</p>
|
||||
|
||||
<p>You can confirm your account email through the link below:</p>
|
||||
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
|
|
@ -0,0 +1,8 @@
|
|||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
||||
|
||||
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
|
||||
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
<p>Your password won't change until you access the link above and create a new one.</p>
|
7
app/views/users/mailer/unlock_instructions.html.erb
Normal file
7
app/views/users/mailer/unlock_instructions.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
|
||||
|
||||
<p>Click the link below to unlock your account:</p>
|
||||
|
||||
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
|
22
app/views/users/passwords/edit.html.erb
Normal file
22
app/views/users/passwords/edit.html.erb
Normal file
|
@ -0,0 +1,22 @@
|
|||
<h2>Change your password</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= f.hidden_field :reset_password_token %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password, "New password" %><br />
|
||||
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Change my password" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "users/shared/links" %>
|
16
app/views/users/passwords/new.html.erb
Normal file
16
app/views/users/passwords/new.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
<h2>Forgot your password?</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Send me reset password instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "users/shared/links" %>
|
18
app/views/users/recapitulatif/_commentaires_flux.html.haml
Normal file
18
app/views/users/recapitulatif/_commentaires_flux.html.haml
Normal file
|
@ -0,0 +1,18 @@
|
|||
.content#commentaires_flux{style:'width:100%;'}
|
||||
%div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'}
|
||||
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do
|
||||
%textarea.form-control{id: 'texte_commentaire', name: 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255', placeholder:"Dialoguer avec votre interlocuteur privilégié en charge de votre dossier."}
|
||||
%input.form-control.btn.btn-primary{:type => 'submit', :value => 'Poster', style: 'float:right'}
|
||||
%br
|
||||
%br
|
||||
|
||||
-@commentaires.each do |com|
|
||||
%span.text-info#email_contact{style: 'font-weight:bold'}
|
||||
=com.email
|
||||
%span#created_at
|
||||
\-
|
||||
=com.created_at_fr
|
||||
%br
|
||||
.description#body
|
||||
=com.body
|
||||
%br
|
29
app/views/users/recapitulatif/show.html.haml
Normal file
29
app/views/users/recapitulatif/show.html.haml
Normal file
|
@ -0,0 +1,29 @@
|
|||
%div.row#recap_dossier
|
||||
%div.col-md-2.col-lg-2
|
||||
%h2
|
||||
='Récapitulatif'
|
||||
|
||||
%div.col-md-8.col-lg-8
|
||||
|
||||
%div.col-md-2.col-lg-2
|
||||
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
|
||||
= "Dossier n°#{@dossier.id}"
|
||||
|
||||
- unless gestionnaire_signed_in?
|
||||
-if @dossier.draft?
|
||||
= form_tag(url_for({controller: :recapitulatif, action: :propose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
%button#action_button.btn.btn-success
|
||||
= 'Soumettre mon dossier'
|
||||
-elsif @dossier.confirmed?
|
||||
= form_tag(url_for({controller: :recapitulatif, action: :depose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
%button#action_button.btn.btn-success
|
||||
= 'Déposer mon dossier'
|
||||
-else
|
||||
%h3{:class => 'text-success', :style => 'text-align:right'}
|
||||
= @dossier.state_fr
|
||||
|
||||
%br
|
||||
|
||||
= render partial: '/dossiers/infos_dossier'
|
||||
%br
|
||||
= render partial: 'commentaires_flux'
|
39
app/views/users/registrations/edit.html.erb
Normal file
39
app/views/users/registrations/edit.html.erb
Normal file
|
@ -0,0 +1,39 @@
|
|||
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
||||
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
||||
<%= f.password_field :password, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
||||
<%= f.password_field :current_password, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Update" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<h3>Cancel my account</h3>
|
||||
|
||||
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
|
||||
|
||||
<%= link_to "Back", :back %>
|
29
app/views/users/registrations/new.html.erb
Normal file
29
app/views/users/registrations/new.html.erb
Normal file
|
@ -0,0 +1,29 @@
|
|||
<h2>Sign up</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password %>
|
||||
<% if @validatable %>
|
||||
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
||||
<% end %><br />
|
||||
<%= f.password_field :password, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Sign up" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "users/shared/links" %>
|
19
app/views/users/sessions/new.html.haml
Normal file
19
app/views/users/sessions/new.html.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
%h2#login_user Connexion
|
||||
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
|
||||
.field
|
||||
= f.label :email
|
||||
%br
|
||||
= f.email_field :email, autofocus: true
|
||||
.field
|
||||
= f.label :password
|
||||
%br
|
||||
= f.password_field :password, autocomplete: "off"
|
||||
%br
|
||||
/ - if devise_mapping.rememberable?
|
||||
/ .field
|
||||
/ = f.check_box :remember_me
|
||||
/ = f.label :remember_me
|
||||
.actions
|
||||
= f.submit "Se connecter"
|
||||
|
||||
= render "users/shared/links"
|
25
app/views/users/shared/_links.html.erb
Normal file
25
app/views/users/shared/_links.html.erb
Normal file
|
@ -0,0 +1,25 @@
|
|||
<%- if controller_name != 'sessions' %>
|
||||
<%= link_to "Log in", new_session_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
||||
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
||||
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.omniauthable? %>
|
||||
<%- resource_class.omniauth_providers.each do |provider| %>
|
||||
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
|
||||
<% end -%>
|
||||
<% end -%>
|
|
@ -5,5 +5,5 @@
|
|||
Site de démonstration d’un service public de saisie d’un projet ou de dépôt d’une démarche administrative, auprès d’un ou plusieurs organismes publics, simplifié des informations déjà connues des administrations, grâce à la fourniture du numéro SIRET.
|
||||
|
||||
.row
|
||||
= render partial: '/start/pro'
|
||||
= render partial: 'pro'
|
||||
|
16
app/views/users/unlocks/new.html.erb
Normal file
16
app/views/users/unlocks/new.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
<h2>Resend unlock instructions</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Resend unlock instructions" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "users/shared/links" %>
|
|
@ -78,5 +78,7 @@ fr:
|
|||
not_saved:
|
||||
one: "1 erreur a empêché ce(tte) %{resource} d'être sauvegardé(e) :"
|
||||
other: "%{count} erreurs ont empêché ce(tte) %{resource} d'être sauvegardé(e) :"
|
||||
dossier_not_found: "Le dossier n'existe pas"
|
||||
invalid_siret: "Le siret est incorrect"
|
||||
|
||||
|
||||
|
|
|
@ -1,40 +1,59 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
devise_for :users, controllers: {
|
||||
sessions: 'users/sessions'
|
||||
}
|
||||
|
||||
devise_for :gestionnaires, controllers: {
|
||||
sessions: 'gestionnaires/sessions'
|
||||
|
||||
}, skip: [:password, :registrations]
|
||||
|
||||
|
||||
root 'start#index'
|
||||
# root 'welcome#index'
|
||||
root 'users/dossiers#index'
|
||||
|
||||
get 'start/index'
|
||||
get 'start/error_siret'
|
||||
get 'start/error_login'
|
||||
get 'start/error_dossier'
|
||||
namespace :users do
|
||||
get 'siret' => 'siret#index'
|
||||
resources :dossiers do
|
||||
get '/description' => 'description#show'
|
||||
get '/description/error' => 'description#error'
|
||||
post 'description' => 'description#create'
|
||||
get '/recapitulatif' => 'recapitulatif#show'
|
||||
post '/recapitulatif/propose' => 'recapitulatif#propose'
|
||||
post '/recapitulatif/depose' => 'recapitulatif#depose'
|
||||
get '/demande' => 'demandes#show'
|
||||
post '/demande' => 'demandes#update'
|
||||
post '/commentaire' => 'commentaires#create'
|
||||
end
|
||||
resource :dossiers
|
||||
|
||||
resources :dossiers do
|
||||
get '/demande' => 'demandes#show'
|
||||
post '/demande' => 'demandes#update'
|
||||
|
||||
get '/carte/position' => 'carte#get_position'
|
||||
get '/carte' => 'carte#show'
|
||||
post '/carte' => 'carte#save_ref_api_carto'
|
||||
|
||||
get '/description' => 'description#show'
|
||||
get '/description/error' => 'description#error'
|
||||
post 'description' => 'description#create'
|
||||
|
||||
get '/recapitulatif' => 'recapitulatif#show'
|
||||
|
||||
post '/commentaire' => 'commentaires#create'
|
||||
end
|
||||
|
||||
|
||||
# resources :dossiers do
|
||||
|
||||
|
||||
# # get '/carte/position' => 'carte#get_position'
|
||||
# # get '/carte' => 'carte#show'
|
||||
# # post '/carte' => 'carte#save_ref_api_carto'
|
||||
|
||||
# # get '/description' => 'description#show'
|
||||
# # get '/description/error' => 'description#error'
|
||||
# # post 'description' => 'description#create'
|
||||
|
||||
|
||||
# post '/commentaire' => 'commentaires#create'
|
||||
|
||||
# end
|
||||
|
||||
|
||||
get 'backoffice' => 'backoffice#index'
|
||||
|
||||
namespace :backoffice do
|
||||
get 'sign_in' => '/gestionnaires/sessions#new'
|
||||
resources :dossiers, only: [:show]
|
||||
resources :dossiers do
|
||||
post 'confirme' => 'dossiers#confirme'
|
||||
end
|
||||
resources :commentaires, only: [:create]
|
||||
end
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
|
|
42
db/migrate/20150922141232_create_users.rb
Normal file
42
db/migrate/20150922141232_create_users.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
class CreateUsers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table(:users) do |t|
|
||||
## Database authenticatable
|
||||
t.string :email, null: false, default: ""
|
||||
t.string :encrypted_password, null: false, default: ""
|
||||
|
||||
## Recoverable
|
||||
t.string :reset_password_token
|
||||
t.datetime :reset_password_sent_at
|
||||
|
||||
## Rememberable
|
||||
t.datetime :remember_created_at
|
||||
|
||||
## Trackable
|
||||
t.integer :sign_in_count, default: 0, null: false
|
||||
t.datetime :current_sign_in_at
|
||||
t.datetime :last_sign_in_at
|
||||
t.inet :current_sign_in_ip
|
||||
t.inet :last_sign_in_ip
|
||||
|
||||
## Confirmable
|
||||
# t.string :confirmation_token
|
||||
# t.datetime :confirmed_at
|
||||
# t.datetime :confirmation_sent_at
|
||||
# t.string :unconfirmed_email # Only if using reconfirmable
|
||||
|
||||
## Lockable
|
||||
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
||||
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
||||
# t.datetime :locked_at
|
||||
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :users, :email, unique: true
|
||||
add_index :users, :reset_password_token, unique: true
|
||||
# add_index :users, :confirmation_token, unique: true
|
||||
# add_index :users, :unlock_token, unique: true
|
||||
end
|
||||
end
|
6
db/migrate/20150923101000_add_user_to_dossier.rb
Normal file
6
db/migrate/20150923101000_add_user_to_dossier.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class AddUserToDossier < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :dossiers, :user, index: true
|
||||
add_foreign_key :dossiers, :users
|
||||
end
|
||||
end
|
25
db/schema.rb
25
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150922141000) do
|
||||
ActiveRecord::Schema.define(version: 20150923101000) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -46,10 +46,12 @@ ActiveRecord::Schema.define(version: 20150922141000) do
|
|||
t.date "date_previsionnelle"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "state"
|
||||
t.string "state"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
||||
add_index "dossiers", ["user_id"], name: "index_dossiers_on_user_id", using: :btree
|
||||
|
||||
create_table "entreprises", force: :cascade do |t|
|
||||
t.string "siren"
|
||||
|
@ -130,6 +132,25 @@ ActiveRecord::Schema.define(version: 20150922141000) do
|
|||
t.integer "procedure_id"
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.integer "sign_in_count", default: 0, null: false
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.inet "current_sign_in_ip"
|
||||
t.inet "last_sign_in_ip"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
||||
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
||||
|
||||
add_foreign_key "cerfas", "dossiers"
|
||||
add_foreign_key "commentaires", "dossiers"
|
||||
add_foreign_key "dossiers", "users"
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Backoffice::CommentairesController, type: :controller do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:dossier) { create(:dossier, :with_user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:email_commentaire) { 'test@test.com' }
|
||||
let(:texte_commentaire) { 'Commentaire de test' }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Backoffice::DossiersController, type: :controller do
|
||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
|
@ -19,7 +19,7 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
|
||||
it "le numéro de dossier n'existe pas" do
|
||||
get :show, id: bad_dossier_id
|
||||
expect(response).to redirect_to('/start/error_dossier')
|
||||
expect(response).to redirect_to('/backoffice')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -28,4 +28,20 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
it { is_expected.to redirect_to('/gestionnaires/sign_in') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #confirme' do
|
||||
context 'le gestionnaire valide un dossier' do
|
||||
before do
|
||||
dossier.proposed!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'dossier change is state for confirmed' do
|
||||
post :confirme, dossier_id: dossier_id
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('confirmed')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe CommentairesController, type: :controller do
|
||||
let(:dossier) { create(:dossier) }
|
||||
describe Users::CommentairesController, type: :controller do
|
||||
let(:dossier) { create(:dossier, :with_user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:email_commentaire) { 'test@test.com' }
|
||||
let(:texte_commentaire) { 'Commentaire de test' }
|
||||
|
@ -9,8 +9,9 @@ describe CommentairesController, type: :controller do
|
|||
describe '#POST create' do
|
||||
context 'création correct d\'un commentaire' do
|
||||
it 'depuis la page récapitulatif' do
|
||||
sign_in dossier.user
|
||||
post :create, dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DescriptionController, type: :controller do
|
||||
let(:dossier) { create(:dossier, :with_procedure) }
|
||||
describe Users::DescriptionController, type: :controller do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :with_procedure, user: user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||
|
||||
|
@ -13,7 +14,7 @@ describe DescriptionController, type: :controller do
|
|||
|
||||
it 'redirection vers start si mauvais dossier ID' do
|
||||
get :show, dossier_id: bad_dossier_id
|
||||
expect(response).to redirect_to(controller: :start, action: :error_dossier)
|
||||
expect(response).to redirect_to(controller: :siret)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,7 +38,7 @@ describe DescriptionController, type: :controller do
|
|||
# TODO separer en deux tests : check donnees et check redirect
|
||||
it 'Premier enregistrement des données' do
|
||||
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
|
||||
# TODO changer les valeurs des champs et check in bdd
|
||||
|
@ -63,7 +64,7 @@ describe DescriptionController, type: :controller do
|
|||
end
|
||||
|
||||
it 'Redirection vers la page récapitulatif' do
|
||||
expect(response).to redirect_to("/dossiers/#{dossier_id}/recapitulatif")
|
||||
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,119 +1,124 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe DossiersController, type: :controller do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:siret_not_found) { 999_999_999_999 }
|
||||
describe DossiersController, type: :controller do
|
||||
# let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
# let(:procedure) { create(:procedure) }
|
||||
# let(:dossier_id) { dossier.id }
|
||||
# let(:siret_not_found) { 999_999_999_999 }
|
||||
|
||||
let(:siren) { dossier.siren }
|
||||
let(:siret) { dossier.siret }
|
||||
let(:bad_siret) { 1 }
|
||||
# let(:siren) { dossier.siren }
|
||||
# let(:siret) { dossier.siret }
|
||||
# let(:bad_siret) { 1 }
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success with dossier_id valid' do
|
||||
get :show, id: dossier_id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
# describe 'GET #show' do
|
||||
# it 'returns http success with dossier_id valid' do
|
||||
# get :show, id: dossier_id
|
||||
# expect(response).to have_http_status(:success)
|
||||
# end
|
||||
|
||||
it 'redirection vers start si mauvais dossier ID' do
|
||||
get :show, id: siret_not_found
|
||||
expect(response).to redirect_to('/start/error_dossier')
|
||||
end
|
||||
end
|
||||
# it 'redirection vers siret si mauvais dossier ID' do
|
||||
# get :show, id: siret_not_found
|
||||
# expect(response).to redirect_to('/siret')
|
||||
# end
|
||||
# end
|
||||
|
||||
describe 'POST #create' do
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 404, body: 'fake body')
|
||||
# describe 'POST #create' do
|
||||
# before do
|
||||
# stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
|
||||
# .to_return(status: 404, body: 'fake body')
|
||||
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||
# stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
# .to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||
end
|
||||
# stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
# .to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||
# end
|
||||
|
||||
describe 'professionnel fills form' do
|
||||
context 'when pro_dossier_id is empty' do
|
||||
context 'with valid siret ' do
|
||||
before do
|
||||
post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last
|
||||
end
|
||||
# describe 'professionnel fills form' do
|
||||
# context 'when pro_dossier_id is empty' do
|
||||
# context 'with valid siret ' do
|
||||
|
||||
it 'create a dossier' do
|
||||
expect { post :create, siret: siret, pro_dossier_id: '' }.to change { Dossier.count }.by(1)
|
||||
end
|
||||
# subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
|
||||
|
||||
it 'creates entreprise' do
|
||||
expect { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }.to change { Entreprise.count }.by(1)
|
||||
end
|
||||
|
||||
it 'links entreprise to dossier' do
|
||||
expect(Entreprise.last.dossier).to eq(Dossier.last)
|
||||
end
|
||||
# it 'create a dossier' do
|
||||
# expect { subject }.to change { Dossier.count }.by(1)
|
||||
# end
|
||||
|
||||
it 'creates etablissement for dossier' do
|
||||
expect { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }.to change { Etablissement.count }.by(1)
|
||||
end
|
||||
# it 'creates entreprise' do
|
||||
# expect { subject }.to change { Entreprise.count }.by(1)
|
||||
# end
|
||||
|
||||
it 'links etablissement to dossier' do
|
||||
expect(Etablissement.last.dossier).to eq(Dossier.last)
|
||||
end
|
||||
# it 'links entreprise to dossier' do
|
||||
# expect(Entreprise.last.dossier).to eq(Dossier.last)
|
||||
# end
|
||||
|
||||
it 'links etablissement to entreprise' do
|
||||
expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
||||
end
|
||||
# it 'creates etablissement for dossier' do
|
||||
# expect { subject }.to change { Etablissement.count }.by(1)
|
||||
# end
|
||||
|
||||
it 'links procedure to dossier' do
|
||||
expect(Dossier.last.procedure).to eq(Procedure.last)
|
||||
end
|
||||
# it 'links etablissement to dossier' do
|
||||
# subject
|
||||
# expect(Etablissement.last.dossier).to eq(Dossier.last)
|
||||
# end
|
||||
|
||||
it 'state of dossier is draft' do
|
||||
expect(Dossier.last.state).to eq('draft')
|
||||
end
|
||||
end
|
||||
# it 'links etablissement to entreprise' do
|
||||
# subject
|
||||
# expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
||||
# end
|
||||
|
||||
context 'with non existant siret' do
|
||||
let(:siret_not_found) { '11111111111111' }
|
||||
subject { post :create, siret: siret_not_found, pro_dossier_id: '' }
|
||||
it 'does not create new dossier' do
|
||||
expect { subject }.not_to change { Dossier.count }
|
||||
end
|
||||
# it 'links procedure to dossier' do
|
||||
# subject
|
||||
# expect(Dossier.last.procedure).to eq(Procedure.last)
|
||||
# end
|
||||
|
||||
it 'redirects to show' do
|
||||
expect(subject).to redirect_to(controller: :start, action: :error_siret)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# it 'state of dossier is draft' do
|
||||
# subject
|
||||
# expect(Dossier.last.state).to eq('draft')
|
||||
# end
|
||||
# end
|
||||
|
||||
describe 'PUT #update' do
|
||||
before do
|
||||
put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
||||
end
|
||||
context 'when Checkbox is checked' do
|
||||
let(:autorisation_donnees) { '1' }
|
||||
it 'redirects to demande' do
|
||||
expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
|
||||
end
|
||||
# context 'with non existant siret' do
|
||||
# let(:siret_not_found) { '11111111111111' }
|
||||
# subject { post :create, siret: siret_not_found, pro_dossier_id: '', procedure_id: procedure.id }
|
||||
# it 'does not create new dossier' do
|
||||
# expect { subject }.not_to change { Dossier.count }
|
||||
# end
|
||||
|
||||
it 'update dossier' do
|
||||
dossier.reload
|
||||
expect(dossier.autorisation_donnees).to be_truthy
|
||||
end
|
||||
end
|
||||
# it 'redirects to show' do
|
||||
# expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
context 'when Checkbox is not checked' do
|
||||
let(:autorisation_donnees) { '0' }
|
||||
it 'uses flash alert to display message' do
|
||||
expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
|
||||
end
|
||||
# describe 'PUT #update' do
|
||||
# before do
|
||||
# put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
||||
# end
|
||||
# context 'when Checkbox is checked' do
|
||||
# let(:autorisation_donnees) { '1' }
|
||||
# it 'redirects to demande' do
|
||||
# expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
|
||||
# end
|
||||
|
||||
it "doesn't update dossier autorisation_donnees" do
|
||||
dossier.reload
|
||||
expect(dossier.autorisation_donnees).to be_falsy
|
||||
end
|
||||
end
|
||||
end
|
||||
# it 'update dossier' do
|
||||
# dossier.reload
|
||||
# expect(dossier.autorisation_donnees).to be_truthy
|
||||
# end
|
||||
# end
|
||||
|
||||
# context 'when Checkbox is not checked' do
|
||||
# let(:autorisation_donnees) { '0' }
|
||||
# it 'uses flash alert to display message' do
|
||||
# expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
|
||||
# end
|
||||
|
||||
# it "doesn't update dossier autorisation_donnees" do
|
||||
# dossier.reload
|
||||
# expect(dossier.autorisation_donnees).to be_falsy
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe RecapitulatifController, type: :controller do
|
||||
let(:dossier) { create(:dossier) }
|
||||
|
||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier.id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'redirection vers start si mauvais dossier ID' do
|
||||
get :show, dossier_id: bad_dossier_id
|
||||
expect(response).to redirect_to('/start/error_dossier')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,77 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe StartController, type: :controller do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
|
||||
describe 'GET #index' do
|
||||
before do
|
||||
get :index, procedure_id: procedure
|
||||
end
|
||||
|
||||
context 'when params procedure_id is present' do
|
||||
context 'when procedure_id is valid' do
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
|
||||
context 'when procedure_id is not valid' do
|
||||
let(:procedure) { '' }
|
||||
it { expect(response).to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when params procedure_id is not present' do
|
||||
before do
|
||||
get :index
|
||||
end
|
||||
it { expect(response).to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #index with bad SIRET' do
|
||||
before do
|
||||
get :error_siret, procedure_id: procedure
|
||||
end
|
||||
|
||||
it 'returns http success and flash alert is present' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
it 'la flash alert est présente' do
|
||||
expect(flash[:alert]).to be_present
|
||||
end
|
||||
it 'la flash alert a un libellé correct' do
|
||||
expect(flash[:alert]).to have_content('Ce SIRET n\'est pas valide')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #index with bad LOGIN' do
|
||||
before do
|
||||
get :error_login
|
||||
end
|
||||
|
||||
it 'returns http success and flash alert is present' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
it 'la flash alert est présente' do
|
||||
expect(flash[:alert]).to be_present
|
||||
end
|
||||
it 'la flash alert a un libellé correct' do
|
||||
expect(flash[:alert]).to have_content('Ce compte n\'existe pas')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #index with bad DOSSIER' do
|
||||
before do
|
||||
get :error_dossier
|
||||
end
|
||||
|
||||
it 'returns http success and flash alert is present' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
it 'la flash alert est présente' do
|
||||
expect(flash[:alert]).to be_present
|
||||
end
|
||||
it 'la flash alert a un libellé correct' do
|
||||
expect(flash[:alert]).to have_content('Ce dossier n\'existe pas')
|
||||
end
|
||||
end
|
||||
end
|
156
spec/controllers/users/dossiers_controller_spec.rb
Normal file
156
spec/controllers/users/dossiers_controller_spec.rb
Normal file
|
@ -0,0 +1,156 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::DossiersController, type: :controller do
|
||||
let(:user) { create(:user) }
|
||||
describe '.index' do
|
||||
subject { get :index }
|
||||
context 'when user is not logged in' do
|
||||
it { is_expected.to redirect_to('/users/sign_in') }
|
||||
end
|
||||
context 'when user is logged in' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
it { is_expected.to render_template('users/dossiers/index') }
|
||||
it { is_expected.to have_http_status(:success) }
|
||||
end
|
||||
end
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:siret_not_found) { 999_999_999_999 }
|
||||
|
||||
let(:siren) { dossier.siren }
|
||||
let(:siret) { dossier.siret }
|
||||
let(:bad_siret) { 1 }
|
||||
|
||||
describe 'GET #show' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
it 'returns http success with dossier_id valid' do
|
||||
get :show, id: dossier_id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'redirection vers siret si mauvais dossier ID' do
|
||||
get :show, id: siret_not_found
|
||||
expect(response).to redirect_to('/users/siret')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 404, body: 'fake body')
|
||||
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||
end
|
||||
|
||||
describe 'professionnel fills form' do
|
||||
let(:user) { create(:user) }
|
||||
context 'when pro_dossier_id is empty' do
|
||||
context 'with valid siret ' do
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
|
||||
|
||||
|
||||
it 'create a dossier' do
|
||||
expect { subject }.to change { Dossier.count }.by(1)
|
||||
end
|
||||
|
||||
it 'creates entreprise' do
|
||||
expect { subject }.to change { Entreprise.count }.by(1)
|
||||
end
|
||||
|
||||
it 'links entreprise to dossier' do
|
||||
subject
|
||||
expect(Entreprise.last.dossier).to eq(Dossier.last)
|
||||
end
|
||||
|
||||
it "links dossier to user" do
|
||||
subject
|
||||
expect(Dossier.last.user).to eq(user)
|
||||
end
|
||||
|
||||
it 'creates etablissement for dossier' do
|
||||
expect { subject }.to change { Etablissement.count }.by(1)
|
||||
end
|
||||
|
||||
it 'links etablissement to dossier' do
|
||||
subject
|
||||
expect(Etablissement.last.dossier).to eq(Dossier.last)
|
||||
end
|
||||
|
||||
it 'links etablissement to entreprise' do
|
||||
subject
|
||||
expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
||||
end
|
||||
|
||||
it 'links procedure to dossier' do
|
||||
subject
|
||||
expect(Dossier.last.procedure).to eq(Procedure.last)
|
||||
end
|
||||
|
||||
it 'state of dossier is draft' do
|
||||
subject
|
||||
expect(Dossier.last.state).to eq('draft')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with non existant siret' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
|
||||
let(:siret_not_found) { '11111111111111' }
|
||||
subject { post :create, siret: siret_not_found, pro_dossier_id: '', procedure_id: procedure.id }
|
||||
it 'does not create new dossier' do
|
||||
expect { subject }.not_to change { Dossier.count }
|
||||
end
|
||||
|
||||
it 'redirects to show' do
|
||||
expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
||||
end
|
||||
context 'when Checkbox is checked' do
|
||||
let(:autorisation_donnees) { '1' }
|
||||
it 'redirects to demande' do
|
||||
expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
|
||||
end
|
||||
|
||||
it 'update dossier' do
|
||||
dossier.reload
|
||||
expect(dossier.autorisation_donnees).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context 'when Checkbox is not checked' do
|
||||
let(:autorisation_donnees) { '0' }
|
||||
it 'uses flash alert to display message' do
|
||||
expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
|
||||
end
|
||||
|
||||
it "doesn't update dossier autorisation_donnees" do
|
||||
dossier.reload
|
||||
expect(dossier.autorisation_donnees).to be_falsy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
58
spec/controllers/users/recapitulatif_controller_spec.rb
Normal file
58
spec/controllers/users/recapitulatif_controller_spec.rb
Normal file
|
@ -0,0 +1,58 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::RecapitulatifController, type: :controller do
|
||||
let(:dossier) { create(:dossier, :with_user) }
|
||||
let(:bad_dossier_id) { Dossier.count + 100000 }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'returns http success' do
|
||||
get :show, dossier_id: dossier.id
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'redirection vers siret si mauvais dossier ID' do
|
||||
get :show, dossier_id: bad_dossier_id
|
||||
expect(response).to redirect_to('/users/siret')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #propose' do
|
||||
context 'when an user propose his dossier' do
|
||||
before do
|
||||
post :propose, dossier_id: dossier.id
|
||||
end
|
||||
|
||||
it 'dossier change his state for processed' do
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('proposed')
|
||||
end
|
||||
|
||||
it 'a message informe user what his dossier is proposed' do
|
||||
expect(flash[:notice]).to include('Dossier soumis avec succès.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #depose' do
|
||||
context 'when an user depose his dossier' do
|
||||
before do
|
||||
dossier.confirmed!
|
||||
post :depose, dossier_id: dossier.id
|
||||
end
|
||||
|
||||
it 'dossier change his state for deposed' do
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('deposited')
|
||||
end
|
||||
|
||||
it 'a message informe user what his dossier is proposed' do
|
||||
expect(flash[:notice]).to include('Dossier déposé avec succès.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
82
spec/controllers/users/siret_controller_spec.rb
Normal file
82
spec/controllers/users/siret_controller_spec.rb
Normal file
|
@ -0,0 +1,82 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::SiretController, type: :controller do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
|
||||
describe 'GET #index' do
|
||||
before do
|
||||
get :index, procedure_id: procedure
|
||||
end
|
||||
|
||||
context 'when params procedure_id is present' do
|
||||
context 'when procedure_id is valid' do
|
||||
context 'when user is logged in' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
subject { get :index, procedure_id: procedure }
|
||||
it { expect(subject).to have_http_status(:success) }
|
||||
context 'when procedure_id is not valid' do
|
||||
let(:procedure) { '' }
|
||||
it { is_expected.to have_http_status(404) }
|
||||
end
|
||||
context 'when params procedure_id is not present' do
|
||||
subject { get :index }
|
||||
it { is_expected.to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
context 'when user is not logged' do
|
||||
it { expect(response).to have_http_status(302) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# describe 'GET #index with bad SIRET' do
|
||||
# before do
|
||||
# get :error_siret, procedure_id: procedure
|
||||
# end
|
||||
|
||||
# it 'returns http success and flash alert is present' do
|
||||
# expect(response).to have_http_status(:success)
|
||||
# end
|
||||
# it 'la flash alert est présente' do
|
||||
# expect(flash[:alert]).to be_present
|
||||
# end
|
||||
# it 'la flash alert a un libellé correct' do
|
||||
# expect(flash[:alert]).to have_content('Ce SIRET n\'est pas valide')
|
||||
# end
|
||||
# end
|
||||
|
||||
# describe 'GET #index with bad LOGIN' do
|
||||
# before do
|
||||
# get :error_login
|
||||
# end
|
||||
|
||||
# it 'returns http success and flash alert is present' do
|
||||
# expect(response).to have_http_status(:success)
|
||||
# end
|
||||
# it 'la flash alert est présente' do
|
||||
# expect(flash[:alert]).to be_present
|
||||
# end
|
||||
# it 'la flash alert a un libellé correct' do
|
||||
# expect(flash[:alert]).to have_content('Ce compte n\'existe pas')
|
||||
# end
|
||||
# end
|
||||
|
||||
# describe 'GET #index with bad DOSSIER' do
|
||||
# before do
|
||||
# get :error_dossier
|
||||
# end
|
||||
|
||||
# it 'returns http success and flash alert is present' do
|
||||
# expect(response).to have_http_status(:success)
|
||||
# end
|
||||
# it 'la flash alert est présente' do
|
||||
# expect(flash[:alert]).to be_present
|
||||
# end
|
||||
# it 'la flash alert a un libellé correct' do
|
||||
# expect(flash[:alert]).to have_content('Ce dossier n\'existe pas')
|
||||
# end
|
||||
# end
|
||||
end
|
|
@ -1,10 +1,50 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DossierDecorator do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:dossier) { create(:dossier, :with_user) }
|
||||
subject { dossier.decorate }
|
||||
|
||||
describe 'last_update' do
|
||||
subject { Timecop.freeze(Time.new(2015, 12, 24, 14, 10)) { super().last_update } }
|
||||
it { is_expected.to eq('24/12/2015 14:10') }
|
||||
end
|
||||
|
||||
describe 'state_fr' do
|
||||
subject{ super().state_fr }
|
||||
|
||||
it 'draft is brouillon' do
|
||||
dossier.draft!
|
||||
expect(subject).to eq('Brouillon')
|
||||
end
|
||||
|
||||
it 'proposed is propose' do
|
||||
dossier.proposed!
|
||||
expect(subject).to eq('Soumis')
|
||||
end
|
||||
|
||||
it 'reply is repondu' do
|
||||
dossier.reply!
|
||||
expect(subject).to eq('Répondu')
|
||||
end
|
||||
|
||||
it 'updated is mis à jour' do
|
||||
dossier.updated!
|
||||
expect(subject).to eq('Mis à jour')
|
||||
end
|
||||
|
||||
it 'confirmed is valide' do
|
||||
dossier.confirmed!
|
||||
expect(subject).to eq('Validé')
|
||||
end
|
||||
|
||||
it 'deposited is dépose' do
|
||||
dossier.deposited!
|
||||
expect(subject).to eq('Déposé')
|
||||
end
|
||||
|
||||
it 'processed is traité' do
|
||||
dossier.processed!
|
||||
expect(subject).to eq('Traité')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :dossier do
|
||||
nom_projet "Demande de subvention dans le cadre d'accompagnement d'enfant à l'étranger"
|
||||
state 'draft'
|
||||
trait :with_entreprise do
|
||||
after(:build) do |dossier, _evaluator|
|
||||
etablissement = create(:etablissement)
|
||||
|
@ -16,5 +17,11 @@ FactoryGirl.define do
|
|||
dossier.procedure = procedure
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_user do
|
||||
after(:build) do |dossier, _evaluator|
|
||||
dossier.user = create(:user)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
7
spec/factories/user.rb
Normal file
7
spec/factories/user.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
sequence(:user_email) { |n| "plop#{n}@plop.com" }
|
||||
factory :user do
|
||||
email { generate(:user_email) }
|
||||
password 'password'
|
||||
end
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'add commentaire on backoffice' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') }
|
||||
let(:email_commentaire) { 'test@test.com' }
|
||||
|
@ -36,13 +36,5 @@ feature 'add commentaire on backoffice' do
|
|||
scenario 'Champs de texte' do
|
||||
expect(page).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]')
|
||||
end
|
||||
|
||||
scenario 'Champs email' do
|
||||
expect(page).to have_selector('input[id=email_commentaire][name=email_commentaire]')
|
||||
end
|
||||
|
||||
scenario 'Champs email est prérempli' do
|
||||
expect(page).to have_selector("input[id=email_commentaire][value='#{gestionnaire.email}']")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
feature 'when gestionnaire come to /backoffice and is not authenticated' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_user, procedure: procedure) }
|
||||
before do
|
||||
visit backoffice_path
|
||||
end
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Admin/Dossier#Show Page' do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
login_gestionnaire
|
||||
visit "/backoffice/dossiers/#{dossier_id}"
|
||||
end
|
||||
|
||||
context 'sur la page admin du dossier' do
|
||||
scenario 'la section infos entreprise est présente' do
|
||||
expect(page).to have_selector('#infos_entreprise')
|
||||
end
|
||||
|
||||
scenario 'la section infos dossier est présente' do
|
||||
expect(page).to have_selector('#infos_dossier')
|
||||
end
|
||||
|
||||
scenario 'le numéro de dossier est présent sur la page' do
|
||||
expect(page).to have_selector('#dossier_id')
|
||||
expect(page).to have_content(dossier_id)
|
||||
end
|
||||
|
||||
context 'les liens de modifications sont non présent' do
|
||||
scenario 'le lien vers carte' do
|
||||
expect(page).to_not have_selector('a[id=modif_carte]')
|
||||
end
|
||||
|
||||
scenario 'le lien vers description' do
|
||||
expect(page).to_not have_selector('a[id=modif_description]')
|
||||
end
|
||||
end
|
||||
|
||||
#TODO réactiver
|
||||
# context 'la liste des pièces justificatives est présente' do
|
||||
# context 'Attestation MSA' do
|
||||
# let(:id_piece_justificative) { 93 }
|
||||
#
|
||||
# scenario 'la ligne de la pièce justificative est présente' do
|
||||
# expect(page).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||
# end
|
||||
#
|
||||
# scenario 'le bouton "Récupérer" est présent' do
|
||||
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_selector("a[href='']")
|
||||
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Récupérer')
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context 'Attestation RDI' do
|
||||
# let(:id_piece_justificative) { 103 }
|
||||
#
|
||||
# scenario 'la ligne de la pièce justificative est présente' do
|
||||
# expect(page).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||
# end
|
||||
#
|
||||
# scenario 'le libelle "Pièce manquante" est présent' do
|
||||
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Pièce non fournie')
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context 'Devis' do
|
||||
# let(:id_piece_justificative) { 388 }
|
||||
# let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
|
||||
#
|
||||
# before do
|
||||
# piece_justificative = dossier.pieces_justificatives.where(type_de_piece_justificative_id: 388).first
|
||||
# piece_justificative.content = content
|
||||
# piece_justificative.save!
|
||||
# visit "/admin/dossiers/#{dossier_id}"
|
||||
# end
|
||||
#
|
||||
# scenario 'la ligne de la pièce justificative est présente' do
|
||||
# expect(page).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||
# end
|
||||
#
|
||||
# scenario 'le libelle "Consulter" est présent' do
|
||||
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}] a")[:href]).to have_content('piece_justificative_388.pdf')
|
||||
# expect(page.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Consulter')
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
scenario 'la carte est bien présente' do
|
||||
expect(page).to have_selector('#map_qp')
|
||||
end
|
||||
|
||||
scenario 'la page des sources CSS de l\'API cart est chargée' do
|
||||
expect(page).to have_selector('#sources_CSS_api_carto')
|
||||
end
|
||||
|
||||
scenario 'la page des sources JS backend de l\'API cart est chargée' do
|
||||
expect(page).to have_selector('#sources_JS_api_carto_backend')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
feature 'on backoffice page' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_user, :with_entreprise, procedure: procedure, state: 'reply') }
|
||||
before do
|
||||
visit backoffice_path
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'On the description page' do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
|
||||
before do
|
||||
visit dossier_description_path dossier
|
||||
visit users_dossier_description_path dossier
|
||||
end
|
||||
scenario 'date_previsionnelle field is present' do
|
||||
expect(page).to have_css('#date_previsionnelle')
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Description#Show Page' do
|
||||
let(:dossier) { create(:dossier, :with_procedure) }
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :with_procedure, user: user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
visit "/dossiers/#{dossier_id}/description"
|
||||
visit users_dossier_description_path(dossier_id: dossier_id)
|
||||
end
|
||||
|
||||
context 'tous les attributs sont présents sur la page' do
|
||||
scenario 'Le formulaire envoie vers /dossiers/:dossier_id/description en #POST' do
|
||||
expect(page).to have_selector("form[action='/dossiers/#{dossier_id}/description'][method=post]")
|
||||
scenario 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do
|
||||
expect(page).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]")
|
||||
end
|
||||
|
||||
scenario 'Nom du projet' do
|
||||
|
@ -62,7 +63,7 @@ feature 'Description#Show Page' do
|
|||
|
||||
context 'si la page précédente est recapitularif' do
|
||||
before do
|
||||
visit "/dossiers/#{dossier_id}/description?back_url=recapitulatif"
|
||||
visit "/users/dossiers/#{dossier_id}/description?back_url=recapitulatif"
|
||||
end
|
||||
|
||||
scenario 'le bouton "Terminer" n\'est pas présent' do
|
||||
|
@ -78,7 +79,7 @@ feature 'Description#Show Page' do
|
|||
end
|
||||
|
||||
scenario 'le lien de retour au récapitulatif est présent' do
|
||||
expect(page).to have_selector("a[href='/dossiers/#{dossier_id}/recapitulatif']")
|
||||
expect(page).to have_selector("a[href='/users/dossiers/#{dossier_id}/recapitulatif']")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,7 +90,8 @@ feature 'Description#Show Page' do
|
|||
description: 'Description de test',
|
||||
montant_projet: 12_000,
|
||||
montant_aide_demande: 3000,
|
||||
date_previsionnelle: '20/01/2016')
|
||||
date_previsionnelle: '20/01/2016',
|
||||
user: user)
|
||||
end
|
||||
|
||||
scenario 'Nom du projet' do
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'user is on description page' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
|
||||
before do
|
||||
visit dossier_description_path dossier
|
||||
visit users_dossier_description_path dossier
|
||||
end
|
||||
it { expect(page).to have_css('#description_page') }
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature '_Commentaires_Flux Recapitulatif#Show Page' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
|
||||
let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') }
|
||||
let(:body) { 'Commentaire de test' }
|
||||
|
||||
before do
|
||||
visit "/dossiers/#{dossier_id}/recapitulatif"
|
||||
end
|
||||
|
||||
context 'Affichage du flux de commentaire' do
|
||||
scenario 'l\'email du contact est présent' do
|
||||
expect(page).to have_selector('span[id=email_contact]')
|
||||
end
|
||||
|
||||
scenario 'la date du commentaire est présent' do
|
||||
expect(page).to have_selector('span[id=created_at]')
|
||||
end
|
||||
|
||||
scenario 'le corps du commentaire est présent' do
|
||||
expect(page).to have_selector('div[class=description][id=body]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'Affichage du formulaire de commentaire' do
|
||||
scenario 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do
|
||||
expect(page).to have_selector("form[action='/dossiers/#{dossier_id}/commentaire'][method=post]")
|
||||
end
|
||||
|
||||
scenario 'Champs de texte' do
|
||||
expect(page).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]')
|
||||
end
|
||||
|
||||
scenario 'Champs email' do
|
||||
expect(page).to have_selector('input[id=email_commentaire][name=email_commentaire]')
|
||||
end
|
||||
|
||||
scenario 'Champs email est prérempli' do
|
||||
expect(page).to have_content(email_commentaire)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,58 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Recapitulatif#Show Page' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
Capybara.current_session.driver.header('Referer', '/description')
|
||||
visit "/dossiers/#{dossier_id}/recapitulatif"
|
||||
end
|
||||
|
||||
context 'sur la page recapitulative' do
|
||||
scenario 'la section infos dossier est présente' do
|
||||
expect(page).to have_selector('#infos_dossier')
|
||||
end
|
||||
|
||||
scenario 'le flux de commentaire est présent' do
|
||||
expect(page).to have_selector('#commentaires_flux')
|
||||
end
|
||||
|
||||
scenario 'le numéro de dossier est présent' do
|
||||
expect(page).to have_selector('#dossier_id')
|
||||
expect(page).to have_content(dossier_id)
|
||||
end
|
||||
|
||||
context 'les liens de modifications' do
|
||||
context 'lien description' do
|
||||
scenario 'le lien vers description est présent' do
|
||||
expect(page).to have_css('#modif_description')
|
||||
end
|
||||
|
||||
scenario 'le lien vers description est correct' do
|
||||
expect(page).to have_selector("a[id=modif_description][href='/dossiers/#{dossier_id}/description?back_url=recapitulatif']")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'visibilité Félicitation' do
|
||||
scenario 'Est affiché quand l\'on vient de la page description hors modification' do
|
||||
expect(page).to have_content('Félicitation')
|
||||
end
|
||||
|
||||
scenario 'N\'est pas affiché quand l\'on vient d\'une autre la page que description' do
|
||||
Capybara.current_session.driver.header('Referer', '/')
|
||||
visit "/dossiers/#{dossier_id}/recapitulatif"
|
||||
|
||||
expect(page).to_not have_content('Félicitation')
|
||||
end
|
||||
|
||||
scenario 'N\'est pas affiché quand l\'on vient de la page description en modification' do
|
||||
Capybara.current_session.driver.header('Referer', '/description?back_url=recapitulatif')
|
||||
visit "/dossiers/#{dossier_id}/recapitulatif"
|
||||
|
||||
expect(page).to_not have_content('Félicitation')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
63
spec/features/users/complete_demande_spec.rb
Normal file
63
spec/features/users/complete_demande_spec.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'user path for dossier creation' do
|
||||
let(:user) { create(:user) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:siret) { '53272417600013' }
|
||||
let(:siren) { siret[0...9] }
|
||||
context 'user arrives on siret page' do
|
||||
before do
|
||||
visit users_siret_path(procedure_id: procedure.id)
|
||||
end
|
||||
|
||||
scenario 'he is redirected on login page' do
|
||||
expect(page).to have_css('#login_user')
|
||||
end
|
||||
|
||||
context 'user sign_in' do
|
||||
before do
|
||||
page.find_by_id('user_email').set user.email
|
||||
page.find_by_id('user_password').set user.password
|
||||
page.click_on 'Se connecter'
|
||||
end
|
||||
scenario 'redirects to siret page' do
|
||||
expect(page).to have_css('#siret')
|
||||
end
|
||||
context 'sets siret' do
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||
page.find_by_id('siret').set siret
|
||||
page.click_on 'Commencer'
|
||||
end
|
||||
scenario 'user is on page recap info entreprise' do
|
||||
expect(page).to have_css('#recap_info_entreprise')
|
||||
end
|
||||
context 'when validating info entreprise recap page' do
|
||||
before do
|
||||
page.check('dossier_autorisation_donnees')
|
||||
page.click_on 'Etape suivante'
|
||||
end
|
||||
scenario 'user is on description page' do
|
||||
expect(page).to have_css('#description_page')
|
||||
end
|
||||
context 'user fill and validate description page' do
|
||||
before do
|
||||
page.find_by_id('nom_projet').set 'Mon super projet'
|
||||
page.find_by_id('description').set 'Ma super description'
|
||||
page.find_by_id('montant_projet').set 10_000
|
||||
page.find_by_id('montant_aide_demande').set 1_000
|
||||
page.find_by_id('date_previsionnelle').set '09/09/2015'
|
||||
page.click_on 'Terminer la procédure'
|
||||
end
|
||||
scenario 'user is on recap page' do
|
||||
expect(page).to have_css('#recap_dossier')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
spec/features/users/list_dossiers_spec.rb
Normal file
26
spec/features/users/list_dossiers_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'user access to the list of his dossier' do
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier') }
|
||||
let!(:dossier2) { create(:dossier, :with_user, nom_projet: 'mon deuxième dossier') }
|
||||
before do
|
||||
visit root_path
|
||||
page.find_by_id('user_email').set user.email
|
||||
page.find_by_id('user_password').set user.password
|
||||
page.click_on 'Se connecter'
|
||||
end
|
||||
scenario 'the list of dossier is displayed' do
|
||||
expect(page).to have_content(dossier1.nom_projet)
|
||||
expect(page).not_to have_content(dossier2.nom_projet)
|
||||
end
|
||||
context 'when user clicks on a projet in list' do
|
||||
before do
|
||||
page.click_on dossier1.nom_projet
|
||||
end
|
||||
scenario 'user is redirected to dossier page' do
|
||||
expect(page).to have_css('#recap_dossier')
|
||||
end
|
||||
end
|
||||
end
|
39
spec/features/users/start_demande_spec.rb
Normal file
39
spec/features/users/start_demande_spec.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'user arrive on siret page' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:user) { create(:user) }
|
||||
let(:siret) { '42149333900020' }
|
||||
let(:siren) { siret[0...9] }
|
||||
context 'when user is not logged in' do
|
||||
before do
|
||||
visit users_siret_path(procedure_id: procedure.id)
|
||||
end
|
||||
scenario 'he is redirected to login page' do
|
||||
expect(page).to have_css('#login_user')
|
||||
end
|
||||
context 'when he enter login information' do
|
||||
before do
|
||||
page.find_by_id('user_email').set user.email
|
||||
page.find_by_id('user_password').set user.password
|
||||
page.click_on 'Se connecter'
|
||||
end
|
||||
scenario 'he is redirected to siret page to enter a siret' do
|
||||
expect(page).to have_css('#pro_section')
|
||||
end
|
||||
context 'when enter a siret' do
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||
page.find_by_id('siret').set siret
|
||||
page.click_on 'Commencer'
|
||||
end
|
||||
scenario 'he is redirected to recap info entreprise page' do
|
||||
expect(page).to have_css('#recap_info_entreprise')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Dossier do
|
||||
let(:user) { create(:user) }
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:description) }
|
||||
it { is_expected.to have_db_column(:autorisation_donnees) }
|
||||
|
@ -21,6 +22,7 @@ describe Dossier do
|
|||
it { is_expected.to have_one(:cerfa) }
|
||||
it { is_expected.to have_one(:etablissement) }
|
||||
it { is_expected.to have_one(:entreprise) }
|
||||
it { is_expected.to belong_to(:user) }
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
|
@ -53,7 +55,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe 'methods' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) }
|
||||
|
||||
let(:entreprise) { dossier.entreprise }
|
||||
let(:etablissement) { dossier.etablissement }
|
||||
|
@ -70,7 +72,7 @@ describe Dossier do
|
|||
|
||||
describe 'creation' do
|
||||
it 'create default cerfa' do
|
||||
expect { described_class.create }.to change { Cerfa.count }.by(1)
|
||||
expect { described_class.create(user: user) }.to change { Cerfa.count }.by(1)
|
||||
end
|
||||
|
||||
it 'link cerfa to dossier' do
|
||||
|
@ -93,7 +95,7 @@ describe Dossier do
|
|||
|
||||
describe '#build_default_pieces_justificatives' do
|
||||
context 'when dossier is linked to a procedure' do
|
||||
let(:dossier) { create(:dossier, :with_procedure) }
|
||||
let(:dossier) { create(:dossier, :with_procedure, user: user) }
|
||||
it 'build all pieces justificatives needed' do
|
||||
expect(dossier.pieces_justificatives.count).to eq(2)
|
||||
end
|
||||
|
@ -101,7 +103,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe '#save' do
|
||||
subject { create(:dossier, procedure_id: nil) }
|
||||
subject { create(:dossier, procedure_id: nil, user: user) }
|
||||
context 'when is linked to a procedure' do
|
||||
it 'creates default pieces justificatives' do
|
||||
expect(subject).to receive(:build_default_pieces_justificatives)
|
||||
|
@ -115,5 +117,287 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
#TODO revoir le nommage
|
||||
describe '#next_step' do
|
||||
let(:dossier) { create(:dossier, :with_user) }
|
||||
let(:role) { 'user' }
|
||||
let(:action) { 'propose' }
|
||||
|
||||
subject { dossier.next_step! role, action }
|
||||
|
||||
context 'when action is not valid' do
|
||||
let(:action) { 'test' }
|
||||
it { expect{ subject }.to raise_error('action is not valid') }
|
||||
end
|
||||
|
||||
context 'when role is not valid' do
|
||||
let(:role) { 'test' }
|
||||
it { expect{ subject }.to raise_error('role is not valid') }
|
||||
end
|
||||
|
||||
context 'when dossier is at state draft' do
|
||||
before do
|
||||
dossier.draft!
|
||||
end
|
||||
|
||||
context 'when user is connected' do
|
||||
let(:role) { 'user' }
|
||||
|
||||
context 'when he updates dossier informations' do
|
||||
let(:action) {'update'}
|
||||
|
||||
it { is_expected.to eq('draft') }
|
||||
end
|
||||
|
||||
context 'when he posts a comment' do
|
||||
let(:action) {'comment'}
|
||||
|
||||
it { is_expected.to eq('draft') }
|
||||
end
|
||||
|
||||
context 'when he proposes a dossier' do
|
||||
let(:action) { 'propose' }
|
||||
|
||||
it { is_expected.to eq('proposed') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state proposed' do
|
||||
before do
|
||||
dossier.proposed!
|
||||
end
|
||||
|
||||
context 'when user is connect' do
|
||||
let(:role) { 'user' }
|
||||
|
||||
context 'when is update dossier informations' do
|
||||
let(:action) { 'update' }
|
||||
|
||||
it {is_expected.to eq('proposed')}
|
||||
end
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it {is_expected.to eq('proposed')}
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire is connect' do
|
||||
let(:role) { 'gestionnaire' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('reply')}
|
||||
end
|
||||
|
||||
context 'when is confirmed the dossier' do
|
||||
let(:action) { 'confirme' }
|
||||
|
||||
it {is_expected.to eq('confirmed')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state reply' do
|
||||
before do
|
||||
dossier.reply!
|
||||
end
|
||||
|
||||
context 'when user is connect' do
|
||||
let(:role) { 'user' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('updated') }
|
||||
end
|
||||
|
||||
context 'when is updated dossier informations' do
|
||||
let(:action) { 'update' }
|
||||
|
||||
it {
|
||||
|
||||
is_expected.to eq('updated')
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire is connect' do
|
||||
let(:role) { 'gestionnaire' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('reply')}
|
||||
end
|
||||
|
||||
context 'when is confirmed the dossier' do
|
||||
let(:action) { 'confirme' }
|
||||
|
||||
it {is_expected.to eq('confirmed')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state updated' do
|
||||
before do
|
||||
dossier.updated!
|
||||
end
|
||||
|
||||
context 'when user is connect' do
|
||||
let(:role) { 'user' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('updated')}
|
||||
end
|
||||
|
||||
context 'when is updated dossier informations' do
|
||||
let(:action) { 'update' }
|
||||
|
||||
it { is_expected.to eq('updated')}
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire is connect' do
|
||||
let(:role) { 'gestionnaire' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('reply')}
|
||||
end
|
||||
|
||||
context 'when is confirmed the dossier' do
|
||||
let(:action) { 'confirme' }
|
||||
|
||||
it {is_expected.to eq('confirmed')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state confirmed' do
|
||||
before do
|
||||
dossier.confirmed!
|
||||
end
|
||||
|
||||
context 'when user is connect' do
|
||||
let(:role) { 'user' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
it { is_expected.to eq('confirmed') }
|
||||
end
|
||||
|
||||
context 'when is deposed the dossier' do
|
||||
let(:action) { 'depose' }
|
||||
|
||||
it { is_expected.to eq('deposited') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire is connect' do
|
||||
let(:role) { 'gestionnaire' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('confirmed')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state deposited' do
|
||||
before do
|
||||
dossier.deposited!
|
||||
end
|
||||
|
||||
context 'when user is connect' do
|
||||
let(:role) { 'user' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('deposited') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire is connect' do
|
||||
let(:role) { 'gestionnaire' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it {is_expected.to eq('deposited')}
|
||||
end
|
||||
|
||||
context 'when is processed the dossier' do
|
||||
let(:action) { 'process' }
|
||||
|
||||
it {is_expected.to eq('processed')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state processed' do
|
||||
before do
|
||||
dossier.processed!
|
||||
end
|
||||
|
||||
context 'when user is connect' do
|
||||
let(:role) { 'user' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('processed')}
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gestionnaire is connect' do
|
||||
let(:role) { 'gestionnaire' }
|
||||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('processed')}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'gestionnaire backoffice methods' do
|
||||
let!(:dossier1) { create(:dossier, :with_user, :with_procedure, state: 'draft')}
|
||||
let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'proposed')}
|
||||
let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'proposed')}
|
||||
let!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'reply')}
|
||||
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
|
||||
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'confirmed')}
|
||||
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}
|
||||
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'processed')}
|
||||
|
||||
describe '#a_traiter' do
|
||||
subject { described_class.a_traiter }
|
||||
|
||||
it { expect(subject.size).to eq(4) }
|
||||
end
|
||||
|
||||
describe '#en_attente' do
|
||||
subject { described_class.en_attente }
|
||||
|
||||
it { expect(subject.size).to eq(2) }
|
||||
end
|
||||
|
||||
describe '#termine' do
|
||||
subject { described_class.termine }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
21
spec/models/user_spec.rb
Normal file
21
spec/models/user_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe User, type: :model do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:email) }
|
||||
it { is_expected.to have_db_column(:encrypted_password) }
|
||||
it { is_expected.to have_db_column(:reset_password_token) }
|
||||
it { is_expected.to have_db_column(:reset_password_sent_at) }
|
||||
it { is_expected.to have_db_column(:remember_created_at) }
|
||||
it { is_expected.to have_db_column(:sign_in_count) }
|
||||
it { is_expected.to have_db_column(:current_sign_in_at) }
|
||||
it { is_expected.to have_db_column(:last_sign_in_at) }
|
||||
it { is_expected.to have_db_column(:current_sign_in_ip) }
|
||||
it { is_expected.to have_db_column(:last_sign_in_ip) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
end
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_many(:dossiers) }
|
||||
end
|
||||
end
|
|
@ -65,6 +65,7 @@ RSpec.configure do |config|
|
|||
|
||||
config.order = 'random'
|
||||
|
||||
config.include Devise::TestHelpers, type: :view
|
||||
config.include Devise::TestHelpers, type: :controller
|
||||
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
|
|
184
spec/views/backoffice/dossiers/show.html.html_spec.rb
Normal file
184
spec/views/backoffice/dossiers/show.html.html_spec.rb
Normal file
|
@ -0,0 +1,184 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'backoffice/dossiers/show.html.haml', type: :view do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, :with_user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
sign_in create(:gestionnaire)
|
||||
|
||||
assign(:dossier, dossier.decorate)
|
||||
assign(:entreprise, dossier.entreprise.decorate)
|
||||
assign(:etablissement, dossier.etablissement)
|
||||
assign(:procedure, dossier.procedure)
|
||||
assign(:commentaires, dossier.commentaires)
|
||||
end
|
||||
|
||||
context 'sur la rendered admin du dossier' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
it 'la section infos entreprise est présente' do
|
||||
expect(rendered).to have_selector('#infos_entreprise')
|
||||
end
|
||||
|
||||
it 'la section infos dossier est présente' do
|
||||
expect(rendered).to have_selector('#infos_dossier')
|
||||
end
|
||||
|
||||
it 'le numéro de dossier est présent sur la rendered' do
|
||||
expect(rendered).to have_selector('#dossier_id')
|
||||
expect(rendered).to have_content(dossier_id)
|
||||
end
|
||||
|
||||
context 'les liens de modifications sont non présent' do
|
||||
it 'le lien vers carte' do
|
||||
expect(rendered).to_not have_selector('a[id=modif_carte]')
|
||||
end
|
||||
|
||||
it 'le lien vers description' do
|
||||
expect(rendered).to_not have_selector('a[id=modif_description]')
|
||||
end
|
||||
|
||||
it 'le bouton Editer mon dossier n\'est pas present' do
|
||||
expect(rendered).to_not have_css('#maj_infos')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'gestion des etats du dossier' do
|
||||
context 'when dossier have state proposed' do
|
||||
before do
|
||||
dossier.proposed!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Soumis') }
|
||||
|
||||
it 'button Valider le dossier est present' do
|
||||
expect(rendered).to have_css('#action_button')
|
||||
expect(rendered).to have_content('Valider le dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state reply' do
|
||||
before do
|
||||
dossier.reply!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Répondu') }
|
||||
|
||||
it 'button Valider le dossier est present' do
|
||||
expect(rendered).to have_css('#action_button')
|
||||
expect(rendered).to have_content('Valider le dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state update' do
|
||||
before do
|
||||
dossier.updated!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Mis à jour') }
|
||||
|
||||
it 'button Valider le dossier est present' do
|
||||
expect(rendered).to have_css('#action_button')
|
||||
expect(rendered).to have_content('Valider le dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state confirmed' do
|
||||
before do
|
||||
dossier.confirmed!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Validé') }
|
||||
|
||||
it 'button Valider le dossier n\'est pas present' do
|
||||
expect(rendered).not_to have_css('#action_button')
|
||||
expect(rendered).not_to have_content('Valider le dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state deposited' do
|
||||
before do
|
||||
dossier.deposited!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Déposé') }
|
||||
|
||||
it 'button Valider le dossier n\'est pas present' do
|
||||
expect(rendered).not_to have_css('#action_button')
|
||||
expect(rendered).not_to have_content('Valider le dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state processed' do
|
||||
before do
|
||||
dossier.processed!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Traité') }
|
||||
|
||||
it 'button Valider le dossier n\'est pas present' do
|
||||
expect(rendered).not_to have_css('#action_button')
|
||||
expect(rendered).not_to have_content('Valider le dossier')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#TODO réactiver
|
||||
# context 'la liste des pièces justificatives est présente' do
|
||||
# context 'Attestation MSA' do
|
||||
# let(:id_piece_justificative) { 93 }
|
||||
#
|
||||
# it 'la ligne de la pièce justificative est présente' do
|
||||
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||
# end
|
||||
#
|
||||
# it 'le bouton "Récupérer" est présent' do
|
||||
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_selector("a[href='']")
|
||||
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Récupérer')
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context 'Attestation RDI' do
|
||||
# let(:id_piece_justificative) { 103 }
|
||||
#
|
||||
# it 'la ligne de la pièce justificative est présente' do
|
||||
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||
# end
|
||||
#
|
||||
# it 'le libelle "Pièce manquante" est présent' do
|
||||
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Pièce non fournie')
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context 'Devis' do
|
||||
# let(:id_piece_justificative) { 388 }
|
||||
# let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
|
||||
#
|
||||
# before do
|
||||
# piece_justificative = dossier.pieces_justificatives.where(type_de_piece_justificative_id: 388).first
|
||||
# piece_justificative.content = content
|
||||
# piece_justificative.save!
|
||||
# visit "/admin/dossiers/#{dossier_id}"
|
||||
# end
|
||||
#
|
||||
# it 'la ligne de la pièce justificative est présente' do
|
||||
# expect(rendered).to have_selector("tr[id=piece_justificative_#{id_piece_justificative}]")
|
||||
# end
|
||||
#
|
||||
# it 'le libelle "Consulter" est présent' do
|
||||
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}] a")[:href]).to have_content('piece_justificative_388.pdf')
|
||||
# expect(rendered.find("tr[id=piece_justificative_#{id_piece_justificative}]")).to have_content('Consulter')
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
end
|
|
@ -2,15 +2,19 @@ require 'spec_helper'
|
|||
|
||||
describe 'backoffice/index.html.haml', type: :view do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
let!(:decorated_dossier) { create(:dossier, procedure: procedure).decorate }
|
||||
let!(:decorate_dossier) { create(:dossier, :with_user, procedure: procedure).decorate }
|
||||
before do
|
||||
assign(:dossiers, [decorated_dossier])
|
||||
assign(:dossiers_a_traiter, Dossier.a_traiter.decorate)
|
||||
assign(:dossiers_en_attente, Dossier.en_attente.decorate)
|
||||
assign(:dossiers_termine, Dossier.termine.decorate)
|
||||
|
||||
decorate_dossier.proposed!
|
||||
render
|
||||
end
|
||||
subject { rendered }
|
||||
it { is_expected.to have_css('#backoffice') }
|
||||
it { is_expected.to have_content('Demande de subvention') }
|
||||
it { is_expected.to have_content(procedure.libelle) }
|
||||
it { is_expected.to have_content(decorated_dossier.nom_projet) }
|
||||
it { is_expected.to have_content(decorated_dossier.last_update) }
|
||||
it { is_expected.to have_content(decorate_dossier.nom_projet) }
|
||||
it { is_expected.to have_content(decorate_dossier.state_fr) }
|
||||
it { is_expected.to have_content(decorate_dossier.last_update) }
|
||||
end
|
|
@ -1 +1,14 @@
|
|||
# TODO à écrire
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'dossiers/_infos_dossier.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
|
||||
let(:maj_infos) { 'Mettre à jour les informations' }
|
||||
let(:proposer) { 'Soumettre mon dossier' }
|
||||
|
||||
before do
|
||||
assign(:dossier, dossier.decorate)
|
||||
assign(:commentaires, dossier.commentaires)
|
||||
render
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'dossiers/show.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
|
||||
|
||||
before do
|
||||
assign(:dossier, dossier)
|
||||
|
@ -14,20 +15,20 @@ describe 'dossiers/show.html.haml', type: :view do
|
|||
expect(rendered).to have_css('#dossier_autorisation_donnees')
|
||||
end
|
||||
|
||||
context 'sur la page d\'information d\'un SIRET' do
|
||||
it 'Le formulaire envoie vers /dossiers/:dossier_id en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/dossiers/#{dossier.id}'][method=post]")
|
||||
context "sur la page d'information d'un SIRET" do
|
||||
it 'Le formulaire envoie vers /users/dossiers/:dossier_id en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/users/dossiers'][method=post]")
|
||||
end
|
||||
|
||||
it 'la checkbox d\'information est présente' do
|
||||
it "la checkbox d'information est présente" do
|
||||
expect(rendered).to have_css('#dossier_autorisation_donnees')
|
||||
end
|
||||
|
||||
it 'le texte d\'information des droits est correct' do
|
||||
it "le texte d'information des droits est correct" do
|
||||
expect(rendered).to have_content("J'autorise les organismes publics à vérifier les informations de mon entreprise auprès des administrations concernées. Ces informations resteront strictement confidentielles.")
|
||||
end
|
||||
|
||||
it 'les informations de l\'entreprise sont présents' do
|
||||
it "les informations de l'entreprise sont présents" do
|
||||
expect(rendered).to have_content('Siret')
|
||||
end
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'recapitulatif/show.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
||||
before do
|
||||
assign(:dossier, dossier.decorate)
|
||||
assign(:commentaires, dossier.commentaires)
|
||||
render
|
||||
end
|
||||
# it { expect(rendered).to have_content("Contacter l'administration") }
|
||||
# it { expect(rendered).to include(dossier.mailto.gsub('&','&')) }
|
||||
end
|
16
spec/views/users/dossiers/index.html.haml_spec.rb
Normal file
16
spec/views/users/dossiers/index.html.haml_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/dossiers/index.html.haml', type: :view do
|
||||
|
||||
describe 'list dossiers' do
|
||||
let(:dossier1) { create(:dossier, :with_user).decorate }
|
||||
let(:dossier2) { create(:dossier, :with_user).decorate }
|
||||
before do
|
||||
assign(:dossiers, [dossier1, dossier2])
|
||||
render
|
||||
end
|
||||
subject { rendered }
|
||||
it { expect(subject).to have_content(dossier1.nom_projet) }
|
||||
end
|
||||
|
||||
end
|
39
spec/views/users/recapitulatif/_commentaires_flux_spec.rb
Normal file
39
spec/views/users/recapitulatif/_commentaires_flux_spec.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_procedure, :with_user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
|
||||
let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') }
|
||||
let(:body) { 'Commentaire de test' }
|
||||
|
||||
before do
|
||||
assign(:dossier, dossier.decorate)
|
||||
assign(:commentaires, dossier.commentaires.all.decorate)
|
||||
render
|
||||
end
|
||||
|
||||
context 'Affichage du flux de commentaire' do
|
||||
it 'l\'email du contact est présent' do
|
||||
expect(rendered).to have_selector('span[id=email_contact]')
|
||||
end
|
||||
|
||||
it 'la date du commentaire est présent' do
|
||||
expect(rendered).to have_selector('span[id=created_at]')
|
||||
end
|
||||
|
||||
it 'le corps du commentaire est présent' do
|
||||
expect(rendered).to have_selector('div[class=description][id=body]')
|
||||
end
|
||||
end
|
||||
|
||||
context 'Affichage du formulaire de commentaire' do
|
||||
it 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/commentaire'][method=post]")
|
||||
end
|
||||
|
||||
it 'Champs de texte' do
|
||||
expect(rendered).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]')
|
||||
end
|
||||
end
|
||||
end
|
131
spec/views/users/recapitulatif/show.html.haml_spec.rb
Normal file
131
spec/views/users/recapitulatif/show.html.haml_spec.rb
Normal file
|
@ -0,0 +1,131 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_user, :with_entreprise, :with_procedure) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
assign(:dossier, dossier.decorate)
|
||||
assign(:procedure, dossier.procedure)
|
||||
assign(:commentaires, dossier.commentaires)
|
||||
end
|
||||
|
||||
context 'sur la rendered recapitulative' do
|
||||
context 'test de composition de la page' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it 'la section infos dossier est présente' do
|
||||
expect(rendered).to have_selector('#infos_dossier')
|
||||
end
|
||||
|
||||
it 'le flux de commentaire est présent' do
|
||||
expect(rendered).to have_selector('#commentaires_flux')
|
||||
end
|
||||
|
||||
it 'le numéro de dossier est présent' do
|
||||
expect(rendered).to have_selector('#dossier_id')
|
||||
expect(rendered).to have_content(dossier_id)
|
||||
end
|
||||
|
||||
context 'les liens de modifications' do
|
||||
context 'lien description' do
|
||||
it 'le lien vers description est présent' do
|
||||
expect(rendered).to have_css('#maj_infos')
|
||||
end
|
||||
|
||||
it 'le lien vers description est correct' do
|
||||
expect(rendered).to have_selector("a[id=maj_infos][href='/users/dossiers/#{dossier_id}/description?back_url=recapitulatif']")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'buttons to change dossier state' do
|
||||
context 'when dossier state is draft' do
|
||||
before do
|
||||
dossier.draft!
|
||||
render
|
||||
end
|
||||
|
||||
it 'button Soumettre mon dossier est present' do
|
||||
expect(rendered).to have_css('#action_button')
|
||||
expect(rendered).to have_content('Soumettre mon dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier state is proposed' do
|
||||
before do
|
||||
dossier.proposed!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Soumis') }
|
||||
end
|
||||
|
||||
context 'when dossier state is reply' do
|
||||
before do
|
||||
dossier.reply!
|
||||
render
|
||||
end
|
||||
|
||||
#TODO gestionnaire test
|
||||
it { expect(rendered).to have_content('Répondu') }
|
||||
end
|
||||
|
||||
context 'when dossier state is updated' do
|
||||
before do
|
||||
dossier.updated!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Mis à jour') }
|
||||
end
|
||||
|
||||
context 'when dossier state is confirmed' do
|
||||
before do
|
||||
dossier.confirmed!
|
||||
render
|
||||
end
|
||||
|
||||
it 'button Déposer mon dossier est present' do
|
||||
expect(rendered).to have_css('#action_button')
|
||||
expect(rendered).to have_content('Déposer mon dossier')
|
||||
end
|
||||
|
||||
it 'button Editer mon dossier n\'est plus present' do
|
||||
expect(rendered).not_to have_css('#maj_infos')
|
||||
expect(rendered).not_to have_content('Editer mon dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier state is deposited' do
|
||||
before do
|
||||
dossier.deposited!
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content('Déposé') }
|
||||
|
||||
it 'button Editer mon dossier n\'est plus present' do
|
||||
expect(rendered).not_to have_css('#maj_infos')
|
||||
expect(rendered).not_to have_content('Editer mon dossier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier state is traité' do
|
||||
before do
|
||||
dossier.processed!
|
||||
render
|
||||
end
|
||||
it { expect(rendered).to have_content('Traité') }
|
||||
|
||||
it 'button Editer mon dossier n\'est plus present' do
|
||||
expect(rendered).not_to have_css('#maj_infos')
|
||||
expect(rendered).not_to have_content('Editer mon dossier')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'start/index.html.haml', type: :view do
|
||||
describe 'users/siret/index.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, libelle: 'Demande de subvention') }
|
||||
before do
|
||||
assign(:procedure, procedure)
|
||||
|
@ -13,7 +13,7 @@ describe 'start/index.html.haml', type: :view do
|
|||
|
||||
context 'dans la section professionnel' do
|
||||
it 'le formulaire envoie vers /dossiers en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/dossiers'][method=post]")
|
||||
expect(rendered).to have_selector("form[action='/users/dossiers'][method=post]")
|
||||
end
|
||||
|
||||
it 'le champs "Numéro SIRET" est présent' do
|
Loading…
Reference in a new issue