Connexion page is contextualized with procedure title and description when is access with link.
This commit is contained in:
parent
95bb773275
commit
4d1cb9ecfe
9 changed files with 115 additions and 21 deletions
|
@ -11,7 +11,13 @@ class Users::SessionsController < Sessions::SessionsController
|
|||
|
||||
# GET /resource/sign_in
|
||||
def new
|
||||
unless user_return_to_procedure_id.nil?
|
||||
@dossier = Dossier.new(procedure: Procedure.not_archived(user_return_to_procedure_id))
|
||||
end
|
||||
|
||||
@user = User.new
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
error_procedure
|
||||
end
|
||||
|
||||
#POST /resource/sign_in
|
||||
|
@ -39,10 +45,21 @@ class Users::SessionsController < Sessions::SessionsController
|
|||
end
|
||||
end
|
||||
|
||||
# protected
|
||||
def no_procedure
|
||||
session['user_return_to'] = nil
|
||||
redirect_to new_user_session_path
|
||||
end
|
||||
|
||||
# You can put the params you want to permit in the empty array.
|
||||
# def configure_sign_in_params
|
||||
# devise_parameter_sanitizer.for(:sign_in) << :attribute
|
||||
# end
|
||||
private
|
||||
|
||||
def error_procedure
|
||||
flash.alert = t('errors.messages.procedure_not_found')
|
||||
redirect_to url_for root_path
|
||||
end
|
||||
|
||||
def user_return_to_procedure_id
|
||||
return nil if session["user_return_to"].nil?
|
||||
|
||||
NumberService.to_number session["user_return_to"].split("?procedure_id=").second
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,6 +25,10 @@ class Procedure < ActiveRecord::Base
|
|||
types_de_champ.order(:order_place)
|
||||
end
|
||||
|
||||
def self.not_archived id
|
||||
Procedure.where(archived: false).find(id)
|
||||
end
|
||||
|
||||
def switch_types_de_champ index_of_first_element
|
||||
return false if index_of_first_element < 0
|
||||
types_de_champ_tmp = types_de_champ_ordered
|
||||
|
|
5
app/services/number_service.rb
Normal file
5
app/services/number_service.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class NumberService
|
||||
def self.to_number string
|
||||
string.to_s if Float(string) rescue nil
|
||||
end
|
||||
end
|
11
app/views/users/dossiers/_title_procedure.html.haml
Normal file
11
app/views/users/dossiers/_title_procedure.html.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
- if @dossier.procedure.euro_flag
|
||||
#euro_flag.flag
|
||||
=image_tag('drapeau_europe.png')
|
||||
|
||||
#logo_procedure.flag
|
||||
=image_tag( @dossier.procedure.decorate.logo_img )
|
||||
|
||||
%h2#titre_procedure.text-info
|
||||
= @dossier.procedure.libelle
|
||||
%p
|
||||
= h @dossier.procedure.description.html_safe
|
|
@ -1,20 +1,7 @@
|
|||
.container.center#users_siret_index
|
||||
.row
|
||||
%p.lead{id: 'pro_section'}
|
||||
%br
|
||||
%br
|
||||
|
||||
- if @dossier.procedure.euro_flag
|
||||
#euro_flag.flag
|
||||
=image_tag('drapeau_europe.png')
|
||||
|
||||
#logo_procedure.flag
|
||||
=image_tag( @dossier.procedure.decorate.logo_img )
|
||||
|
||||
%h2#titre_procedure.text-info
|
||||
= @dossier.procedure.libelle
|
||||
%p
|
||||
= h @dossier.procedure.description.html_safe
|
||||
%p.lead{id: 'pro_section', style:'padding-top: 120px'}
|
||||
= render partial: 'title_procedure'
|
||||
%br
|
||||
|
||||
= form_for @dossier, url: {controller: 'users/dossiers', action: :create}, method: :post do |f|
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#form_login
|
||||
= image_tag('logo-tps.png')
|
||||
%br
|
||||
- if @dossier
|
||||
= link_to 'X', users_no_procedure_url, class: 'btn btn-xs', style:'float: right'
|
||||
= render partial: 'users/dossiers/title_procedure'
|
||||
- else
|
||||
= image_tag('logo-tps.png', {id: 'logo_tps'})
|
||||
%br
|
||||
|
||||
%h2#login_user Connexion
|
||||
|
||||
%a.btn_fc#btn_fcp{href: '/france_connect/particulier'}
|
||||
|
|
|
@ -18,6 +18,7 @@ Rails.application.routes.draw do
|
|||
|
||||
devise_scope :user do
|
||||
get '/users/sign_in/demo' => 'users/sessions#demo'
|
||||
get '/users/no_procedure' => 'users/sessions#no_procedure'
|
||||
end
|
||||
|
||||
devise_scope :gestionnaire do
|
||||
|
|
|
@ -67,4 +67,33 @@ describe Users::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.new' do
|
||||
subject { get :new }
|
||||
|
||||
context 'when procedure_id is not present in user_return_to session params' do
|
||||
it { expect(subject.status).to eq 200}
|
||||
end
|
||||
|
||||
context 'when procedure_id is present in user_return_to session params' do
|
||||
context 'when procedure_id does not exist' do
|
||||
before do
|
||||
session["user_return_to"] = '?procedure_id=0'
|
||||
end
|
||||
|
||||
it { expect(subject.status).to eq 302}
|
||||
it { expect(subject).to redirect_to root_path }
|
||||
end
|
||||
|
||||
context 'when procedure_id exist' do
|
||||
let(:procedure) { create :procedure }
|
||||
|
||||
before do
|
||||
session["user_return_to"] = "?procedure_id=#{procedure.id}"
|
||||
end
|
||||
|
||||
it { expect(subject.status).to eq 200}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
34
spec/views/users/sessions/new.html.haml_spec.rb
Normal file
34
spec/views/users/sessions/new.html.haml_spec.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/sessions/new.html.haml', type: :view do
|
||||
let(:dossier) { create :dossier }
|
||||
|
||||
before(:each) do
|
||||
allow(view).to receive(:devise_mapping).and_return(Devise.mappings[:user])
|
||||
allow(view).to receive(:resource_name).and_return(:user)
|
||||
end
|
||||
|
||||
before do
|
||||
assign(:user, User.new)
|
||||
end
|
||||
|
||||
context 'when user_return_to session params contains a procedure_id' do
|
||||
before do
|
||||
assign(:dossier, dossier)
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_selector('#form_login #logo_procedure') }
|
||||
it { expect(rendered).to have_selector('#form_login #titre_procedure') }
|
||||
it { expect(rendered).to have_content(dossier.procedure.libelle) }
|
||||
it { expect(rendered).to have_content(dossier.procedure.description) }
|
||||
end
|
||||
|
||||
context 'when user_return_to session params not contains a procedure_id' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_selector('#form_login #logo_tps') }
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue