FC information: remove funny find_by
This commit is contained in:
parent
8e26a50f16
commit
7024e14d1c
3 changed files with 2 additions and 21 deletions
|
@ -11,7 +11,8 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
user_infos = FranceConnectService.retrieve_user_informations_particulier(params[:code])
|
||||
|
||||
if user_infos.present?
|
||||
france_connect_information = FranceConnectInformation.find_by_france_connect_particulier(user_infos)
|
||||
france_connect_information = FranceConnectInformation
|
||||
.find_by(france_connect_particulier_id: user_infos[:france_connect_particulier_id])
|
||||
|
||||
if france_connect_information.nil?
|
||||
france_connect_information = FranceConnectInformation.create(
|
||||
|
|
|
@ -2,8 +2,4 @@ class FranceConnectInformation < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
|
||||
validates :france_connect_particulier_id, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
def self.find_by_france_connect_particulier user_info
|
||||
FranceConnectInformation.find_by(france_connect_particulier_id: user_info[:france_connect_particulier_id])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,20 +8,4 @@ describe FranceConnectInformation, type: :model do
|
|||
it { is_expected.to allow_value('mon super projet').for(:france_connect_particulier_id) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.find_by_france_connect_particulier' do
|
||||
let(:user_info) { {france_connect_particulier_id: '123456'} }
|
||||
|
||||
subject { described_class.find_by_france_connect_particulier user_info }
|
||||
|
||||
context 'when france_connect_particulier_id is prensent in database' do
|
||||
let!(:france_connect_information) { create(:france_connect_information, france_connect_particulier_id: '123456') }
|
||||
|
||||
it { is_expected.to eq france_connect_information }
|
||||
end
|
||||
|
||||
context 'when france_connect_particulier_id is prensent in database' do
|
||||
it { is_expected.to eq nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue