Add unified_login feature flip
This commit is contained in:
parent
e942274773
commit
fa762dbb39
8 changed files with 40 additions and 20 deletions
|
@ -14,7 +14,7 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
|
|
||||||
after_create :build_default_preferences_list_dossier
|
after_create :build_default_preferences_list_dossier
|
||||||
after_create :build_default_preferences_smart_listing_page
|
after_create :build_default_preferences_smart_listing_page
|
||||||
after_save :sync_credentials
|
after_update :sync_credentials, if: -> { Features.unified_login }
|
||||||
|
|
||||||
def dossiers_follow
|
def dossiers_follow
|
||||||
dossiers.joins(:follows).where("follows.gestionnaire_id = #{id}")
|
dossiers.joins(:follows).where("follows.gestionnaire_id = #{id}")
|
||||||
|
|
|
@ -15,8 +15,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information
|
delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information
|
||||||
accepts_nested_attributes_for :france_connect_information
|
accepts_nested_attributes_for :france_connect_information
|
||||||
|
after_update :sync_credentials, if: -> { Features.unified_login }
|
||||||
after_update :sync_credentials
|
|
||||||
|
|
||||||
def self.find_for_france_connect email, siret
|
def self.find_for_france_connect email, siret
|
||||||
user = User.find_by_email(email)
|
user = User.find_by_email(email)
|
||||||
|
|
|
@ -6,11 +6,12 @@ describe Gestionnaires::PasswordsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "update" do
|
describe "update" do
|
||||||
context "when associated gestionnaire" do
|
context "unified login" do
|
||||||
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
|
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
|
||||||
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
|
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
allow(Features).to receive(:unified_login).and_return(true)
|
||||||
@token = gestionnaire.send(:set_reset_password_token)
|
@token = gestionnaire.send(:set_reset_password_token)
|
||||||
user # make sure it's created
|
user # make sure it's created
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,11 +6,12 @@ describe Users::PasswordsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "update" do
|
describe "update" do
|
||||||
context "when associated gestionnaire" do
|
context "unified login" do
|
||||||
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
|
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
|
||||||
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
|
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
allow(Features).to receive(:unified_login).and_return(true)
|
||||||
@token = user.send(:set_reset_password_token)
|
@token = user.send(:set_reset_password_token)
|
||||||
gestionnaire # make sure it's created
|
gestionnaire # make sure it's created
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,9 +34,10 @@ describe Users::SessionsController, type: :controller do
|
||||||
it { is_expected.to be_falsey }
|
it { is_expected.to be_falsey }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when associated gestionnaire" do
|
context "unified login" do
|
||||||
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
|
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
|
||||||
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
|
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
|
||||||
|
before { allow(Features).to receive(:unified_login).and_return(true) }
|
||||||
|
|
||||||
it 'signs user in' do
|
it 'signs user in' do
|
||||||
post :create, user: { email: user.email, password: user.password }
|
post :create, user: { email: user.email, password: user.password }
|
||||||
|
|
|
@ -185,14 +185,18 @@ describe Gestionnaire, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'syncs credentials to associated user' do
|
context 'unified login' do
|
||||||
gestionnaire = create(:gestionnaire)
|
before { allow(Features).to receive(:unified_login).and_return(true) }
|
||||||
user = create(:user, email: gestionnaire.email)
|
|
||||||
|
|
||||||
gestionnaire.update_attributes(email: 'whoami@plop.com', password: 'super secret')
|
it 'syncs credentials to associated user' do
|
||||||
|
gestionnaire = create(:gestionnaire)
|
||||||
|
user = create(:user, email: gestionnaire.email)
|
||||||
|
|
||||||
user.reload
|
gestionnaire.update_attributes(email: 'whoami@plop.com', password: 'super secret')
|
||||||
expect(user.email).to eq('whoami@plop.com')
|
|
||||||
expect(user.valid_password?('super secret')).to be(true)
|
user.reload
|
||||||
|
expect(user.email).to eq('whoami@plop.com')
|
||||||
|
expect(user.valid_password?('super secret')).to be(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,14 +73,18 @@ describe User, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'syncs credentials to associated gestionnaire' do
|
context 'unified login' do
|
||||||
user = create(:user)
|
before { allow(Features).to receive(:unified_login).and_return(true) }
|
||||||
gestionnaire = create(:gestionnaire, email: user.email)
|
|
||||||
|
|
||||||
user.update_attributes(email: 'whoami@plop.com', password: 'super secret')
|
it 'syncs credentials to associated gestionnaire' do
|
||||||
|
user = create(:user)
|
||||||
|
gestionnaire = create(:gestionnaire, email: user.email)
|
||||||
|
|
||||||
gestionnaire.reload
|
user.update_attributes(email: 'whoami@plop.com', password: 'super secret')
|
||||||
expect(gestionnaire.email).to eq('whoami@plop.com')
|
|
||||||
expect(gestionnaire.valid_password?('super secret')).to be(true)
|
gestionnaire.reload
|
||||||
|
expect(gestionnaire.email).to eq('whoami@plop.com')
|
||||||
|
expect(gestionnaire.valid_password?('super secret')).to be(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,6 +75,16 @@ module SmartListing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Features
|
||||||
|
#def self.remote_storage
|
||||||
|
# true
|
||||||
|
#end
|
||||||
|
|
||||||
|
def self.unified_login
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
WebMock.disable_net_connect!(allow_localhost: true)
|
WebMock.disable_net_connect!(allow_localhost: true)
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
|
|
Loading…
Reference in a new issue