This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/spec/support/integration_helpers.rb
2018-03-28 11:32:47 +08:00

31 lines
639 B
Ruby

module IntegrationHelpers
def create_user
get "/u/hp.json"
expect(response).to be_success
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).to be_success
body = JSON.parse(response.body)
User.find(body["user_id"])
end
def sign_in(user)
get "/session/#{user.username}/become"
user
end
end