0
0
Fork 0

Fix RSpec/LetSetup cop in auth controller specs (#28464)

This commit is contained in:
Matt Jankowski 2023-12-22 03:03:59 -05:00 committed by GitHub
parent e70a65761a
commit 513d35969e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 13 deletions

View file

@ -123,9 +123,8 @@ RSpec.describe Auth::SessionsController do
let(:previous_ip) { '1.2.3.4' }
let(:current_ip) { '4.3.2.1' }
let!(:previous_login) { Fabricate(:login_activity, user: user, ip: previous_ip) }
before do
Fabricate(:login_activity, user: user, ip: previous_ip)
allow(controller.request).to receive(:remote_ip).and_return(current_ip)
user.update(current_sign_in_at: 1.month.ago)
post :create, params: { user: { email: user.email, password: user.password } }
@ -328,12 +327,6 @@ RSpec.describe Auth::SessionsController 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
codes = user.generate_otp_backup_codes!
user.save
return codes
end
let!(:webauthn_credential) do
user.update(webauthn_id: WebAuthn.generate_user_id)
public_key_credential = WebAuthn::Credential.from_create(fake_client.create)
@ -356,6 +349,11 @@ RSpec.describe Auth::SessionsController do
let(:fake_credential) { fake_client.get(challenge: challenge, sign_count: sign_count) }
before do
user.generate_otp_backup_codes!
user.save
end
context 'when using email and password' do
before do
post :create, params: { user: { email: user.email, password: user.password } }