discourse/spec/support/integration_helpers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
762 B
Ruby
Raw Normal View History

# 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)
2018-03-28 11:31:43 +08:00
get "/session/#{user.username}/become"
user
end
def read_secure_session
SecureSession.new(session[:secure_session_id])
end
end