Skip to content

Commit

Permalink
N'autorise pas le compte de démo à changer d'email
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneCharignon committed Mar 8, 2024
1 parent 86f7954 commit d2e362e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/ability_utilisateur.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def droit_compte(compte)
comptes_generiques_ou_comptes_admin(compte)
droits_validation_comptes(compte)
cannot(:destroy, Compte) { |c| Campagne.exists?(compte: c) }
cannot :update, compte if compte.email == Eva::EMAIL_DEMO
end

def droit_structure(compte)
Expand Down
9 changes: 9 additions & 0 deletions spec/integrations/ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,13 @@
expect(subject).not_to be_able_to(:read, Evaluation)
end
end

context 'Compte de démo' do
let!(:compte) { create :compte_conseiller, :structure_avec_admin, email: Eva::EMAIL_DEMO }

it 'ne peut pas modifier son compte' do
expect(subject).to be_able_to(:read, compte)
expect(subject).not_to be_able_to(:update, compte)
end
end
end

0 comments on commit d2e362e

Please sign in to comment.