sign_up: display procedure context if available

This commit is contained in:
Pierre de La Morinerie 2019-01-14 15:26:53 +00:00
parent 4fd9fa6610
commit ae763d93f3
5 changed files with 34 additions and 16 deletions

View file

@ -1,10 +1,9 @@
class Users::RegistrationsController < Devise::RegistrationsController class Users::RegistrationsController < Devise::RegistrationsController
include ProcedureContextConcern
# before_action :configure_sign_up_params, only: [:create] # before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update] # before_action :configure_account_update_params, only: [:update]
before_action :restore_procedure_context, only: [:new, :create]
# def after_sign_up_path_for(resource_or_scope)
# super
# end
layout 'procedure_context', only: [:new, :create] layout 'procedure_context', only: [:new, :create]

View file

@ -9,17 +9,30 @@ describe Users::RegistrationsController, type: :controller do
end end
describe '#new' do describe '#new' do
subject! { get :new } subject { get :new }
it { expect(response).to have_http_status(:ok) } it { expect(subject).to have_http_status(:ok) }
it { expect(response).to render_template(:new) } it { expect(subject).to render_template(:new) }
context 'when an email address is provided' do context 'when an email address is provided' do
render_views true render_views true
subject! { get :new, params: { user: { email: 'test@exemple.fr' } } } subject { get :new, params: { user: { email: 'test@exemple.fr' } } }
it 'prefills the form with the email address' do it 'prefills the form with the email address' do
expect(response.body).to include('test@exemple.fr') expect(subject.body).to include('test@exemple.fr')
end
end
context 'when a procedure location has been stored' do
let(:procedure) { create :procedure, :published }
before do
controller.store_location_for(:user, new_dossier_path(procedure_id: procedure.id))
end
it 'makes the saved procedure available' do
expect(subject.status).to eq 200
expect(assigns(:procedure)).to eq procedure
end end
end end
end end

View file

@ -34,7 +34,7 @@ feature 'Signing up:' do
end end
context 'when visiting a procedure' do context 'when visiting a procedure' do
let(:procedure) { create :simple_procedure } let(:procedure) { create :simple_procedure, :with_service }
before do before do
visit commencer_path(path: procedure.path) visit commencer_path(path: procedure.path)
@ -43,13 +43,14 @@ feature 'Signing up:' do
scenario 'a new user can sign-up and fill the procedure' do scenario 'a new user can sign-up and fill the procedure' do
expect(page).to have_current_path new_user_session_path expect(page).to have_current_path new_user_session_path
click_on 'Créer un compte' click_on 'Créer un compte'
expect_page_to_have_procedure_description(procedure)
sign_up_with user_email, user_password sign_up_with user_email, user_password
expect(page).to have_content "nous avons besoin de vérifier votre adresse #{user_email}" expect(page).to have_content "nous avons besoin de vérifier votre adresse #{user_email}"
click_confirmation_link_for user_email click_confirmation_link_for user_email
expect(page).to have_content 'Votre compte a été activé' expect(page).to have_content 'Votre compte a été activé'
expect(page).to have_content procedure.libelle expect_page_to_have_procedure_description(procedure)
end end
end end

View file

@ -22,15 +22,12 @@ feature 'Signin in:' do
scenario 'an existing user can sign-in and fill the procedure' do scenario 'an existing user can sign-in and fill the procedure' do
expect(page).to have_current_path new_user_session_path expect(page).to have_current_path new_user_session_path
expect(page).to have_content procedure.libelle expect_page_to_have_procedure_description(procedure)
expect(page).to have_content procedure.description
expect(page).to have_content procedure.service.email
sign_in_with user.email, password sign_in_with user.email, password
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last) expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last)
expect(page).to have_content procedure.libelle expect_page_to_have_procedure_description(procedure)
expect(page).to have_content procedure.description
expect(page).to have_content "Données d'identité" expect(page).to have_content "Données d'identité"
end end
end end

View file

@ -50,6 +50,14 @@ module FeatureHelpers
visit "/users/confirmation?#{token_params}" visit "/users/confirmation?#{token_params}"
end end
def expect_page_to_have_procedure_description(procedure)
# Procedure context on the page
expect(page).to have_content(procedure.libelle)
expect(page).to have_content(procedure.description)
# Procedure contact infos in the footer
expect(page).to have_content(procedure.service.email)
end
end end
RSpec.configure do |config| RSpec.configure do |config|