Merge branch 'develop' of github.com:sgmap/tps into develop

Conflicts:
	.gitignore
This commit is contained in:
Tanguy PATTE 2016-01-12 15:32:13 +01:00
commit 0df5324891
106 changed files with 1687 additions and 636 deletions

4
.gitignore vendored
View file

@ -22,10 +22,12 @@
*.iws
public/uploads
public/downloads
bin/*
config/initializers/token.rb
doc/*.svg
rubocop.html
config/france_connect.yml
vendor/**/*
uploads/*
uploads/*

View file

@ -72,6 +72,8 @@ gem 'hashie'
gem 'mailjet'
gem "smart_listing"
group :test do
gem 'capybara'
gem 'factory_girl'
@ -88,6 +90,9 @@ group :test do
end
group :development, :test do
gem 'terminal-notifier'
gem 'terminal-notifier-guard'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'pry-byebug'

View file

@ -178,6 +178,9 @@ GEM
multi_json (>= 1.3)
securecompare
url_safe_base64
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.3)
leaflet-draw-rails (0.1.0)
leaflet-markercluster-rails (0.7.0)
@ -363,6 +366,11 @@ GEM
simplecov-html (~> 0.8.0)
simplecov-html (0.8.0)
slop (3.6.0)
smart_listing (1.1.2)
coffee-rails
jquery-rails
kaminari (~> 0.16.1)
rails (>= 3.2)
spring (1.3.6)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
@ -378,6 +386,8 @@ GEM
httpclient (>= 2.4)
i18n
json (>= 1.4.3)
terminal-notifier (1.6.3)
terminal-notifier-guard (1.6.4)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
@ -480,8 +490,11 @@ DEPENDENCIES
sentry-raven
shoulda-matchers
simplecov
smart_listing
spring
spring-commands-rspec
terminal-notifier
terminal-notifier-guard
therubyracer
timecop
turbolinks

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -24,3 +24,5 @@
//= require concavehull.min
//= require graham_scan.min
//= require leaflet.freedraw
//= require smart_listing
//= require franceconnect_kit

View file

@ -0,0 +1,133 @@
$(document).on('page:load', franceconnect_kit);
$(document).ready(franceconnect_kit);
function franceconnect_kit() {
init_franceconnect_kit();
}
var fconnect = {
tracesUrl: '/traces',
aboutUrl: ''
};
function init_franceconnect_kit() {
initCurrentHostnameSource();
includeFCCss();
var fconnectProfile = document.getElementById('fconnect-profile');
if (fconnectProfile) {
var fcLogoutUrl = fconnectProfile.getAttribute('data-fc-logout-url');
var access = createFCAccessElement(fcLogoutUrl);
fconnectProfile.parentNode.appendChild(access);
fconnectProfile.onclick = toogleElement.bind(access);
}
}
function initCurrentHostnameSource() {
var currentScript = 'https://fcp.integ01.dev-franceconnect.fr/js/franceconnect.js';
var parseUrl = currentScript.split('/');
fconnect.currentHost = parseUrl[2];
}
function includeFCCss() {
var linkCss = document.createElement('link');
linkCss.rel = 'stylesheet';
linkCss.href = '//' + fconnect.currentHost + '/stylesheets/franceconnect.css';
linkCss.type = 'text/css';
linkCss.media = 'screen';
document.getElementsByTagName('head')[0].appendChild(linkCss);
}
function toogleElement(event) {
event.preventDefault();
if (this.style.display === "block") {
this.style.display = "none";
} else {
this.style.display = "block";
}
}
function closeFCPopin(event) {
event.preventDefault();
fconnect.popin.className = 'fade-out';
setTimeout(function() {
document.body.removeChild(fconnect.popin);
}, 200);
}
function openFCPopin() {
fconnect.popin = document.createElement('div');
fconnect.popin.id = 'fc-background';
var iframe = createFCIframe();
document.body.appendChild(fconnect.popin);
fconnect.popin.appendChild(iframe);
setTimeout(function() {
fconnect.popin.className = 'fade-in';
}, 200);
}
function createFCIframe() {
var iframe = document.createElement("iframe");
iframe.setAttribute('id', 'fconnect-iframe');
iframe.frameBorder = 0;
iframe.name = 'fconnect-iframe';
return iframe;
}
function createFCAccessElement(logoutUrl) {
var access = document.createElement('div');
access.id = 'fconnect-access';
access.innerHTML = '<h5>Vous êtes identifié grâce à FranceConnect</h5>';
access.appendChild(createAboutLink());
access.appendChild(document.createElement('hr'));
access.appendChild(createHistoryLink());
access.appendChild(createLogoutElement(logoutUrl));
return access;
}
function createHistoryLink() {
var historyLink = document.createElement('a');
historyLink.target = 'fconnect-iframe';
historyLink.href = '//' + fconnect.currentHost + fconnect.tracesUrl;
historyLink.onclick = openFCPopin;
historyLink.innerHTML = 'Historique des connexions/échanges de données';
return historyLink;
}
function createAboutLink() {
var aboutLink = document.createElement('a');
aboutLink.href = fconnect.aboutUrl ? '//' + fconnect.currentHost + fconnect.aboutUrl : '#';
if (fconnect.aboutUrl) {
aboutLink.target = 'fconnect-iframe';
aboutLink.onclick = openFCPopin;
}
aboutLink.innerHTML = 'Qu\'est-ce-que FranceConnect ?';
return aboutLink;
}
function createLogoutElement(logoutUrl) {
var elm = document.createElement('div');
elm.className = 'logout';
elm.innerHTML = '<a class="btn btn-default" href="' + logoutUrl + '">Se déconnecter</a>'
return elm;
}
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
// Listen to message from child window
eventer(messageEvent,function(e) {
var key = e.message ? "message" : "data";
var data = e[key];
if(data === 'close_popup'){
closeFCPopin(e);
}
},false);

View file

@ -61,7 +61,7 @@ body {
box-shadow: none;
float: right;
margin-top: 8px;
margin-right: 80px;
margin-right: 105px;
}
.alert.alert-success,
@ -184,4 +184,35 @@ div.pagination {
.fa {
width: 15px;
text-align: center;
}
.off-fc-link {
font-size: 15px !important;
margin-top: -4px;
}
#fconnect-access {
right: 50px;
}
#fconnect-access:before {
left: 22.7% !important;
}
#fconnect-access:after {
left: 23% !important;
}
#fconnect-profile {
margin-top: 5px;
display: inline-block;
a {
color: #3471A9 !important;
text-decoration: none;
font-size: 16px !important;
margin-right: 0px !important;
}
}

View file

@ -0,0 +1,5 @@
#france_connect_particulier_email{
width: 300px;
margin-left:auto;
margin-right:auto;
}

View file

@ -7,15 +7,12 @@
padding: 20px;
#btn_fc {
margin-top:8%;
background-image: image-url('logo_FC_02.png');
background-repeat: no-repeat;
background-size: 38px;
background-position-x: 5px;
background-position-y: 1px;
}
.btn_fc {
img {
height: 100px;
}
}
#new_user{
width: 80%;
@ -24,7 +21,6 @@
}
hr {
margin-top: 50px;
margin-bottom: 40px;
border: 0;
height: 1px;

View file

@ -1,5 +1,6 @@
class Admin::PiecesJustificativesController < AdminController
before_action :retrieve_procedure
before_action :procedure_locked?
def show
end

View file

@ -1,27 +1,38 @@
class Admin::ProceduresController < AdminController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :retrieve_procedure, only: :edit
before_action :retrieve_procedure, only: [:show, :edit]
before_action :procedure_locked?, only: [:edit]
def index
@procedures = current_administrateur.procedures.where(archived: false)
.paginate(:page => params[:page]).decorate
@procedures = smart_listing_create :procedures,
current_administrateur.procedures.where(archived: false),
partial: "admin/procedures/list",
array: true
@page = 'active'
active_class
end
def archived
@procedures = current_administrateur.procedures.where(archived: true)
.paginate(:page => params[:page]).decorate
@procedures = smart_listing_create :procedures,
current_administrateur.procedures.where(archived: true),
partial: "admin/procedures/list",
array: true
@page = 'archived'
archived_class
render 'index'
end
def show
informations
@facade = AdminProceduresShowFacades.new @procedure
@facade = AdminProceduresShowFacades.new @procedure.decorate
end
def edit
informations
end
def new
@ -66,6 +77,14 @@ class Admin::ProceduresController < AdminController
redirect_to admin_procedures_path
end
def active_class
@active_class = 'active' if @page == 'active'
end
def archived_class
@archived_class = 'active' if @page == 'archived'
end
private
def create_procedure_params
@ -75,12 +94,4 @@ class Admin::ProceduresController < AdminController
def create_module_api_carto_params
params.require(:procedure).require(:module_api_carto_attributes).permit(:id, :use_api_carto, :quartiers_prioritaires, :cadastre)
end
def informations
@procedure = current_administrateur.procedures.find(params[:id]).decorate
rescue ActiveRecord::RecordNotFound
flash.alert = 'Procédure inéxistante'
redirect_to admin_procedures_path
end
end

View file

@ -1,6 +1,7 @@
class Admin::TypesDeChampController < AdminController
before_action :retrieve_procedure
before_action :procedure_locked?
def destroy
@procedure.types_de_champ.destroy(params[:id])
render 'show', format: :js

View file

@ -6,15 +6,19 @@ class AdminController < ApplicationController
end
def retrieve_procedure
id = params[:procedure_id] || params[:id ]
id = params[:procedure_id] || params[:id]
@procedure = current_administrateur.procedures.find(id)
if @procedure.locked?
render json: {message: 'Procedure locked'}, status: 403
end
rescue ActiveRecord::RecordNotFound
render json: {message: 'Procedure not found'}, status: 404
flash.alert = 'Procédure inéxistante'
redirect_to admin_procedures_path, status: 404
end
def procedure_locked?
if @procedure.locked?
flash.alert = 'Procédure verrouillée'
redirect_to admin_procedure_path(id: @procedure.id)
end
end
end

View file

@ -1,38 +1,26 @@
class Backoffice::DossiersController < ApplicationController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :authenticate_gestionnaire!
def index
if params[:liste] == 'a_traiter' || params[:liste].nil?
@dossiers = current_gestionnaire.dossiers.waiting_for_gestionnaire
@dossiers_a_traiter = @dossiers
@liste = params[:liste] || 'a_traiter'
@liste = 'a_traiter'
@dossiers = smart_listing_create :dossiers,
dossiers_to_display,
partial: "backoffice/dossiers/list",
array: true
elsif params[:liste] == 'en_attente'
@dossiers = current_gestionnaire.dossiers.waiting_for_user
@dossiers_en_attente = @dossiers
@liste = 'en_attente'
elsif params[:liste] == 'termine'
@dossiers = current_gestionnaire.dossiers.termine
@dossiers_termine = @dossiers
@liste = 'termine'
end
@dossiers = @dossiers.paginate(:page => (params[:page] || 1)).decorate
total_dossiers_per_state
end
def show
initialize_instance_params params[:id]
create_dossier_facade params[:id]
end
def search
@search_terms = params[:q]
@dossiers_search, @dossier = Dossier.search(current_gestionnaire, @search_terms)
unless @dossiers_search.empty?
@ -47,20 +35,20 @@ class Backoffice::DossiersController < ApplicationController
end
def valid
initialize_instance_params params[:dossier_id]
create_dossier_facade params[:dossier_id]
@dossier.next_step! 'gestionnaire', 'valid'
@facade.dossier.next_step! 'gestionnaire', 'valid'
flash.notice = 'Dossier confirmé avec succès.'
NotificationMailer.dossier_validated(@dossier).deliver_now!
NotificationMailer.dossier_validated(@facade.dossier).deliver_now!
render 'show'
end
def close
initialize_instance_params params[:dossier_id]
create_dossier_facade params[:dossier_id]
@dossier.next_step! 'gestionnaire', 'close'
@facade.dossier.next_step! 'gestionnaire', 'close'
flash.notice = 'Dossier traité avec succès.'
render 'show'
@ -68,25 +56,36 @@ class Backoffice::DossiersController < ApplicationController
private
def total_dossiers_per_state
@dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_gestionnaire.dossiers.waiting_for_gestionnaire.size
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_gestionnaire.dossiers.waiting_for_user.size
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_gestionnaire.dossiers.termine.size
def dossiers_to_display
{'a_traiter' => waiting_for_gestionnaire,
'en_attente' => waiting_for_user,
'termine' => termine}[@liste]
end
def initialize_instance_params dossier_id
@dossier = Dossier.where(archived: false).find(dossier_id)
@entreprise = @dossier.entreprise.decorate
@etablissement = @dossier.etablissement
@pieces_justificatives = @dossier.pieces_justificatives
@commentaires = @dossier.ordered_commentaires
@commentaires = @commentaires.all.decorate
@commentaire_email = current_gestionnaire.email
def waiting_for_gestionnaire
@a_traiter_class = (@liste == 'a_traiter' ? 'active' : '')
@waiting_for_gestionnaire ||= current_gestionnaire.dossiers.waiting_for_gestionnaire
end
@procedure = @dossier.procedure
def waiting_for_user
@en_attente_class = (@liste == 'en_attente' ? 'active' : '')
@waiting_for_user ||= current_gestionnaire.dossiers.waiting_for_user
end
def termine
@termine_class = (@liste == 'termine' ? 'active' : '')
@termine ||= current_gestionnaire.dossiers.termine
end
def total_dossiers_per_state
@dossiers_a_traiter_total = waiting_for_gestionnaire.count
@dossiers_en_attente_total = waiting_for_user.count
@dossiers_termine_total = termine.count
end
def create_dossier_facade dossier_id
@facade = DossierFacades.new dossier_id, current_gestionnaire.email
@dossier = @dossier.decorate
@champs = @dossier.ordered_champs
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(controller: '/backoffice')

View file

@ -1,7 +1,11 @@
class DemoController < ApplicationController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
def index
@procedures = Procedure.where(archived: false).order('libelle ASC').decorate
smart_listing_create :procedures,
Procedure.where(archived: false),
partial: "demo/list",
array: true
end
end

View file

@ -23,7 +23,7 @@ class FranceConnect::EntrepriseController < ApplicationController
sign_in @user
@user.loged_in_with_france_connect = true
@user.loged_in_with_france_connect = 'entreprise'
@user.save
redirect_to stored_location_for(current_user) || signed_in_root_path(current_user)

View file

@ -0,0 +1,91 @@
class FranceConnect::ParticulierController < ApplicationController
def login
client = FranceConnectParticulierClient.new
session[:state] = SecureRandom.hex(16)
session[:nonce] = SecureRandom.hex(16)
authorization_uri = client.authorization_uri(
scope: [:profile, :email],
state: session[:state],
nonce: session[:nonce]
)
redirect_to authorization_uri
end
def new
return redirect_to root_path if france_connect_particulier_id_blank?
@user = (User.new create_user_params).decorate
end
def create
user = User.new create_user_params
user.password = Devise.friendly_token[0, 20]
unless user.valid?
flash.alert = 'Email non valide'
return redirect_to france_connect_particulier_new_path user: params[:user]
end
user.save
connect_france_connect_particulier user
end
def check_email
return create if User.find_by_email(params[:user][:email]).nil?
return redirect_to root_path if france_connect_particulier_id_blank?
unless params[:user][:password].nil?
user = User.find_by_email(params[:user][:email])
valid_password = user.valid_password?(params[:user][:password])
if valid_password
user.update_attributes create_user_params
return connect_france_connect_particulier user
else
flash.now.alert = 'Mot de passe invalide'
end
end
@user = (User.new create_user_params).decorate
end
def callback
return redirect_to new_user_session_path unless params.has_key?(:code)
user_infos = FranceConnectService.retrieve_user_informations_particulier(params[:code])
unless user_infos.nil?
user = User.find_for_france_connect_particulier user_infos
if user.nil?
return redirect_to france_connect_particulier_new_path(user: user_infos)
end
connect_france_connect_particulier user
end
rescue Rack::OAuth2::Client::Error => e
Rails.logger.error e.message
flash.alert = t('errors.messages.france_connect.connexion')
redirect_to(new_user_session_path)
end
private
def create_user_params
params.require(:user).permit(:france_connect_particulier_id, :gender, :given_name, :family_name, :birthdate, :birthplace, :email)
end
def france_connect_particulier_id_blank?
redirect_to root_path if params[:user][:france_connect_particulier_id].blank?
end
def connect_france_connect_particulier user
sign_in user
user.loged_in_with_france_connect = 'particulier'
user.save
redirect_to stored_location_for(current_user) || signed_in_root_path(current_user)
end
end

View file

@ -45,7 +45,7 @@ class Users::CarteController < UsersController
end
def get_position
tmp_position = Carto::Geocodeur.convert_adresse_to_point(current_user_dossier.etablissement.adresse.gsub("\r\n", ' '))
tmp_position = Carto::Geocodeur.convert_adresse_to_point(current_user_dossier.etablissement.geo_adresse)
if !tmp_position.point.nil?
render json: {lon: tmp_position.point.x.to_s, lat: tmp_position.point.y.to_s, dossier_id: params[:dossier_id]}

View file

@ -1,31 +1,20 @@
class Users::DossiersController < UsersController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :authenticate_user!
before_action :check_siret, only: :create
def index
order = 'DESC'
if params[:liste] == 'a_traiter' || params[:liste].nil?
@dossiers = current_user.dossiers.waiting_for_user order
@dossiers_a_traiter = @dossiers
@liste = params[:liste] || 'a_traiter'
@liste = 'a_traiter'
@dossiers = smart_listing_create :dossiers,
dossiers_to_display,
partial: "users/dossiers/list",
array: true
elsif params[:liste] == 'en_attente'
@dossiers = current_user.dossiers.waiting_for_gestionnaire order
@dossiers_en_attente = @dossiers
@liste = 'en_attente'
elsif params[:liste] == 'termine'
@dossiers = current_user.dossiers.termine order
@dossiers_termine = @dossiers
@liste = 'termine'
end
@dossiers = @dossiers.paginate(:page => (params[:page] || 1)).decorate
total_dossiers_per_state
end
@ -40,46 +29,53 @@ class Users::DossiersController < UsersController
end
def show
@dossier = current_user_dossier params[:id]
@facade = DossierFacades.new params[:id], current_user.email
@etablissement = @dossier.etablissement
@entreprise = @dossier.entreprise.decorate
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for users_dossiers_path
end
def create
@etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
@entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
etablissement = Etablissement.new(SIADE::EtablissementAdapter.new(siret).to_params)
entreprise = Entreprise.new(SIADE::EntrepriseAdapter.new(siren).to_params)
rna_information = SIADE::RNAAdapter.new(siret).to_params
exercices = SIADE::ExercicesAdapter.new(siret).to_params
mandataires_sociaux = SIADE::MandatairesSociauxAdapter.new(siren).to_params
unless exercices.nil?
exercices.each_value do |exercice|
exercice = Exercice.new(exercice)
exercice.etablissement = @etablissement
exercice.etablissement = etablissement
exercice.save
end
end
mandataire_social = false
@dossier = Dossier.create(user: current_user, state: 'draft', procedure_id: create_params[:procedure_id])
mandataires_sociaux.each do |k, mandataire|
break mandataire_social = true if !current_user.france_connect_particulier_id.nil? &&
mandataire[:nom] == current_user.family_name &&
mandataire[:prenom] == current_user.given_name &&
mandataire[:date_naissance_timestamp] == current_user.birthdate.to_time.to_i
@entreprise.dossier = @dossier
@entreprise.save
end
dossier = Dossier.create(user: current_user, state: 'draft', procedure_id: create_params[:procedure_id], mandataire_social: mandataire_social)
entreprise.dossier = dossier
entreprise.save
unless rna_information.nil?
rna_information = RNAInformation.new(rna_information)
rna_information.entreprise = @entreprise
rna_information.entreprise = entreprise
rna_information.save
end
@etablissement.dossier = @dossier
@etablissement.entreprise = @entreprise
@etablissement.save
etablissement.dossier = dossier
etablissement.entreprise = entreprise
etablissement.save
redirect_to url_for(controller: :dossiers, action: :show, id: @dossier.id)
redirect_to url_for(controller: :dossiers, action: :show, id: dossier.id)
rescue RestClient::ResourceNotFound
errors_valid_siret
@ -90,27 +86,25 @@ class Users::DossiersController < UsersController
end
def update
@facade = DossierFacades.new params[:id], current_user.email
@dossier = current_user_dossier params[:id]
if checked_autorisation_donnees?
@dossier.update_attributes(update_params)
@facade.dossier.update_attributes(update_params)
if @dossier.procedure.module_api_carto.use_api_carto
redirect_to url_for(controller: :carte, action: :show, dossier_id: @dossier.id)
if @facade.dossier.procedure.module_api_carto.use_api_carto
redirect_to url_for(controller: :carte, action: :show, dossier_id: @facade.dossier.id)
else
redirect_to url_for(controller: :description, action: :show, dossier_id: @dossier.id)
redirect_to url_for(controller: :description, action: :show, dossier_id: @facade.dossier.id)
end
else
@etablissement = @dossier.etablissement
@entreprise = @dossier.entreprise.decorate
flash.now.alert = 'Les conditions sont obligatoires.'
render 'show'
end
end
def archive
@dossier = current_user.dossiers.find(params[:dossier_id])
@dossier.update_attributes({archived: true})
dossier = current_user.dossiers.find(params[:dossier_id])
dossier.update_attributes({archived: true})
flash.notice = 'Dossier archivé'
redirect_to users_dossiers_path
@ -122,6 +116,33 @@ class Users::DossiersController < UsersController
private
def dossiers_to_display
{'a_traiter' => waiting_for_user,
'en_attente' => waiting_for_gestionnaire,
'termine' => termine}[@liste]
end
def waiting_for_user
@a_traiter_class = (@liste == 'a_traiter' ? 'active' : '')
@waiting_for_user ||= current_user.dossiers.waiting_for_user 'DESC'
end
def waiting_for_gestionnaire
@en_attente_class = (@liste == 'en_attente' ? 'active' : '')
@waiting_for_gestionnaire ||= current_user.dossiers.waiting_for_gestionnaire 'DESC'
end
def termine
@termine_class = (@liste == 'termine' ? 'active' : '')
@termine ||= current_user.dossiers.termine 'DESC'
end
def total_dossiers_per_state
@dossiers_a_traiter_total = waiting_for_user.count
@dossiers_en_attente_total = waiting_for_gestionnaire.count
@dossiers_termine_total = termine.count
end
def check_siret
errors_valid_siret unless Siret.new(siret: siret).valid?
end
@ -135,10 +156,6 @@ class Users::DossiersController < UsersController
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
@ -151,17 +168,13 @@ class Users::DossiersController < UsersController
siret[0..8]
end
def total_dossiers_per_state
@dossiers_a_traiter_total = !@dossiers_a_traiter.nil? ? @dossiers_a_traiter.size : current_user.dossiers.waiting_for_user.size
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_user.dossiers.waiting_for_gestionnaire.size
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_user.dossiers.termine.size
end
def create_params
params.require(:dossier).permit(:siret, :procedure_id)
end
def error_procedure
render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
flash.alert = t('errors.messages.procedure_not_found')
redirect_to url_for users_dossiers_path
end
end

View file

@ -1,36 +1,35 @@
class Users::RecapitulatifController < UsersController
def show
@dossier = current_user_dossier
@dossier = @dossier.decorate
@procedure = @dossier.procedure
@champs = @dossier.ordered_champs
@commentaires = @dossier.ordered_commentaires
@commentaires = @commentaires.all.decorate
@commentaire_email = current_user.email
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(root_path)
create_dossier_facade
end
def initiate
show
create_dossier_facade
@dossier.next_step! 'user', 'initiate'
@facade.dossier.next_step! 'user', 'initiate'
flash.notice = 'Dossier soumis avec succès.'
render 'show'
end
def submit
show
create_dossier_facade
@dossier.next_step! 'user', 'submit'
@facade.dossier.next_step! 'user', 'submit'
flash.notice = 'Dossier déposé avec succès.'
NotificationMailer.dossier_submitted(@dossier).deliver_now!
NotificationMailer.dossier_submitted(@facade.dossier).deliver_now!
render 'show'
end
private
def create_dossier_facade
@facade = DossierFacades.new current_user_dossier.id, current_user.email
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for(root_path)
end
end

View file

@ -2,6 +2,11 @@ class Users::RegistrationsController < Devise::RegistrationsController
# before_filter :configure_sign_up_params, only: [:create]
# before_filter :configure_account_update_params, only: [:update]
def after_sign_up_path_for(resource_or_scope)
WelcomeMailer.welcome_email(User.last).deliver_now!
super
end
# GET /resource/sign_up
# def new
# super
@ -9,9 +14,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
# POST /resource
def create
retour = super
WelcomeMailer.welcome_email(User.last).deliver_now!
retour
super
end
# GET /resource/edit

View file

@ -1,38 +1,40 @@
class Users::SessionsController < Sessions::SessionsController
# before_filter :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
# def new
# super
# end
# GET /resource/sign_in
# def new
# super
# end
#POST /resource/sign_in
#POST /resource/sign_in
def create
super
current_user.update_attributes(loged_in_with_france_connect: false)
current_user.update_attributes(loged_in_with_france_connect: '')
end
# DELETE /resource/sign_out
def destroy
connected_with_france_connect = current_user.loged_in_with_france_connect
current_user.update_attributes(loged_in_with_france_connect: false)
current_user.update_attributes(loged_in_with_france_connect: '')
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
yield if block_given?
if connected_with_france_connect
if connected_with_france_connect == 'entreprise'
redirect_to FRANCE_CONNECT.entreprise_logout_endpoint
elsif connected_with_france_connect == 'particulier'
redirect_to FRANCE_CONNECT.particulier_logout_endpoint
else
respond_to_on_destroy
end
end
# protected
# 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
# 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

View file

@ -2,7 +2,7 @@ class DossierDecorator < Draper::Decorator
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
delegate_all
def date_fr
def display_date
date_previsionnelle.to_date.strftime('%d/%m/%Y')
rescue
'dd/mm/YYYY'
@ -12,7 +12,7 @@ class DossierDecorator < Draper::Decorator
updated_at.localtime.strftime('%d/%m/%Y %H:%M')
end
def state_fr
def display_state
DossierDecorator.case_state_fr state
end
@ -27,23 +27,6 @@ class DossierDecorator < Draper::Decorator
end
def self.case_state_fr state=self.state
case state
when 'draft'
'Brouillon'
when 'initiated'
'Soumis'
when 'replied'
'Répondu'
when 'updated'
'Mis à jour'
when 'validated'
'Validé'
when 'submitted'
'Déposé'
when 'closed'
'Traité'
else
fail 'State not valid'
end
h.t("activerecord.attributes.dossier.state.#{state}")
end
end

View file

@ -0,0 +1,12 @@
class UserDecorator < Draper::Decorator
delegate_all
def gender_fr
return 'Mr' if gender == 'male'
return 'Mme' if gender == 'female'
end
def birthdate_fr
birthdate.strftime('%d/%m/%Y')
end
end

View file

@ -0,0 +1,40 @@
class DossierFacades
#TODO rechercher en fonction de la personne/email
def initialize dossier_id, email
@dossier = Dossier.where(archived: false).find(dossier_id)
@email = email
end
def dossier
@dossier.decorate
end
def champs
@dossier.ordered_champs
end
def entreprise
@dossier.entreprise.decorate
end
def etablissement
@dossier.etablissement
end
def pieces_justificatives
@dossier.pieces_justificatives
end
def commentaires
@dossier.ordered_commentaires.all.decorate
end
def commentaire_email
@email
end
def procedure
@dossier.procedure
end
end

View file

@ -3,4 +3,8 @@ class Etablissement < ActiveRecord::Base
belongs_to :entreprise
has_many :exercices
def geo_adresse
numero_voie.to_s << ' ' << type_voie.to_s << ' ' << nom_voie.to_s << ' ' << complement_adresse.to_s << ' ' << code_postal.to_s << ' ' << localite.to_s
end
end

View file

@ -0,0 +1,17 @@
class FranceConnectParticulierClient < OpenIDConnect::Client
def initialize params={}
super(
identifier: FRANCE_CONNECT.particulier_identifier,
secret: FRANCE_CONNECT.particulier_secret,
redirect_uri: FRANCE_CONNECT.particulier_redirect_uri,
authorization_endpoint: FRANCE_CONNECT.particulier_authorization_endpoint,
token_endpoint: FRANCE_CONNECT.particulier_token_endpoint,
userinfo_endpoint: FRANCE_CONNECT.particulier_userinfo_endpoint,
logout_endpoint: FRANCE_CONNECT.particulier_logout_endpoint
)
self.authorization_code = params[:code] if params.has_key? :code
end
end

View file

@ -1,4 +1,7 @@
class User < ActiveRecord::Base
enum loged_in_with_france_connect: {particulier: 'particulier',
entreprise: 'entreprise'}
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
@ -6,13 +9,22 @@ class User < ActiveRecord::Base
has_many :dossiers
def self.find_for_france_connect_particulier user_info
User.find_by(france_connect_particulier_id: user_info[:france_connect_particulier_id])
end
def self.find_for_france_connect email, siret
user = User.find_by_email(email)
if user.nil?
return User.create(email: email, password: Devise.friendly_token[0,20], siret: siret)
return User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret)
else
user.update_attributes(siret: siret)
user
end
end
def loged_in_with_france_connect?
!loged_in_with_france_connect.nil?
end
end

View file

@ -6,4 +6,15 @@ class FranceConnectService
user_info = access_token.userinfo!
Hashie::Mash.new user_info.raw_attributes
end
def self.retrieve_user_informations_particulier code
client = FranceConnectParticulierClient.new code: code
access_token = client.access_token!(client_auth_method: :secret)
user_info = access_token.userinfo!
hash = Hashie::Mash.new user_info.raw_attributes
hash.france_connect_particulier_id = hash.sub
hash
end
end

View file

@ -0,0 +1,41 @@
require 'securerandom'
class Downloader
BASE_PATH_DISK = File.join(Rails.root, "public/downloads/")
def initialize(filename, filename_suffix = '')
@filename = filename.to_s
@filename_suffix = filename_suffix.empty? ? '' : "_#{filename_suffix}"
@extension = @filename.split(/[.]/).last
generate_random_base_path!
FileUtils.ln_s @filename, "#{@base_path}/#{@filename_suffix}.#{@extension}"
end
def url
@url ||= File.join(TPS::Application::URL, 'downloads', random_folder_name, "#{@filename_suffix}.#{@extension}")
end
protected
attr_accessor :random_folder_name
def generate_random_base_path!
@base_path ||= begin
loop do
self.random_folder_name = SecureRandom.hex
base_path = File.join(BASE_PATH_DISK, self.random_folder_name)
unless File.directory?(BASE_PATH_DISK)
Dir.mkdir(BASE_PATH_DISK)
end
unless File.directory?(base_path)
Dir.mkdir(base_path)
break base_path
end
end
end
end
end

View file

@ -1,14 +1,21 @@
%table.table
%thead
%th#id ID
%th#libelle Libellé
%th#lien Lien
- @procedures.each do |procedure|
%tr
%td.col-md-1.col-lg-1= procedure.id
%td.col-md-6.col-lg-6
= link_to(procedure.libelle, "/admin/procedures/#{procedure.id}")
%td= link_to procedure.lien, procedure.lien
- unless smart_listing.empty?
%table.table
%thead
%th#ID= smart_listing.sortable 'ID', 'id'
%th#libelle= smart_listing.sortable 'Libellé', 'libelle'
%th#lien Lien
.pagination
= will_paginate @procedures, renderer: BootstrapPagination::Rails
- @procedures.each do |procedure|
- procedure = procedure.decorate
%tr
%td.col-md-1.col-lg-1= procedure.id
%td.col-md-6.col-lg-6
= link_to(procedure.libelle, "/admin/procedures/#{procedure.id}")
%td= link_to procedure.lien, procedure.lien
= smart_listing.paginate
= smart_listing.pagination_per_page_links
- else
%h4.center
Aucune procédure

View file

@ -1,11 +1,11 @@
#onglets
%ul.nav.nav-tabs
%li{class: "#{'active' if @page == 'active' }"}
%li{class: @active_class}
%a{:href => "#{url_for :admin_procedures}"}
%h5.text-success
= "Actives"
%li{class: "#{'active' if @page == 'archived' }"}
%li{class: @archived_class}
%a{:href => "#{url_for :admin_procedures_archived}"}
%h5{style: 'color: black'}
="Archivées"

View file

@ -1,7 +0,0 @@
= link_to("Nouvelle procédure", "/admin/procedures/new", class: 'btn btn-success', style: 'float:right; margin-top:2%;')
%h1 Gestion des procédures
%br
= render partial: 'onglets'
= render partial: 'list'

View file

@ -4,4 +4,4 @@
= render partial: 'onglets'
= render partial: 'list'
= smart_listing_render :procedures

View file

@ -0,0 +1 @@
<%= smart_listing_update :procedures %>

View file

@ -1,30 +1,30 @@
#procedure_show
%h2.text-info
=@procedure.libelle
=@facade.procedure.libelle
%br
%ul.nav.nav-tabs
%li.active
= link_to('Informations', admin_procedure_path(@procedure))
= link_to('Informations', admin_procedure_path(@facade.procedure))
%li{ class: ('disabled' if @procedure.locked?) }
= link_to_unless(@procedure.locked?, 'Description', edit_admin_procedure_path(@procedure)) do
%li{ class: ('disabled' if @facade.procedure.locked?) }
= link_to_unless(@facade.procedure.locked?, 'Description', edit_admin_procedure_path(@facade.procedure)) do
= link_to('Description', '#')
%li{ class: ('disabled' if @procedure.locked?) }
= link_to_unless(@procedure.locked?, 'Champs', admin_procedure_types_de_champ_path(@procedure)) do
%li{ class: ('disabled' if @facade.procedure.locked?) }
= link_to_unless(@facade.procedure.locked?, 'Champs', admin_procedure_types_de_champ_path(@facade.procedure)) do
= link_to('Champs', '#')
%li{ class: ('disabled' if @procedure.locked?) }
= link_to_unless(@procedure.locked?, 'Pièces justificatives', admin_procedure_pieces_justificatives_path(@procedure)) do
%li{ class: ('disabled' if @facade.procedure.locked?) }
= link_to_unless(@facade.procedure.locked?, 'Pièces justificatives', admin_procedure_pieces_justificatives_path(@facade.procedure)) do
= link_to('Pièces justificatives', '#')
%li{style:'float:right'}
= form_tag admin_procedure_archive_path(procedure_id: @procedure.id, archive: !@procedure.archived?), method: :put do
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put do
%button#archive.btn.btn-nav.text-info{type: :button}
%i.fa.fa-eraser
- if @procedure.archived
- if @facade.procedure.archived
= 'Réactiver'
- else
= 'Archiver'
@ -36,7 +36,7 @@
%i.fa.fa-remove
Annuler
- if @procedure.locked?
- if @facade.procedure.locked?
#procedure_locked.center
%h5
.label.label-info La procédure ne peut plus être modifiée car un usagé a déjà déposé un dossier
@ -44,9 +44,35 @@
%div
%h3 Lien procédure
%div{style:'margin-left:3%'}
= @procedure.lien
= @facade.procedure.lien
%br
%h3 Détails
.row{style:'margin-right:3%; margin-left:3%;'}
.description.col-md-4.col-lg-4
%h4.text-info
= @facade.procedure.libelle
= @facade.procedure.description
.champs.col-md-4.col-lg-4
%h4.text-info
Champs
.badge.progress-bar-info
= @facade.procedure.types_de_champ.size
- @facade.procedure.types_de_champ.each do |champ|
= champ.libelle
%br
.pieces_justificatives.col-md-4.col-lg-4
%h4.text-info
Pièces justificatives
.badge.progress-bar-info
= @facade.procedure.types_de_piece_justificative.size
- @facade.procedure.types_de_piece_justificative.each do |piece_justificative|
= piece_justificative.libelle
%br
%br
%h3 Dossiers
.row
@ -73,7 +99,7 @@
%ul
- @facade.dossiers_archived_by_state_total.each do |dossier|
%li
= dossier.state_fr
= dossier.display_state
\:
= dossier.total
- else

View file

@ -1,16 +1,22 @@
%table.table
%thead.row
%th.col-md-4.col-lg-4 Procédure
%th.col-md-4.col-lg-4 Dossier
%th.col-md-2.col-lg-2 État
%th.col-md-2.col-lg-2 Date de mise à jour
- @dossiers.each do |dossier|
%tr
%td= dossier.procedure.libelle
%td
= link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}")
%td= dossier.state_fr
%td= dossier.last_update
- unless smart_listing.empty?
%table.table
%thead.row
%th.col-md-4.col-lg-4= smart_listing.sortable 'Procédure', 'procedure.libelle'
%th.col-md-4.col-lg-4= smart_listing.sortable 'Dossier', 'nom_projet'
%th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
%th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
.pagination
= will_paginate @dossiers, renderer: BootstrapPagination::Rails
- @dossiers.each do |dossier|
- dossier = dossier.decorate
%tr
%td= dossier.procedure.libelle
%td
= link_to(dossier.nom_projet, "/backoffice/dossiers/#{dossier.id}")
%td= dossier.display_state
%td= dossier.last_update
= smart_listing.paginate
= smart_listing.pagination_per_page_links
- else
%h4.center
Aucun dossier

View file

@ -3,24 +3,27 @@
#onglets
%ul.nav.nav-tabs
%li{ class: (@dossiers.active_class_a_traiter(@liste) unless @dossiers.nil?) }
%li{ class: (@a_traiter_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'a_traiter')}"}
%h5.text-danger
= "À traiter "
.badge.progress-bar-danger
=@dossiers_a_traiter_total
%li{ class: (@dossiers.active_class_en_attente(@liste) unless @dossiers.nil?) }
%li{ class: (@en_attente_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'en_attente')}"}
%h5.text-info
="En attente "
.badge.progress-bar-info
=@dossiers_en_attente_total
%li{ class: (@dossiers.active_class_termine(@liste) unless @dossiers.nil?) }
%li{ class: (@termine_class) }
%a{:href => "#{url_for backoffice_dossiers_path(liste: 'termine')}"}
%h5.text-success
= "Terminé"
.badge.progress-bar-success
=@dossiers_termine_total
%li#search{class: "#{'active' unless @dossiers_search.nil?}", style:'float:right'}
%a
= form_tag(backoffice_dossiers_search_url, method: :get) do

View file

@ -1,4 +1,4 @@
#backoffice_index
= render partial: 'onglets'
= render partial: 'list'
= smart_listing_render :dossiers

View file

@ -0,0 +1 @@
<%= smart_listing_update :dossiers %>

View file

@ -19,7 +19,7 @@
%td.col-md-2.col-lg-2
= @dossier.etablissement.siret
%td.col-md-1.col-lg-1{class: @dossier.state_color_class}
= @dossier.state_fr
= @dossier.display_state
%br
- if @dossiers_search.empty? && @dossier.nil?
@ -44,7 +44,7 @@
%td= dossier.entreprise.raison_sociale
%td= dossier.user.email
%td= dossier.etablissement.siret
%td{class: dossier.state_color_class}= dossier.state_fr
%td{class: dossier.state_color_class}= dossier.display_state
.pagination
= will_paginate @dossiers_search, renderer: BootstrapPagination::Rails

View file

@ -1,9 +1,9 @@
#backoffice_dossier_show
%h1#dossier_id.text-info{ :style => 'text-align:right'}
= "Dossier n°#{@dossier.id}"
= "Dossier n°#{@facade.dossier.id}"
%h3{:class => 'text-success', :style => 'text-align:right'}
= @dossier.state_fr
= @facade.dossier.display_state
= render partial: '/dossiers/infos_entreprise'
@ -17,5 +17,5 @@
%br
-#%script{type: 'text/javascript'}
-# ="url_carte = '#{@dossier.id}/'"
-# ="ref_dossier = '#{@dossier.ref_dossier_carto}'"
-# ="url_carte = '#{@facade.dossier.id}/'"
-# ="ref_dossier = '#{@facade.dossier.ref_dossier_carto}'"

View file

@ -0,0 +1,27 @@
- unless smart_listing.empty?
%table.table
%tr
%th{colspan: 4}
%h4 Lien vers les procédures TPS
%tr
%th= smart_listing.sortable 'ID', 'id'
%th= smart_listing.sortable 'Titre', 'libelle'
%th Description
%th= smart_listing.sortable 'Organisation', 'organisation'
- smart_listing.collection.each do |procedure|
- procedure = procedure.decorate
%tr
%td
= procedure.id
%td.col-md-4.col-lg-4
= link_to procedure.libelle, procedure.lien
%td
= procedure.description
%td.col-md-3.col-lg-3
= procedure.organisation
= smart_listing.paginate
= smart_listing.pagination_per_page_links
- else
%p Aucune procédure trouvée

View file

@ -1,20 +1 @@
%table.table
%tr
%th{colspan: 4}
%h4 Lien vers les procédures TPS
%tr
%th ID
%th Titre
%th Description
%th Organisation
- @procedures.each do |procedure|
%tr
%td
= procedure.id
%td.col-md-4.col-lg-4
= link_to procedure.libelle, procedure.lien
%td
= procedure.description
%td.col-md-3.col-lg-3
= procedure.organisation
= smart_listing_render :procedures

View file

@ -0,0 +1 @@
<%= smart_listing_update :procedures %>

View file

@ -3,33 +3,43 @@
%div.row
.col-lg-6.col-md-6
%h3.text-info
= @dossier.nom_projet
= @facade.dossier.nom_projet
%h4
= @dossier.procedure.libelle
= @facade.dossier.procedure.libelle
.description
- begin
- @dossier.description.split(/(?:\n\r?|\r\n?')/).each do |line|
- @facade.dossier.description.split(/(?:\n\r?|\r\n?')/).each do |line|
= line
%br
- rescue
=''
- if @dossier.procedure.module_api_carto.use_api_carto
- if @facade.dossier.mandataire_social && gestionnaire_signed_in?
.mandataire_social.text-success.center
%br
="Il est probable que le soumissionnaire du dossier soit un des mandataire social de l'entreprise ("
%b
="#{@facade.dossier.user.given_name} #{@facade.dossier.user.family_name}"
=")"
- if @facade.dossier.procedure.module_api_carto.use_api_carto
.col-lg-6.col-md-6
#map.mini{class: @dossier.class_qp_active}
#map.mini{class: @facade.dossier.class_qp_active}
%input{id: 'json_latlngs', type:'hidden', value: "#{@dossier.json_latlngs}"}
%input{id: 'quartier_prioritaires', type:'hidden', value: "#{@dossier.quartier_prioritaires.to_json}"}
%input{id: 'json_latlngs', type:'hidden', value: "#{@facade.dossier.json_latlngs}"}
%input{id: 'quartier_prioritaires', type:'hidden', value: "#{@facade.dossier.quartier_prioritaires.to_json}"}
%script{type: 'text/javascript'}
= "var dossier_id =#{@dossier.id}"
= "var dossier_id =#{@facade.dossier.id}"
initCarto();
%br
-unless @champs.nil?
-unless @facade.champs.nil?
.row
.col-lg-6.col-md-6
%table.table#liste_champs
-@champs.each do |champ|
-@facade.champs.each do |champ|
%tr
%th{ style: 'width:25%' }
=champ.libelle
@ -41,20 +51,20 @@
%div.row{style: 'text-align:right'}
-unless gestionnaire_signed_in?
-if !@dossier.validated? && !@dossier.submitted? && !@dossier.closed?
-if @dossier.procedure.module_api_carto.use_api_carto
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@dossier.id}/carte"}
-if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed?
-if @facade.dossier.procedure.module_api_carto.use_api_carto
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@facade.dossier.id}/carte"}
= 'Editer ma carte'
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description"}
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@facade.dossier.id}/description"}
= 'Editer mon dossier'
-unless user_signed_in?
-if !@dossier.validated? && !@dossier.submitted? && !@dossier.closed?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
-if !@facade.dossier.validated? && !@facade.dossier.submitted? && !@facade.dossier.closed?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Valider le dossier'
-elsif @dossier.submitted?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
-elsif @facade.dossier.submitted?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Traiter le dossier'

View file

@ -1,37 +1,37 @@
.col-md-12
%h4
= @entreprise.raison_sociale_or_name
= @facade.entreprise.raison_sociale_or_name
.row#infos_entreprise
.col-lg-6.col-md-6
%dl.dl-horizontal
%dt Siret :
%dd.text-success= @etablissement.siret
%dd.text-success= @facade.etablissement.siret
- if @etablissement.siret != @entreprise.siret_siege_social
- if @facade.etablissement.siret != @facade.entreprise.siret_siege_social
%dt SIRET siège social :
%dd= @entreprise.siret_siege_social
%dd= @facade.entreprise.siret_siege_social
%dt Forme juridique :
%dd= @entreprise.forme_juridique
%dd= @facade.entreprise.forme_juridique
%dt Libellé naf :
%dd= @etablissement.libelle_naf
%dd= @facade.etablissement.libelle_naf
%dt Code naf :
%dd= @etablissement.naf
%dd= @facade.etablissement.naf
%dt Date de création :
%dd= Time.at(@entreprise.date_creation).strftime "%d-%m-%Y"
%dd= Time.at(@facade.entreprise.date_creation).strftime "%d-%m-%Y"
%dt Effectif organisation :
%dd= @entreprise.effectif
%dd= @facade.entreprise.effectif
%dt Code effectif :
%dd= @entreprise.code_effectif_entreprise
%dd= @facade.entreprise.code_effectif_entreprise
%dt Numéro TVA intracommunautaire :
%dd= @entreprise.numero_tva_intracommunautaire
%dd= @facade.entreprise.numero_tva_intracommunautaire
.col-lg-6.col-md-6
@ -39,21 +39,21 @@
%dt Adresse :
%dd
%address
- @etablissement.adresse.split("\n").each do |line|
- @facade.etablissement.adresse.split("\n").each do |line|
= line
%br
%dt Capital social :
%dd= @entreprise.pretty_capital_social
%dd= @facade.entreprise.pretty_capital_social
%dt Exercices :
%dd
%address
- @etablissement.exercices.each_with_index do |exercice, index|
- @facade.etablissement.exercices.each_with_index do |exercice, index|
%strong
= "#{exercice.dateFinExercice.year} : "
= number_to_currency(exercice.ca)
%br
- unless @entreprise.rna_information.nil?
- unless @facade.entreprise.rna_information.nil?
= render partial: '/dossiers/infos_rna'

View file

@ -2,22 +2,22 @@
.col-lg-6.col-md-6
%dl.dl-horizontal
%dt Association ID :
%dd.text-success= @entreprise.rna_information.association_id
%dd.text-success= @facade.entreprise.rna_information.association_id
%dt Titre :
%dd= @entreprise.rna_information.titre
%dd= @facade.entreprise.rna_information.titre
%dt Objet :
%dd= @entreprise.rna_information.objet
%dd= @facade.entreprise.rna_information.objet
.col-lg-6.col-md-6
%dl.dl-horizontal
%dt Date création :
%dd= @entreprise.rna_information.date_creation
%dd= @facade.entreprise.rna_information.date_creation
%dt Capital publication :
%dd= @entreprise.rna_information.date_publication
%dd= @facade.entreprise.rna_information.date_publication
%dt Capital déclaration :
%dd= @entreprise.rna_information.date_declaration
%dd= @facade.entreprise.rna_information.date_declaration

View file

@ -1,23 +1,22 @@
#pieces_justificatives
-#%h3.text-info Liste des pièces justificatives
-#%br
%table.table
-if @procedure.lien_demarche != nil
-if @facade.procedure.lien_demarche != nil
%tr{id: "piece_justificative_0"}
%th{class:'col-lg-6'}
='CERFA'
-if @procedure.lien_demarche != nil
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Lien CERFA
='Formulaire'
%td.col-lg-6.col-md-6
- if !@dossier.cerfa.empty?
- if !@facade.dossier.cerfa.empty?
- if user_signed_in?
= 'Pièce fournie'
- elsif gestionnaire_signed_in?
%a{ href: "#{@dossier.cerfa.content}", target: '_blank' } Consulter
%a{ href: "#{(Downloader.new @facade.dossier.cerfa.content, 'CERFA').url}", target: '_blank' } Consulter
- else
= 'Pièce non fournie'
- @dossier.pieces_justificatives.each do |piece_justificative|
- @facade.dossier.pieces_justificatives.each do |piece_justificative|
%tr{ id: "piece_justificative_#{piece_justificative.type}" }
%th.col-lg-6
= piece_justificative.libelle
@ -25,7 +24,10 @@
- if piece_justificative.api_entreprise
%span.text-success Nous l'avons récupéré pour vous.
- elsif !piece_justificative.empty?
%a{ href: "#{piece_justificative.content}", target: '_blank' } Consulter
- if user_signed_in?
= 'Pièce fournie'
- elsif gestionnaire_signed_in?
%a{ href: "#{(Downloader.new piece_justificative.content, piece_justificative.type_de_piece_justificative.libelle).url}", target: '_blank' } Consulter
- else
= 'Pièce non fournie'

View file

@ -5,7 +5,7 @@
%div.row
= render partial: '/dossiers/infos_entreprise'
%br
= form_for @dossier, url: { controller: '/users/dossiers', action: :update } do |f|
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
%label{ style:'font-weight:normal' }
= f.check_box :autorisation_donnees
J'autorise les décideurs publics à vérifier les informations de mon organisation auprès des administrations concernées. Ces informations resteront strictement confidentielles.

View file

@ -0,0 +1,28 @@
%h2.text-info
= image_tag('logo_FC_02_small.png', style: 'height: 55px')
&nbsp;France Connect - Particulier
%h3 Nouvelle connexion
%h4.text-warning{style:'margin-left: 20px'} Email déjà utilisé
%br
%p
%h4.center Nous vous avons trouvé un compte qui utilise déjà cette adresse email.
%p.center
Afin d'associer ce compte à votre identifiant France Connect, merci de saisir votre mot de passe TPS.
%br
.center
#france_connect_particulier_email
= form_for @user, url: {controller: 'france_connect/particulier', action: :check_email}, method: :post do |f|
.form-group.form-group-lg
= f.text_field :email, class: "form-control", placeholder: "Entrez votre email", readonly: 'readonly'
%br
= f.password_field :password, class: "form-control", placeholder: "Entrez votre mot de passe"
= f.hidden_field :email
= f.hidden_field :gender
= f.hidden_field :given_name
= f.hidden_field :family_name
= f.hidden_field :birthdate
= f.hidden_field :birthplace
= f.hidden_field :france_connect_particulier_id
= f.submit 'Terminer', class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', id: 'valid_new_fcp'

View file

@ -0,0 +1,36 @@
%h2.text-info
= image_tag('logo_FC_02_small.png', style: 'height: 55px')
&nbsp;France Connect - Particulier
%h3 Nouvelle connexion
%br
%p
Nous vous avons correctement identifié comme étant
%h4.text-info.center
%strong
= @user.gender_fr
= @user.given_name
= @user.family_name
né le
%strong
= @user.birthdate_fr
%br
%h4
Afin de finaliser votre première connexion à TPS, merci de saisir un email valide :
%br
.center
#france_connect_particulier_email
= form_for @user, url: {controller: 'france_connect/particulier', action: :check_email}, method: :post do |f|
.form-group.form-group-lg
= f.text_field :email, class: "form-control", placeholder: "Entrez votre email"
= f.hidden_field :gender
= f.hidden_field :given_name
= f.hidden_field :family_name
= f.hidden_field :birthdate
= f.hidden_field :birthplace
= f.hidden_field :france_connect_particulier_id
= f.submit 'Terminer', class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', id: 'valid_new_fcp'

View file

@ -25,12 +25,18 @@
= render partial: 'administrateurs/login_banner'
- elsif user_signed_in?
%div.user
-if current_user.loged_in_with_france_connect
= image_tag('logo_FC_02_small.png', class: 'logo_fc_small')
-if current_user.loged_in_with_france_connect?
%div{ id: "fconnect-profile", "data-fc-logout-url" => '/users/sign_out" data-method="delete' }
%a.text-info{ href: "#" }
= "#{current_user.given_name} #{current_user.family_name}"
= link_to "", '/users/sign_out', method: :delete, :class => 'btn fa fa-power-off off-fc-link'
-else
%i.fa.fa-user
= current_user.email
= link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md'
= current_user.email
= link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md'
#flash_message.center
- if flash.notice
@ -42,3 +48,4 @@
%div{:style => 'margin-left:10%; margin-right:10%;'}
= yield

View file

@ -40,15 +40,18 @@
%br
%h3 Documents administratifs
-if @procedure.lien_demarche != nil
%p
Formulaire / documentation de la démarche :
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Accéder
%br
//TODO a refactorer
%table{class:'table', style:'width:55%; margin-left:5%'}
%tr
%th{class:'col-lg-6'}
='Charger votre CERFA (.pdf)'
-if @procedure.lien_demarche != nil
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Lien CERFA
='Formulaire (.pdf / .doc)'
%td{class:'col-lg-5'}
-if !@dossier.cerfa.empty?

View file

@ -1,17 +1,23 @@
%table.table
%thead
%th Procédure
%th Nom du Projet
%th Etat
%th Mise à jour
- @dossiers.each do |dossier|
%tr
%td
= dossier.procedure.libelle
%td
= link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier))
%td{id: "dossier_#{dossier.id}_state"}= dossier.state_fr
%td= dossier.last_update
- unless smart_listing.empty?
%table.table
%thead
%th.col-md-4.col-lg-4= smart_listing.sortable 'Procédure', 'procedure.libelle'
%th.col-md-4.col-lg-4= smart_listing.sortable 'Nom du Projet', 'nom_projet'
%th.col-md-2.col-lg-2= smart_listing.sortable 'État', 'state'
%th.col-md-2.col-lg-2= smart_listing.sortable 'Date de mise à jour', 'updated_at'
- @dossiers.each do |dossier|
- dossier = dossier.decorate
%tr
%td
= dossier.procedure.libelle
%td
= link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier))
%td{id: "dossier_#{dossier.id}_state"}= dossier.display_state
%td= dossier.last_update
.pagination
= will_paginate @dossiers, renderer: BootstrapPagination::Rails
= smart_listing.paginate
= smart_listing.pagination_per_page_links
- else
%h4.center
Aucun dossier

View file

@ -3,21 +3,21 @@
#onglets
%ul.nav.nav-tabs
%li{ class: (@dossiers.active_class_a_traiter(@liste) unless @dossiers.nil?) }
%li{ class: @a_traiter_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'a_traiter')}"}
%h5.text-danger
= "À traiter "
.badge.progress-bar-danger
= @dossiers_a_traiter_total
%li{ class: (@dossiers.active_class_en_attente(@liste) unless @dossiers.nil?) }
%li{ class: @en_attente_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'en_attente')}"}
%h5.text-info
="En attente "
.badge.progress-bar-info
= @dossiers_en_attente_total
%li{ class: (@dossiers.active_class_termine(@liste) unless @dossiers.nil?) }
%li{ class: @termine_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'termine')}"}
%h5.text-success
= "Terminé"

View file

@ -1,4 +1,4 @@
#users_index
= render partial: 'onglets'
= render partial: 'list'
= smart_listing_render :dossiers

View file

@ -0,0 +1 @@
<%= smart_listing_update :dossiers %>

View file

@ -1,12 +1,12 @@
.content#commentaires_flux{style:'width:100%;'}
%div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'}
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @facade.dossier.id }), class: 'form-inline', method: 'POST') do
%textarea.form-control{id: 'texte_commentaire', name: 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255', placeholder:"Dialoguer avec votre interlocuteur privilégié en charge de votre dossier."}
%input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'}
%br
%br
-@commentaires.each do |com|
-@facade.commentaires.each do |com|
%span.text-info#email_contact{style: 'font-weight:bold'}
=com.email
%span#created_at

View file

@ -4,7 +4,7 @@
.col-md-6.col-lg-6
%h2 Récapitulatif
.col-md-6.col-lg-6
= form_tag "/users/dossiers/#{@dossier.id}/archive", style:'margin-top:21px', action: :archive, method: :put do
= form_tag "/users/dossiers/#{@facade.dossier.id}/archive", style:'margin-top:21px', action: :archive, method: :put do
%button#archive.btn.btn-sm.btn-default.text-info{type: :button}
%i.fa.fa-eraser
Archiver
@ -20,17 +20,17 @@
.col-md-3.col-lg-3
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
= "Dossier n°#{@dossier.id}"
= "Dossier n°#{@facade.dossier.id}"
- unless gestionnaire_signed_in?
-if @dossier.validated?
-if @facade.dossier.validated?
%br
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @dossier.id}), method: 'POST') do
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @facade.dossier.id}), method: 'POST') do
%button#validate_button.btn.btn-success
= 'Déposer mon dossier'
-else
%h3{:class => 'text-success', :style => 'text-align:right'}
= @dossier.state_fr
= @facade.dossier.display_state
%br

View file

@ -3,14 +3,15 @@
%br
%h2#login_user Connexion
-#%a.btn.btn-default.btn-lg.btn-primary#btn_fc{href: '/france_connect'}
-# %div{style:'margin-left:35px'}
-# S'identifier avec
-# France Connect
-#%hr
%a.btn_fc#btn_fcp{href: '/france_connect/particulier'}
= image_tag 'franceconnect_logo.png'
%br
%br
%a.text-info{href: 'https://fcp.integ01.dev-franceconnect.fr/a-propos', target: '_blank'}
Quest-ce que FranceConnect ?
%hr
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
%h4
= f.label :email

View file

@ -1,8 +0,0 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

View file

@ -1,8 +0,0 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require_relative '../config/boot'
require 'rake'
Rake.application.run

View file

@ -1,15 +0,0 @@
#!/usr/bin/env ruby
# This file loads spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.
unless defined?(Spring)
require "rubygems"
require "bundler"
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq }
gem "spring", match[1]
require "spring/binstub"
end
end

View file

@ -26,5 +26,13 @@ module TPS
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
if Rails.env.production?
URL = "https://tps.apientreprise.fr/"
elsif Rails.env.staging?
URL = "https://tps-dev.apientreprise.fr/"
else
URL = "http://localhost:3000/"
end
end
end

View file

@ -68,7 +68,8 @@ set :shared_paths, [
"config/initializers/token.rb",
"config/unicorn.rb",
"config/initializers/raven.rb",
'config/france_connect.yml'
'config/france_connect.yml',
'config/initializers/mailjet.rb'
]

View file

@ -23,6 +23,12 @@ fr:
will_paginate:
next_label: 'Suivant'
previous_label: 'Précédent'
views:
pagination:
next: Suivant
last: Dernier
previous: Précédent
first: Premier
number:
currency:
@ -32,6 +38,22 @@ fr:
separator: ','
precision: 2
format: '%n %u'
activerecord:
errors:
models:
user:
attributes:
email:
invalid: invalide
taken: déjà utilisé
blank: est vide
password:
too_short: ': Le mot de passe est trop court'
blank: ': Le mot de passe est vide'
password_confirmation:
confirmation: ': Les deux mots de passe ne correspondent pas'
devise:
confirmations:
confirmed: 'Votre compte a été confirmé avec succès.'
@ -93,6 +115,7 @@ fr:
dossier_not_found: "Le dossier n'existe pas ou vous n'y avez pas accès."
dossier_map_not_activated: "Le dossier n'a pas accès à la cartographie."
invalid_siret: "Le siret est incorrect"
procedure_not_found: "La procédure n'existe pas"
france_connect:
connexion: "Erreur lors de la connexion à France Connect."

View file

@ -9,6 +9,15 @@ fr:
montant_projet: 'Le montant du projet'
montant_aide_demande: "Le montant d'aide demandée"
date_previsionnelle: "La date de début prévisionnelle"
state:
draft: "Brouillon"
initiated: "Soumis"
replied: "Répondu"
updated: "Mis à jour"
validated: "Validé"
submitted: "Déposé"
closed: "Traité"
errors:
models:
dossier:

View file

@ -16,8 +16,15 @@ Rails.application.routes.draw do
root 'root#index'
namespace :france_connect do
get 'entreprise' => 'entreprise#login'
get 'entreprise/callback' => 'entreprise#callback'
# get 'entreprise' => 'entreprise#login'
# get 'entreprise/callback' => 'entreprise#callback'
get 'particulier' => 'particulier#login'
get 'particulier/callback' => 'particulier#callback'
get 'particulier/new' => 'particulier#new'
post 'particulier/create' => 'particulier#create'
post 'particulier/check_email' => 'particulier#check_email'
end
get 'demo' => 'demo#index'
@ -38,7 +45,6 @@ Rails.application.routes.draw do
post '/carte' => 'carte#save'
put '/archive' => 'dossiers#archive'
end
resource :dossiers
end

View file

@ -0,0 +1,9 @@
class AddFranceConnectParticulierAttributsToUser < ActiveRecord::Migration
def change
add_column :users, :gender, :string
add_column :users, :given_name, :string
add_column :users, :family_name, :string
add_column :users, :birthdate, :date
add_column :users, :birthplace, :string
end
end

View file

@ -0,0 +1,5 @@
class ChangeTypeOfLogedInWithFranceConnectToUser < ActiveRecord::Migration
def change
change_column :users, :loged_in_with_france_connect, :string
end
end

View file

@ -0,0 +1,5 @@
class AddOpenidToUser < ActiveRecord::Migration
def change
add_column :users, :france_connect_particulier_id, :string
end
end

View file

@ -0,0 +1,5 @@
class AddMandataireSocialToDossier < ActiveRecord::Migration
def change
add_column :dossiers, :mandataire_social, :boolean, default: false
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151214133426) do
ActiveRecord::Schema.define(version: 20160106100227) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -69,6 +69,7 @@ ActiveRecord::Schema.define(version: 20151214133426) do
t.integer "user_id"
t.text "json_latlngs"
t.boolean "archived", default: false
t.boolean "mandataire_social", default: false
end
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
@ -201,12 +202,12 @@ ActiveRecord::Schema.define(version: 20151214133426) do
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
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.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"
@ -214,7 +215,13 @@ ActiveRecord::Schema.define(version: 20151214133426) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "siret"
t.boolean "loged_in_with_france_connect", default: false
t.string "loged_in_with_france_connect", default: "false"
t.string "gender"
t.string "given_name"
t.string "family_name"
t.date "birthdate"
t.string "birthplace"
t.string "france_connect_particulier_id"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree

View file

@ -0,0 +1,35 @@
class SIADE::MandatairesSociauxAdapter
def initialize(siren)
@siren = siren
end
def data_source
@data_source ||= JSON.parse(SIADE::API.entreprise(@siren), symbolize_names: true)
rescue
@data_source = nil
end
def to_params
params = {}
data_source[:entreprise][:mandataires_sociaux].each_with_index do |mandataire, i|
params[i] = {}
mandataire.each do |k, v|
params[i][k] = v if attr_to_fetch.include?(k)
end
end
params
rescue
nil
end
def attr_to_fetch
[:nom,
:prenom,
:fonction,
:date_naissance,
:date_naissance_timestamp]
end
end

View file

@ -19,7 +19,7 @@ describe Admin::PiecesJustificativesController, type: :controller do
context 'when procedure have at least a file' do
let!(:dossier) { create(:dossier, :with_user, procedure: procedure, state: :initiated) }
it { expect(subject.status).to eq(403) }
it { is_expected.to redirect_to admin_procedure_path id: procedure_id }
end
context 'when procedure does not belong to admin' do

View file

@ -68,7 +68,7 @@ describe Admin::ProceduresController, type: :controller do
context 'when procedure have at least a file' do
let!(:dossier) { create(:dossier, :with_user, procedure: procedure, state: :initiated) }
it { expect(subject.status).to eq(403) }
it { is_expected.to redirect_to admin_procedure_path id: procedure_id }
end
context "when procedure doesn't exist" do

View file

@ -21,7 +21,7 @@ describe Admin::TypesDeChampController, type: :controller do
context 'when procedure have at least a file' do
let!(:dossier) { create(:dossier, :with_user, procedure: procedure, state: :initiated) }
it { expect(subject.status).to eq(403) }
it { is_expected.to redirect_to admin_procedure_path id: procedure_id }
end
context 'when procedure does not belong to admin' do

View file

@ -1,61 +0,0 @@
require 'spec_helper'
describe FranceConnect::EntrepriseController, type: :controller do
describe '.login' do
it 'redirect to france connect serveur' do
get :login
expect(response.status).to eq(302)
end
end
describe '.callback' do
context 'when param code is missing' do
it 'redirect to login page' do
get :callback
expect(response).to redirect_to(new_user_session_path)
end
end
context 'when params code is present' do
let(:code) { 'plop' }
let(:email) { 'patator@cake.com' }
let(:siret) { '41123069100049' }
let(:user_info) { Hashie::Mash.new(email: email, siret: siret) }
context 'when code is correct' do
let(:email) { 'patator@cake.com' }
let(:current_user) { User.find_by_email(email) }
before do
allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_info)
get :callback, code: code
end
it 'current user have attribut loged_in_with_france_connect at true' do
expect(current_user.loged_in_with_france_connect).to be_truthy
end
let(:stored_location) { '/plip/plop' }
it 'redirect to stored location' do
subject.store_location_for(:user, stored_location)
get :callback, code: code
expect(response).to redirect_to(stored_location)
end
end
context 'when code is not correct' do
before do
allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
get :callback, code: code
end
it 'redirect to login page' do
expect(response).to redirect_to(new_user_session_path)
end
it 'display error message' do
expect(flash[:alert]).to be_present
end
end
end
end
end

View file

@ -0,0 +1,61 @@
# require 'spec_helper'
#
# describe FranceConnect::EntrepriseController, type: :controller do
#
# describe '.login' do
# it 'redirect to france connect serveur' do
# get :login
# expect(response.status).to eq(302)
# end
# end
#
# describe '.callback' do
# context 'when param code is missing' do
# it 'redirect to login page' do
# get :callback
# expect(response).to redirect_to(new_user_session_path)
# end
# end
# context 'when params code is present' do
# let(:code) { 'plop' }
# let(:email) { 'patator@cake.com' }
# let(:siret) { '41123069100049' }
# let(:user_info) { Hashie::Mash.new(email: email, siret: siret) }
# context 'when code is correct' do
# let(:email) { 'patator@cake.com' }
# let(:current_user) { User.find_by_email(email) }
#
# before do
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_info)
# get :callback, code: code
# end
#
# it 'current user have attribut loged_in_with_france_connect at enterprise' do
# expect(current_user.loged_in_with_france_connect).to eq 'entreprise'
# end
# let(:stored_location) { '/plip/plop' }
# it 'redirect to stored location' do
# subject.store_location_for(:user, stored_location)
# get :callback, code: code
# expect(response).to redirect_to(stored_location)
# end
# end
#
# context 'when code is not correct' do
# before do
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
# get :callback, code: code
# end
#
# it 'redirect to login page' do
# expect(response).to redirect_to(new_user_session_path)
# end
#
# it 'display error message' do
# expect(flash[:alert]).to be_present
# end
# end
# end
# end
# end
#

View file

@ -0,0 +1,138 @@
require 'spec_helper'
describe FranceConnect::ParticulierController, type: :controller do
let(:code) { 'plop' }
let(:given_name) { 'titi' }
let(:family_name) { 'toto' }
let(:birthdate) { '20150821' }
let(:gender) { 'M' }
let(:birthplace) { '1234' }
let(:france_connect_particulier_id) { 'blabla' }
let(:email) { '' }
let(:password) { '' }
let(:user_info) { Hashie::Mash.new(france_connect_particulier_id: france_connect_particulier_id, given_name: given_name, family_name: family_name, birthdate: birthdate, birthplace: birthplace, gender: gender, email: email, password: password) }
describe '.login' do
it 'redirect to france connect serveur' do
get :login
expect(response.status).to eq(302)
end
end
describe '.callback' do
context 'when param code is missing' do
it 'redirect to login page' do
get :callback
expect(response).to redirect_to(new_user_session_path)
end
end
context 'when params code is present' do
context 'when code is correct' do
before do
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier).and_return(user_info)
get :callback, code: code
end
context 'when france_connect_particulier_id exist in database' do
before do
create(:user, france_connect_particulier_id: france_connect_particulier_id, email: email, given_name: given_name, family_name: family_name, birthdate: birthdate, gender: gender, birthplace: birthplace)
get :callback, code: code
end
let(:email) { 'plop@plop.com' }
let(:current_user) { User.find_by_email(email) }
let(:stored_location) { '/plip/plop' }
it 'current user have attribut loged_in_with_france_connect? at true' do
expect(current_user.loged_in_with_france_connect?).to be_truthy
end
it 'redirect to stored location' do
subject.store_location_for(:user, stored_location)
get :callback, code: code
expect(response).to redirect_to(stored_location)
end
end
context 'when france_connect_particulier_id does not exist in database' do
it 'redirects to check email FC page' do
expect(response).to redirect_to(france_connect_particulier_new_path(user: user_info))
end
end
end
context 'when code is not correct' do
before do
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
get :callback, code: code
end
it 'redirect to login page' do
expect(response).to redirect_to(new_user_session_path)
end
it 'display error message' do
expect(flash[:alert]).to be_present
end
end
end
end
describe 'POST #create' do
let(:email) { 'plop@gmail.com' }
subject { post :create, user: user_info }
context 'when email is filled' do
it { expect { subject }.to change { User.count }.by(1) }
it 'redirects user root page' do
subject
expect(response).to redirect_to(root_path)
end
end
context 'when email is incorrect' do
let(:email) { '' }
it { expect { subject }.to change { User.count }.by(0) }
it 'redirect to check email FC page' do
subject
expect(response).to redirect_to(france_connect_particulier_new_path(user: user_info))
end
end
end
describe 'POST #check_email' do
let(:email) { 'plop@gmail.com' }
let(:password) { 'blabla141415' }
subject { post :check_email, user: user_info }
context 'when email is linked at an existant user' do
context 'when email and password couple is valid' do
let!(:user) { create(:user, email: email, password: password) }
it { expect { subject }.to change { user.reload.france_connect_particulier_id } }
it { is_expected.to redirect_to root_path }
end
context 'when email and password couple is not valid' do
let!(:user) { create(:user, email: email, password: 'plop12345678') }
before do
subject
end
it { expect(flash[:alert]).to be_present }
end
end
context 'when email is not used' do
it { expect { subject }.to change { User.count }.by(1) }
end
end
end

View file

@ -10,7 +10,7 @@ RSpec.describe Users::CarteController, type: :controller do
let!(:entreprise) { create(:entreprise, dossier: dossier) }
let!(:etablissement) { create(:etablissement, dossier: dossier) }
let(:bad_dossier_id) { Dossier.count + 1000 }
let(:adresse) { etablissement.adresse }
let(:adresse) { etablissement.geo_adresse }
before do
sign_in dossier.user
@ -137,10 +137,10 @@ RSpec.describe Users::CarteController, type: :controller do
describe '#get_position' do
context 'Geocodeur renvoie des positions nil' do
let(:etablissement) { create(:etablissement, adresse: bad_adresse) }
let(:etablissement) { create(:etablissement, adresse: bad_adresse, numero_voie: 'dzj', type_voie: 'fzjfk', nom_voie: 'hdidjkz', complement_adresse: 'fjef', code_postal: 'fjeiefk', localite: 'zjfkfz') }
let(:dossier) { create(:dossier, :with_procedure, :with_user, etablissement: etablissement) }
before do
stub_request(:get, "http://api-adresse.data.gouv.fr/search?limit=1&q=#{bad_adresse}")
stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/)
.to_return(status: 200, body: '{"query": "babouba", "version": "draft", "licence": "ODbL 1.0", "features": [], "type": "FeatureCollection", "attribution": "BAN"}', headers: {})
get :get_position, dossier_id: dossier.id
end

View file

@ -46,7 +46,7 @@ describe Users::DossiersController, type: :controller do
context 'when procedure is archived' do
let(:procedure) { create(:procedure, archived: 'true') }
it { is_expected.to have_http_status(404) }
it { is_expected.to redirect_to users_dossiers_path }
end
end
context 'when user is not logged' do
@ -61,7 +61,7 @@ describe Users::DossiersController, type: :controller do
sign_in create(:user)
end
it { is_expected.to have_http_status(404) }
it { is_expected.to redirect_to users_dossiers_path }
end
end
end
@ -86,6 +86,7 @@ describe Users::DossiersController, type: :controller do
describe 'dossier attributs' do
let(:user) { create(:user) }
context 'with valid siret ' do
before do
sign_in user
@ -140,6 +141,30 @@ describe Users::DossiersController, type: :controller do
expect(Dossier.last.state).to eq('draft')
end
describe 'Mandataires Sociaux' do
let(:user) { create(:user, given_name: given_name, family_name: family_name, birthdate: birthdate, france_connect_particulier_id: '1234567') }
before do
subject
end
context 'when user is present in mandataires sociaux' do
let(:given_name) { 'GERARD' }
let(:family_name) { 'DEGONSE' }
let(:birthdate) { '1947-07-03' }
it { expect(Dossier.last.mandataire_social).to be_truthy }
end
context 'when user is not present in mandataires sociaux' do
let(:given_name) { 'plop' }
let(:family_name) { 'plip' }
let(:birthdate) { '1965-01-27' }
it { expect(Dossier.last.mandataire_social).to be_falsey }
end
end
describe 'get rna informations' do
context 'when siren have not rna informations' do
let(:rna_status) { 404 }

View file

@ -5,7 +5,7 @@ describe Users::RegistrationsController, type: :controller do
let(:email) { 'test@octo.com' }
let(:password) { 'password' }
let(:user) { { email: email, password: password, password_confirmation: password } }
let(:user) { {email: email, password: password, password_confirmation: password} }
before do
@request.env["devise.mapping"] = Devise.mappings[:user]
@ -14,13 +14,25 @@ describe Users::RegistrationsController, type: :controller do
describe '.create' do
subject { post :create, user: user }
it { expect(described_class).to be < Devise::RegistrationsController }
context 'when user is correct' do
it { expect(described_class).to be < Devise::RegistrationsController }
it 'welcome email is send' do
expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer)
expect(WelcomeMailer).to receive(:deliver_now!)
it 'welcome email is send' do
expect(WelcomeMailer).to receive(:welcome_email).and_return(WelcomeMailer)
expect(WelcomeMailer).to receive(:deliver_now!)
subject
subject
end
end
context 'when user is not correct' do
let(:user) { {email: '', password: password, password_confirmation: password} }
it 'welcome email is not send' do
expect(WelcomeMailer).not_to receive(:welcome_email)
subject
end
end
end
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Users::SessionsController, type: :controller do
let(:loged_in_with_france_connect) { true }
let(:loged_in_with_france_connect) { 'entreprise' }
let(:user) { create(:user, loged_in_with_france_connect: loged_in_with_france_connect) }
before do
@ -17,7 +17,7 @@ describe Users::SessionsController, type: :controller do
user.reload
end
subject { user.loged_in_with_france_connect }
subject { user.loged_in_with_france_connect? }
it { is_expected.to be_falsey }
end
@ -33,19 +33,27 @@ describe Users::SessionsController, type: :controller do
expect(subject.current_user).to be_nil
end
it 'loged_in_with_france_connect current_user attribut is false' do
it 'loged_in_with_france_connect current_user attribut is nil' do
user.reload
expect(user.loged_in_with_france_connect).to be_falsey
expect(user.loged_in_with_france_connect?).to be_falsey
end
context 'when user is connect with france connect' do
context 'when user is connect with france connect entreprise' do
it 'redirect to france connect logout page' do
expect(response).to redirect_to(FRANCE_CONNECT.entreprise_logout_endpoint)
end
end
context 'when user is connect with france connect entreprise' do
let(:loged_in_with_france_connect) { 'particulier' }
it 'redirect to france connect logout page' do
expect(response).to redirect_to(FRANCE_CONNECT.particulier_logout_endpoint)
end
end
context 'when user is not connect with france connect' do
let(:loged_in_with_france_connect) { false }
let(:loged_in_with_france_connect) { '' }
it 'redirect to root page' do
expect(response).to redirect_to(root_path)

View file

@ -10,7 +10,7 @@ describe DossierDecorator do
end
describe 'state_fr' do
subject{ super().state_fr }
subject{ super().display_state }
it 'draft is brouillon' do
dossier.draft!

View file

@ -0,0 +1,81 @@
# require 'spec_helper'
#
# feature 'France Connect Connexion' do
# context 'when user is on login page' do
#
# before do
# visit new_user_session_path
# end
#
# scenario 'link to France Connect is present' do
# expect(page).to have_css('a#btn_fce')
# end
#
# context 'and click on france connect link' do
# let(:code) { 'plop' }
#
# context 'when authentification is ok' do
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(Hashie::Mash.new(email: 'patator@cake.com'))
# page.find_by_id('btn_fce').click
# end
#
# scenario 'he is redirected to france connect' do
# expect(page).to have_content('Mes dossiers')
# end
# end
#
# context 'when authentification is not ok' do
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
# page.find_by_id('btn_fce').click
# end
#
# scenario 'he is redirected to login page' do
# expect(page).to have_css('a#btn_fce')
# end
#
# scenario 'error message is displayed' do
# expect(page).to have_content(I18n.t('errors.messages.france_connect.connexion'))
# end
# end
# end
# end
#
#
# feature 'redirection' do
# before do
# visit initial_path
# end
# context 'when he use france connect' do
# let(:code) { 'my_code' }
# let(:email) { 'plop@plop.com' }
# let(:siret) { '00000000000000' }
# let(:user_infos) { Hashie::Mash.new(email: email, siret: siret) }
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_entreprise_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_infos)
# page.find_by_id('btn_fce').click
# end
# context 'when starting page is dossiers list' do
# let(:initial_path) { users_dossiers_path }
# scenario 'he is redirected to dossier list' do
# expect(page).to have_css('#users_index')
# end
# end
# context 'when starting page is procedure' do
# let(:procedure) { create(:procedure) }
# let(:initial_path) { new_users_dossiers_path(procedure_id: procedure.id ) }
# scenario 'he is redirected to siret page' do
# expect(page).to have_css('#users_siret_index')
# end
#
# scenario 'the siret is already written in form' do
# expect(page.find_by_id('dossier_siret').value).to have_content(siret)
# end
# end
# end
# end
# end

View file

@ -0,0 +1,84 @@
require 'spec_helper'
feature 'France Connect Particulier Connexion' do
let(:code) { 'plop' }
let(:given_name) { 'titi' }
let(:family_name) { 'toto' }
let(:birthdate) { '20150821' }
let(:gender) { 'M' }
let(:birthplace) { '1234' }
let(:email) { 'plop@plop.com' }
let(:know_france_connect_particulier_id) { 'blabla' }
let(:unknow_france_connect_particulier_id) { 'titi' }
let(:user_info) { Hashie::Mash.new(france_connect_particulier_id: france_connect_particulier_id, given_name: given_name, family_name: family_name, birthdate: birthdate, birthplace: birthplace, gender: gender, email: email) }
context 'when user is on login page' do
before do
visit new_user_session_path
end
scenario 'link to France Connect is present' do
expect(page).to have_css('a#btn_fcp')
end
context 'and click on france connect link' do
let(:code) { 'plop' }
context 'when authentification is ok' do
let!(:user) { create(:user, france_connect_particulier_id: know_france_connect_particulier_id, given_name: given_name, family_name: family_name, birthdate: birthdate, birthplace: birthplace, gender: gender) }
before do
allow_any_instance_of(FranceConnectParticulierClient).to receive(:authorization_uri).and_return(france_connect_particulier_callback_path(code: code))
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier).and_return(user_info)
page.find_by_id('btn_fcp').click
end
context 'when is the first connexion' do
let(:france_connect_particulier_id) { unknow_france_connect_particulier_id }
scenario 'he is redirected to france connect particulier page' do
expect(page).to have_content('Nouvelle connexion')
end
context 'when he fill an email and valid' do
before do
page.find_by_id('user_email').set email
page.find_by_id('valid_new_fcp').click
end
scenario 'he is redirected to user dossiers page' do
expect(page).to have_content('Mes dossiers')
end
end
end
context 'when is not the first connexion' do
let(:france_connect_particulier_id) { know_france_connect_particulier_id }
scenario 'he is redirected to user dossiers page' do
expect(page).to have_content('Mes dossiers')
end
end
end
context 'when authentification is not ok' do
before do
allow_any_instance_of(FranceConnectParticulierClient).to receive(:authorization_uri).and_return(france_connect_particulier_callback_path(code: code))
allow(FranceConnectService).to receive(:retrieve_user_informations_particulier) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
page.find_by_id('btn_fcp').click
end
scenario 'he is redirected to login page' do
expect(page).to have_css('a#btn_fcp')
end
scenario 'error message is displayed' do
expect(page).to have_content(I18n.t('errors.messages.france_connect.connexion'))
end
end
end
end
end

View file

@ -1,81 +0,0 @@
require 'spec_helper'
feature 'France Connect Connexion' do
# context 'when user is on login page' do
#
# before do
# visit new_user_session_path
# end
#
# scenario 'link to France Connect is present' do
# expect(page).to have_css('a#btn_fc')
# end
#
# context 'and click on france connect link' do
# let(:code) { 'plop' }
#
# context 'when authentification is ok' do
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(Hashie::Mash.new(email: 'patator@cake.com'))
# page.find_by_id('btn_fc').click
# end
#
# scenario 'he is redirected to france connect' do
# expect(page).to have_content('Mes dossiers')
# end
# end
#
# context 'when authentification is not ok' do
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise) { raise Rack::OAuth2::Client::Error.new(500, error: 'Unknown') }
# page.find_by_id('btn_fc').click
# end
#
# scenario 'he is redirected to login page' do
# expect(page).to have_css('a#btn_fc')
# end
#
# scenario 'error message is displayed' do
# expect(page).to have_content(I18n.t('errors.messages.france_connect.connexion'))
# end
# end
# end
# end
#
#
# feature 'redirection' do
# before do
# visit initial_path
# end
# context 'when he use france connect' do
# let(:code) { 'my_code' }
# let(:email) { 'plop@plop.com' }
# let(:siret) { '00000000000000' }
# let(:user_infos) { Hashie::Mash.new(email: email, siret: siret) }
# before do
# allow_any_instance_of(FranceConnectEntrepriseClient).to receive(:authorization_uri).and_return(france_connect_callback_path(code: code))
# allow(FranceConnectService).to receive(:retrieve_user_informations_entreprise).and_return(user_infos)
# page.find_by_id('btn_fc').click
# end
# context 'when starting page is dossiers list' do
# let(:initial_path) { users_dossiers_path }
# scenario 'he is redirected to dossier list' do
# expect(page).to have_css('#users_index')
# end
# end
# context 'when starting page is procedure' do
# let(:procedure) { create(:procedure) }
# let(:initial_path) { new_users_dossiers_path(procedure_id: procedure.id ) }
# scenario 'he is redirected to siret page' do
# expect(page).to have_css('#users_siret_index')
# end
#
# scenario 'the siret is already written in form' do
# expect(page.find_by_id('dossier_siret').value).to have_content(siret)
# end
# end
# end
# end
end

View file

@ -5,6 +5,7 @@ feature 'user arrive on siret page' do
let(:user) { create(:user) }
let(:siret) { '42149333900020' }
let(:siren) { siret[0...9] }
context 'when user is not logged in' do
before do
visit new_users_dossiers_path(procedure_id: procedure.id)

View file

@ -109,9 +109,7 @@ describe SIADE::API do
let(:status) { 200 }
let(:body) { File.read('spec/support/files/rna.json') }
it 'raises RestClient::Unauthorized' do
expect(subject).to eq(body)
end
it{ expect(subject).to eq(body) }
end
end
end

View file

@ -0,0 +1,43 @@
require 'spec_helper'
describe SIADE::MandatairesSociauxAdapter do
subject { described_class.new('418166096').to_params }
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/418166096?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
end
it '#to_params class est une Hash ?' do
expect(subject).to be_an_instance_of(Hash)
end
describe 'Mandataires Sociaux' do
it { expect(subject.size).to eq(8) }
describe 'Attributs' do
it 'Un mandataire social possède bien un nom' do
expect(subject[0][:nom]).to eq('HISQUIN')
end
it 'Un mandataire social possède bien un prenom' do
expect(subject[0][:prenom]).to eq('FRANCOIS')
end
it 'Un mandataire social possède bien une fonction' do
expect(subject[0][:fonction]).to eq('PRESIDENT DU DIRECTOIRE')
end
it 'Un mandataire social possède bien une date de naissance' do
expect(subject[0][:date_naissance]).to eq('1965-01-27')
end
it 'Un mandataire social possède bien une date de naissance au format timestamp' do
expect(subject[0][:date_naissance_timestamp]).to eq(-155523600)
end
end
end
end

View file

@ -4,6 +4,7 @@ describe SIADE::RNAAdapter do
let(:siret) { '50480511000013' }
let(:body) { File.read('spec/support/files/rna.json') }
let(:status) { 200 }
subject { described_class.new(siret).to_params }
before do
@ -15,36 +16,23 @@ describe SIADE::RNAAdapter do
let(:siret) { '234567' }
let(:body) { '' }
let(:status) { '404' }
it { is_expected.to eq(nil) }
end
it '#to_params class est une Hash ?' do
expect(subject).to be_an_instance_of(Hash)
end
it { expect(subject).to be_an_instance_of(Hash) }
context 'Attributs Associations' do
it 'L\'associations contient bien un id' do
expect(subject[:association_id]).to eq('W595001988')
end
describe 'Attributs Associations' do
it { expect(subject[:association_id]).to eq('W595001988') }
it 'L\'associations contient bien un titre' do
expect(subject[:titre]).to eq('UN SUR QUATRE')
end
it { expect(subject[:titre]).to eq('UN SUR QUATRE') }
it 'L\'associations contient bien un objet' do
expect(subject[:objet]).to eq("valoriser, transmettre et partager auprès des publics les plus larges possibles, les bienfaits de l'immigration, la richesse de la diversité et la curiosité de l'autre autrement")
end
it { expect(subject[:objet]).to eq("valoriser, transmettre et partager auprès des publics les plus larges possibles, les bienfaits de l'immigration, la richesse de la diversité et la curiosité de l'autre autrement") }
it 'L\'associations contient bien une date de creation' do
expect(subject[:date_creation]).to eq('2014-01-23')
end
it { expect(subject[:date_creation]).to eq('2014-01-23') }
it 'L\'associations contient bien une date de de declaration' do
expect(subject[:date_declaration]).to eq('2014-01-24')
end
it { expect(subject[:date_declaration]).to eq('2014-01-24') }
it 'L\'associations contient bien une date de publication' do
expect(subject[:date_publication]).to eq('2014-02-08')
end
it { expect(subject[:date_publication]).to eq('2014-02-08') }
end
end

View file

@ -0,0 +1,17 @@
require 'spec_helper'
describe FranceConnectParticulierClient do
describe '.initialize' do
it 'create an openid client' do
expect(described_class).to be < OpenIDConnect::Client
end
context 'when given code in params' do
let(:code) { 'plop' }
subject { described_class.new(code: code) }
it 'set authorisation code' do
expect_any_instance_of(described_class).to receive(:authorization_code=).with(code)
described_class.new(code: code)
end
end
end
end

View file

@ -16,6 +16,13 @@ describe User, type: :model do
it { is_expected.to have_db_column(:updated_at) }
it { is_expected.to have_db_column(:siret) }
it { is_expected.to have_db_column(:loged_in_with_france_connect) }
it { is_expected.to have_db_column(:given_name) }
it { is_expected.to have_db_column(:family_name) }
it { is_expected.to have_db_column(:birthdate) }
it { is_expected.to have_db_column(:gender) }
it { is_expected.to have_db_column(:birthplace) }
it { is_expected.to have_db_column(:france_connect_particulier_id) }
end
describe 'associations' do
it { is_expected.to have_many(:dossiers) }

View file

@ -2,12 +2,11 @@ require 'spec_helper'
describe FranceConnectService do
describe '.retrieve_user_informations_entreprise' do
let(:code) { 'plop' }
let(:access_token) { 'my access_token' }
let(:email) { 'patator@cake.com' }
let(:siret) { '41123069100049' }
let(:user_info_hash) { {'email' => email, 'siret' => siret} }
let(:user_info_hash) { {'email' => email, 'siret' => siret} }
let(:user_info) { instance_double('OpenIDConnect::ResponseObject::UserInfo', raw_attributes: user_info_hash, email: email) }
subject { described_class.retrieve_user_informations_entreprise code }
@ -26,4 +25,44 @@ describe FranceConnectService do
expect(subject.siret).to eq(siret)
end
end
describe '.retrieve_user_informations_particulier' do
let(:code) { 'plop' }
let(:access_token) { 'my access_token' }
let(:given_name) { 'plop1' }
let(:family_name) { 'plop2' }
let(:birthdate) { 'plop3' }
let(:gender) { 'plop4' }
let(:birthplace) { 'plop5' }
let(:email) { 'plop@emaiL.com' }
let(:phone) { '012345678' }
let(:france_connect_particulier_id) { 'izhikziogjuziegj' }
let(:user_info_hash) { {sub: france_connect_particulier_id, given_name: given_name, family_name: family_name, birthdate: birthdate, gender: gender, birthplace: birthplace, email: email, phone: phone} }
let(:user_info) { instance_double('OpenIDConnect::ResponseObject::UserInfo', raw_attributes: user_info_hash) }
subject { described_class.retrieve_user_informations_particulier code }
before do
allow_any_instance_of(FranceConnectParticulierClient).to receive(:access_token!).and_return(access_token)
allow(access_token).to receive(:userinfo!).and_return(user_info)
end
it 'set code for FranceConnectEntrepriseClient' do
expect_any_instance_of(FranceConnectParticulierClient).to receive(:authorization_code=).with(code)
subject
end
it 'returns user informations in a object' do
expect(subject.given_name).to eq(given_name)
expect(subject.family_name).to eq(family_name)
expect(subject.birthdate).to eq(birthdate)
expect(subject.gender).to eq(gender)
expect(subject.email).to eq(email)
expect(subject.phone).to eq(phone)
expect(subject.birthplace).to eq(birthplace)
expect(subject.france_connect_particulier_id).to eq(france_connect_particulier_id)
end
end
end

View file

@ -51,6 +51,17 @@ SIADETOKEN = :valid_token unless defined? SIADETOKEN
include Warden::Test::Helpers
include SmartListing::Helper
include SmartListing::Helper::ControllerExtensions
module SmartListing
module Helper
def view_context
'mock'
end
end
end
WebMock.disable_net_connect!(allow_localhost: true)
RSpec.configure do |config|

View file

@ -4,8 +4,7 @@ describe 'admin/procedures/show.html.haml', type: :view do
let(:procedure) { create(:procedure) }
before do
assign(:procedure, procedure.decorate)
assign(:facade, AdminProceduresShowFacades.new(procedure))
assign(:facade, AdminProceduresShowFacades.new(procedure.decorate))
render
end

View file

@ -9,11 +9,15 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
let!(:decorate_dossier_replied) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet replied', state: 'replied').decorate }
let!(:decorate_dossier_closed) { create(:dossier, :with_user, procedure: procedure, nom_projet: 'projet closed', state: 'closed').decorate }
describe 'on tab a_traiter' do
before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_gestionnaire.paginate(:page => 1).decorate)
assign(:dossiers, (smart_listing_create :dossiers,
gestionnaire.dossiers.waiting_for_gestionnaire,
partial: "backoffice/dossiers/list",
array: true))
assign(:liste, 'a_traiter')
assign(:a_traiter_class, 'active')
render
end
@ -21,7 +25,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_initiated.nom_projet) }
it { is_expected.to have_content(decorate_dossier_initiated.state_fr) }
it { is_expected.to have_content(decorate_dossier_initiated.display_state) }
it { is_expected.to have_content(decorate_dossier_initiated.last_update) }
it { is_expected.not_to have_content(decorate_dossier_replied.nom_projet) }
@ -35,8 +39,13 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
describe 'on tab en_attente' do
before do
assign(:dossiers, gestionnaire.dossiers.waiting_for_user.paginate(:page => 1).decorate)
assign(:dossiers, (smart_listing_create :dossiers,
gestionnaire.dossiers.waiting_for_user,
partial: "backoffice/dossiers/list",
array: true))
assign(:liste, 'en_attente')
assign(:en_attente_class, 'active')
render
end
@ -44,7 +53,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_replied.nom_projet) }
it { is_expected.to have_content(decorate_dossier_replied.state_fr) }
it { is_expected.to have_content(decorate_dossier_replied.display_state) }
it { is_expected.to have_content(decorate_dossier_replied.last_update) }
it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) }
@ -57,16 +66,21 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
describe 'on tab termine' do
before do
assign(:dossiers, gestionnaire.dossiers.termine.paginate(:page => 1).decorate)
assign(:dossiers, (smart_listing_create :dossiers,
gestionnaire.dossiers.termine,
partial: "backoffice/dossiers/list",
array: true))
assign(:termine_class, 'active')
assign(:liste, 'termine')
render
end
subject { rendered }
it { is_expected.to have_css('#backoffice_index') }
it { is_expected.to have_content(procedure.libelle) }
it { is_expected.to have_content(decorate_dossier_closed.nom_projet) }
it { is_expected.to have_content(decorate_dossier_closed.state_fr) }
it { is_expected.to have_content(decorate_dossier_closed.display_state) }
it { is_expected.to have_content(decorate_dossier_closed.last_update) }
it { is_expected.not_to have_content(decorate_dossier_initiated.nom_projet) }

Some files were not shown because too many files have changed in this diff Show more