[link to #4557] An instructeur cannot change its email on its own
This commit is contained in:
parent
21910c959e
commit
058442c84e
2 changed files with 21 additions and 0 deletions
|
@ -1,5 +1,9 @@
|
|||
module Users
|
||||
class ProfilController < UserController
|
||||
before_action :redirect_if_instructeur,
|
||||
only: :update_email,
|
||||
if: -> { instructeur_signed_in? }
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
|
@ -32,5 +36,9 @@ module Users
|
|||
def requested_email
|
||||
update_email_params[:email]
|
||||
end
|
||||
|
||||
def redirect_if_instructeur
|
||||
redirect_to profil_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,5 +60,18 @@ describe Users::ProfilController, type: :controller do
|
|||
it { expect(response).to redirect_to(profil_path) }
|
||||
it { expect(flash.alert).to eq(['Email invalide']) }
|
||||
end
|
||||
|
||||
context 'when the user has an instructeur role' do
|
||||
let(:instructeur_email) { 'instructeur_email@a.com' }
|
||||
let!(:user) { create(:instructeur, email: instructeur_email).user }
|
||||
|
||||
before do
|
||||
patch :update_email, params: { user: { email: 'loulou@lou.com' } }
|
||||
user.reload
|
||||
end
|
||||
|
||||
it { expect(user.unconfirmed_email).to be_nil }
|
||||
it { expect(response).to redirect_to(profil_path) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue