summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
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