forbid admin merge yet
This commit is contained in:
parent
5009c583ea
commit
77d14d4a60
2 changed files with 14 additions and 2 deletions
|
@ -2,10 +2,11 @@ module Manager
|
||||||
class UsersController < Manager::ApplicationController
|
class UsersController < Manager::ApplicationController
|
||||||
def update
|
def update
|
||||||
user = User.find(params[:id])
|
user = User.find(params[:id])
|
||||||
|
|
||||||
preexisting_user = User.find_by(email: targeted_email)
|
preexisting_user = User.find_by(email: targeted_email)
|
||||||
|
|
||||||
if preexisting_user.nil?
|
if user.administrateur.present?
|
||||||
|
flash[:error] = "« #{targeted_email} » est un administrateur. On ne sait pas encore faire."
|
||||||
|
elsif preexisting_user.nil?
|
||||||
user.skip_reconfirmation!
|
user.skip_reconfirmation!
|
||||||
user.update(email: targeted_email)
|
user.update(email: targeted_email)
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,17 @@ describe Manager::UsersController, type: :controller do
|
||||||
|
|
||||||
expect(User.find_by(id: user.id).email).to eq(nouvel_email)
|
expect(User.find_by(id: user.id).email).to eq(nouvel_email)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'and the user is an administrateur' do
|
||||||
|
let(:user) { create(:administrateur).user }
|
||||||
|
|
||||||
|
it 'rejects the modification' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(flash[:error]).to match("« nouvel.email@domaine.fr » est un administrateur. On ne sait pas encore faire.")
|
||||||
|
expect(user.reload.email).not_to eq(nouvel_email)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with an invalid email' do
|
describe 'with an invalid email' do
|
||||||
|
|
Loading…
Reference in a new issue