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