diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-06-19 14:59:42 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-06-19 14:59:42 -0400 |
commit | 6c8f0fe906d76cf27f22ffcd3475084f6e0398ec (patch) | |
tree | 9f0b9e2675cbbc4884fc57473585cf504194f3ac /spec/models | |
parent | 7964e7d6a1c77e470b93ca3cca69b03f506505ac (diff) | |
download | gitlab-ce-6c8f0fe906d76cf27f22ffcd3475084f6e0398ec.tar.gz |
Add convenience methods to User for getting and setting 2FA status
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/user_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f3e278e5c5f..fa7680fbbec 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -210,6 +210,30 @@ describe User do end end + describe '#two_factor_enabled' do + it 'returns two-factor authentication status' do + enabled = build_stubbed(:user, two_factor_enabled: true) + disabled = build_stubbed(:user) + + expect(enabled).to be_two_factor_enabled + expect(disabled).not_to be_two_factor_enabled + end + end + + describe '#two_factor_enabled=' do + it 'enables two-factor authentication' do + user = build_stubbed(:user, two_factor_enabled: false) + expect { user.two_factor_enabled = true }. + to change { user.two_factor_enabled? }.to(true) + end + + it 'disables two-factor authentication' do + user = build_stubbed(:user, two_factor_enabled: true) + expect { user.two_factor_enabled = false }. + to change { user.two_factor_enabled? }.to(false) + end + end + describe 'authentication token' do it "should have authentication token" do user = create(:user) |