Simplify log in for request specs.
This commit is contained in:
parent
70be8124a3
commit
21ae49ab92
|
@ -75,7 +75,7 @@ class SessionController < ApplicationController
|
|||
|
||||
# For use in development mode only when login options could be limited or disabled.
|
||||
# NEVER allow this to work in production.
|
||||
if Rails.env.development?
|
||||
if !Rails.env.production?
|
||||
skip_before_action :check_xhr, only: [:become]
|
||||
|
||||
def become
|
||||
|
|
|
@ -292,7 +292,7 @@ Discourse::Application.routes.draw do
|
|||
get "extra-locales/:bundle" => "extra_locales#show"
|
||||
|
||||
resources :session, id: RouteFormat.username, only: [:create, :destroy, :become] do
|
||||
if Rails.env.development?
|
||||
if !Rails.env.production?
|
||||
get 'become'
|
||||
end
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ RSpec.describe UsersController do
|
|||
SiteSetting.enable_local_logins = false
|
||||
|
||||
post "/users/second_factors.json", params: {
|
||||
password: 'somecomplicatedpassword'
|
||||
password: 'myawesomepassword'
|
||||
}
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
|
@ -449,7 +449,7 @@ RSpec.describe UsersController do
|
|||
SiteSetting.enable_sso = true
|
||||
|
||||
post "/users/second_factors.json", params: {
|
||||
password: 'somecomplicatedpassword'
|
||||
password: 'myawesomepassword'
|
||||
}
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
|
@ -461,7 +461,7 @@ RSpec.describe UsersController do
|
|||
user.user_second_factor.update!(data: "abcdefghijklmnop")
|
||||
|
||||
post "/users/second_factors.json", params: {
|
||||
password: 'somecomplicatedpassword'
|
||||
password: 'myawesomepassword'
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
|
|
@ -24,11 +24,7 @@ module IntegrationHelpers
|
|||
end
|
||||
|
||||
def sign_in(user)
|
||||
password = 'somecomplicatedpassword'
|
||||
user.update!(password: password)
|
||||
Fabricate(:email_token, confirmed: true, user: user)
|
||||
post "/session.json", params: { login: user.username, password: password }
|
||||
expect(response).to be_success
|
||||
get "/session/#{user.username}/become"
|
||||
user
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue