Merge branch 'dev'

This commit is contained in:
Mathieu Magnin 2017-12-22 09:38:39 +01:00
commit 8af0011271
21 changed files with 150 additions and 100 deletions

View file

@ -154,7 +154,7 @@ GEM
http_parser.rb (~> 0.6.0)
erubis (2.7.0)
eventmachine (1.2.1)
excon (0.54.0)
excon (0.60.0)
execjs (2.7.0)
factory_girl (4.7.0)
activesupport (>= 3.0.0)
@ -214,9 +214,9 @@ GEM
fog-json (~> 1.0)
fog-xml (~> 0.1)
ipaddress (~> 0.8)
fog-core (1.43.0)
fog-core (1.45.0)
builder
excon (~> 0.49)
excon (~> 0.58)
formatador (~> 0.2)
fog-dynect (0.0.3)
fog-core
@ -285,9 +285,9 @@ GEM
fog-xenserver (0.2.3)
fog-core
fog-xml
fog-xml (0.1.2)
fog-xml (0.1.3)
fog-core
nokogiri (~> 1.5, >= 1.5.11)
nokogiri (>= 1.5.11, < 2.0.0)
font-awesome-rails (4.7.0.1)
railties (>= 3.2, < 5.1)
formatador (0.2.5)
@ -330,17 +330,18 @@ GEM
sysexits (~> 1.1)
hashdiff (0.3.1)
hashie (3.4.6)
html2haml (2.0.0)
html2haml (2.2.0)
erubis (~> 2.7.0)
haml (~> 4.0.0)
nokogiri (~> 1.6.0)
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
htmlentities (4.3.4)
http-cookie (1.0.3)
domain_name (~> 0.5)
http_parser.rb (0.6.0)
httpclient (2.8.3)
i18n (0.8.1)
i18n (0.9.1)
concurrent-ruby (~> 1.0)
inflecto (0.0.2)
ipaddress (0.8.3)
jquery-rails (4.2.1)
@ -392,16 +393,16 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.2)
mini_portile2 (2.1.0)
minitest (5.10.1)
mini_portile2 (2.3.0)
minitest (5.10.3)
multi_json (1.12.1)
multipart-post (2.0.0)
mustermann (1.0.1)
nenv (0.3.0)
netrc (0.11.0)
nio4r (1.2.1)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
@ -475,9 +476,9 @@ GEM
actionpack (~> 5.x)
actionview (~> 5.x)
activesupport (~> 5.x)
rails-dom-testing (2.0.2)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.0.1)
@ -493,8 +494,8 @@ GEM
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rbvmomi (1.9.4)
builder (~> 3.2)
rbvmomi (1.11.6)
builder (~> 3.0)
json (>= 1.8)
nokogiri (~> 1.5)
trollop (~> 2.1)
@ -546,8 +547,8 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
ruby_dep (1.5.0)
ruby_parser (3.8.3)
sexp_processor (~> 4.1)
ruby_parser (3.10.1)
sexp_processor (~> 4.9)
rubyzip (1.0.0)
safe_yaml (1.0.4)
sass (3.4.22)
@ -571,7 +572,7 @@ GEM
thor (~> 0.14)
sentry-raven (2.2.0)
faraday (>= 0.7.6, < 1.0)
sexp_processor (4.7.0)
sexp_processor (4.10.0)
shellany (0.0.1)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
@ -617,14 +618,14 @@ GEM
ref
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.5)
tilt (2.0.8)
timecop (0.8.1)
trollop (2.1.2)
ttfunk (1.4.0)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.3)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (3.0.4)
execjs (>= 0.3.0, < 3)
@ -666,7 +667,7 @@ GEM
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)
xml-simple (1.1.5)
xpath (2.0.0)
xpath (2.1.0)
nokogiri (~> 1.3)
xray-rails (0.2.0)
rails (>= 3.1.0)

View file

