Merge branch 'staging'

This commit is contained in:
Guillaume Lazzara 2016-02-09 17:22:09 +01:00
commit 016295291d
93 changed files with 1347 additions and 333 deletions

View file

@ -505,4 +505,4 @@ DEPENDENCIES
will_paginate-bootstrap
BUNDLED WITH
1.10.6
1.11.2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 KiB

After

Width:  |  Height:  |  Size: 771 KiB

View file

@ -0,0 +1,14 @@
$(document).on('page:load', destroy_action);
$(document).ready(destroy_action);
function destroy_action(){
$("#destroy").on('click', function(){
$("#destroy").hide();
$("#confirm").show();
});
$("#confirm #cancel").on('click', function(){
$("#destroy").show();
$("#confirm").hide();
});
}

View file

@ -28,11 +28,18 @@
//= require turf
//= require franceconnect
$(document).ready(function() {
$(document).on('page:load', scroll_to);
$(document).ready(scroll_to);
function scroll_to() {
$('.js-scrollTo').on('click', function () { // Au clic sur un élément
var page = $(this).attr('cible'); // Page cible
var speed = 600; // Durée de l'animation (en ms)
$('html, body').animate({scrollTop: $(page).offset().top - 100}, speed); // Go
return false;
});
});
}

View file

@ -23,21 +23,27 @@
@import "bootstrap";
body {
background-color: rgb(255, 255, 255)
background-color: rgb(255, 255, 255);
}
html, body {
height: 100%;
}
body {
padding-top: 50px;
}
#wrap {
min-height: 100%;
margin-bottom: -50px;
}
#wrap:after {
content: "";
display: block;
}
#footer, #wrap:after {
height: 40px;
}
@ -46,6 +52,11 @@ html, body {
background-color: rgb(240, 240, 240)
}
.main_div {
margin-left: 10rem;
margin-right: 10rem;
}
.logo {
margin-left: 10px;
padding-top: 5px;
@ -85,14 +96,26 @@ html, body {
margin-right: 105px;
}
.alert.alert-success,
.alert.alert-danger {
margin-top: -20px
#header {
top: 0;
left: -3px;
position: fixed;
width: 100%;
z-index: 10;
}
.navbar {
height: 35px;
background-color: rgb(235, 235, 235)
background-color: rgba(235, 235, 235, 0.95);
.sign_in_FC {
margin-top: -18px;
height: 70px;
}
}
.btn {
@ -161,6 +184,7 @@ div.pagination {
height: 52px;
width: 100%;
margin-top: 0px;
z-index: 10;
}
@ -212,7 +236,6 @@ div.pagination {
margin-top: -4px;
}
#fconnect-access {
right: 50px;
}

View file

@ -1,15 +1,13 @@
#wrap {
}
.max-size {
margin-left: -13%;
margin-right: -13%;
margin-left: -10rem;
margin-right: -10rem;
}
#landing {
margin-top: -20px;
background-image: image-url('landing_background.jpg');
background-attachment: fixed;
background-position: top center;
background-repeat: no-repeat;
#title {
@ -20,30 +18,28 @@
font-size: 35px;
}
.btn {
text-shadow: none;
}
color: white;
padding-top: 6%;
padding-bottom: 9%;
text-shadow: 3px 3px 4px rgba(0, 0, 0, .6);
padding-bottom: 7%;
text-shadow: 0px 0px 10px rgb(0, 0, 0);
}
.logo img {
width: 70px;
}
#buttons {
margin-top: 5%;
button {
margin-left: 30px;
margin-right: 30px;
}
}
}
#suite {
.row{
width: 100%;
margin-left: 0;
margin-right: 0;
}
.word {
border-bottom: solid darkgrey 1px;
//height: 300px;
img {
padding-top: 50px;
@ -53,22 +49,49 @@
}
}
.simplifier {
ul {
margin-top: 16%;
}
}
.securiser {
img {
width: 300px;
}
ul {
margin-top: 11%;
}
}
.echanger {
ul {
margin-top: 6%;
margin-top: 4%;
}
}
.profiter {
border-bottom: none;
//border-bottom: none;
ul {
margin-top: 9%;
margin-top: 11%;
}
}
.open_admin_compte {
border-bottom: none;
padding-top: 25px;
padding-bottom: 25px;
ol {
margin-top: 1%;
}
.btn-lg {
font-size: 20px;
padding: 12px 18px;
margin-top: 16%;
}
}
}

View file

@ -1,13 +1,11 @@
.dynamic_ul {
list-style-type: none;
margin-left: 20px;
margin-top: 13%;
li {
font: 200 20px/1.5 Helvetica, Verdana, sans-serif;
border-bottom: 1px solid #ccc;
margin-top: 9px;
margin-bottom: 9px;
margin-top: 15px;
margin-bottom: 15px;
}
li:last-child {

View file

@ -0,0 +1,41 @@
class Admin::GestionnairesController < AdminController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
def index
@gestionnaires = smart_listing_create :gestionnaires,
current_administrateur.gestionnaires,
partial: "admin/gestionnaires/list",
array: true
@gestionnaire ||= Gestionnaire.new
end
def create
gestionnaire_params = create_gestionnaire_params
@gestionnaire = Gestionnaire.create(gestionnaire_params)
if @gestionnaire.errors.messages.empty?
flash.notice = 'Gestionnaire ajouté'
GestionnaireMailer.new_gestionnaire(gestionnaire_params[:email], gestionnaire_params[:password]).deliver_now!
else
flash.alert = @gestionnaire.errors.full_messages.join('<br />').html_safe
end
redirect_to admin_gestionnaires_path
end
def destroy
Gestionnaire.find(params[:id]).destroy
redirect_to admin_gestionnaires_path
end
def create_gestionnaire_params
params.require(:gestionnaire).permit(:email)
.merge(administrateur_id: current_administrateur.id)
.merge(password: SecureRandom.hex(5))
end
end

View file

@ -86,7 +86,7 @@ class Admin::ProceduresController < AdminController
private
def create_procedure_params
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :euro_flag, :logo, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
params.require(:procedure).permit(:libelle, :description, :organisation, :direction, :lien_demarche, :euro_flag, :logo, :cerfa_flag, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id)
end
def create_module_api_carto_params

View file

@ -2,7 +2,7 @@ class API::V1::DossiersController < APIController
def index
procedure = current_administrateur.procedures.find(params[:procedure_id])
dossiers = procedure.dossiers.paginate(page: params[:page])
dossiers = procedure.dossiers.where.not(state: :draft).paginate(page: params[:page])
render json: dossiers, each_serializer: DossiersSerializer, meta: pagination(dossiers), meta_key: 'pagination', status: 200
rescue ActiveRecord::RecordNotFound => e
render json: {}, status: 404

View file

@ -1,6 +1,5 @@
class API::V1::ProceduresController < APIController
def show
@procedure = current_administrateur.procedures.find(params[:id]).decorate
render json: @procedure

View file

@ -4,5 +4,4 @@ class Backoffice::CommentairesController < CommentairesController
def is_gestionnaire?
true
end
end

View file

@ -6,9 +6,9 @@ class CommentairesController < ApplicationController
if is_gestionnaire?
@commentaire.email = current_gestionnaire.email
@commentaire.dossier.next_step! 'gestionnaire', 'comment'
else #is_user
else
@commentaire.email = current_user.email
@commentaire.dossier.next_step! 'user', 'comment'
@commentaire.dossier.next_step! 'user', 'comment' if current_user.email == @commentaire.dossier.user.email
end
@commentaire.body = params['texte_commentaire']
@ -17,6 +17,9 @@ class CommentairesController < ApplicationController
if is_gestionnaire?
NotificationMailer.new_answer(@commentaire.dossier).deliver_now!
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
elsif current_user.email != @commentaire.dossier.user.email
invite = Invite.find_by_email current_user.email
redirect_to url_for(controller: 'users/dossiers/invites', action: :show, id: invite.id)
else
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params['dossier_id'])
end

View file

@ -0,0 +1,23 @@
class InvitesController < ApplicationController
def create
email_sender = current_gestionnaire.email
user = User.find_by_email(params[:email])
invite = Invite.create(dossier_id: params[:dossier_id], user: user, email: params[:email], email_sender: email_sender)
if invite.valid?
InviteMailer.invite_user(invite).deliver_now! unless invite.user.nil?
InviteMailer.invite_guest(invite).deliver_now! if invite.user.nil?
flash.notice = "Invitation envoyée (#{invite.email})"
else
flash.alert = invite.errors.full_messages.join('<br />').html_safe
end
if gestionnaire_signed_in?
redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id'])
# else
# redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: params['dossier_id'])
end
end
end

View file

@ -11,7 +11,7 @@ class RootController < ApplicationController
redirect_to admin_procedures_path
else
redirect_to new_user_session_path
render 'landing'
end
end
end

View file

@ -23,6 +23,8 @@ class Users::DescriptionController < UsersController
def create
@dossier = current_user_dossier
@procedure = @dossier.procedure
unless @dossier.update_attributes(create_params)
@dossier = @dossier.decorate
@procedure = @dossier.procedure
@ -30,11 +32,14 @@ class Users::DescriptionController < UsersController
flash.now.alert = @dossier.errors.full_messages.join('<br />').html_safe
return render 'show'
end
if @procedure.cerfa_flag?
unless params[:cerfa_pdf].nil?
cerfa = @dossier.cerfa
cerfa.content = params[:cerfa_pdf]
cerfa.save
end
end
unless params[:champs].nil?
@dossier.champs.each do |champ|

View file

@ -0,0 +1,3 @@
class Users::Dossiers::CommentairesController < CommentairesController
before_action :authenticate_user!
end

View file

@ -0,0 +1,10 @@
class Users::Dossiers::InvitesController < UsersController
def show
@facade = InviteDossierFacades.new params[:id], current_user.email
render 'users/recapitulatif/show'
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for users_dossiers_path
end
end

View file

@ -107,7 +107,8 @@ class Users::DossiersController < UsersController
def dossiers_to_display
{'a_traiter' => waiting_for_user,
'en_attente' => waiting_for_gestionnaire,
'termine' => termine}[@liste]
'termine' => termine,
'invite' => invite}[@liste]
end
def waiting_for_user
@ -125,10 +126,16 @@ class Users::DossiersController < UsersController
@termine ||= current_user.dossiers.termine 'DESC'
end
def invite
@invite_class = (@liste == 'invite' ? 'active' : '')
@invite ||= current_user.invites
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
@dossiers_invite_total = invite.count
end
def check_siret

