diff options
author | Kaylee <kaylee@codethat.sucks> | 2017-05-02 20:07:12 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-02 21:07:12 +0200 |
commit | 7880671f3527b80de891053beaeae4a8a22c8c58 (patch) | |
tree | 43f4cc6ef4f4b90e7d9e4a585f7e6c5c9470ffd0 /spec/models | |
parent | b5eec3423044f66066d64bd5c9422f40113c543a (diff) |
Add option to disable two factor auth in admin accounts panel. (#2584)
* Add option to disable two factor auth in admin accounts panel. Closes #2578 * Add @mjankowski's suggestions. * Moves destroy actions behind User#disable_two_factor! * Adds spec coverage for Admin:TwoFactorAuthenticationsController and User#disable_two_factor!
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/user_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a86bf4ece..fffd92e3d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -126,6 +126,20 @@ RSpec.describe User, type: :model do end end + describe '#disable_two_factor!' do + it 'sets otp_required_for_login to false' do + user = Fabricate.build(:user, otp_required_for_login: true) + user.disable_two_factor! + expect(user.otp_required_for_login).to be false + end + + it 'clears otp_backup_codes' do + user = Fabricate.build(:user, otp_backup_codes: %w[dummy dummy]) + user.disable_two_factor! + expect(user.otp_backup_codes.empty?).to be true + end + end + describe 'whitelist' do around(:each) do |example| old_whitelist = Rails.configuration.x.email_whitelist |