@ -51,6 +51,17 @@ class Admin::ProceduresController < AdminController
redirect_to admin_procedures_draft_path
end
def destroy
procedure = current_administrateur.procedures.find(params[:id])
return render json: {}, status: 401 if procedure.publiee_ou_archivee?
procedure.destroy
flash.notice = 'Procédure supprimée'
redirect_to admin_procedures_draft_path
end
def new
@procedure ||= Procedure.new
@procedure.module_api_carto ||= ModuleAPICarto.new

View file

@ -39,7 +39,7 @@ class Backoffice::AvisController < ApplicationController
sign_in(gestionnaire, scope: :gestionnaire)
Avis.link_avis_to_gestionnaire(gestionnaire)
avis = Avis.find(params[:id])
redirect_to url_for(backoffice_dossier_path(avis.dossier_id))
redirect_to url_for(avis_index_path)
else
flash[:alert] = gestionnaire.errors.full_messages
redirect_to url_for(avis_sign_up_path(params[:id], email))

View file

@ -8,9 +8,4 @@ class Gestionnaires::SessionsController < Sessions::SessionsController
def create
super
end
def after_sign_in_path_for(resource)
# stored_location_for(resource) ||
backoffice_path
end
end

View file

@ -2,32 +2,19 @@ class RootController < ApplicationController
layout 'new_application'
def index
if params[:new_ui] && gestionnaire_signed_in? # TODO delete new_ui when old UI is no longer used
# TODO delete new_ui when old UI is no longer used
if params[:new_ui].present? && gestionnaire_signed_in?
return redirect_to procedures_path
end
if administrateur_signed_in?
elsif administrateur_signed_in?
return redirect_to admin_procedures_path
elsif gestionnaire_signed_in?
return redirect_to backoffice_invitations_path if current_gestionnaire.avis.any?
procedure_id = current_gestionnaire.procedure_filter
if procedure_id.nil?
procedure_list = current_gestionnaire.procedures
if procedure_list.count > 0
return redirect_to backoffice_dossiers_procedure_path(id: procedure_list.first.id)
else
flash.alert = "Vous n'avez aucune procédure d'affectée"
end
else
return redirect_to backoffice_dossiers_procedure_path(id: procedure_id)
# to be removed when old ui is deleted
if params[:old_ui].present?
return redirect_to backoffice_path
end
return redirect_to procedures_path
elsif user_signed_in?
return redirect_to users_dossiers_path
elsif administration_signed_in?
return redirect_to administrations_path
end

View file

@ -39,7 +39,7 @@ class Users::DescriptionController < UsersController
errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params)
return redirect_to_description_with_errors(dossier, errors_upload) if errors_upload.any?
if params[:champs] && !brouillon_submission?
if params[:champs] && !(brouillon_submission? || brouillon_then_dashboard_submission?)
errors =
ChampsService.build_error_messages(dossier.champs) +
PiecesJustificativesService.missing_pj_error_messages(dossier)
@ -48,6 +48,8 @@ class Users::DescriptionController < UsersController
if brouillon_submission?
flash.notice = 'Votre brouillon a bien été sauvegardé.'
redirect_to users_dossier_description_path(dossier.id)
elsif brouillon_then_dashboard_submission?
redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon)
else
if dossier.brouillon?
@ -110,7 +112,11 @@ class Users::DescriptionController < UsersController
end
def brouillon_submission?
params[:submit] && params[:submit].keys.first == 'brouillon'
params[:submit] && params[:submit]['brouillon'].present?
end
def brouillon_then_dashboard_submission?
params[:submit] && params[:submit]['brouillon_then_dashboard'].present?
end
def check_autorisation_donnees

View file

@ -26,7 +26,7 @@ class Users::SessionsController < Sessions::SessionsController
if user_signed_in?
redirect_to after_sign_in_path_for(:user)
elsif gestionnaire_signed_in?
location = stored_location_for(:gestionnaire) || backoffice_path
location = stored_location_for(:gestionnaire) || procedures_path
redirect_to location
elsif administrateur_signed_in?
redirect_to admin_path

View file

@ -57,7 +57,7 @@
Dimensions conseillées : au minimum 500 px de largeur ou de hauteur, poids maximum : 0,5 Mo.
.form-group
= f.label :footer, 'Adresse en bas de page'
= f.label :footer, 'Pied de page'
= f.text_field :footer, class: 'form-control', maxlength: 190
%button.btn.btn-primary{ formaction: admin_procedure_attestation_template_preview_path, formtarget: '_blank' } Prévisualiser

View file

@ -1,5 +1,5 @@
.col-xs-2
%a#title-navbar{ href: '/' }
%a#title-navbar{ href: root_path(old_ui: 1) }
.row#home
.col-lg-6.no-padding
= image_tag('marianne_small.png', class: 'logo')

View file

@ -12,7 +12,7 @@
Usager
- if gestionnaire_signed_in?
%li
= link_to(backoffice_dossiers_path) do
= link_to(procedures_path) do
%i.fa.fa-user
&nbsp;
Accompagnateur

View file

@ -43,9 +43,9 @@
.description
%h4 Refuser
L'usager sera notifié que son dossier a été refusé
= render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Accepter le dossier', popup_class: 'accept', process_action: 'accepter', title: 'Accepter', confirm: 'Accepter ce dossier ?' }
= render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Classer le dossier sans suite', popup_class: 'without-continuation', process_action: 'classer_sans_suite', title: 'Classer sans suite', confirm: 'Confirmer vous le classement sans suite de ce dossier ?' }
= render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Refuser le dossier', popup_class: 'refuse', process_action: 'refuser', title: 'Refuser', confirm: 'Confirmer vous le refus de ce dossier ?' }
= render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Accepter le dossier', popup_class: 'accept', process_action: 'accepter', title: 'Accepter', confirm: "Confirmez-vous l'acceptation ce dossier ?" }
= render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Classer le dossier sans suite', popup_class: 'without-continuation', process_action: 'classer_sans_suite', title: 'Classer sans suite', confirm: 'Confirmez-vous le classement sans suite de ce dossier ?' }
= render partial: 'new_gestionnaire/dossiers/state_button_motivation', locals: { dossier: dossier, popup_title: 'Refuser le dossier', popup_class: 'refuse', process_action: 'refuser', title: 'Refuser', confirm: 'Confirmez-vous le refus de ce dossier ?' }
- else
- if dossier.motivation.present? || dossier.attestation.present?

View file

@ -1,7 +1,7 @@
.motivation{ class: popup_class }
%h3
%span.icon{ class: popup_class }
#{popup_title} #{dossier.id}
#{popup_title}
= form_tag(terminer_dossier_path(dossier.procedure, dossier), method: :post, class: 'form') do
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: 'Rédigez votre motivation ici (facultative)'

View file

@ -44,3 +44,4 @@
- else
= submit_tag 'Soumettre mon dossier', id: 'suivant', name: 'submit[nouveaux]', class: 'btn btn btn-success', style: 'float: right;', disabled: @procedure.archivee?, data: { disable_with: 'Soumettre votre dossier', submit: true }
= submit_tag 'Enregistrer un brouillon', id: 'brouillon', name: 'submit[brouillon]', class: 'btn btn-xs btn-default', style: 'float: right; margin-right: 10px; margin-top: 6px;', disabled: @procedure.archivee?, data: { disable_with: 'Enregistrer un brouillon', submit: true }
= submit_tag "Enregistrer et voir mes dossiers", id: 'brouillon_then_dashboard', name: 'submit[brouillon_then_dashboard]', class: 'btn btn-xs btn-default', style: 'float: right; margin-right: 10px; margin-top: 6px;', disabled: @procedure.archivee?, data: { disable_with: 'Voir mes brouillons et dossiers', submit: true }

View file