View file

@ -3,7 +3,9 @@ class Users::RegistrationsController < Devise::RegistrationsController
# before_filter :configure_account_update_params, only: [:update]
def after_sign_up_path_for(resource_or_scope)
WelcomeMailer.welcome_email(User.last).deliver_now!
WelcomeMailer.welcome_email(resource_or_scope).deliver_now!
check_invite! resource_or_scope
super
end
@ -62,4 +64,11 @@ class Users::RegistrationsController < Devise::RegistrationsController
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
private
def check_invite! user
Invite.where(email: user.email)
.each { |invite| invite.update_attribute(:user, user) }
end
end

View file

@ -1,6 +1,10 @@
class UsersController < ApplicationController
before_action :authenticate_user!
def index
redirect_to root_path
end
def current_user_dossier dossier_id=nil
dossier_id ||= params[:dossier_id] || params[:id]

View file

@ -37,4 +37,8 @@ class DossierFacades
def procedure
@dossier.procedure
end
def invites
@dossier.invites
end
end

View file

@ -0,0 +1,9 @@
class InviteDossierFacades < DossierFacades
#TODO rechercher en fonction de la personne/email
def initialize dossier_id, email
@dossier = (Invite.where(email: email).find(dossier_id)).dossier
@email = email
end
end

View file

@ -0,0 +1,20 @@
class GestionnaireMailer < ApplicationMailer
def new_gestionnaire email, password
send_mail email, password, "Vous avez été nommé accompagnateur sur la plateforme TPS"
end
private
def vars_mailer email, password
@password = password
@email = email
end
def send_mail email, password, subject
vars_mailer email, password
mail(from: "tps@apientreprise.fr", to: email,
subject: subject)
end
end

View file

@ -0,0 +1,25 @@
class InviteMailer < ApplicationMailer
def invite_user invite
vars_mailer invite
send_mail invite.email, "TPS - Participez à l'élaboration d'un dossier" unless invite.user.nil?
end
def invite_guest invite
vars_mailer invite
send_mail invite.email, "Invitation - #{invite.email_sender} vous invite à consulter un dossier sur la plateforme TPS"
end
private
def vars_mailer invite
@invite = invite
end
def send_mail email, subject
mail(from: "tps@apientreprise.fr", to: email,
subject: subject)
end
end

View file

@ -16,6 +16,7 @@ class Dossier < ActiveRecord::Base
has_many :quartier_prioritaires, dependent: :destroy
has_many :cadastres, dependent: :destroy
has_many :commentaires, dependent: :destroy
has_many :invites, dependent: :destroy
belongs_to :procedure
belongs_to :user
@ -25,8 +26,7 @@ class Dossier < ActiveRecord::Base
delegate :types_de_piece_justificative, to: :procedure
delegate :types_de_champ, to: :procedure
before_create :build_default_cerfa
after_save :build_default_cerfa, if: Proc.new { procedure.cerfa_flag? && procedure_id_changed? }
after_save :build_default_pieces_justificatives, if: Proc.new { procedure_id_changed? }
after_save :build_default_champs, if: Proc.new { procedure_id_changed? }
@ -188,10 +188,15 @@ class Dossier < ActiveRecord::Base
return composed_scope, dossier
end
def cerfa_available?
procedure.cerfa_flag? && !cerfa.empty?
end
private
def build_default_cerfa
build_cerfa
create_cerfa
true
end
end

10
app/models/invite.rb Normal file
View file

@ -0,0 +1,10 @@
class Invite < ActiveRecord::Base
belongs_to :dossier
belongs_to :user
validates_presence_of :email
validates_uniqueness_of :email, :scope => :dossier_id
validates :email, email_format: true
end

View file

@ -8,6 +8,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable
has_many :dossiers, dependent: :destroy
has_many :invites, dependent: :destroy
has_one :france_connect_information, dependent: :destroy
delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information

View file

@ -0,0 +1,11 @@
class EmailFormatValidator < ActiveModel::Validator
def email_regex
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
end
def validate(record)
return if record.email.blank?
record.errors[:base] << "Email invalide" unless email_regex.match(record.email)
end
end

View file

@ -0,0 +1,5 @@
-{email: 'Email*'}.each do |key, value|
.form-group{class: ('has-error' if @gestionnaire.errors.messages[key])}
%h4
=value
=f.text_field key, class: 'form-control', placeholder: value

View file

@ -0,0 +1,25 @@
- unless smart_listing.empty?
%table.table
%thead
%th#libelle= smart_listing.sortable 'Email', 'email'
- @gestionnaires.each do |gestionnaire|
%tr
%td= gestionnaire.email
%td{ style: 'text-align:right' }
%span#destroy{ class: "fa fa-times" }
#confirm
=link_to(admin_gestionnaire_path(id: gestionnaire.id), method: :delete) do
%span#valid{ class: "fa fa-check btn-success" }
%span#valid
Valider
%span
|
%span#cancel{ class: "fa fa-minus btn-danger" }
= smart_listing.paginate
= smart_listing.pagination_per_page_links
- else
%h4.center
Aucun gestionnaire

View file

@ -0,0 +1,19 @@
%h1 Gestion des gestionnaires
%br
.row
.col-md-4.col-lg-4
= smart_listing_render :gestionnaires
.col-md-1.col-lg-1
&nbsp;
.col-md-6.col-lg-6
%h3 Ajouter un gestionnaire
#procedure_new.section.section-label
= form_for @gestionnaire, url: {controller: 'admin/gestionnaires', action: :create} do |f|
.row
.col-md-5.col-lg-5
=render partial: 'informations', locals: {f: f}
.col-md-2.col-lg-2
%br
%br
=f.submit 'Valider', class: 'btn btn-info', style: 'float:left'

View file

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

View file

