Remove or fix now nonsense code
This commit is contained in:
parent
0d71a820a8
commit
47b7dc368b
8 changed files with 2 additions and 78 deletions
|
@ -24,7 +24,6 @@ class Administrateurs::ActivateController < ApplicationController
|
||||||
if administrateur && administrateur.errors.empty?
|
if administrateur && administrateur.errors.empty?
|
||||||
sign_in(administrateur, scope: :administrateur)
|
sign_in(administrateur, scope: :administrateur)
|
||||||
try_to_authenticate(User, administrateur.email, password)
|
try_to_authenticate(User, administrateur.email, password)
|
||||||
try_to_authenticate(Instructeur, administrateur.email, password)
|
|
||||||
flash.notice = "Mot de passe enregistré"
|
flash.notice = "Mot de passe enregistré"
|
||||||
redirect_to admin_procedures_path
|
redirect_to admin_procedures_path
|
||||||
else
|
else
|
||||||
|
|
|
@ -17,7 +17,6 @@ class Users::SessionsController < Sessions::SessionsController
|
||||||
remember_me = params[:user][:remember_me] == '1'
|
remember_me = params[:user][:remember_me] == '1'
|
||||||
|
|
||||||
if resource_locked?(try_to_authenticate(User, remember_me)) ||
|
if resource_locked?(try_to_authenticate(User, remember_me)) ||
|
||||||
resource_locked?(try_to_authenticate(Instructeur, remember_me)) ||
|
|
||||||
resource_locked?(try_to_authenticate(Administrateur, remember_me))
|
resource_locked?(try_to_authenticate(Administrateur, remember_me))
|
||||||
flash.alert = 'Votre compte est verrouillé.'
|
flash.alert = 'Votre compte est verrouillé.'
|
||||||
new
|
new
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Administration < ApplicationRecord
|
||||||
AdministrationMailer.new_admin_email(administrateur, self).deliver_later
|
AdministrationMailer.new_admin_email(administrateur, self).deliver_later
|
||||||
administrateur.invite!(id)
|
administrateur.invite!(id)
|
||||||
|
|
||||||
User.create({
|
user = User.create({
|
||||||
email: email,
|
email: email,
|
||||||
password: password,
|
password: password,
|
||||||
confirmed_at: Time.zone.now
|
confirmed_at: Time.zone.now
|
||||||
|
@ -28,7 +28,7 @@ class Administration < ApplicationRecord
|
||||||
|
|
||||||
Instructeur.create({
|
Instructeur.create({
|
||||||
email: email,
|
email: email,
|
||||||
password: password
|
user: user
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -35,20 +35,6 @@ describe Sessions::SessionsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create with instructeur connected' do
|
|
||||||
before do
|
|
||||||
@request.env["devise.mapping"] = Devise.mappings[:instructeur]
|
|
||||||
|
|
||||||
allow_any_instance_of(described_class).to receive(:instructeur_signed_in?).and_return(true)
|
|
||||||
allow_any_instance_of(described_class).to receive(:current_instructeur).and_return(instructeur)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'calls sign out for instructeur' do
|
|
||||||
expect_any_instance_of(described_class).to receive(:sign_out).with(:instructeur)
|
|
||||||
post :create
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#create with administrateur connected' do
|
describe '#create with administrateur connected' do
|
||||||
before do
|
before do
|
||||||
@request.env["devise.mapping"] = Devise.mappings[:administrateur]
|
@request.env["devise.mapping"] = Devise.mappings[:administrateur]
|
||||||
|
|
|
@ -103,47 +103,11 @@ describe Users::SessionsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when associated instructeur" do
|
|
||||||
let(:user) { create(:user, email: 'unique@plop.com', password: 'démarches-simplifiées-pwd') }
|
|
||||||
let(:instructeur) { create(:instructeur, email: 'unique@plop.com', password: 'démarches-simplifiées-pwd') }
|
|
||||||
|
|
||||||
it 'signs user out' do
|
|
||||||
sign_in user
|
|
||||||
delete :destroy
|
|
||||||
expect(@response.redirect?).to be(true)
|
|
||||||
expect(subject.current_user).to be(nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'signs instructeur out' do
|
|
||||||
sign_in instructeur
|
|
||||||
delete :destroy
|
|
||||||
expect(@response.redirect?).to be(true)
|
|
||||||
expect(subject.current_instructeur).to be(nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'signs user + instructeur out' do
|
|
||||||
sign_in user
|
|
||||||
sign_in instructeur
|
|
||||||
delete :destroy
|
|
||||||
expect(@response.redirect?).to be(true)
|
|
||||||
expect(subject.current_user).to be(nil)
|
|
||||||
expect(subject.current_instructeur).to be(nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'signs user out from france connect' do
|
|
||||||
user.update(loged_in_with_france_connect: User.loged_in_with_france_connects.fetch(:particulier))
|
|
||||||
sign_in user
|
|
||||||
delete :destroy
|
|
||||||
expect(@response.headers["Location"]).to eq(FRANCE_CONNECT[:particulier][:logout_endpoint])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when associated administrateur" do
|
context "when associated administrateur" do
|
||||||
let(:administrateur) { create(:administrateur, email: 'unique@plop.com') }
|
let(:administrateur) { create(:administrateur, email: 'unique@plop.com') }
|
||||||
|
|
||||||
it 'signs user + instructeur + administrateur out' do
|
it 'signs user + instructeur + administrateur out' do
|
||||||
sign_in user
|
sign_in user
|
||||||
sign_in administrateur.instructeur
|
|
||||||
sign_in administrateur
|
sign_in administrateur
|
||||||
delete :destroy
|
delete :destroy
|
||||||
expect(@response.redirect?).to be(true)
|
expect(@response.redirect?).to be(true)
|
||||||
|
|
|
@ -28,7 +28,6 @@ describe Administrateur, type: :model do
|
||||||
|
|
||||||
instructeur.reload
|
instructeur.reload
|
||||||
expect(instructeur.email).to eq('whoami@plop.com')
|
expect(instructeur.email).to eq('whoami@plop.com')
|
||||||
expect(instructeur.valid_password?('et encore un autre mdp')).to be(true)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -142,17 +142,6 @@ describe Instructeur, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'unified login' do
|
context 'unified login' do
|
||||||
it 'syncs credentials to associated user' do
|
|
||||||
instructeur = create(:instructeur)
|
|
||||||
user = create(:user, email: instructeur.email)
|
|
||||||
|
|
||||||
instructeur.update(email: 'whoami@plop.com', password: 'démarches-simplifiées-pwd')
|
|
||||||
|
|
||||||
user.reload
|
|
||||||
expect(user.email).to eq('whoami@plop.com')
|
|
||||||
expect(user.valid_password?('démarches-simplifiées-pwd')).to be(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'syncs credentials to associated administrateur' do
|
it 'syncs credentials to associated administrateur' do
|
||||||
admin = create(:administrateur)
|
admin = create(:administrateur)
|
||||||
instructeur = admin.instructeur
|
instructeur = admin.instructeur
|
||||||
|
|
|
@ -102,18 +102,6 @@ describe User, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'unified login' do
|
context 'unified login' do
|
||||||
it 'syncs credentials to associated instructeur' do
|
|
||||||
user = create(:user)
|
|
||||||
instructeur = create(:instructeur, email: user.email)
|
|
||||||
|
|
||||||
user.update(email: 'whoami@plop.com', password: 'démarches-simplifiées2')
|
|
||||||
user.confirm
|
|
||||||
|
|
||||||
instructeur.reload
|
|
||||||
expect(instructeur.email).to eq('whoami@plop.com')
|
|
||||||
expect(instructeur.valid_password?('démarches-simplifiées2')).to be(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'syncs credentials to associated administrateur' do
|
it 'syncs credentials to associated administrateur' do
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
admin = create(:administrateur, email: user.email)
|
admin = create(:administrateur, email: user.email)
|
||||||
|
|
Loading…
Reference in a new issue