mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 22:28:34 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
33 lines
678 B
Ruby
33 lines
678 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
|
|
end
|