@ -21,9 +21,10 @@
=f.check_box :euro_flag
Afficher le drapeau européen
%br
.row
.col-md-6.col-lg-6
%h4 Cartographie
= f.fields_for :module_api_carto, @procedure.module_api_carto do |ff|
@ -40,3 +41,8 @@
%label
= ff.check_box :cadastre
Cadastre
.col-md-6.col-lg-6
%h4 Formulaire / CERFA
%label
=f.check_box :cerfa_flag
Activer l'envoi de formulaire / CERFA

View file

@ -10,11 +10,15 @@
= link_to(admin_procedures_path, id: :menu_item_procedure) do
%i.fa.fa-list{ style: "background-size: 10px;"}
&nbsp;Procédures
%li
= link_to(admin_gestionnaires_path) do
%i.fa.fa-user
&nbsp;Gestionnaires
%li.divider{ role: :separator}
%li
= link_to(admin_profile_path, id: :profile) do
%i.fa.fa-user
&nbsp;Profile
%li.divider{ role: :separator}
%li
= link_to('/administrateurs/sign_out',id: :admin_sign_out, method: :delete) do
%i.fa.fa-power-off

View file

@ -2,20 +2,31 @@
%h1#dossier_id.text-info{ :style => 'text-align:right'}
= "Dossier n°#{@facade.dossier.id}"
%h3{:class => 'text-success', :style => 'text-align:right'}
%div{:style => 'text-align:right'}
%h3{:class => 'text-success'}
= @facade.dossier.display_state
= render partial: '/dossiers/infos_entreprise'
%br
= render partial: '/dossiers/infos_dossier'
%br
%br
%div
%ul{class: "nav nav-tabs", role: "tablist"}
%li{role: "presentation", class: "active"}
%a{href: "#commentaires", 'aria-controls' => "commentaires", role: "tab", 'data-toggle' => "tab"}
Commentaires
%li{role: "presentation"}
%a{href: "#invites", 'aria-controls' => "invites", role: "tab", 'data-toggle' => "tab"}
Invités
%div{class: "tab-content"}
%div{role: "tabpanel", class: "tab-pane fade in active", id:"commentaires"}
%h3 Flux de commentaires
%br
= render partial: '/users/recapitulatif/commentaires_flux'
%br
%br
%div{role: "tabpanel", class: "tab-pane fade", id:"invites"}
= render partial: '/dossiers/invites'
-#%script{type: 'text/javascript'}
-# ="url_carte = '#{@facade.dossier.id}/'"
-# ="ref_dossier = '#{@facade.dossier.ref_dossier_carto}'"
%br
%br

View file

@ -1,4 +1,3 @@
#infos_dossier
%div.row
.col-lg-6.col-md-6
@ -51,8 +50,8 @@
=render partial: '/dossiers/pieces_justificatives'
%br
%div.row{style: 'text-align:right'}
-unless gestionnaire_signed_in?
.row{style: 'text-align:right'}
-if user_signed_in? && (current_user.email == @facade.dossier.user.email)
-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"}
@ -60,7 +59,7 @@
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@facade.dossier.id}/description"}
= 'Editer mon dossier'
-unless user_signed_in?
-if gestionnaire_signed_in?
-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

View file

@ -0,0 +1,18 @@
%h3 Personnes invitées à voir ce dossier
%br
.row
.col-md-4.col-lg-4
- if @facade.invites.size > 0
%ul
- @facade.invites.each do |invite|
%li
= invite.email
- else
Aucune personne invité
.col-md-3.col-lg-3
=form_tag backoffice_dossier_invites_path(dossier_id: @facade.dossier.id), method: :post, class: 'form-inline' do
=text_field_tag :email, '', class: 'form-control', placeholder: 'Envoyer une invitation'
=submit_tag 'Ajouter', class: 'btn btn-success'

View file

@ -8,7 +8,7 @@
%th{class:'col-lg-6'}
='Formulaire'
%td.col-lg-6.col-md-6
- if !@facade.dossier.cerfa.empty?
- if @facade.dossier.cerfa_available?
- if user_signed_in?
= 'Pièce fournie'
- elsif gestionnaire_signed_in?

View file

@ -0,0 +1,12 @@
Bienvenue sur la plateforme TPS
Vous venez d'être nommé accompagnateur sur la plateforme TPS. Pour mémoire, voici quelques informations utiles :
URL : https://tps.apientreprise.fr/gestionnaires/sign_in
Login : <%= @email %>
Mot de passe : <%= @password %>
Bonne journée,
---
L'équipe TPS - tps@apientreprise.fr

View file

@ -0,0 +1,12 @@
Bonjour <%= @invite.email %>
L'utilisateur <%= @invite.email_sender %> souhaite que vous participiez à l'élaboration d'un dossier sur la plateforme TPS.
Cette plateforme permet à ses utilisateurs d'établir des dossiers 100% en ligne et de dialoguer avec plusieurs interlocuteurs privilégiés avant d'instruire un dépot.
Afin de répondre à cette invitation, merci de vous inscrit avec l'adresse email <%= @invite.email %> sur <%= users_dossiers_invite_url(@invite.id) %>.
Bonne journée.
---
L'équide TPS - tps@apientreprise.fr

View file

@ -0,0 +1,11 @@
Bonjour <%= @invite.email %>
L'utilisateur <%= @invite.email_sender %> souhaite que vous participiez à l'élaboration d'un dossier sur la plateforme TPS.
Ce dossier se nomme : <%= @invite.dossier.nom_projet %>
Pour le consulter, merci de suivre ce lien : <%= users_dossiers_invite_url(@invite.id) %>
Bonne journée.
---
L'équide TPS - tps@apientreprise.fr

View file

@ -9,10 +9,11 @@
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= csrf_meta_tags
%body
%div#wrap
%div#header.navbar
#beta
Beta
%div#wrap
%div.navbar
= image_tag('marianne_small.png', class: 'logo')
%a{href: '/'}
= image_tag('logo-tps.png', class: 'logo')
@ -38,6 +39,10 @@
= current_user.email
= link_to "Déconnexion", '/users/sign_out', method: :delete, :class => 'btn btn-md'
- else
= link_to "Utilisateur", '/users/sign_in', method: :get, :class => 'btn btn-md'
= link_to "Accompagnateur", '/gestionnaires/sign_in', method: :get, :class => 'btn btn-md'
= link_to "Administrateur", '/administrateurs/sign_in', method: :get, :class => 'btn btn-md'
#flash_message.center
- if flash.notice
@ -47,7 +52,7 @@
.alert.alert-danger
= flash.alert
%div{:style => 'margin-left:10%; margin-right:10%;'}
%div.main_div
= yield
%br
@ -60,7 +65,7 @@
=link_to 'SGMAP', "http://etatplateforme.modernisation.gouv.fr"
2016. All Rights Reserved
2016 - Tous droits réservés
=link_to 'contact@tps.apientreprise.fr', "mailto:contact@tps.apientreprise.fr"

View file

@ -7,19 +7,14 @@
%br
%h3.center
Simplifié toutes vos démarches pour les rendre 100% en ligne.
Simplifiez toutes vos démarches pour les rendre 100% en ligne.
%br
%br
.center
%button.js-scrollTo.btn.btn-lg.btn-success{cible: '.open_admin_compte'}
Ouvrir un compte TPS
#buttons.center
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.simplifier'}
Simplifier
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.securiser'}
Sécuriser
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.echanger'}
Échanger
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.faciliter'}
Faciliter
%button.js-scrollTo.btn.btn-lg.btn-default{cible: '.profiter'}
Profiter
#suite.max-size
.row.word.simplifier
@ -28,11 +23,9 @@
.col-md-6.col-lg-6
%ul.dynamic_ul
%li
%a Générateur simplifiée de démarches en ligne
%a Générateur simplifiée de démarches en ligne pour les administrations
%li
%a Ne demander que les informations strictement nécessaires
%li
%a Gérer les procédures, publication, suspension, en un clic.
.row.word.securiser
.col-md-6.col-lg-6
@ -58,23 +51,31 @@
%li
Vérifier les pièces au fur et à mesure
.row.word.faciliter
.col-md-6.col-lg-6
%ul.dynamic_ul
%li
Construire la démarche en plusieurs fois
%li
Gagner du temps sur linstruction
.col-md-6.col-lg-6
= image_tag image_url('keywords/faciliter.png')
.row.word.profiter
.col-md-6.col-lg-6
= image_tag image_url('keywords/profiter.png')
.col-md-6.col-lg-6
%ul.dynamic_ul
%li
Récupérer des informations officielles collectées directement auprès des administrations
%li
Profiter des ressources cartographiques directement mobilisées, si nécessaire
%li
Récupérer des informations officielles collectées directement auprès des administrations
.col-md-6.col-lg-6
= image_tag image_url('keywords/profiter.png')
.row.word.open_admin_compte
.col-md-6.col-lg-6
.center
=link_to 'Ouvrir un compte TPS', 'https://tps.apientreprise.fr/users/dossiers/new?procedure_id=31', {class: 'btn btn-lg btn-success', target: '_blank'}
.col-md-6.col-lg-6
%h3 Envie d'essayer ? Rien de plus simple
%br
%ol.dynamic_ul
%li
Cliquez sur le bouton vert à gauche
%li
Inscrivez-vous avec votre email professionnel
%li
Entrez le SIRET de votre organisme
%li
Composez un dossier en trois clics et VOILÀ !
%br
%h4 Après, nos équipes prendrons rapidement contact avec vous via la plateforme.