@ -93,7 +93,7 @@ fr:
attestation_template:
attributes:
footer:
too_long: ": l'adresse en bas de page est trop longue."
too_long: ": le pied de page est trop long."
piece_justificative:
attributes:
content:

View file

@ -54,6 +54,54 @@ describe Admin::ProceduresController, type: :controller do
it { expect(response.status).to eq(200) }
end
describe 'DELETE #destroy' do
let(:procedure_draft) { create :procedure, administrateur: admin, published_at: nil, archived_at: nil }
let(:procedure_published) { create :procedure, administrateur: admin, published_at: Time.now, archived_at: nil }
let(:procedure_archived) { create :procedure, administrateur: admin, published_at: nil, archived_at: Time.now }
subject { delete :destroy, params: {id: procedure.id} }
context 'when procedure is draft' do
let!(:procedure) { procedure_draft }
describe 'tech params' do
before do
subject
end
it { expect(subject.status).to eq 302 }
it { expect(flash[:notice]).to be_present }
end
it 'destroy procedure is call' do
expect_any_instance_of(Procedure).to receive(:destroy)
subject
end
it { expect { subject }.to change { Procedure.count }.by(-1) }
end
context 'when procedure is published' do
let(:procedure) { procedure_published }
it { expect(subject.status).to eq 401 }
end
context 'when procedure is archived' do
let(:procedure) { procedure_published }
it { expect(subject.status).to eq 401 }
end
context "when administrateur does not own the procedure" do
let(:procedure_not_owned) { create :procedure, administrateur: create(:administrateur), published_at: nil, archived_at: nil }
subject { delete :destroy, params: {id: procedure_not_owned.id} }
it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) }
end
end
describe 'GET #edit' do
let(:published_at) { nil }
let(:procedure) { create(:procedure, administrateur: admin, published_at: published_at) }

View file

@ -177,7 +177,7 @@ describe Backoffice::AvisController, type: :controller do
it { expect(Avis).to have_received(:link_avis_to_gestionnaire) }
it { expect(subject.current_gestionnaire).to eq(created_gestionnaire) }
it { is_expected.to redirect_to backoffice_dossier_path(dossier) }
it { is_expected.to redirect_to avis_index_path }
end
context 'when the gestionnaire creation fails' do

View file

