about summary refs log tree commit diff
path: root/spec/controllers/auth
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-09-19 00:22:39 +0200
committerGitHub <noreply@github.com>2019-09-19 00:22:39 +0200
commitfebcdad2e2c98aee62b55ee21bdf0debf7c6fd6b (patch)
tree1a99988dd7a46824527e59ee1861aa72ad7412ce /spec/controllers/auth
parentab646fac5f582fe9bef22d8b9a4995fbb4b42d7d (diff)
parent2ecc7106d7fc222ca84777fc279e9f46f80afd5a (diff)
Merge pull request #1221 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/controllers/auth')
-rw-r--r--spec/controllers/auth/sessions_controller_spec.rb24
1 files changed, 8 insertions, 16 deletions
diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb
index 87ef4f2bb..7ed5edde0 100644
--- a/spec/controllers/auth/sessions_controller_spec.rb
+++ b/spec/controllers/auth/sessions_controller_spec.rb
@@ -5,11 +5,11 @@ require 'rails_helper'
 RSpec.describe Auth::SessionsController, type: :controller do
   render_views
 
-  describe 'GET #new' do
-    before do
-      request.env['devise.mapping'] = Devise.mappings[:user]
-    end
+  before do
+    request.env['devise.mapping'] = Devise.mappings[:user]
+  end
 
+  describe 'GET #new' do
     it 'returns http success' do
       get :new
       expect(response).to have_http_status(200)
@@ -19,10 +19,6 @@ RSpec.describe Auth::SessionsController, type: :controller do
   describe 'DELETE #destroy' do
     let(:user) { Fabricate(:user) }
 
-    before do
-      request.env['devise.mapping'] = Devise.mappings[:user]
-    end
-
     context 'with a regular user' do
       it 'redirects to home after sign out' do
         sign_in(user, scope: :user)
@@ -51,10 +47,6 @@ RSpec.describe Auth::SessionsController, type: :controller do
   end
 
   describe 'POST #create' do
-    before do
-      request.env['devise.mapping'] = Devise.mappings[:user]
-    end
-
     context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
       context 'using a valid password' do
         before do
@@ -191,11 +183,11 @@ RSpec.describe Auth::SessionsController, type: :controller do
     end
 
     context 'using two-factor authentication' do
-      let(:user) do
-        Fabricate(:user, email: 'x@y.com', password: 'abcdefgh',
-                         otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
+      let!(:user) do
+        Fabricate(:user, email: 'x@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
       end
-      let(:recovery_codes) do
+
+      let!(:recovery_codes) do
         codes = user.generate_otp_backup_codes!
         user.save
         return codes