View file

@ -37,10 +37,11 @@
'data-provide' => ('datepicker' if champ.type_champ == 'datetime'),
'data-date-format' => ('dd/mm/yyyy' if champ.type_champ == 'datetime')}
-if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.pieces_justificatives.size > 1
%br
%h3 Documents administratifs
-if @procedure.lien_demarche != nil
-unless @procedure.lien_demarche.blank?
%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
@ -49,12 +50,13 @@
%br
//TODO a refactorer
%table{class:'table', style:'width:55%; margin-left:5%'}
- if @procedure.cerfa_flag
%tr
%th{class:'col-lg-6'}
='Formulaire (.pdf / .doc)'
%td{class:'col-lg-5'}
-if !@dossier.cerfa.empty?
-if @dossier.cerfa_available?
%span.btn.btn-sm.btn-file.btn-success
Modifier
%input{type: 'file', name:'cerfa_pdf', id:'cerfa_pdf', accept: ".pdf"}
@ -75,6 +77,7 @@
%span.btn.btn-sm.btn-file.btn-success
Modifier
= file_field_tag "piece_justificative_#{piece_justificative.type}", accept: '.pdf'
%div{style: 'text-align:right'}
%h6 Tous les champs portant un * sont obligatoires.

View file

@ -6,12 +6,18 @@
%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|
- if dossier.class == Invite
-invite = dossier
-dossier = dossier.dossier.decorate
- else
- dossier = dossier.decorate
%tr
%td
= dossier.procedure.libelle
%td
= link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier))
= link_to(dossier.nom_projet, users_dossiers_invite_path(id: invite.id)) unless invite.nil?
= link_to(dossier.nom_projet, users_dossier_recapitulatif_path(dossier)) if invite.nil?
%td{id: "dossier_#{dossier.id}_state"}= dossier.display_state
%td= dossier.last_update

View file

@ -23,4 +23,11 @@
= "Terminé"
.badge.progress-bar-success
= @dossiers_termine_total
%li{ class: @invite_class }
%a{:href => "#{url_for users_dossiers_path(liste: 'invite')}"}
%h5{style: 'color: #696969'}
= "Invitation"
.badge{style: 'background-color: #696969'}
= @dossiers_invite_total
%br

View file

@ -1,22 +0,0 @@
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "users/shared/links" %>

View file

@ -0,0 +1,59 @@
-#<h2>Sign up</h2>
-#
-#<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
-# <%= devise_error_messages! %>
-#
-# <div class="field">
-# <%= f.label :email %><br />
-# <%= f.email_field :email, autofocus: true %>
-# </div>
-#
-# <div class="field">
-# <%= f.label :password %>
-# <% if @validatable %>
-# <em>(<%= @minimum_password_length %> characters minimum)</em>
-# <% end %><br />
-# <%= f.password_field :password, autocomplete: "off" %>
-# </div>
-#
-# <div class="field">
-# <%= f.label :password_confirmation %><br />
-# <%= f.password_field :password_confirmation, autocomplete: "off" %>
-# </div>
-#
-# <div class="actions">
-# <%= f.submit "Sign up" %>
-# </div>
-#<% end %>
= devise_error_messages!
#form_login
= image_tag('logo-tps.png')
%br
%h2#gestionnaire_login Changement de mot de passe
%br
%br
#new_user
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
= f.hidden_field :reset_password_token
%h4
= f.label 'Nouveau mot de passe'
.input-group
.input-group-addon
%span.glyphicon.glyphicon-asterisk
= f.password_field :password, autofocus: true, autocomplete: "off", class: 'form-control'
%br
%h4
= f.label 'Retaper le mot de passe'
.input-group
.input-group-addon
%span.glyphicon.glyphicon-asterisk
= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control'
%br
%br
.actions
= f.submit "Changer", class:'btn btn-primary'
%br

View file

@ -1,16 +0,0 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "users/shared/links" %>

View file

@ -0,0 +1,50 @@
-#<h2>Sign up</h2>
-#
-#<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
-# <%= devise_error_messages! %>
-#
-# <div class="field">
-# <%= f.label :email %><br />
-# <%= f.email_field :email, autofocus: true %>
-# </div>
-#
-# <div class="field">
-# <%= f.label :password %>
-# <% if @validatable %>
-# <em>(<%= @minimum_password_length %> characters minimum)</em>
-# <% end %><br />
-# <%= f.password_field :password, autocomplete: "off" %>
-# </div>
-#
-# <div class="field">
-# <%= f.label :password_confirmation %><br />
-# <%= f.password_field :password_confirmation, autocomplete: "off" %>
-# </div>
-#
-# <div class="actions">
-# <%= f.submit "Sign up" %>
-# </div>
-#<% end %>
= devise_error_messages!
#form_login
= image_tag('logo-tps.png')
%br
%h2#gestionnaire_login Mot de passe oublié
%br
%br
#new_user
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
%h4
= f.label :email
.input-group
.input-group-addon
%span.glyphicon.glyphicon-user
= f.email_field :email, class: 'form-control', placeholder: 'Email'
%br
%br
.actions
= f.submit "Renvoyer", class:'btn btn-primary'
%br

View file

@ -1,7 +1,7 @@
.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: @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."}
= 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', 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

View file

@ -4,6 +4,7 @@
.col-md-6.col-lg-6
%h2 Récapitulatif
.col-md-6.col-lg-6
- if current_user.email == @facade.dossier.user.email
= 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
@ -22,7 +23,7 @@
%h2#dossier_id{:class => 'text-info', :style => 'text-align:right; margin-bottom:15px'}
= "Dossier n°#{@facade.dossier.id}"
- unless gestionnaire_signed_in?
- if user_signed_in? && current_user.email == @facade.dossier.user.email
-if @facade.dossier.validated?
%br
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @facade.dossier.id}), method: 'POST') do
@ -36,4 +37,4 @@
= render partial: '/dossiers/infos_dossier'
%br
= render partial: 'commentaires_flux'
= render partial: '/users/recapitulatif/commentaires_flux'

View file

@ -1,39 +0,0 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>

View file

@ -3,16 +3,14 @@
%br
%h2#login_user Connexion
-#%a.btn_fc#btn_fcp{href: '/france_connect/particulier'}
-# = image_tag 'franceconnect_logo.png'
-#
-#%br
-#%a.text-info{href: 'https://fcp.integ01.dev-franceconnect.fr/a-propos', target: '_blank'}
-# Quest-ce que FranceConnect ?
-#
-#%hr
%a.btn_fc#btn_fcp{href: '/france_connect/particulier'}
= image_tag 'franceconnect_logo.png'
%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
@ -32,19 +30,18 @@
.actions
= f.submit "Se connecter", class:'btn btn-primary'
%br
= render "users/shared/links"
%br
%div{style:'text-align:center'}
\-
%br
%a{href: '/gestionnaires/sign_in'}
= 'Accompagnateur'
%br
%a{href: '/administrateurs/sign_in'}
= 'Administrateur'
-#\-
-#%br
-#%a{href: '/gestionnaires/sign_in'}
-# = 'Accompagnateur'
-#%br
-#%a{href: '/administrateurs/sign_in'}
-# = 'Administrateur'
%br
\-
%br
%a{href: 'https://github.com/sgmap/tps/releases', target: '_blank'}

