summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-05-09 15:46:18 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-05-09 17:32:48 -0400
commit5f43cae6ca2c9ebd3f6561a7b40c64c65913e064 (patch)
treee22dd76df2b1e32a3c6836f54d1b24004864e4b0 /spec
parentb050bb5bada27f38c6308ca33ac081f56cc681a5 (diff)
downloadgitlab-ce-5f43cae6ca2c9ebd3f6561a7b40c64c65913e064.tar.gz
Add :two_factor trait to User factory
Diffstat (limited to 'spec')
-rw-r--r--spec/factories.rb7
-rw-r--r--spec/features/login_spec.rb12
2 files changed, 11 insertions, 8 deletions
diff --git a/spec/factories.rb b/spec/factories.rb
index 19f2935f30e..26e8a795fa4 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -28,6 +28,13 @@ FactoryGirl.define do
admin true
end
+ trait :two_factor do
+ before(:create) do |user|
+ user.otp_required_for_login = true
+ user.otp_secret = User.generate_otp_secret
+ end
+ end
+
factory :omniauth_user do
ignore do
extern_uid '123456'
diff --git a/spec/features/login_spec.rb b/spec/features/login_spec.rb
index ca7fb022a2a..e44ddc17993 100644
--- a/spec/features/login_spec.rb
+++ b/spec/features/login_spec.rb
@@ -1,16 +1,10 @@
require 'spec_helper'
feature 'Login' do
- let(:user) { create(:user) }
-
context 'with two-factor authentication' do
- before do
- user.otp_required_for_login = true
- user.otp_secret = User.generate_otp_secret
- user.save!
- end
-
context 'with valid username/password' do
+ let(:user) { create(:user, :two_factor) }
+
before do
login_with(user)
expect(page).to have_content('Two-factor Authentication')
@@ -80,6 +74,8 @@ feature 'Login' do
end
context 'without two-factor authentication' do
+ let(:user) { create(:user) }
+
it 'allows basic login' do
login_with(user)
expect(current_path).to eq root_path