2014-09-22 18:06:19 -05:00
|
|
|
# encoding: UTF-8
|
2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
2014-09-22 18:06:19 -05:00
|
|
|
|
2015-10-11 04:41:23 -05:00
|
|
|
require 'rails_helper'
|
2014-09-22 18:06:19 -05:00
|
|
|
|
|
|
|
describe 'invite only' do
|
|
|
|
|
|
|
|
describe '#create invite only' do
|
|
|
|
it 'can create user via API' do
|
|
|
|
|
|
|
|
SiteSetting.invite_only = true
|
2019-04-03 11:04:05 -05:00
|
|
|
Jobs.run_immediately!
|
2014-09-22 18:06:19 -05:00
|
|
|
|
|
|
|
admin = Fabricate(:admin)
|
|
|
|
api_key = Fabricate(:api_key, user: admin)
|
|
|
|
|
2017-08-30 23:06:56 -05:00
|
|
|
post '/users.json', params: {
|
2014-09-22 18:06:19 -05:00
|
|
|
name: 'bob',
|
|
|
|
username: 'bob',
|
|
|
|
password: 'strongpassword',
|
|
|
|
email: 'bob@bob.com',
|
|
|
|
api_key: api_key.key,
|
|
|
|
api_username: admin.username
|
2017-08-30 23:06:56 -05:00
|
|
|
}
|
2014-09-22 18:06:19 -05:00
|
|
|
|
|
|
|
user_id = JSON.parse(response.body)["user_id"]
|
2015-04-25 10:18:35 -05:00
|
|
|
expect(user_id).to be > 0
|
2014-09-22 18:06:19 -05:00
|
|
|
|
|
|
|
# activate and approve
|
2017-08-30 23:06:56 -05:00
|
|
|
put "/admin/users/#{user_id}/activate.json", params: {
|
|
|
|
api_key: api_key.key,
|
|
|
|
api_username: admin.username
|
|
|
|
}
|
2014-09-22 18:06:19 -05:00
|
|
|
|
2017-08-30 23:06:56 -05:00
|
|
|
put "/admin/users/#{user_id}/approve.json", params: {
|
|
|
|
api_key: api_key.key,
|
|
|
|
api_username: admin.username
|
|
|
|
}
|
2014-09-22 18:06:19 -05:00
|
|
|
|
|
|
|
u = User.find(user_id)
|
2015-04-25 10:18:35 -05:00
|
|
|
expect(u.active).to eq(true)
|
|
|
|
expect(u.approved).to eq(true)
|
2014-09-22 18:06:19 -05:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|