View file

@ -1,3 +1,6 @@
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "S'inscrire", new_registration_path(resource_name) %><br />
<%= link_to "S'inscrire", new_registration_path(resource_name), {class: 'btn btn-sm btn-success'} %><br />
<% end -%>
<br>
<%= link_to "Mot de passe oublié ?", new_password_path(resource_name) %><br />

View file

@ -52,7 +52,19 @@ fr:
blank: ': Le mot de passe est vide'
password_confirmation:
confirmation: ': Les deux mots de passe ne correspondent pas'
invite:
attributes:
email:
blank: est vide
taken: ': Invitation déjà envoyée'
gestionnaire:
attributes:
email:
invalid: invalide
taken: déjà utilisé
blank: est vide
password:
blank: ': Le mot de passe est vide'
devise:
confirmations:

View file

@ -10,7 +10,8 @@ Rails.application.routes.draw do
devise_for :users, controllers: {
sessions: 'users/sessions',
registrations: 'users/registrations'
registrations: 'users/registrations',
passwords: 'users/passwords'
}
root 'root#index'
@ -25,8 +26,15 @@ Rails.application.routes.draw do
end
get 'demo' => 'demo#index'
get 'users' => 'users#index'
namespace :users do
namespace :dossiers do
resources :invites, only: [:index, :show]
post '/commentaire' => 'commentaires#create'
end
resources :dossiers do
get '/description' => 'description#show'
get '/description/error' => 'description#error'
@ -66,6 +74,7 @@ Rails.application.routes.draw do
resource :pieces_justificatives, only: [:show, :update]
resources :pieces_justificatives, only: :destroy
end
resources :gestionnaires, only: [:index, :create, :destroy]
end
get 'backoffice' => 'backoffice#index'
@ -78,6 +87,8 @@ Rails.application.routes.draw do
resources :dossiers do
post 'valid' => 'dossiers#valid'
post 'close' => 'dossiers#close'
post 'invites' => '/invites#create'
end
resources :commentaires, only: [:create]

View file

@ -0,0 +1,5 @@
class AddCerfaFlagToProcedure < ActiveRecord::Migration
def change
add_column :procedures, :cerfa_flag, :boolean, :default => false
end
end

View file

@ -0,0 +1,11 @@
class CreateInvites < ActiveRecord::Migration
def change
create_table :invites do |t|
t.string :email
t.string :email_sender
end
add_reference :invites, :dossier, references: :dossiers
add_reference :invites, :user, references: :users
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: 20160127170437) do
ActiveRecord::Schema.define(version: 20160204155519) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -159,6 +159,13 @@ ActiveRecord::Schema.define(version: 20160127170437) do
add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree
add_index "gestionnaires", ["reset_password_token"], name: "index_gestionnaires_on_reset_password_token", unique: true, using: :btree
create_table "invites", force: :cascade do |t|
t.string "email"
t.string "email_sender"
t.integer "dossier_id"
t.integer "user_id"
end
create_table "module_api_cartos", force: :cascade do |t|
t.integer "procedure_id"
t.boolean "use_api_carto", default: false
@ -189,6 +196,7 @@ ActiveRecord::Schema.define(version: 20160127170437) do
t.boolean "archived", default: false
t.boolean "euro_flag", default: false
t.string "logo"
t.boolean "cerfa_flag", default: false
end
create_table "quartier_prioritaires", force: :cascade do |t|

38
lib/tasks/dev.rake Normal file
View file

@ -0,0 +1,38 @@
namespace :dev do
desc 'Initialise dev environment'
task :init do
puts 'start initialisation'
Rake::Task['dev:generate_token_file'].invoke
Rake::Task['dev:generate_franceconnect_file'].invoke
puts 'end initialisation'
end
task :generate_token_file do
puts 'creating token.rb file'
res = `rake secret`.gsub("\n", '')
file = File.new('config/initializers/token.rb', 'w+')
comment = <<EOF
EOF
file.write(comment)
file.write("TPS::Application.config.SIADETOKEN = '#{res}'")
file.close
end
task :generate_franceconnect_file do
file = File.new('config/france_connect.yml', 'w+')
comment = <<EOF
particulier_identifier: plop
particulier_secret: plip
particulier_redirect_uri: 'http://localhost:3000/france_connect/particulier/callback'
particulier_authorization_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/authorize'
particulier_token_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/token'
particulier_userinfo_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/userinfo'
particulier_logout_endpoint: 'https://fcp.integ01.dev-franceconnect.fr/api/v1/logout'
EOF
file.write(comment)
file.close
end
end

View file

@ -0,0 +1,106 @@
require 'spec_helper'
describe Admin::GestionnairesController, type: :controller do
let(:admin) { create(:administrateur) }
before do
sign_in admin
end
describe 'GET #index' do
subject { get :index }
it { expect(subject.status).to eq(200) }
end
describe 'POST #create' do
let(:email) { 'test@plop.com' }
subject { post :create, gestionnaire: { email: email } }
context 'When email is valid' do
before do
subject
end
it { expect(response.status).to eq(302) }
it { expect(response).to redirect_to admin_gestionnaires_path }
describe 'Gestionnaire attributs in database' do
let(:gestionnaire) { Gestionnaire.last }
it { expect(gestionnaire.email).to eq(email) }
it { expect(gestionnaire.administrateur_id).to eq(admin.id) }
end
end
context 'when email is not valid' do
before do
subject
end
let(:email) { 'piou' }
it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) }
end
context 'when email is empty' do
before do
subject
end
let(:email) { '' }
it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) }
it 'Notification email is not send' do
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!)
end
end
context ' when email already exists' do
let(:email) { 'test@plop.com' }
before do
subject
post :create, gestionnaire: { email: email }
end
it { expect(response.status).to eq(302) }
it { expect{ response }.not_to change(Gestionnaire, :count) }
end
context 'Email notification' do
it 'Notification email is sent when email is valid' do
expect(GestionnaireMailer).to receive(:new_gestionnaire).and_return(GestionnaireMailer)
expect(GestionnaireMailer).to receive(:deliver_now!)
subject
end
context 'is not sent when email is not valid' do
let(:email) { 'testplop.com' }
it {
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!)
subject
}
end
it 'is not sent when email already exists' do
subject
expect(GestionnaireMailer).not_to receive(:new_gestionnaire)
expect(GestionnaireMailer).not_to receive(:deliver_now!)
subject
end
end
end
describe 'DELETE #destroy' do
let(:email) { 'test@plop.com' }
before do
post :create, gestionnaire: { email: email }
end
let(:gestionnaire) { Gestionnaire.last }
let(:response) { delete :destroy, id: gestionnaire.id }
it { expect(response.status).to eq(302) }
it { expect(response).to redirect_to admin_gestionnaires_path }
it { expect{response}.to change(Gestionnaire, :count).by(-1) }
end
end

View file

@ -6,10 +6,11 @@ describe API::V1::DossiersController do
let(:wrong_procedure) { create(:procedure) }
it { expect(described_class).to be < APIController }
describe 'GET index' do
let(:response) { get :index, token: admin.api_token, procedure_id: procedure_id }
subject { response }
subject { response }
context 'when procedure is not found' do
let(:procedure_id) { 99_999_999 }
@ -24,10 +25,13 @@ describe API::V1::DossiersController do
context 'when procedure is found and belongs to admin' do
let(:procedure_id) { procedure.id }
let(:date_creation) { Time.local(2008, 9, 1, 10, 5, 0) }
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure) } }
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } }
let(:body) { JSON.parse(response.body, symbolize_names: true) }
it { expect(response.code).to eq('200') }
it { expect(body).to have_key :pagination }
it { expect(body).to have_key :dossiers }
describe 'pagination' do
@ -54,14 +58,17 @@ describe API::V1::DossiersController do
context 'when there are multiple pages' do
let(:response) { get :index, token: admin.api_token, procedure_id: procedure_id, page: 2 }
let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure) }
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure) }
let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
before do
allow(Dossier).to receive(:per_page).and_return(1)
end
describe 'pagination' do
subject { body[:pagination] }
it { expect(subject[:page]).to eq(2) }
it { expect(subject[:resultats_par_page]).to eq(1) }
it { expect(subject[:nombre_de_page]).to eq(3) }

