2014-09-22 19:06:19 -04:00
|
|
|
# encoding: UTF-8
|
2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
2014-09-22 19:06:19 -04:00
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe "invite only" do
|
2014-09-22 19:06:19 -04:00
|
|
|
describe "#create invite only" do
|
|
|
|
it "can create user via API" do
|
|
|
|
SiteSetting.invite_only = true
|
2024-12-16 21:46:04 -05:00
|
|
|
SiteSetting.hide_email_address_taken = false
|
2019-04-03 12:04:05 -04:00
|
|
|
Jobs.run_immediately!
|
2014-09-22 19:06:19 -04:00
|
|
|
|
|
|
|
admin = Fabricate(:admin)
|
|
|
|
api_key = Fabricate(:api_key, user: admin)
|
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
post "/users.json",
|
|
|
|
params: {
|
2014-09-22 19:06:19 -04:00
|
|
|
name: "bob",
|
|
|
|
username: "bob",
|
|
|
|
password: "strongpassword",
|
|
|
|
email: "bob@bob.com",
|
2020-04-06 18:55:44 -04:00
|
|
|
},
|
|
|
|
headers: {
|
|
|
|
HTTP_API_KEY: api_key.key,
|
|
|
|
HTTP_API_USERNAME: admin.username,
|
2017-08-31 00:06:56 -04:00
|
|
|
}
|
2014-09-22 19:06:19 -04:00
|
|
|
|
2020-05-07 11:04:12 -04:00
|
|
|
user_id = response.parsed_body["user_id"]
|
2015-04-25 11:18:35 -04:00
|
|
|
expect(user_id).to be > 0
|
2014-09-22 19:06:19 -04:00
|
|
|
|
|
|
|
# activate and approve
|
2020-04-06 18:55:44 -04:00
|
|
|
put "/admin/users/#{user_id}/activate.json",
|
|
|
|
headers: {
|
|
|
|
HTTP_API_KEY: api_key.key,
|
|
|
|
HTTP_API_USERNAME: admin.username,
|
2017-08-31 00:06:56 -04:00
|
|
|
}
|
2023-01-09 06:18:21 -05:00
|
|
|
|
2020-04-06 18:55:44 -04:00
|
|
|
put "/admin/users/#{user_id}/approve.json",
|
|
|
|
headers: {
|
|
|
|
HTTP_API_KEY: api_key.key,
|
|
|
|
HTTP_API_USERNAME: admin.username,
|
2017-08-31 00:06:56 -04:00
|
|
|
}
|
2014-09-22 19:06:19 -04:00
|
|
|
|
|
|
|
u = User.find(user_id)
|
2015-04-25 11:18:35 -04:00
|
|
|
expect(u.active).to eq(true)
|
|
|
|
expect(u.approved).to eq(true)
|
2014-09-22 19:06:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|