From c983622805ff1c054de1d5f7e27de48e876426a8 Mon Sep 17 00:00:00 2001 From: kara Diaby Date: Tue, 4 Aug 2020 10:45:49 +0200 Subject: [PATCH 1/6] fix attestation template boolean on procedure detail page (new admin interface) --- app/views/new_administrateur/procedures/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/new_administrateur/procedures/show.html.haml b/app/views/new_administrateur/procedures/show.html.haml index 68320f480..d8e40772b 100644 --- a/app/views/new_administrateur/procedures/show.html.haml +++ b/app/views/new_administrateur/procedures/show.html.haml @@ -122,14 +122,14 @@ %h2.procedure-admin-explanation Pour aller plus loin .procedure-grid .card-admin - - if @procedure.attestation_template.present? + - if @procedure.attestation_template.present? && @procedure.attestation_template.activated %div %span.icon.accept %p.card-admin-status-accept Activée - else %div %span.icon.clock - %p.card-admin-status-todo À activer + %p.card-admin-status-todo Désactivée %div %p.card-admin-title Attestation %p.card-admin-subtitle Délivrance automatique pour les dossiers acceptés From 502d2b5606bae8a4dce3f1df405ba8fe835f1c97 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 13:30:26 +0000 Subject: [PATCH 2/6] Bump elliptic from 6.5.2 to 6.5.3 Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3. - [Release notes](https://github.com/indutny/elliptic/releases) - [Commits](https://github.com/indutny/elliptic/compare/v6.5.2...v6.5.3) Signed-off-by: dependabot[bot] --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index b654b1b20..827891110 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2003,9 +2003,9 @@ bluebird@^3.5.5: integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.4.0: - version "4.11.8" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" - integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== + version "4.11.9" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" + integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw== bn.js@^5.1.1: version "5.1.1" @@ -3458,9 +3458,9 @@ electron-to-chromium@^1.3.413: integrity sha512-BVXnq+NCefidU7GOFPx4CPBfPcccLCRBKZYSbvBJMSn2kwGD7ML+eUA9tqfHAumRqy3oX5zaeTI1Bpt7qVat0Q== elliptic@^6.0.0, elliptic@^6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.2.tgz#05c5678d7173c049d8ca433552224a495d0e3762" - integrity sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw== + version "6.5.3" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" + integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw== dependencies: bn.js "^4.4.0" brorand "^1.0.1" From cc9341a83c18ee699fb2a3704a9f02a38dd27d75 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 29 Jun 2020 16:58:58 +0200 Subject: [PATCH 3/6] fix missing header for account creation --- app/views/users/confirmations/new.html.haml | 3 ++- spec/features/accessibilite/wcag_usager_spec.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/users/confirmations/new.html.haml b/app/views/users/confirmations/new.html.haml index 748ce3f67..cb77e94ab 100644 --- a/app/views/users/confirmations/new.html.haml +++ b/app/views/users/confirmations/new.html.haml @@ -1,4 +1,4 @@ -- content_for(:title, 'Confirmer votre adresse email') +- content_for(:title, 'Confirmez votre adresse email') - content_for :footer do = render partial: 'root/footer' @@ -6,6 +6,7 @@ .container.devise-container.devise-confirmations .one-column-centered = devise_error_messages! + %h1.center Confirmez votre adresse email %img.confirmation-icon{ src: image_url("user/confirmation-email.svg"), alt: "" } diff --git a/spec/features/accessibilite/wcag_usager_spec.rb b/spec/features/accessibilite/wcag_usager_spec.rb index c8ef9cee8..6a6ead408 100644 --- a/spec/features/accessibilite/wcag_usager_spec.rb +++ b/spec/features/accessibilite/wcag_usager_spec.rb @@ -22,7 +22,7 @@ feature 'wcag rules for usager', js: true do perform_enqueued_jobs do click_button 'Créer un compte' - expect(page).to be_accessible.skipping(:'page-has-heading-one', :'role-img-alt', :label) + expect(page).to be_accessible.skipping(:'role-img-alt', :label) end end From 101acafb65ae7361916d4506d6a2ca97c363e25f Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 29 Jun 2020 17:11:39 +0200 Subject: [PATCH 4/6] fix hidden label --- app/assets/stylesheets/new_design/confirmations.scss | 11 ++++++----- app/views/users/confirmations/new.html.haml | 3 ++- spec/features/accessibilite/wcag_usager_spec.rb | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/new_design/confirmations.scss b/app/assets/stylesheets/new_design/confirmations.scss index 7c59e979b..2936770e0 100644 --- a/app/assets/stylesheets/new_design/confirmations.scss +++ b/app/assets/stylesheets/new_design/confirmations.scss @@ -37,7 +37,8 @@ } .confirmation-resend { - p { + p, + label { margin-bottom: $default-padding; } @@ -45,6 +46,10 @@ display: flex; flex-wrap: wrap; + label { + flex-basis: 100%; + } + input, button { margin-bottom: $default-spacer; @@ -56,9 +61,5 @@ margin-right: $default-spacer; } } - - label { - display: none; - } } } diff --git a/app/views/users/confirmations/new.html.haml b/app/views/users/confirmations/new.html.haml index cb77e94ab..d7833d88a 100644 --- a/app/views/users/confirmations/new.html.haml +++ b/app/views/users/confirmations/new.html.haml @@ -27,7 +27,8 @@ %p Si vous n’avez pas reçu notre message (avez-vous vérifié les indésirables ?), nous pouvons vous le renvoyer. = form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { class: 'form' }) do |f| - = f.label :email, 'Email' + = f.label :email, 'Votre email' + %br = f.email_field :email, placeholder: 'Email', class: 'small', autofocus: true = f.submit 'Renvoyer un email de confirmation', class: 'button' diff --git a/spec/features/accessibilite/wcag_usager_spec.rb b/spec/features/accessibilite/wcag_usager_spec.rb index 6a6ead408..86c53aea3 100644 --- a/spec/features/accessibilite/wcag_usager_spec.rb +++ b/spec/features/accessibilite/wcag_usager_spec.rb @@ -22,7 +22,7 @@ feature 'wcag rules for usager', js: true do perform_enqueued_jobs do click_button 'Créer un compte' - expect(page).to be_accessible.skipping(:'role-img-alt', :label) + expect(page).to be_accessible.skipping(:'role-img-alt') end end From 21221a7c4979a5cab891e3aa741da89ffa5f9c76 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 29 Jun 2020 17:22:11 +0200 Subject: [PATCH 5/6] fix missing alt --- app/views/users/confirmations/new.html.haml | 2 +- spec/features/accessibilite/wcag_usager_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/confirmations/new.html.haml b/app/views/users/confirmations/new.html.haml index d7833d88a..b272a5c84 100644 --- a/app/views/users/confirmations/new.html.haml +++ b/app/views/users/confirmations/new.html.haml @@ -8,7 +8,7 @@ = devise_error_messages! %h1.center Confirmez votre adresse email - %img.confirmation-icon{ src: image_url("user/confirmation-email.svg"), alt: "" } + %img.confirmation-icon{ src: image_url("user/confirmation-email.svg"), alt: "Email envoyé" } %p.confirmation-preamble = succeed '.' do diff --git a/spec/features/accessibilite/wcag_usager_spec.rb b/spec/features/accessibilite/wcag_usager_spec.rb index 86c53aea3..056987182 100644 --- a/spec/features/accessibilite/wcag_usager_spec.rb +++ b/spec/features/accessibilite/wcag_usager_spec.rb @@ -22,7 +22,7 @@ feature 'wcag rules for usager', js: true do perform_enqueued_jobs do click_button 'Créer un compte' - expect(page).to be_accessible.skipping(:'role-img-alt') + expect(page).to be_accessible end end From 8962db38ccbefd8eb750e85fcc89cfefee63da55 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 4 Aug 2020 16:53:46 +0200 Subject: [PATCH 6/6] models: render attestations in a simpler way The older method of instanciating an entire new rendering stack can be made simpler using Rails >= 5.0 methods. See https://api.rubyonrails.org/classes/ActionController/Renderer.html#method-i-render --- app/models/attestation_template.rb | 7 +++++-- spec/models/attestation_template_spec.rb | 13 ++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/models/attestation_template.rb b/app/models/attestation_template.rb index 3b1ac23ed..667335812 100644 --- a/app/models/attestation_template.rb +++ b/app/models/attestation_template.rb @@ -109,8 +109,11 @@ class AttestationTemplate < ApplicationRecord def build_pdf(dossier) attestation = render_attributes_for(dossier: dossier) - action_view = ActionView::Base.new(ActionController::Base.view_paths, attestation: attestation) - attestation_view = action_view.render(file: 'new_administrateur/attestation_templates/show', formats: [:pdf]) + attestation_view = ApplicationController.render( + file: 'new_administrateur/attestation_templates/show', + formats: :pdf, + assigns: { attestation: attestation } + ) StringIO.new(attestation_view) end diff --git a/spec/models/attestation_template_spec.rb b/spec/models/attestation_template_spec.rb index ddb33465e..a9561e26c 100644 --- a/spec/models/attestation_template_spec.rb +++ b/spec/models/attestation_template_spec.rb @@ -122,12 +122,11 @@ describe AttestationTemplate, type: :model do end let(:view_args) do - original_new = ActionView::Base.method(:new) arguments = nil - allow(ActionView::Base).to receive(:new) do |paths, args| - arguments = args - original_new.call(paths, args) + allow(ApplicationController).to receive(:render).and_wrap_original do |m, *args| + arguments = args.first[:assigns] + m.call(*args) end attestation_template.attestation_for(dossier) @@ -162,10 +161,14 @@ describe AttestationTemplate, type: :model do .update(value: 'libelle2') end - it do + it 'passes the correct parameters to the view' do expect(view_args[:attestation][:title]).to eq('title libelle1') expect(view_args[:attestation][:body]).to eq('body libelle2') + end + + it 'generates an attestation' do expect(attestation.title).to eq('title libelle1') + expect(attestation.pdf).to be_attached end end end