View file

@ -43,5 +43,20 @@ describe Users::CommentairesController, type: :controller do
end
end
end
context 'when invite is connected' do
let(:invite) { create(:invite, :with_user, dossier: dossier) }
before do
sign_in invite.user
dossier.replied!
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
dossier.reload
end
it { is_expected.to redirect_to users_dossiers_invite_path(invite.id) }
it { expect(dossier.state).to eq 'replied' }
end
end
end

View file

@ -0,0 +1,87 @@
require 'spec_helper'
describe InvitesController, type: :controller do
let(:dossier) { create(:dossier) }
let(:email) { 'plop@octo.com' }
describe '#POST create' do
let(:invite) { Invite.last }
before do
sign_in create(:gestionnaire)
end
subject { post :create, dossier_id: dossier.id, email: email }
it { expect { subject }.to change(Invite, :count).by(1) }
context 'when email is assign to an user' do
let! (:user) { create(:user, email: email) }
before do
subject
end
it { expect(invite.user).to eq user }
it { expect(flash[:notice]).to be_present }
end
context 'when email is not assign to an user' do
before do
subject
end
it { expect(invite.user).to be_nil }
it { expect(flash[:notice]).to be_present }
end
describe 'not an email' do
context 'when email is not valid' do
let(:email) { 'plip.com' }
before do
subject
end
it { expect { subject }.not_to change(Invite, :count) }
it { expect(flash[:alert]).to be_present }
end
context 'when email is already used' do
let!(:invite) { create(:invite, dossier: dossier) }
before do
subject
end
it { expect { subject }.not_to change(Invite, :count) }
it { expect(flash[:alert]).to be_present }
end
end
describe 'send invitation email' do
context 'when user does not exist' do
it 'send email' do
expect(InviteMailer).to receive(:invite_guest).and_return(InviteMailer)
expect(InviteMailer).to receive(:deliver_now!)
subject
end
end
context 'when user exist' do
before do
create :user, email: email
end
it 'send email' do
expect(InviteMailer).to receive(:invite_user).and_return(InviteMailer)
expect(InviteMailer).to receive(:deliver_now!)
subject
end
end
end
end
end

View file

@ -29,6 +29,12 @@ describe RootController, type: :controller do
end
context 'when nobody is connected' do
it { expect(subject).to redirect_to(new_user_session_path) }
render_views
before do
subject
end
it { expect(response.body).to have_css('#landing') }
end
end

View file

@ -7,7 +7,7 @@ RSpec.describe Users::CarteController, type: :controller do
let(:procedure) { create(:procedure, module_api_carto: module_api_carto) }
let(:dossier) { create(:dossier, procedure: procedure) }
let(:dossier_with_no_carto) { create(:dossier, :with_procedure) }
let(:dossier_with_no_carto) { create(:dossier) }
let!(:entreprise) { create(:entreprise, dossier: dossier) }
let!(:etablissement) { create(:etablissement, dossier: dossier) }
let(:bad_dossier_id) { Dossier.count + 1000 }
@ -34,7 +34,7 @@ RSpec.describe Users::CarteController, type: :controller do
end
context 'when dossiers procedure does not have api carto actived' do
let(:dossier) { create(:dossier, :with_procedure) }
let(:dossier) { create(:dossier) }
before do
get :show, dossier_id: dossier.id
@ -86,7 +86,7 @@ RSpec.describe Users::CarteController, type: :controller do
end
context 'En train de modifier la localisation' do
let(:dossier) { create(:dossier, :with_procedure, state: 'initiated') }
let(:dossier) { create(:dossier, state: 'initiated') }
before do
post :save, dossier_id: dossier.id, json_latlngs: ''
end
@ -109,7 +109,7 @@ RSpec.describe Users::CarteController, type: :controller do
context 'when json_latlngs params is empty' do
context 'when dossier have quartier prioritaire in database' do
let!(:dossier) { create(:dossier, :with_procedure, :with_two_quartier_prioritaires) }
let!(:dossier) { create(:dossier, :with_two_quartier_prioritaires) }
before do
dossier.reload
@ -156,7 +156,7 @@ RSpec.describe Users::CarteController, type: :controller do
context 'when json_latlngs params is empty' do
context 'when dossier have cadastres in database' do
let!(:dossier) { create(:dossier, :with_procedure, :with_two_cadastres) }
let!(:dossier) { create(:dossier, :with_two_cadastres) }
before do
dossier.reload
@ -200,7 +200,7 @@ RSpec.describe Users::CarteController, type: :controller do
describe '#get_position' do
context 'Geocodeur renvoie les positions par defaut' do
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, etablissement: etablissement) }
let(:dossier) { create(:dossier, etablissement: etablissement) }
before do
stub_request(:get, /http:\/\/api-adresse[.]data[.]gouv[.]fr\/search[?]limit=1&q=/)

View file

@ -2,9 +2,12 @@ require 'spec_helper'
describe Users::DescriptionController, type: :controller do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) }
let!(:dossier) { create(:dossier, procedure: procedure, user: user) }
let(:dossier_id) { dossier.id }
let(:bad_dossier_id) { Dossier.count + 10 }
let(:bad_dossier_id) { Dossier.count + 10000 }
before do
sign_in dossier.user
@ -119,6 +122,7 @@ describe Users::DescriptionController, type: :controller do
end
end
context 'Quand la procédure accepte les CERFA' do
context 'Sauvegarde du CERFA PDF' do
before do
post :create, dossier_id: dossier_id,
@ -140,10 +144,14 @@ describe Users::DescriptionController, type: :controller do
end
context 'les anciens CERFA PDF sont écrasées à chaque fois' do
it 'il n\'y a qu\'un CERFA PDF par dossier' do
let(:cerfas) { Cerfa.find_by_dossier_id(dossier_id) }
before do
post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, cerfa_pdf: cerfa_pdf
cerfa = PieceJustificative.where(type_de_piece_justificative_id: '0', dossier_id: dossier_id)
expect(cerfa.many?).to eq(false)
end
it 'il n\'y a qu\'un CERFA PDF par dossier' do
expect(cerfas.class).to eq Cerfa
end
end
@ -151,10 +159,29 @@ describe Users::DescriptionController, type: :controller do
# TODO à écrire
end
end
end
context 'Quand la procédure n\'accepte pas les CERFA' do
context 'Sauvegarde du CERFA PDF' do
let!(:procedure) { create(:procedure) }
before do
post :create, dossier_id: dossier_id,
nom_projet: nom_projet,
description: description,
cerfa_pdf: cerfa_pdf
dossier.reload
end
context 'un CERFA PDF est envoyé' do
it { expect(dossier.cerfa_available?).to be_falsey }
end
end
end
context 'Sauvegarde des champs' do
let(:champs_dossier) { dossier.champs }
let(:dossier_champs_first) { 'test value' }
before do
post :create, {dossier_id: dossier_id,
nom_projet: nom_projet,

View file

@ -345,4 +345,17 @@ describe Users::DossiersController, type: :controller do
end
end
end
describe 'GET #invite' do
context 'when user is connected' do
before do
sign_in user
end
it 'returns http success' do
get :index, liste: :invite
expect(response).to have_http_status(200)
end
end
end
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Users::RecapitulatifController, type: :controller do
let(:dossier) { create(:dossier, :with_procedure, state:'initiated') }
let(:dossier) { create(:dossier, state:'initiated') }
let(:bad_dossier_id) { Dossier.count + 100000 }
before do

View file

@ -23,6 +23,19 @@ describe Users::RegistrationsController, type: :controller do
subject
end
describe '#check_invite!' do
let!(:invite) { create :invite, email: email }
let!(:invite2) { create :invite, email: email }
before do
subject
end
it 'the new user is connect at his two invite' do
expect(User.last.invites.size).to eq 2
end
end
end
context 'when user is not correct' do

View file

@ -5,6 +5,13 @@ FactoryGirl.define do
state 'draft'
association :user, factory: [:user]
before(:create) do |dossier, _evaluator|
unless dossier.procedure
procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ)
dossier.procedure = procedure
end
end
trait :with_entreprise do
after(:build) do |dossier, _evaluator|
etablissement = create(:etablissement)
@ -14,13 +21,6 @@ FactoryGirl.define do
end
end
trait :with_procedure do
after(:build) do |dossier, _evaluator|
procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ)
dossier.procedure = procedure
end
end
trait :with_two_quartier_prioritaires do
after(:build) do |dossier, _evaluator|

20
spec/factories/invite.rb Normal file
View file

@ -0,0 +1,20 @@
FactoryGirl.define do
factory :invite do
email 'plop@octo.com'
after(:build) do |invite, _evaluator|
if invite.dossier.nil?
invite.dossier = create(:dossier)
end
end
trait :with_user do
after(:build) do |invite, _evaluator|
if invite.user.nil?
invite.user = create(:user)
invite.email = invite.user.email
end
end
end
end
end

View file

@ -32,7 +32,7 @@ feature 'Administrator connection' do
page.find_by_id('admin_sign_out').click
end
scenario 'admin is redireted to home page' do
expect(page).to have_css('#login_user')
expect(page).to have_css('#landing')
end
end
context 'when clicking on profile' do

View file

@ -1,7 +1,7 @@
require 'spec_helper'
feature 'add commentaire on backoffice' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
let(:dossier) { create(:dossier, :with_entreprise) }
let(:dossier_id) { dossier.id }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') }
let(:email_commentaire) { 'test@test.com' }

View file

@ -1,7 +1,8 @@
require 'spec_helper'
feature 'user is on description page' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, cerfa_flag: true) }
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure) }
before do
visit users_dossier_description_path dossier

View file

@ -3,13 +3,13 @@ require 'spec_helper'
feature 'user access to the list of his dossier' do
let(:user) { create(:user) }
let!(:last_updated_dossier) { create(:dossier, :with_procedure, user: user, state: 'replied')}
let!(:dossier1) { create(:dossier, :with_procedure, user: user, nom_projet: 'mon permier dossier', state: 'replied') }
let!(:last_updated_dossier) { create(:dossier, user: user, state: 'replied')}
let!(:dossier1) { create(:dossier, user: user, nom_projet: 'mon permier dossier', state: 'replied') }
let!(:dossier2) { create(:dossier, nom_projet: 'mon deuxième dossier') }
before do
last_updated_dossier.update_attributes(nom_projet: 'salut la compagnie')
visit root_path
visit new_user_session_path
within('#new_user') do
page.find_by_id('user_email').set user.email
page.find_by_id('user_password').set user.password

View file

@ -3,7 +3,7 @@ require "rails_helper"
RSpec.describe NotificationMailer, type: :mailer do
describe ".new_answer" do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) }
let(:dossier) { create(:dossier, user: user) }
subject(:subject) { described_class.new_answer(dossier) }
@ -14,7 +14,7 @@ RSpec.describe NotificationMailer, type: :mailer do
describe ".dossier_validated" do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) }
let(:dossier) { create(:dossier, user: user) }
subject(:subject) { described_class.dossier_validated(dossier) }
@ -25,7 +25,7 @@ RSpec.describe NotificationMailer, type: :mailer do
describe ".dossier_submitted" do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) }
let(:dossier) { create(:dossier, user: user) }
subject(:subject) { described_class.dossier_submitted(dossier) }

View file

@ -24,6 +24,7 @@ describe Dossier do
it { is_expected.to have_one(:etablissement) }
it { is_expected.to have_one(:entreprise) }
it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:invites) }
end
describe 'delegation' do
@ -47,7 +48,7 @@ describe Dossier do
end
describe 'methods' do
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure, user: user) }
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
let(:entreprise) { dossier.entreprise }
let(:etablissement) { dossier.etablissement }
@ -63,13 +64,27 @@ describe Dossier do
end
describe 'creation' do
describe 'Procedure accepts cerfa upload' do
let(:procedure) { create(:procedure, cerfa_flag: true) }
let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, user: user) }
it 'create default cerfa' do
expect { described_class.create(user: user) }.to change { Cerfa.count }.by(1)
expect { subject.to change(Cerfa.count).by(1) }
expect { subject.cerfa_available.to be_truthy }
end
it 'link cerfa to dossier' do
dossier = described_class.create
expect(dossier.cerfa).to eq(Cerfa.last)
expect { subject.cerfa.to eq(Cerfa.last) }
end
end
describe 'Procedure does not accept cerfa upload' do
let(:procedure) { create(:procedure, cerfa_flag: false) }
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
it 'default cerfa is not created' do
expect { subject.to change(Cerfa.count).by(0) }
expect { subject.cerfa.to eq(nil) }
expect { subject.cerfa_available.to be_falsey }
end
end
end
@ -87,7 +102,7 @@ describe Dossier do
describe '#build_default_pieces_justificatives' do
context 'when dossier is linked to a procedure' do
let(:dossier) { create(:dossier, :with_procedure, user: user) }
let(:dossier) { create(:dossier, user: user) }
it 'build all pieces justificatives needed' do
expect(dossier.pieces_justificatives.count).to eq(2)
end
@ -96,7 +111,8 @@ describe Dossier do
describe '#build_default_champs' do
context 'when dossier is linked to a procedure' do
let(:dossier) { create(:dossier, :with_procedure, user: user) }
let(:dossier) { create(:dossier, user: user) }
it 'build all champs needed' do
expect(dossier.champs.count).to eq(1)
end
@ -104,20 +120,21 @@ describe Dossier do
end
describe '#save' do
subject { create(:dossier, procedure_id: nil, user: user) }
subject { build(:dossier, procedure: procedure, user: user) }
let!(:procedure) { create(:procedure) }
context 'when is linked to a procedure' do
it 'creates default pieces justificatives' do
expect(subject).to receive(:build_default_pieces_justificatives)
subject.update_attributes(procedure_id: procedure.id)
subject.save
end
it 'creates default champs' do
expect(subject).to receive(:build_default_champs)
subject.update_attributes(procedure_id: procedure.id)
subject.save
end
end
context 'when is not linked to a procedure' do
subject { create(:dossier, procedure: procedure, user: user) }
it 'does not create default pieces justificatives' do
expect(subject).not_to receive(:build_default_pieces_justificatives)
subject.update_attributes(description: 'plop')
@ -382,7 +399,7 @@ describe Dossier do
end
end
context 'gestionnaire backoffice methods' do
describe 'gestionnaire backoffice methods' do
let(:admin) { create(:administrateur) }
let(:admin_2) { create(:administrateur) }
@ -504,4 +521,26 @@ describe Dossier do
end
end
end
describe '#cerfa_available?' do
let(:procedure) { create(:procedure, cerfa_flag: cerfa_flag) }
let(:dossier) { create(:dossier, procedure: procedure)}
context 'Procedure accepts CERFA' do
let(:cerfa_flag) { true }
context 'when cerfa is not uploaded' do
it { expect(dossier.cerfa_available?).to be_falsey }
end
context 'when cerfa is uploaded' do
let(:dossier_with_cerfa) { create(:dossier, procedure: procedure) }
before do
allow_any_instance_of(Cerfa).to receive(:empty?).and_return(false)
end
it { expect(dossier_with_cerfa.cerfa_available?).to be_truthy }
end
end
context 'Procedure does not accept CERFA' do
let(:cerfa_flag) { false }
it { expect(dossier.cerfa_available?).to be_falsey }
end
end
end

View file

@ -0,0 +1,38 @@
require 'spec_helper'
describe Invite do
describe 'database columns' do
it { is_expected.to have_db_column(:email) }
end
describe 'associations' do
it { is_expected.to belong_to(:dossier) }
it { is_expected.to belong_to(:user) }
end
describe 'an email can be used for multiple dossier' do
let(:email1) { 'plop@octo.com' }
let!(:dossier1) { create(:dossier) }
let!(:dossier2) { create(:dossier) }
context 'when an email is invite on two dossier' do
subject do
create(:invite, email: email1, dossier: dossier1)
create(:invite, email: email1, dossier: dossier2)
end
it { expect{ subject }.to change(Invite, :count).by(2) }
end
context 'when an email is invite twice on a dossier' do
subject do
create(:invite, email: email1, dossier: dossier1)
create(:invite, email: email1, dossier: dossier1)
end
it { expect{ subject }.to raise_error ActiveRecord::RecordInvalid }
end
end
end

