FC ParticulierController: create is private

yep, I know this is strange
This commit is contained in:
simon lehericey 2018-01-15 14:37:28 +01:00 committed by Simon Lehericey
parent d2f93b3441
commit 7cbd6ed067
3 changed files with 2 additions and 25 deletions

View file

@ -64,6 +64,8 @@ class FranceConnect::ParticulierController < ApplicationController
@user = User.new(france_connect_information: france_connect_information).decorate
end
private
def create
user = User.new email: params[:user][:email_france_connect]
user.password = Devise.friendly_token[0, 20]
@ -80,8 +82,6 @@ class FranceConnect::ParticulierController < ApplicationController
connect_france_connect_particulier user
end
private
def connect_france_connect_particulier user
sign_out :user if user_signed_in?
sign_out :gestionnaire if gestionnaire_signed_in?

View file

@ -67,7 +67,6 @@ Rails.application.routes.draw do
get 'particulier/callback' => 'particulier#callback'
get 'particulier/new' => 'particulier#new'
post 'particulier/create' => 'particulier#create'
post 'particulier/check_email' => 'particulier#check_email'
end

View file

@ -200,26 +200,4 @@ describe FranceConnect::ParticulierController, type: :controller do
end
end
end
describe 'POST #create' do
let!(:france_connect_information) { create(:france_connect_information, email_france_connect: email) }
let(:france_connect_information_id) { france_connect_information.id }
let(:salt) { FranceConnectSaltService.new(france_connect_information).salt }
subject { post :create, params: {fci_id: france_connect_information_id, salt: salt, user: {email_france_connect: france_connect_information.email_france_connect}} }
context 'when email is filled' do
let(:email) { 'plop@gmail.com' }
it { expect { subject }.to change { User.count }.by(1) }
it { expect(subject).to redirect_to(root_path) }
end
context 'when email is incorrect' do
let(:email) { '' }
it { expect { subject }.not_to change { User.count } }
it { expect(subject).to redirect_to(france_connect_particulier_new_path(fci_id: france_connect_information_id, salt: salt, user: {email_france_connect: france_connect_information.email_france_connect})) }
end
end
end