Merge branch 'develop' of ssh://37.187.249.111:2200/opt/git/tps into develop
Conflicts: app/views/users/recapitulatif/show.html.haml spec/features/recapitulatif_page/_commentaires_flux_spec.rb spec/features/recapitulatif_page/show_page_spec.rb
This commit is contained in:
commit
8693f4194c
80 changed files with 1414 additions and 382 deletions
2
Gemfile
2
Gemfile
|
@ -59,6 +59,8 @@ gem 'chartkick'
|
||||||
|
|
||||||
gem 'logstasher'
|
gem 'logstasher'
|
||||||
|
|
||||||
|
gem "font-awesome-rails"
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'capybara'
|
gem 'capybara'
|
||||||
gem 'factory_girl'
|
gem 'factory_girl'
|
||||||
|
|
|
@ -114,6 +114,8 @@ GEM
|
||||||
faraday (0.9.1)
|
faraday (0.9.1)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
ffi (1.9.6)
|
ffi (1.9.6)
|
||||||
|
font-awesome-rails (4.4.0.0)
|
||||||
|
railties (>= 3.2, < 5.0)
|
||||||
globalid (0.3.5)
|
globalid (0.3.5)
|
||||||
activesupport (>= 4.1.0)
|
activesupport (>= 4.1.0)
|
||||||
haml (4.0.6)
|
haml (4.0.6)
|
||||||
|
@ -339,6 +341,7 @@ DEPENDENCIES
|
||||||
devise
|
devise
|
||||||
draper
|
draper
|
||||||
factory_girl
|
factory_girl
|
||||||
|
font-awesome-rails
|
||||||
haml-rails
|
haml-rails
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
|
@ -372,3 +375,6 @@ DEPENDENCIES
|
||||||
unicorn
|
unicorn
|
||||||
web-console (~> 2.0)
|
web-console (~> 2.0)
|
||||||
webmock
|
webmock
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
1.10.4
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*= require_self
|
*= require_self
|
||||||
*= require bootstrap-datepicker3
|
*= require bootstrap-datepicker3
|
||||||
*= require leaflet
|
*= require leaflet
|
||||||
|
*= require font-awesome
|
||||||
*/
|
*/
|
||||||
@import "bootstrap-sprockets";
|
@import "bootstrap-sprockets";
|
||||||
@import "bootstrap";
|
@import "bootstrap";
|
||||||
|
|
|
@ -14,12 +14,8 @@ class Backoffice::DossiersController < ApplicationController
|
||||||
|
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
redirect_start
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
|
redirect_to url_for(controller: '/backoffice')
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def redirect_start
|
|
||||||
redirect_to url_for(controller: '/start', action: :error_dossier)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ class CarteController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@dossier = current_dossier
|
@dossier = current_dossier
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
redirect_to url_for(controller: :siret, action: :error_dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_ref_api_carto
|
def save_ref_api_carto
|
||||||
|
|
|
@ -1,69 +1,73 @@
|
||||||
class DossiersController < ApplicationController
|
class DossiersController < ApplicationController
|
||||||
def show
|
# def show
|
||||||
@dossier = Dossier.find(params[:id])
|
# @dossier = Dossier.find(params[:id])
|
||||||
|
|
||||||
@etablissement = @dossier.etablissement
|
# @etablissement = @dossier.etablissement
|
||||||
@entreprise = @dossier.entreprise.decorate
|
# @entreprise = @dossier.entreprise.decorate
|
||||||
rescue ActiveRecord::RecordNotFound
|
# rescue ActiveRecord::RecordNotFound
|
||||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
# flash.alert = t('errors.messages.dossier_not_found')
|
||||||
end
|
# redirect_to url_for(controller: :siret)
|
||||||
|
# end
|
||||||
|
|
||||||
def create
|
# def create
|
||||||
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
# procedure = Procedure.find(params['procedure_id'])
|
||||||
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
# @etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
|
||||||
@dossier = Dossier.create
|
# @entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
|
||||||
@dossier.draft!
|
# @dossier = Dossier.create
|
||||||
|
# @dossier.draft!
|
||||||
|
|
||||||
@dossier.procedure = Procedure.find(params['procedure_id'])
|
# @dossier.procedure = procedure
|
||||||
@dossier.save
|
# @dossier.save
|
||||||
|
|
||||||
@entreprise.dossier = @dossier
|
# @entreprise.dossier = @dossier
|
||||||
@entreprise.save
|
# @entreprise.save
|
||||||
|
|
||||||
@etablissement.dossier = @dossier
|
# @etablissement.dossier = @dossier
|
||||||
@etablissement.entreprise = @entreprise
|
# @etablissement.entreprise = @entreprise
|
||||||
@etablissement.save
|
# @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
|
# rescue RestClient::ResourceNotFound
|
||||||
redirect_to url_for(controller: :start, action: :error_siret, procedure_id: params['procedure_id'])
|
# flash.alert = t('errors.messages.invalid_siret')
|
||||||
rescue ActiveRecord::RecordNotFound
|
# redirect_to url_for(controller: :siret, procedure_id: params['procedure_id'])
|
||||||
redirect_to url_for(controller: :start, action: :error_dossier)
|
# rescue ActiveRecord::RecordNotFound
|
||||||
end
|
# flash.alert = t('errors.messages.dossier_not_found')
|
||||||
|
# redirect_to url_for(controller: :siret)
|
||||||
|
# end
|
||||||
|
|
||||||
def update
|
# def update
|
||||||
@dossier = Dossier.find(params[:id])
|
# @dossier = Dossier.find(params[:id])
|
||||||
if checked_autorisation_donnees?
|
# if checked_autorisation_donnees?
|
||||||
@dossier.update_attributes(update_params)
|
# @dossier.update_attributes(update_params)
|
||||||
redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
|
# redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
|
||||||
else
|
# else
|
||||||
@etablissement = @dossier.etablissement
|
# @etablissement = @dossier.etablissement
|
||||||
@entreprise = @dossier.entreprise.decorate
|
# @entreprise = @dossier.entreprise.decorate
|
||||||
flash.now.alert = 'Les conditions sont obligatoires.'
|
# flash.now.alert = 'Les conditions sont obligatoires.'
|
||||||
render 'show'
|
# render 'show'
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
private
|
# private
|
||||||
|
|
||||||
def update_params
|
# def update_params
|
||||||
params.require(:dossier).permit(:autorisation_donnees)
|
# params.require(:dossier).permit(:autorisation_donnees)
|
||||||
end
|
# end
|
||||||
|
|
||||||
def dossier_id_is_present?
|
# def dossier_id_is_present?
|
||||||
@dossier_id != ''
|
# @dossier_id != ''
|
||||||
end
|
# end
|
||||||
|
|
||||||
def checked_autorisation_donnees?
|
# def checked_autorisation_donnees?
|
||||||
update_params[:autorisation_donnees] == '1'
|
# update_params[:autorisation_donnees] == '1'
|
||||||
end
|
# end
|
||||||
|
|
||||||
def siret
|
# def siret
|
||||||
params[:siret]
|
# params[:siret]
|
||||||
end
|
# end
|
||||||
|
|
||||||
def siren
|
# def siren
|
||||||
siret[0..8]
|
# siret[0..8]
|
||||||
end
|
# end
|
||||||
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
|
||||||
|
|
||||||
|
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
|
def show
|
||||||
@dossier = Dossier.find(params[:dossier_id])
|
@dossier = Dossier.find(params[:dossier_id])
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
|
@ -6,7 +6,8 @@ class DescriptionController < ApplicationController
|
||||||
@procedure = @dossier.procedure
|
@procedure = @dossier.procedure
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
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
|
end
|
||||||
|
|
||||||
def error
|
def error
|
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 = Dossier.all.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
|
||||||
|
@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
|
|
@ -1,5 +1,6 @@
|
||||||
class RecapitulatifController < ApplicationController
|
class Users::RecapitulatifController < UsersController
|
||||||
def show
|
def show
|
||||||
|
|
||||||
@dossier = Dossier.find(params[:dossier_id])
|
@dossier = Dossier.find(params[:dossier_id])
|
||||||
@dossier = @dossier.decorate
|
@dossier = @dossier.decorate
|
||||||
@procedure = @dossier.procedure
|
@procedure = @dossier.procedure
|
||||||
|
@ -12,6 +13,7 @@ class RecapitulatifController < ApplicationController
|
||||||
#TODO load user email
|
#TODO load user email
|
||||||
@commentaire_email = 'user@email'
|
@commentaire_email = 'user@email'
|
||||||
rescue ActiveRecord::RecordNotFound
|
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
|
end
|
||||||
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
|
|
@ -12,6 +12,7 @@ class Dossier < ActiveRecord::Base
|
||||||
has_one :cerfa
|
has_one :cerfa
|
||||||
has_many :pieces_justificatives
|
has_many :pieces_justificatives
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
|
belongs_to :user
|
||||||
has_many :commentaires
|
has_many :commentaires
|
||||||
|
|
||||||
delegate :siren, to: :entreprise
|
delegate :siren, to: :entreprise
|
||||||
|
|
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
|
|
@ -16,7 +16,7 @@
|
||||||
=render partial: '/dossiers/pieces_justificatives'
|
=render partial: '/dossiers/pieces_justificatives'
|
||||||
%br
|
%br
|
||||||
|
|
||||||
= render partial: '/recapitulatif/commentaires_flux'
|
= render partial: '/users/recapitulatif/commentaires_flux'
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
|
|
||||||
|
|
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
|
= render partial: 'show'
|
||||||
%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'
|
|
|
@ -17,6 +17,11 @@
|
||||||
%div{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
%div{style: 'decorate:none; box-shadow:none; float:right; margin-top:8px'}
|
||||||
= current_gestionnaire.email
|
= current_gestionnaire.email
|
||||||
= link_to "Déconnexion", '/gestionnaires/sign_out', method: :delete, :class => 'btn btn-md'
|
= 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
|
#flash_message.center
|
||||||
- if flash.notice
|
- if flash.notice
|
||||||
|
|
|
@ -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" %>
|
10
app/views/users/dossiers/index.html.haml
Normal file
10
app/views/users/dossiers/index.html.haml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
%h1 Vos dossiers :
|
||||||
|
|
||||||
|
%table.table
|
||||||
|
%thead
|
||||||
|
%th Nom du Projet
|
||||||
|
%th Mise à jour
|
||||||
|
- @dossiers.each do |dossier|
|
||||||
|
%tr
|
||||||
|
%td= dossier.nom_projet
|
||||||
|
%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" %>
|
25
app/views/users/recapitulatif/show.html.haml
Normal file
25
app/views/users/recapitulatif/show.html.haml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
%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}"
|
||||||
|
-#%h3{:class => 'text-success', :style => 'text-align:right'}
|
||||||
|
-# = @dossier.state_fr
|
||||||
|
- unless gestionnaire_signed_in?
|
||||||
|
%button#action_button.btn.btn-success
|
||||||
|
= 'Soumettre mon dossier'
|
||||||
|
|
||||||
|
%div{style: 'text-align:center'}
|
||||||
|
-if (request.referer != nil) && (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif')
|
||||||
|
%h3.text-success Félicitation, votre demande a bien été enregistrée.
|
||||||
|
|
||||||
|
%br
|
||||||
|
|
||||||
|
= render partial: '/dossiers/infos_dossier'
|
||||||
|
%br
|
||||||
|
= render partial: 'commentaires_flux'
|
29
app/views/users/recapitulatif/show.html_BACKUP_4662.haml
Normal file
29
app/views/users/recapitulatif/show.html_BACKUP_4662.haml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<<<<<<< HEAD:app/views/recapitulatif/show.html.haml
|
||||||
|
%div.row
|
||||||
|
%div.col-md-2.col-lg-2
|
||||||
|
%h2
|
||||||
|
='Récapitulatif'
|
||||||
|
=======
|
||||||
|
%h2#recap_dossier Récapitulatif
|
||||||
|
>>>>>>> 6eeac88c95dce079195f596e05a7e652fd9720c9:app/views/users/recapitulatif/show.html.haml
|
||||||
|
|
||||||
|
%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}"
|
||||||
|
-#%h3{:class => 'text-success', :style => 'text-align:right'}
|
||||||
|
-# = @dossier.state_fr
|
||||||
|
- unless gestionnaire_signed_in?
|
||||||
|
%button#action_button.btn.btn-success
|
||||||
|
= 'Soumettre mon dossier'
|
||||||
|
|
||||||
|
%div{style: 'text-align:center'}
|
||||||
|
-if (request.referer != nil) && (request.referer.include?'/description') && !(request.referer.include?'back_url=recapitulatif')
|
||||||
|
%h3.text-success Félicitation, votre demande a bien été enregistrée.
|
||||||
|
|
||||||
|
%br
|
||||||
|
|
||||||
|
= render partial: '/dossiers/infos_dossier'
|
||||||
|
%br
|
||||||
|
= render partial: 'commentaires_flux'
|
24
app/views/users/recapitulatif/show.html_BASE_4662.haml
Normal file
24
app/views/users/recapitulatif/show.html_BASE_4662.haml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
%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'
|
23
app/views/users/recapitulatif/show.html_REMOTE_4662.haml
Normal file
23
app/views/users/recapitulatif/show.html_REMOTE_4662.haml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
%h2#recap_dossier 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'
|
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.
|
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
|
.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:
|
not_saved:
|
||||||
one: "1 erreur a empêché ce(tte) %{resource} d'être sauvegardé(e) :"
|
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) :"
|
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,35 +1,50 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
|
devise_for :users, controllers: {
|
||||||
|
sessions: 'users/sessions'
|
||||||
|
}
|
||||||
|
|
||||||
devise_for :gestionnaires, controllers: {
|
devise_for :gestionnaires, controllers: {
|
||||||
sessions: 'gestionnaires/sessions'
|
sessions: 'gestionnaires/sessions'
|
||||||
|
|
||||||
}, skip: [:password, :registrations]
|
}, skip: [:password, :registrations]
|
||||||
|
|
||||||
|
|
||||||
root 'start#index'
|
# root 'welcome#index'
|
||||||
|
root 'users/dossiers#index'
|
||||||
|
|
||||||
get 'start/index'
|
namespace :users do
|
||||||
get 'start/error_siret'
|
get 'siret' => 'siret#index'
|
||||||
get 'start/error_login'
|
resources :dossiers do
|
||||||
get 'start/error_dossier'
|
get '/description' => 'description#show'
|
||||||
|
get '/description/error' => 'description#error'
|
||||||
|
post 'description' => 'description#create'
|
||||||
|
get '/recapitulatif' => 'recapitulatif#show'
|
||||||
|
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
|
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'
|
get 'backoffice' => 'backoffice#index'
|
||||||
|
|
||||||
namespace :backoffice do
|
namespace :backoffice do
|
||||||
|
|
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.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -46,10 +46,12 @@ ActiveRecord::Schema.define(version: 20150922141000) do
|
||||||
t.date "date_previsionnelle"
|
t.date "date_previsionnelle"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "state"
|
t.string "state"
|
||||||
|
t.integer "user_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
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|
|
create_table "entreprises", force: :cascade do |t|
|
||||||
t.string "siren"
|
t.string "siren"
|
||||||
|
@ -130,6 +132,25 @@ ActiveRecord::Schema.define(version: 20150922141000) do
|
||||||
t.integer "procedure_id"
|
t.integer "procedure_id"
|
||||||
end
|
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 "cerfas", "dossiers"
|
||||||
add_foreign_key "commentaires", "dossiers"
|
add_foreign_key "commentaires", "dossiers"
|
||||||
|
add_foreign_key "dossiers", "users"
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe Backoffice::DossiersController, type: :controller do
|
||||||
|
|
||||||
it "le numéro de dossier n'existe pas" do
|
it "le numéro de dossier n'existe pas" do
|
||||||
get :show, id: bad_dossier_id
|
get :show, id: bad_dossier_id
|
||||||
expect(response).to redirect_to('/start/error_dossier')
|
expect(response).to redirect_to('/backoffice')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe CommentairesController, type: :controller do
|
describe Users::CommentairesController, type: :controller do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:email_commentaire) { 'test@test.com' }
|
let(:email_commentaire) { 'test@test.com' }
|
||||||
|
@ -10,7 +10,7 @@ describe CommentairesController, type: :controller do
|
||||||
context 'création correct d\'un commentaire' do
|
context 'création correct d\'un commentaire' do
|
||||||
it 'depuis la page récapitulatif' do
|
it 'depuis la page récapitulatif' do
|
||||||
post :create, dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe DescriptionController, type: :controller do
|
describe Users::DescriptionController, type: :controller do
|
||||||
let(:dossier) { create(:dossier, :with_procedure) }
|
let(:dossier) { create(:dossier, :with_procedure) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:bad_dossier_id) { Dossier.count + 10 }
|
let(:bad_dossier_id) { Dossier.count + 10 }
|
||||||
|
@ -13,7 +13,7 @@ describe DescriptionController, type: :controller do
|
||||||
|
|
||||||
it 'redirection vers start si mauvais dossier ID' do
|
it 'redirection vers start si mauvais dossier ID' do
|
||||||
get :show, dossier_id: bad_dossier_id
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ describe DescriptionController, type: :controller do
|
||||||
# TODO separer en deux tests : check donnees et check redirect
|
# TODO separer en deux tests : check donnees et check redirect
|
||||||
it 'Premier enregistrement des données' do
|
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
|
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
|
end
|
||||||
|
|
||||||
# TODO changer les valeurs des champs et check in bdd
|
# TODO changer les valeurs des champs et check in bdd
|
||||||
|
@ -63,7 +63,7 @@ describe DescriptionController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Redirection vers la page récapitulatif' do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,119 +1,124 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
RSpec.describe DossiersController, type: :controller do
|
describe DossiersController, type: :controller do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
# let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||||
let(:dossier_id) { dossier.id }
|
# let(:procedure) { create(:procedure) }
|
||||||
let(:siret_not_found) { 999_999_999_999 }
|
# let(:dossier_id) { dossier.id }
|
||||||
|
# let(:siret_not_found) { 999_999_999_999 }
|
||||||
|
|
||||||
let(:siren) { dossier.siren }
|
# let(:siren) { dossier.siren }
|
||||||
let(:siret) { dossier.siret }
|
# let(:siret) { dossier.siret }
|
||||||
let(:bad_siret) { 1 }
|
# let(:bad_siret) { 1 }
|
||||||
|
|
||||||
describe 'GET #show' do
|
# describe 'GET #show' do
|
||||||
it 'returns http success with dossier_id valid' do
|
# it 'returns http success with dossier_id valid' do
|
||||||
get :show, id: dossier_id
|
# get :show, id: dossier_id
|
||||||
expect(response).to have_http_status(:success)
|
# expect(response).to have_http_status(:success)
|
||||||
end
|
# end
|
||||||
|
|
||||||
it 'redirection vers start si mauvais dossier ID' do
|
# it 'redirection vers siret si mauvais dossier ID' do
|
||||||
get :show, id: siret_not_found
|
# get :show, id: siret_not_found
|
||||||
expect(response).to redirect_to('/start/error_dossier')
|
# expect(response).to redirect_to('/siret')
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
describe 'POST #create' do
|
# describe 'POST #create' do
|
||||||
before do
|
# before do
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
|
# stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
|
||||||
.to_return(status: 404, body: 'fake body')
|
# .to_return(status: 404, body: 'fake body')
|
||||||
|
|
||||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
# 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'))
|
# .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}")
|
# 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'))
|
# .to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||||
end
|
# end
|
||||||
|
|
||||||
describe 'professionnel fills form' do
|
# describe 'professionnel fills form' do
|
||||||
context 'when pro_dossier_id is empty' do
|
# context 'when pro_dossier_id is empty' do
|
||||||
context 'with valid siret ' do
|
# context 'with valid siret ' do
|
||||||
before do
|
|
||||||
post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'create a dossier' do
|
# subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
|
||||||
expect { post :create, siret: siret, pro_dossier_id: '' }.to change { Dossier.count }.by(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
# it 'create a dossier' do
|
||||||
expect(Entreprise.last.dossier).to eq(Dossier.last)
|
# expect { subject }.to change { Dossier.count }.by(1)
|
||||||
end
|
# end
|
||||||
|
|
||||||
it 'creates etablissement for dossier' do
|
# it 'creates entreprise' do
|
||||||
expect { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }.to change { Etablissement.count }.by(1)
|
# expect { subject }.to change { Entreprise.count }.by(1)
|
||||||
end
|
# end
|
||||||
|
|
||||||
it 'links etablissement to dossier' do
|
# it 'links entreprise to dossier' do
|
||||||
expect(Etablissement.last.dossier).to eq(Dossier.last)
|
# expect(Entreprise.last.dossier).to eq(Dossier.last)
|
||||||
end
|
# end
|
||||||
|
|
||||||
it 'links etablissement to entreprise' do
|
# it 'creates etablissement for dossier' do
|
||||||
expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
# expect { subject }.to change { Etablissement.count }.by(1)
|
||||||
end
|
# end
|
||||||
|
|
||||||
it 'links procedure to dossier' do
|
# it 'links etablissement to dossier' do
|
||||||
expect(Dossier.last.procedure).to eq(Procedure.last)
|
# subject
|
||||||
end
|
# expect(Etablissement.last.dossier).to eq(Dossier.last)
|
||||||
|
# end
|
||||||
|
|
||||||
it 'state of dossier is draft' do
|
# it 'links etablissement to entreprise' do
|
||||||
expect(Dossier.last.state).to eq('draft')
|
# subject
|
||||||
end
|
# expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
||||||
end
|
# end
|
||||||
|
|
||||||
context 'with non existant siret' do
|
# it 'links procedure to dossier' do
|
||||||
let(:siret_not_found) { '11111111111111' }
|
# subject
|
||||||
subject { post :create, siret: siret_not_found, pro_dossier_id: '' }
|
# expect(Dossier.last.procedure).to eq(Procedure.last)
|
||||||
it 'does not create new dossier' do
|
# end
|
||||||
expect { subject }.not_to change { Dossier.count }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'redirects to show' do
|
# it 'state of dossier is draft' do
|
||||||
expect(subject).to redirect_to(controller: :start, action: :error_siret)
|
# subject
|
||||||
end
|
# expect(Dossier.last.state).to eq('draft')
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'PUT #update' do
|
# context 'with non existant siret' do
|
||||||
before do
|
# let(:siret_not_found) { '11111111111111' }
|
||||||
put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
# subject { post :create, siret: siret_not_found, pro_dossier_id: '', procedure_id: procedure.id }
|
||||||
end
|
# it 'does not create new dossier' do
|
||||||
context 'when Checkbox is checked' do
|
# expect { subject }.not_to change { Dossier.count }
|
||||||
let(:autorisation_donnees) { '1' }
|
# end
|
||||||
it 'redirects to demande' do
|
|
||||||
expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'update dossier' do
|
# it 'redirects to show' do
|
||||||
dossier.reload
|
# expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
|
||||||
expect(dossier.autorisation_donnees).to be_truthy
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
context 'when Checkbox is not checked' do
|
# describe 'PUT #update' do
|
||||||
let(:autorisation_donnees) { '0' }
|
# before do
|
||||||
it 'uses flash alert to display message' do
|
# put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
||||||
expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
|
# end
|
||||||
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
|
# it 'update dossier' do
|
||||||
dossier.reload
|
# dossier.reload
|
||||||
expect(dossier.autorisation_donnees).to be_falsy
|
# expect(dossier.autorisation_donnees).to be_truthy
|
||||||
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
|
||||||
|
|
||||||
|
# it "doesn't update dossier autorisation_donnees" do
|
||||||
|
# dossier.reload
|
||||||
|
# expect(dossier.autorisation_donnees).to be_falsy
|
||||||
|
# end
|
||||||
|
# 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
|
|
148
spec/controllers/users/dossiers_controller_spec.rb
Normal file
148
spec/controllers/users/dossiers_controller_spec.rb
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Users::DossiersController, type: :controller do
|
||||||
|
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) }
|
||||||
|
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
|
||||||
|
context 'when pro_dossier_id is empty' do
|
||||||
|
context 'with valid siret ' do
|
||||||
|
before do
|
||||||
|
sign_in create(: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
|
||||||
|
expect(Entreprise.last.dossier).to eq(Dossier.last)
|
||||||
|
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
|
22
spec/controllers/users/recapitulatif_controller_spec.rb
Normal file
22
spec/controllers/users/recapitulatif_controller_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Users::RecapitulatifController, type: :controller do
|
||||||
|
let(:dossier) { create(:dossier, :with_user) }
|
||||||
|
|
||||||
|
let(:bad_dossier_id) { Dossier.count + 100000 }
|
||||||
|
|
||||||
|
describe 'GET #show' do
|
||||||
|
before do
|
||||||
|
sign_in dossier.user
|
||||||
|
end
|
||||||
|
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
|
||||||
|
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
|
|
@ -17,5 +17,11 @@ FactoryGirl.define do
|
||||||
dossier.procedure = procedure
|
dossier.procedure = procedure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :with_user do
|
||||||
|
after(:build) do |dossier, _evaluator|
|
||||||
|
dossier.user = create(:user)
|
||||||
|
end
|
||||||
|
end
|
||||||
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
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||||
feature 'On the description page' do
|
feature 'On the description page' do
|
||||||
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||||
before do
|
before do
|
||||||
visit dossier_description_path dossier
|
visit users_dossier_description_path dossier
|
||||||
end
|
end
|
||||||
scenario 'date_previsionnelle field is present' do
|
scenario 'date_previsionnelle field is present' do
|
||||||
expect(page).to have_css('#date_previsionnelle')
|
expect(page).to have_css('#date_previsionnelle')
|
||||||
|
|
|
@ -5,12 +5,12 @@ feature 'Description#Show Page' do
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
visit "/dossiers/#{dossier_id}/description"
|
visit users_dossier_description_path(dossier_id: dossier_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'tous les attributs sont présents sur la page' do
|
context 'tous les attributs sont présents sur la page' do
|
||||||
scenario 'Le formulaire envoie vers /dossiers/:dossier_id/description en #POST' do
|
scenario 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do
|
||||||
expect(page).to have_selector("form[action='/dossiers/#{dossier_id}/description'][method=post]")
|
expect(page).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Nom du projet' do
|
scenario 'Nom du projet' do
|
||||||
|
@ -62,7 +62,7 @@ feature 'Description#Show Page' do
|
||||||
|
|
||||||
context 'si la page précédente est recapitularif' do
|
context 'si la page précédente est recapitularif' do
|
||||||
before do
|
before do
|
||||||
visit "/dossiers/#{dossier_id}/description?back_url=recapitulatif"
|
visit "/users/dossiers/#{dossier_id}/description?back_url=recapitulatif"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'le bouton "Terminer" n\'est pas présent' do
|
scenario 'le bouton "Terminer" n\'est pas présent' do
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
||||||
feature 'user is on description page' do
|
feature 'user is on description page' do
|
||||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||||
before do
|
before do
|
||||||
visit dossier_description_path dossier
|
visit users_dossier_description_path dossier
|
||||||
end
|
end
|
||||||
it { expect(page).to have_css('#description_page') }
|
it { expect(page).to have_css('#description_page') }
|
||||||
|
|
||||||
|
|
38
spec/features/recapitulatif_page/_commentaires_flux_spec.rb
Normal file
38
spec/features/recapitulatif_page/_commentaires_flux_spec.rb
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature '_Commentaires_Flux Recapitulatif#Show Page' do
|
||||||
|
let(:dossier) { create(:dossier, :with_user, :with_procedure) }
|
||||||
|
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
|
||||||
|
login_as(dossier.user, scope: :user)
|
||||||
|
visit "/users/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_css('#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_css('.description#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='/users/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
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,12 +1,13 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature 'Recapitulatif#Show Page' do
|
feature 'Recapitulatif#Show Page' do
|
||||||
let(:dossier) { create(:dossier, :with_procedure) }
|
let(:dossier) { create(:dossier, :with_user, :with_procedure) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Capybara.current_session.driver.header('Referer', '/description')
|
Capybara.current_session.driver.header('Referer', '/description')
|
||||||
visit "/dossiers/#{dossier_id}/recapitulatif"
|
login_as(dossier.user, :scope => :user)
|
||||||
|
visit "/users/dossiers/#{dossier_id}/recapitulatif"
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'sur la page recapitulative' do
|
context 'sur la page recapitulative' do
|
||||||
|
@ -42,14 +43,14 @@ feature 'Recapitulatif#Show Page' do
|
||||||
|
|
||||||
scenario 'N\'est pas affiché quand l\'on vient d\'une autre la page que description' do
|
scenario 'N\'est pas affiché quand l\'on vient d\'une autre la page que description' do
|
||||||
Capybara.current_session.driver.header('Referer', '/')
|
Capybara.current_session.driver.header('Referer', '/')
|
||||||
visit "/dossiers/#{dossier_id}/recapitulatif"
|
visit "/users/dossiers/#{dossier_id}/recapitulatif"
|
||||||
|
|
||||||
expect(page).to_not have_content('Félicitation')
|
expect(page).to_not have_content('Félicitation')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'N\'est pas affiché quand l\'on vient de la page description en modification' do
|
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')
|
Capybara.current_session.driver.header('Referer', '/description?back_url=recapitulatif')
|
||||||
visit "/dossiers/#{dossier_id}/recapitulatif"
|
visit "/users/dossiers/#{dossier_id}/recapitulatif"
|
||||||
|
|
||||||
expect(page).to_not have_content('Félicitation')
|
expect(page).to_not have_content('Félicitation')
|
||||||
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
|
16
spec/features/users/list_dossiers_spec.rb
Normal file
16
spec/features/users/list_dossiers_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'user access to the list of his dossier' do
|
||||||
|
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
let!(:dossier1) { create(: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)
|
||||||
|
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
|
|
@ -21,6 +21,7 @@ describe Dossier do
|
||||||
it { is_expected.to have_one(:cerfa) }
|
it { is_expected.to have_one(:cerfa) }
|
||||||
it { is_expected.to have_one(:etablissement) }
|
it { is_expected.to have_one(:etablissement) }
|
||||||
it { is_expected.to have_one(:entreprise) }
|
it { is_expected.to have_one(:entreprise) }
|
||||||
|
it { is_expected.to belong_to(:user) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'delegation' do
|
describe 'delegation' do
|
||||||
|
|
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
|
|
@ -14,20 +14,20 @@ describe 'dossiers/show.html.haml', type: :view do
|
||||||
expect(rendered).to have_css('#dossier_autorisation_donnees')
|
expect(rendered).to have_css('#dossier_autorisation_donnees')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'sur la page d\'information d\'un SIRET' do
|
context "sur la page d'information d'un SIRET" do
|
||||||
it 'Le formulaire envoie vers /dossiers/:dossier_id en #POST' do
|
it 'Le formulaire envoie vers /users/dossiers/:dossier_id en #POST' do
|
||||||
expect(rendered).to have_selector("form[action='/dossiers/#{dossier.id}'][method=post]")
|
expect(rendered).to have_selector("form[action='/users/dossiers'][method=post]")
|
||||||
end
|
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')
|
expect(rendered).to have_css('#dossier_autorisation_donnees')
|
||||||
end
|
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.")
|
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
|
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')
|
expect(rendered).to have_content('Siret')
|
||||||
end
|
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).decorate }
|
||||||
|
let(:dossier2) { create(:dossier).decorate }
|
||||||
|
before do
|
||||||
|
assign(:dossiers, [dossier1, dossier2])
|
||||||
|
render
|
||||||
|
end
|
||||||
|
subject { rendered }
|
||||||
|
it { expect(subject).to have_content(dossier1.nom_projet) }
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'recapitulatif/_commentaires_flux.html.haml', type: :view do
|
describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier, :with_procedure) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
|
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
|
||||||
let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') }
|
let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') }
|
||||||
|
@ -29,7 +29,7 @@ describe 'recapitulatif/_commentaires_flux.html.haml', type: :view do
|
||||||
|
|
||||||
context 'Affichage du formulaire de commentaire' do
|
context 'Affichage du formulaire de commentaire' do
|
||||||
it 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do
|
it 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do
|
||||||
expect(rendered).to have_selector("form[action='/dossiers/#{dossier_id}/commentaire'][method=post]")
|
expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/commentaire'][method=post]")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'Champs de texte' do
|
it 'Champs de texte' do
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
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') }
|
let(:procedure) { create(:procedure, libelle: 'Demande de subvention') }
|
||||||
before do
|
before do
|
||||||
assign(:procedure, procedure)
|
assign(:procedure, procedure)
|
||||||
|
@ -13,7 +13,7 @@ describe 'start/index.html.haml', type: :view do
|
||||||
|
|
||||||
context 'dans la section professionnel' do
|
context 'dans la section professionnel' do
|
||||||
it 'le formulaire envoie vers /dossiers en #POST' 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
|
end
|
||||||
|
|
||||||
it 'le champs "Numéro SIRET" est présent' do
|
it 'le champs "Numéro SIRET" est présent' do
|
Loading…
Reference in a new issue