View file

@ -17,6 +17,7 @@ describe Procedure do
it { is_expected.to have_db_column(:test) }
it { is_expected.to have_db_column(:euro_flag) }
it { is_expected.to have_db_column(:logo) }
it { is_expected.to have_db_column(:cerfa_flag) }
end
describe 'validation' do

View file

@ -20,6 +20,7 @@ describe User, type: :model do
end
describe 'associations' do
it { is_expected.to have_many(:dossiers) }
it { is_expected.to have_many(:invites) }
end
describe '#find_for_france_connect' do
let(:siret) { '00000000000000' }

View file

@ -75,6 +75,7 @@ RSpec.configure do |config|
config.infer_spec_type_from_file_location!
config.tty = true
config.use_transactional_fixtures = false
config.infer_base_class_for_anonymous_controllers = false

View file

@ -0,0 +1,34 @@
require 'spec_helper'
describe 'admin/gestionnaires/index.html.haml', type: :view do
let(:token) { 'super_token' }
let(:admin) { create(:administrateur, api_token: token) }
before do
assign(:gestionnaires, (smart_listing_create :gestionnaires,
admin.gestionnaires,
partial: "admin/gestionnaires/list",
array: true))
assign(:gestionnaire, Gestionnaire.new())
end
context 'Aucun gestionnaire' do
before do
render
end
it { expect(rendered).to have_content('Aucun gestionnaire') }
end
context 'Ajout d\'un gestionnaire' do
before do
create(:gestionnaire, administrateur: admin)
admin.reload
assign(:gestionnaires, (smart_listing_create :gestionnaires,
admin.gestionnaires,
partial: "admin/gestionnaires/list",
array: true))
render
end
it { expect(rendered).to match(/plop\d+@plop.com/) }
end
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe 'backoffice/dossiers/show.html.haml', type: :view do
let!(:dossier) { create(:dossier, :with_entreprise, :with_procedure, state: state) }
let!(:dossier) { create(:dossier, :with_entreprise, state: state) }
let(:state) { 'draft' }
let(:dossier_id) { dossier.id }
let(:gestionnaire) { create(:gestionnaire) }
@ -11,7 +11,7 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
assign(:facade, (DossierFacades.new dossier.id, gestionnaire.email))
end
context 'on the dossier admin page' do
context 'on the dossier gestionnaire page' do
before do
render
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe 'users/carte/show.html.haml', type: :view do
let(:state) { 'draft' }
let(:dossier) { create(:dossier, :with_procedure, state: state) }
let(:dossier) { create(:dossier, state: state) }
let(:dossier_id) { dossier.id }
before do

View file

@ -2,7 +2,9 @@ require 'spec_helper'
describe 'users/description/show.html.haml', type: :view do
let(:user) { create(:user) }
let(:dossier) { create(:dossier, :with_procedure, user: user) }
let(:cerfa_flag) { true }
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: cerfa_flag) }
let(:dossier) { create(:dossier, procedure: procedure, user: user) }
let(:dossier_id) { dossier.id }
before do
@ -67,7 +69,7 @@ describe 'users/description/show.html.haml', type: :view do
context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do
let!(:dossier) do
create(:dossier, :with_procedure,
create(:dossier,
nom_projet: 'Projet de test',
description: 'Description de test',
user: user)
@ -125,4 +127,46 @@ describe 'users/description/show.html.haml', type: :view do
end
end
end
context 'Envoi des CERFA désactivé' do
let!(:cerfa_flag) { false }
before do
render
end
it { expect(rendered).to_not have_css("#cerfa_flag") }
it { expect(rendered).to_not have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') }
end
describe 'display title Documents administratifs' do
before do
render
end
let(:procedure) { create :procedure, lien_demarche: '' }
let(:dossier) { create(:dossier, procedure: procedure) }
context 'when dossier not have cerfa, piece justificative and demarche link' do
it { expect(rendered).not_to have_content 'Documents administratifs' }
end
context 'when dossier have pj' do
let(:dossier) { create(:dossier) }
it { expect(rendered).to have_content 'Documents administratifs' }
end
context 'when procedure have demarche link' do
let(:procedure) { create :procedure }
it { expect(rendered).to have_content 'Documents administratifs' }
end
context 'when procedure have cerfa flag true' do
let(:procedure) {create(:procedure, cerfa_flag: true)}
it { expect(rendered).to have_content 'Documents administratifs' }
end
end
end

View file

@ -3,10 +3,10 @@ require 'spec_helper'
describe 'users/dossiers/index.html.haml', type: :view do
let(:user) { create(:user) }
let!(:dossier) { create(:dossier, :with_procedure, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
let!(:dossier_2) { create(:dossier, :with_procedure, user: user, state: 'replied', nom_projet: 'projet répondu').decorate }
let!(:dossier_3) { create(:dossier, :with_procedure, user: user, state: 'replied', nom_projet: 'projet répondu 2').decorate }
let!(:dossier_termine) { create(:dossier, :with_procedure, user: user, state: 'closed').decorate }
let!(:dossier) { create(:dossier, user: user, state: 'initiated', nom_projet: 'projet de test').decorate }
let!(:dossier_2) { create(:dossier, user: user, state: 'replied', nom_projet: 'projet répondu').decorate }
let!(:dossier_3) { create(:dossier, user: user, state: 'replied', nom_projet: 'projet répondu 2').decorate }
let!(:dossier_termine) { create(:dossier, user: user, state: 'closed').decorate }
describe 'params liste is a_traiter' do
let(:dossiers_list) { user.dossiers.waiting_for_user('DESC') }

View file

@ -3,8 +3,9 @@ require 'spec_helper'
describe 'users/dossiers/new.html.haml', type: :view do
let(:user) { create(:user) }
let(:euro_flag) { false }
let(:cerfa_flag) { false }
let(:logo) { '' }
let(:procedure) { create(:procedure, euro_flag: euro_flag, logo: logo) }
let(:procedure) { create(:procedure, euro_flag: euro_flag, cerfa_flag: cerfa_flag, logo: logo) }
let!(:dossier) { create(:dossier, procedure: procedure, user: user).decorate }
before do
@ -31,7 +32,7 @@ describe 'users/dossiers/new.html.haml', type: :view do
describe 'logo procedure' do
context 'procedure have no logo' do
it 'MPS logo is present' do
it 'TPS logo is present' do
is_expected.to have_css("img[src='/assets#{asset_path('logo-tps.png')}']")
end
end

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_procedure) }
let(:dossier) { create(:dossier) }
let(:dossier_id) { dossier.id }
let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' }
let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description') }

View file

@ -6,6 +6,7 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
let(:state) { 'draft' }
before do
sign_in dossier.user
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
end
@ -28,7 +29,7 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
expect(rendered).to have_content(dossier_id)
end
context 'les liens de modifications' do
describe 'les liens de modifications' do
context 'lien description' do
it 'le lien vers description est présent' do
expect(rendered).to have_css('#maj_infos')
@ -128,5 +129,45 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
end
end
context 'when invite is logged' do
let!(:invite_user) { create(:user, email: 'invite@octo.com') }
before do
create(:invite) { create(:invite, email: invite_user.email, user: invite_user, dossier: dossier) }
sign_out dossier.user
sign_in invite_user
render
end
describe 'les liens de modifications' do
it 'describe link is not present' do
expect(rendered).not_to have_css('#maj_infos')
end
it 'map link is not present' do
expect(rendered).not_to have_css('#maj_carte')
end
it 'archive link is not present' do
expect(rendered).not_to have_content('Archiver')
end
end
context 'when dossier is validated' do
let(:state) { 'validated' }
before do
render
end
it 'submitted link is not present' do
expect(rendered).not_to have_content('Déposer mon dossier')
end
end
end
end
end

View file

@ -10,7 +10,10 @@ var franceConnectKit = {};
//initCurrentHostnameSource();
//includeFCCss();
fconnect.currentHost = 'fcp.integ01.dev-franceconnect.fr'
fconnect.currentHost = 'fcp.integ01.dev-franceconnect.fr';
if (window.location.hostname == 'tps.apientreprise.fr')
fconnect.currentHost = 'app.franceconnect.gouv.fr';
var fconnectProfile = document.getElementById('fconnect-profile');
if (fconnectProfile) {