discourse/spec/support/integration_helpers.rb
Sam 89ad2b5900 DEV: Rails 5.2 upgrade and global gem upgrade
This updates tests to use latest rails 5 practice
and updates ALL dependencies that could be updated

Performance testing shows that performance has not regressed
if anything it is marginally faster now.
2018-06-07 14:21:33 +10:00

31 lines
645 B
Ruby

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