diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-07-10 23:08:39 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-07-10 23:18:30 +0300 |
commit | 22724418d350001e2683b68fad65186af783d3f2 (patch) | |
tree | de5038198d8ab98bc9d592ce4a1437493010d30a /spec/models | |
parent | 526813581b042bc6abad60eb4e582be81620be77 (diff) |
Add User#disable_two_factor!
This method encapsulates all the logic for disabling 2FA on a specific
User model.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/user_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 6d2423ae27a..16902317f10 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -217,6 +217,24 @@ describe User do end end + describe '#disable_two_factor!' do + it 'clears all 2FA-related fields' do + user = create(:user, :two_factor) + + expect(user).to be_two_factor_enabled + expect(user.encrypted_otp_secret).not_to be_nil + expect(user.otp_backup_codes).not_to be_nil + + user.disable_two_factor! + + expect(user).not_to be_two_factor_enabled + expect(user.encrypted_otp_secret).to be_nil + expect(user.encrypted_otp_secret_iv).to be_nil + expect(user.encrypted_otp_secret_salt).to be_nil + expect(user.otp_backup_codes).to be_nil + end + end + describe 'projects' do before do @user = create :user |