@ -13,27 +13,20 @@ describe RootController, type: :controller do
context 'when Gestionnaire is connected' do
let(:gestionnaire) { create(:gestionnaire) }
let(:procedure) { create(:procedure, :published) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
before do
gestionnaire.procedures << procedure
sign_in gestionnaire
end
context 'when gestionnaire is affect to a procedure' do
before do
create :assign_to, procedure: (create :procedure, :published), gestionnaire: gestionnaire
end
it { expect(subject).to redirect_to(procedures_path) }
it { expect(subject).to redirect_to(backoffice_dossiers_procedure_path(id: Procedure.all.first.id)) }
end
context 'and coming with old_ui param' do
subject { get :index, params: { old_ui: 1 } }
context 'when gestionnaire is not affect to a procedure' do
render_views
before do
subject
end
it { expect(response.body).to have_css('.landing') }
it { expect(subject).to redirect_to(backoffice_path) }
end
end

View file

@ -110,8 +110,6 @@ shared_examples 'description_controller_spec' do
context 'Tous les attributs sont bons' do
describe 'Premier enregistrement des données' do
let(:submit) { {nouveaux: 'nouveaux'} }
subject { post :update, params: {dossier_id: dossier_id, submit: submit} }
before do
@ -120,22 +118,38 @@ shared_examples 'description_controller_spec' do
dossier.reload
end
it "redirection vers la page recapitulative" do
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
end
it 'etat du dossier est soumis' do
expect(dossier.state).to eq('en_construction')
end
context 'when user whould like save just a brouillon' do
let(:submit) { {brouillon: 'brouillon'} }
context "when the user submits the dossier" do
let(:submit) { {nouveaux: 'nouveaux'} }
it "redirection vers la page recapitulative" do
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/recapitulatif")
end
it 'etat du dossier est en construction' do
expect(dossier.state).to eq('en_construction')
end
end
context 'when user saves a brouillon' do
let(:submit) { {brouillon: 'brouillon'} }
it "reste sur la page du dossier" do
expect(response).to redirect_to("/users/dossiers/#{dossier_id}/description")
end
it 'etat du dossier est brouillon' do
expect(dossier.state).to eq('brouillon')
end
end
context 'when user saves a brouillon and goes to dashboard' do
let(:submit) { {brouillon_then_dashboard: 'brouillon_then_dashboard'} }
it "goes to dashboard" do
expect(response).to redirect_to("/users/dossiers?liste=brouillon")
end
it 'etat du dossier est soumis' do
it 'etat du dossier est brouillon' do
expect(dossier.state).to eq('brouillon')
end
end

View file

@ -29,8 +29,8 @@ feature 'when gestionnaire come to /backoffice and is not authenticated' do
page.find_by_id(:user_password).set gestionnaire.password
page.click_on 'Se connecter'
end
scenario 'he is redirected to /backoffice' do
expect(page).to have_css('#backoffice-index')
scenario 'he is redirected to /procedures' do
expect(current_path).to eq(procedures_path)
end
end
end

View file

@ -22,6 +22,7 @@ feature 'on backoffice page', js: true do
page.find_by_id(:user_email).set gestionnaire.email
page.find_by_id(:user_password).set gestionnaire.password
page.click_on 'Se connecter'
page.click_on 'Ancienne interface'
end
context 'when he click on first dossier' do
before do

View file

@ -10,7 +10,6 @@ feature 'The gestionnaire part' do
scenario 'A gestionnaire can accept a dossier' do
log_in(gestionnaire.email, password)
click_on 'nouvelle interface'
expect(page).to have_current_path(procedures_path)
click_on procedure.libelle
@ -36,8 +35,6 @@ feature 'The gestionnaire part' do
scenario 'A gestionnaire can follow/unfollow a dossier' do
log_in(gestionnaire.email, password)
click_on 'nouvelle interface'
click_on procedure.libelle
test_statut_bar(a_suivre: 1, tous_les_dossiers: 1)
dossier_present?(dossier.id, 'en construction')
@ -62,7 +59,6 @@ feature 'The gestionnaire part' do
log_in(gestionnaire.email, password)
click_on 'nouvelle interface'
click_on procedure.libelle
click_on dossier.user.email
@ -79,7 +75,6 @@ feature 'The gestionnaire part' do
avis_sign_up(avis, expert_email, 'a good password')
click_on 'nouvelle interface'
expect(page).to have_current_path(avis_index_path)
expect(page).to have_text('avis à donner 1')
expect(page).to have_text('avis donnés 0')
@ -104,7 +99,6 @@ feature 'The gestionnaire part' do
log_in(gestionnaire.email, password)
click_on 'nouvelle interface'
click_on procedure.libelle
click_on dossier.user.email
click_on 'Avis externes'
@ -117,7 +111,6 @@ feature 'The gestionnaire part' do
log_in(gestionnaire.email, password)
click_on 'nouvelle interface'
click_on procedure.libelle
click_on dossier.user.email
@ -143,7 +136,7 @@ feature 'The gestionnaire part' do
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_on 'Se connecter'
expect(page).to have_current_path(backoffice_dossiers_procedure_path(procedure))
expect(page).to have_current_path(procedures_path)
end
def log_out
@ -178,7 +171,7 @@ feature 'The gestionnaire part' do
visit avis_sign_up_path(avis, email)
fill_in 'gestionnaire_password', with: 'a good password'
click_on 'Créer un compte'
expect(page).to have_current_path(backoffice_dossier_path(dossier))
expect(page).to have_current_path(avis_index_path)
end
def dossier_present?(id, statut)