From 7024e14d1cbf575561b9aacd289c7c1eac24c689 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 11 Jan 2018 18:26:55 +0100 Subject: [PATCH] FC information: remove funny find_by --- .../france_connect/particulier_controller.rb | 3 ++- app/models/france_connect_information.rb | 4 ---- spec/models/france_connect_information_spec.rb | 16 ---------------- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/app/controllers/france_connect/particulier_controller.rb b/app/controllers/france_connect/particulier_controller.rb index 451149820..71b9f8e0e 100644 --- a/app/controllers/france_connect/particulier_controller.rb +++ b/app/controllers/france_connect/particulier_controller.rb @@ -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( diff --git a/app/models/france_connect_information.rb b/app/models/france_connect_information.rb index 6bf7f7a85..76e804399 100644 --- a/app/models/france_connect_information.rb +++ b/app/models/france_connect_information.rb @@ -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 diff --git a/spec/models/france_connect_information_spec.rb b/spec/models/france_connect_information_spec.rb index 330fc679c..96413d621 100644 --- a/spec/models/france_connect_information_spec.rb +++ b/spec/models/france_connect_information_spec.rb @@ -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