discourse/spec/support/integration_helpers.rb
Sam Saffron b824898f61
FIX: respect automatic group membership when sso changes email
Previously we were only updating group membership when a user record was
first created in an SSO setting.

This corrects it so we also update it if SSO changes the email
2020-04-08 16:33:50 +10:00

41 lines
806 B
Ruby

# frozen_string_literal: true
module IntegrationHelpers
def create_user
get "/u/hp.json"
expect(response.status).to eq(200)
body = JSON.parse(response.body)
honeypot = body["value"]
challenge = body["challenge"]
user = Fabricate.build(:user)
post "/u.json", params: {
username: user.username,
email: user.email,
password: 'asdasljdhaiosdjioaeiow',
password_confirmation: honeypot,
challenge: challenge.reverse
}
expect(response.status).to eq(200)
body = JSON.parse(response.body)
User.find(body["user_id"])
end
def sign_in(user)
get "/session/#{user.username}/become"
user
end
def sign_out
delete "/session"
end
def read_secure_session
SecureSession.new(session[:secure_session_id])
end
end