Fix RSpec/ContextWording cop (#24739)
This commit is contained in:
parent
cf18cc2891
commit
710745e16b
105 changed files with 559 additions and 668 deletions
|
@ -51,8 +51,8 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
|
||||
context 'using a valid password' do
|
||||
context 'when using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
|
||||
context 'when using a valid password' do
|
||||
before do
|
||||
post :create, params: { user: { email: 'pam_user1', password: '123456' } }
|
||||
end
|
||||
|
@ -66,7 +66,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using an invalid password' do
|
||||
context 'when using an invalid password' do
|
||||
before do
|
||||
post :create, params: { user: { email: 'pam_user1', password: 'WRONGPW' } }
|
||||
end
|
||||
|
@ -80,7 +80,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid email and existing user' do
|
||||
context 'when using a valid email and existing user' do
|
||||
let!(:user) do
|
||||
account = Fabricate.build(:account, username: 'pam_user1', user: nil)
|
||||
account.save!(validate: false)
|
||||
|
@ -102,10 +102,10 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using password authentication' do
|
||||
context 'when using password authentication' do
|
||||
let(:user) { Fabricate(:user, email: 'foo@bar.com', password: 'abcdefgh') }
|
||||
|
||||
context 'using a valid password' do
|
||||
context 'when using a valid password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
@ -119,7 +119,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid password on a previously-used account with a new IP address' do
|
||||
context 'when using a valid password on a previously-used account with a new IP address' do
|
||||
let(:previous_ip) { '1.2.3.4' }
|
||||
let(:current_ip) { '4.3.2.1' }
|
||||
|
||||
|
@ -145,7 +145,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using email with uppercase letters' do
|
||||
context 'when using email with uppercase letters' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email.upcase, password: user.password } }
|
||||
end
|
||||
|
@ -159,7 +159,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using an invalid password' do
|
||||
context 'when using an invalid password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email, password: 'wrongpw' } }
|
||||
end
|
||||
|
@ -173,7 +173,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using an unconfirmed password' do
|
||||
context 'when using an unconfirmed password' do
|
||||
before do
|
||||
request.headers['Accept-Language'] = accept_language
|
||||
post :create, params: { user: { email: unconfirmed_user.email, password: unconfirmed_user.password } }
|
||||
|
@ -187,14 +187,14 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context "logging in from the user's page" do
|
||||
context "when logging in from the user's page" do
|
||||
before do
|
||||
allow(controller).to receive(:single_user_mode?).and_return(single_user_mode)
|
||||
allow(controller).to receive(:stored_location_for).with(:user).and_return("/@#{user.account.username}")
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
||||
context 'in single user mode' do
|
||||
context 'with single user mode' do
|
||||
let(:single_user_mode) { true }
|
||||
|
||||
it 'redirects to home' do
|
||||
|
@ -202,7 +202,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'in non-single user mode' do
|
||||
context 'with non-single user mode' do
|
||||
let(:single_user_mode) { false }
|
||||
|
||||
it "redirects back to the user's page" do
|
||||
|
@ -212,7 +212,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using two-factor authentication' do
|
||||
context 'when using two-factor authentication' do
|
||||
context 'with OTP enabled as second factor' do
|
||||
let!(:user) do
|
||||
Fabricate(:user, email: 'x@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
|
||||
|
@ -224,7 +224,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
return codes
|
||||
end
|
||||
|
||||
context 'using email and password' do
|
||||
context 'when using email and password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
@ -235,7 +235,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using email and password after an unfinished log-in attempt to a 2FA-protected account' do
|
||||
context 'when using email and password after an unfinished log-in attempt to a 2FA-protected account' do
|
||||
let!(:other_user) do
|
||||
Fabricate(:user, email: 'z@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
|
||||
end
|
||||
|
@ -251,7 +251,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using upcase email and password' do
|
||||
context 'when using upcase email and password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email.upcase, password: user.password } }
|
||||
end
|
||||
|
@ -262,7 +262,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid OTP' do
|
||||
context 'when using a valid OTP' do
|
||||
before do
|
||||
post :create, params: { user: { otp_attempt: user.current_otp } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
|
||||
end
|
||||
|
@ -291,7 +291,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid recovery code' do
|
||||
context 'when using a valid recovery code' do
|
||||
before do
|
||||
post :create, params: { user: { otp_attempt: recovery_codes.first } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
|
||||
end
|
||||
|
@ -305,7 +305,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using an invalid OTP' do
|
||||
context 'when using an invalid OTP' do
|
||||
before do
|
||||
post :create, params: { user: { otp_attempt: 'wrongotp' } }, session: { attempt_user_id: user.id, attempt_user_updated_at: user.updated_at.to_s }
|
||||
end
|
||||
|
@ -353,7 +353,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
|
||||
let(:fake_credential) { fake_client.get(challenge: challenge, sign_count: sign_count) }
|
||||
|
||||
context 'using email and password' do
|
||||
context 'when using email and password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email, password: user.password } }
|
||||
end
|
||||
|
@ -364,7 +364,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using upcase email and password' do
|
||||
context 'when using upcase email and password' do
|
||||
before do
|
||||
post :create, params: { user: { email: user.email.upcase, password: user.password } }
|
||||
end
|
||||
|
@ -375,7 +375,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'using a valid webauthn credential' do
|
||||
context 'when using a valid webauthn credential' do
|
||||
before do
|
||||
@controller.session[:webauthn_challenge] = challenge
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue