commit
746dbff3b4
12 changed files with 94 additions and 34 deletions
|
@ -105,6 +105,10 @@
|
||||||
margin-top: $default-padding;
|
margin-top: $default-padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.answer-body p:not(:last-of-type) {
|
||||||
|
margin-bottom: $default-padding;
|
||||||
|
}
|
||||||
|
|
||||||
.avis-icon {
|
.avis-icon {
|
||||||
margin-right: $default-spacer;
|
margin-right: $default-spacer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def sentry_user
|
def sentry_user
|
||||||
user = logged_user
|
user = logged_user
|
||||||
{ id: user&.id, role: user&.class&.name || 'Guest' }.compact
|
{ id: user ? "#{user.class.name}##{user.id}" : 'Guest' }
|
||||||
end
|
end
|
||||||
|
|
||||||
def sentry_config
|
def sentry_config
|
||||||
|
@ -205,6 +205,7 @@ class ApplicationController < ActionController::Base
|
||||||
key: sentry[:client_key],
|
key: sentry[:client_key],
|
||||||
enabled: sentry[:enabled],
|
enabled: sentry[:enabled],
|
||||||
environment: sentry[:environment],
|
environment: sentry[:environment],
|
||||||
|
browser: { modern: browser.modern? },
|
||||||
user: sentry_user
|
user: sentry_user
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,38 +4,39 @@ module Users
|
||||||
|
|
||||||
def commencer
|
def commencer
|
||||||
@procedure = Procedure.publiees.find_by(path: params[:path])
|
@procedure = Procedure.publiees.find_by(path: params[:path])
|
||||||
|
return procedure_not_found if @procedure.blank?
|
||||||
if @procedure.blank?
|
|
||||||
flash.alert = "La démarche est inconnue, ou la création de nouveaux dossiers pour cette démarche est terminée."
|
|
||||||
return redirect_to root_path
|
|
||||||
end
|
|
||||||
|
|
||||||
render 'commencer/show'
|
render 'commencer/show'
|
||||||
end
|
end
|
||||||
|
|
||||||
def commencer_test
|
def commencer_test
|
||||||
@procedure = Procedure.brouillons.find_by(path: params[:path])
|
@procedure = Procedure.brouillons.find_by(path: params[:path])
|
||||||
|
return procedure_not_found if @procedure.blank?
|
||||||
if @procedure.blank?
|
|
||||||
flash.alert = "La démarche est inconnue, ou cette démarche n’est maintenant plus en test."
|
|
||||||
return redirect_to root_path
|
|
||||||
end
|
|
||||||
|
|
||||||
render 'commencer/show'
|
render 'commencer/show'
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_in
|
def sign_in
|
||||||
store_user_location!
|
@procedure = Procedure.find_by(path: params[:path])
|
||||||
|
return procedure_not_found if @procedure.blank?
|
||||||
|
|
||||||
|
store_user_location!(@procedure)
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def sign_up
|
def sign_up
|
||||||
store_user_location!
|
@procedure = Procedure.find_by(path: params[:path])
|
||||||
|
return procedure_not_found if @procedure.blank?
|
||||||
|
|
||||||
|
store_user_location!(@procedure)
|
||||||
redirect_to new_user_registration_path
|
redirect_to new_user_registration_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def france_connect
|
def france_connect
|
||||||
store_user_location!
|
@procedure = Procedure.find_by(path: params[:path])
|
||||||
|
return procedure_not_found if @procedure.blank?
|
||||||
|
|
||||||
|
store_user_location!(@procedure)
|
||||||
redirect_to france_connect_particulier_path
|
redirect_to france_connect_particulier_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,8 +46,21 @@ module Users
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def store_user_location!
|
def procedure_not_found
|
||||||
procedure = Procedure.find_by(path: params[:path])
|
procedure = Procedure.find_by(path: params[:path])
|
||||||
|
|
||||||
|
if procedure&.archivee?
|
||||||
|
flash.alert = t('errors.messages.procedure_archived')
|
||||||
|
elsif procedure&.publiee?
|
||||||
|
flash.alert = t('errors.messages.procedure_not_draft')
|
||||||
|
else
|
||||||
|
flash.alert = t('errors.messages.procedure_not_found')
|
||||||
|
end
|
||||||
|
|
||||||
|
return redirect_to root_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def store_user_location!(procedure)
|
||||||
store_location_for(:user, helpers.procedure_lien(procedure))
|
store_location_for(:user, helpers.procedure_lien(procedure))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,6 +60,12 @@ module ApplicationHelper
|
||||||
# rubocop:enable Rails/OutputSafety
|
# rubocop:enable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_element(selector)
|
||||||
|
# rubocop:disable Rails/OutputSafety
|
||||||
|
raw("document.querySelector('#{selector}').classList.remove('hidden');")
|
||||||
|
# rubocop:enable Rails/OutputSafety
|
||||||
|
end
|
||||||
|
|
||||||
def disable_element(selector)
|
def disable_element(selector)
|
||||||
# rubocop:disable Rails/OutputSafety
|
# rubocop:disable Rails/OutputSafety
|
||||||
raw("document.querySelector('#{selector}').disabled = true;")
|
raw("document.querySelector('#{selector}').disabled = true;")
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import * as Sentry from '@sentry/browser';
|
import * as Sentry from '@sentry/browser';
|
||||||
|
|
||||||
const { key, enabled, user, environment } = gon.sentry || {};
|
const { key, enabled, user, environment, browser } = gon.sentry || {};
|
||||||
|
|
||||||
// We need to check for key presence here as we do not have a dsn for browser yet
|
// We need to check for key presence here as we do not have a dsn for browser yet
|
||||||
if (enabled && key) {
|
if (enabled && key) {
|
||||||
Sentry.init({ dsn: key, environment });
|
Sentry.init({ dsn: key, environment });
|
||||||
|
|
||||||
if (user.email) {
|
Sentry.configureScope(scope => {
|
||||||
Sentry.configureScope(scope => {
|
scope.setUser(user);
|
||||||
scope.setUser(user);
|
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,5 @@
|
||||||
- else
|
- else
|
||||||
%span.waiting En attente de réponse
|
%span.waiting En attente de réponse
|
||||||
= render partial: 'shared/piece_jointe/pj_link', locals: { object: avis, pj: avis.piece_justificative_file }
|
= render partial: 'shared/piece_jointe/pj_link', locals: { object: avis, pj: avis.piece_justificative_file }
|
||||||
%p= avis.answer
|
.answer-body
|
||||||
|
= simple_format(avis.answer)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
<%= render_flash(timeout: 5000, sticky: true) %>
|
<%= render_flash(timeout: 5000, sticky: true) %>
|
||||||
<%= remove_element("#piece_justificative_#{@champ.id}") %>
|
<%= remove_element("#piece_justificative_#{@champ.id}") %>
|
||||||
|
<%= show_element("#champs_#{@champ.id}") %>
|
||||||
let fileInputSelector = '<%= "#champs_#{@champ.id}" %>';
|
|
||||||
document.querySelector(fileInputSelector).classList.remove('hidden');
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ fr:
|
||||||
connexion: "Erreur lors de la connexion à France Connect."
|
connexion: "Erreur lors de la connexion à France Connect."
|
||||||
extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide."
|
extension_white_list_error: "Le format de fichier de la pièce jointe n'est pas valide."
|
||||||
procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier."
|
procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier."
|
||||||
|
procedure_not_draft: "Cette démarche n’est maintenant plus en brouillon."
|
||||||
cadastres_empty:
|
cadastres_empty:
|
||||||
one: "Aucune parcelle cadastrale sur la zone séléctionnée"
|
one: "Aucune parcelle cadastrale sur la zone séléctionnée"
|
||||||
other: "Aucune parcelle cadastrale sur les zones séléctionnées"
|
other: "Aucune parcelle cadastrale sur les zones séléctionnées"
|
||||||
|
|
|
@ -34,7 +34,7 @@ describe ApplicationController, type: :controller do
|
||||||
context 'when no one is logged in' do
|
context 'when no one is logged in' do
|
||||||
it do
|
it do
|
||||||
expect(Raven).to have_received(:user_context)
|
expect(Raven).to have_received(:user_context)
|
||||||
.with({ role: 'Guest' })
|
.with({ id: 'Guest' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
@ -53,7 +53,7 @@ describe ApplicationController, type: :controller do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(Raven).to have_received(:user_context)
|
expect(Raven).to have_received(:user_context)
|
||||||
.with({ id: current_user.id, role: 'User' })
|
.with({ id: "User##{current_user.id}" })
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
@ -77,7 +77,7 @@ describe ApplicationController, type: :controller do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(Raven).to have_received(:user_context)
|
expect(Raven).to have_received(:user_context)
|
||||||
.with({ id: current_user.id, role: 'User' })
|
.with({ id: "User##{current_user.id}" })
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
|
|
@ -87,6 +87,14 @@ describe Users::CommencerController, type: :controller do
|
||||||
|
|
||||||
it { expect(subject).to redirect_to(new_user_session_path) }
|
it { expect(subject).to redirect_to(new_user_session_path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the path doesn’t exist' do
|
||||||
|
subject { get :sign_in, params: { path: 'hello' } }
|
||||||
|
|
||||||
|
it 'redirects with an error message' do
|
||||||
|
expect(subject).to redirect_to(root_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#sign_up' do
|
describe '#sign_up' do
|
||||||
|
@ -111,6 +119,14 @@ describe Users::CommencerController, type: :controller do
|
||||||
|
|
||||||
it { expect(subject).to redirect_to(new_user_registration_path) }
|
it { expect(subject).to redirect_to(new_user_registration_path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the path doesn’t exist' do
|
||||||
|
subject { get :sign_up, params: { path: 'hello' } }
|
||||||
|
|
||||||
|
it 'redirects with an error message' do
|
||||||
|
expect(subject).to redirect_to(root_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#france_connect' do
|
describe '#france_connect' do
|
||||||
|
@ -135,5 +151,13 @@ describe Users::CommencerController, type: :controller do
|
||||||
|
|
||||||
it { expect(subject).to redirect_to(france_connect_particulier_path) }
|
it { expect(subject).to redirect_to(france_connect_particulier_path) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the path doesn’t exist' do
|
||||||
|
subject { get :france_connect, params: { path: 'hello' } }
|
||||||
|
|
||||||
|
it 'redirects with an error message' do
|
||||||
|
expect(subject).to redirect_to(root_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,5 +19,9 @@ FactoryBot.define do
|
||||||
avis.claimant = create :gestionnaire
|
avis.claimant = create :gestionnaire
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :with_answer do
|
||||||
|
answer { "Mon avis se décompose en deux points :\n- La demande semble pertinente\n- Le demandeur remplit les conditions." }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'gestionnaires/shared/avis/_list.html.haml', type: :view do
|
describe 'gestionnaires/shared/avis/_list.html.haml', type: :view do
|
||||||
before { view.extend DossierHelper }
|
before { view.extend DossierHelper }
|
||||||
|
|
||||||
|
@ -5,16 +7,22 @@ describe 'gestionnaires/shared/avis/_list.html.haml', type: :view do
|
||||||
|
|
||||||
let(:gestionnaire) { create(:gestionnaire) }
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
let(:avis) { [create(:avis, claimant: gestionnaire)] }
|
let(:avis) { [create(:avis, claimant: gestionnaire)] }
|
||||||
|
let(:seen_at) { avis.first.created_at + 1.hour }
|
||||||
|
|
||||||
context "with a seen_at after avis created_at" do
|
it { is_expected.to have_text(avis.first.introduction) }
|
||||||
let(:seen_at) { avis.first.created_at + 1.hour }
|
it { is_expected.not_to have_css(".highlighted") }
|
||||||
|
|
||||||
it { is_expected.not_to have_css(".highlighted") }
|
context 'with a seen_at before avis created_at' do
|
||||||
end
|
|
||||||
|
|
||||||
context "with a seen_at after avis created_at" do
|
|
||||||
let(:seen_at) { avis.first.created_at - 1.hour }
|
let(:seen_at) { avis.first.created_at - 1.hour }
|
||||||
|
|
||||||
it { is_expected.to have_css(".highlighted") }
|
it { is_expected.to have_css(".highlighted") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with an answer' do
|
||||||
|
let(:avis) { [create(:avis, :with_answer, claimant: gestionnaire)] }
|
||||||
|
|
||||||
|
it 'renders the answer formatted with newlines' do
|
||||||
|
expect(subject).to include(simple_format(avis.first.answer))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue