2016-12-16 10:21:28 -06:00
|
|
|
module IntegrationHelpers
|
2017-08-30 23:06:56 -05:00
|
|
|
def create_user
|
|
|
|
get "/u/hp.json"
|
|
|
|
|
2018-06-07 03:11:09 -05:00
|
|
|
expect(response.status).to eq(200)
|
2017-08-30 23:06:56 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-06-07 03:11:09 -05:00
|
|
|
expect(response.status).to eq(200)
|
2017-08-30 23:06:56 -05:00
|
|
|
|
|
|
|
body = JSON.parse(response.body)
|
|
|
|
User.find(body["user_id"])
|
|
|
|
end
|
|
|
|
|
2016-12-16 10:21:28 -06:00
|
|
|
def sign_in(user)
|
2018-03-27 22:31:43 -05:00
|
|
|
get "/session/#{user.username}/become"
|
2017-12-13 20:53:21 -06:00
|
|
|
user
|
2016-12-16 10:21:28 -06:00
|
|
|
end
|
|
|
|
end
|