Merge pull request #3323 from betagouv/dev

2019-01-23-02
This commit is contained in:
Pierre de La Morinerie 2019-01-23 16:57:45 +01:00 committed by GitHub
commit 0591d55a0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 6 deletions

View file

@ -39,7 +39,7 @@ class DossierSearchService
def self.to_tsquery(search_terms)
search_terms.strip
.gsub(/['?\\:&|!]/, "") # drop disallowed characters
.gsub(/['?\\:&|!<>\(\)]/, "") # drop disallowed characters
.split(/\s+/) # split words
.map { |x| "#{x}:*" } # enable prefix matching
.join(" & ")

View file

@ -20,8 +20,8 @@
= f.number_field :duree_conservation_dossiers_hors_ds, class: 'form-control', placeholder: '6', required: true
.form-group
%h4 Lien site internet
= f.text_field :lien_site_web, class: 'form-control', placeholder: 'https://www.exemple.fr/'
%h4 Où les usagers trouveront-ils le lien vers la démarche ?
= f.text_field :lien_site_web, class: 'form-control', placeholder: 'https://exemple.gouv.fr/ma_demarche'
- if Flipflop.web_hook?
.form-group

View file

@ -15,13 +15,21 @@
= link_to 'Commencer la démarche', url_for_new_dossier(@procedure), class: ['button large expand primary']
- elsif drafts.count == 1 && not_drafts.count == 0
- dossier = drafts.first
%h1 Vous avez déjà commencé à remplir un dossier
= link_to 'Continuer à remplir mon dossier', brouillon_dossier_path(drafts.first), class: ['button large expand primary']
%p
Il y a <strong>#{time_ago_in_words(dossier.created_at)}</strong>,
vous avez commencé à remplir un dossier sur la démarche « #{dossier.procedure.libelle} ».
= link_to 'Continuer à remplir mon dossier', brouillon_dossier_path(dossier), class: ['button large expand primary']
= link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand']
- elsif not_drafts.count == 1
- dossier = not_drafts.first
%h1 Vous avez déjà déposé un dossier
= link_to 'Voir mon dossier', dossier_path(not_drafts.first), class: ['button large expand primary']
%p
Il y a <strong>#{time_ago_in_words(dossier.en_construction_at)}</strong>,
vous avez déposé un dossier sur la démarche « #{dossier.procedure.libelle} ».
= link_to 'Voir mon dossier déposé', dossier_path(dossier), class: ['button large expand primary']
= link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand']
- else

View file

@ -1,11 +1,13 @@
:javascript
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
// Configure Matomo analytics
_paq.push(["setCookieDomain", "*.www.demarches-simplifiees.fr"]);
_paq.push(["setDomains", ["*.www.demarches-simplifiees.fr"]]);
_paq.push(["setDoNotTrack", true]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
// Load script from Matomo
(function() {
var u="//stats.data.gouv.fr/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
@ -13,3 +15,20 @@
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
// Send Matomo a new event when navigating to a new page using Turbolinks
// (see https://developer.matomo.org/guides/spa-tracking)
(function() {
var previousPageUrl = null;
addEventListener('turbolinks:load', function(event) {
if (previousPageUrl) {
var loadTimeMs = event.data.timing.visitEnd - event.data.timing.visitStart;
_paq.push(['setReferrerUrl', previousPageUrl]);
_paq.push(['setCustomUrl', '/' + window.location.href]);
_paq.push(['setDocumentTitle', document.title]);
_paq.push(['setGenerationTimeMs', loadTimeMs]);
_paq.push(['trackPageView']);
}
previousPageUrl = window.location.href;
});
})();

View file

@ -90,5 +90,11 @@ describe DossierSearchService do
it { expect(subject.size).to eq(1) }
end
describe 'search with characters disallowed by the tsquery parser' do
let(:terms) { "'?\\:&!(OCTO) <plop>" }
it { expect(subject.size).to eq(1) }
end
end
end

View file

@ -45,6 +45,7 @@ RSpec.describe 'commencer/show.html.haml', type: :view do
it 'renders a link to resume the pending draft' do
subject
expect(rendered).to have_text(time_ago_in_words(brouillon.created_at))
expect(rendered).to have_link('Continuer à remplir mon dossier', href: brouillon_dossier_path(brouillon))
end
end
@ -57,6 +58,7 @@ RSpec.describe 'commencer/show.html.haml', type: :view do
it 'renders a link to the submitted dossier' do
subject
expect(rendered).to have_text(time_ago_in_words(dossier.en_construction_at))
expect(rendered).to have_link('Voir mon dossier', href: dossier_path(dossier))
end
end