2014-09-22 19:06:19 -04:00
|
|
|
# encoding: UTF-8
|
|
|
|
|
2015-10-11 05:41:23 -04:00
|
|
|
require 'rails_helper'
|
2014-09-22 19:06:19 -04:00
|
|
|
|
|
|
|
describe 'invite only' do
|
|
|
|
|
|
|
|
describe '#create invite only' do
|
|
|
|
it 'can create user via API' do
|
|
|
|
|
|
|
|
SiteSetting.invite_only = true
|
|
|
|
|
|
|
|
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',
|
|
|
|
api_key: api_key.key,
|
|
|
|
api_username: admin.username
|
2017-08-31 00:06:56 -04:00
|
|
|
}
|
2014-09-22 19:06:19 -04:00
|
|
|
|
|
|
|
user_id = JSON.parse(response.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
|
2017-08-31 00:06:56 -04:00
|
|
|
put "/admin/users/#{user_id}/activate.json", params: {
|
|
|
|
api_key: api_key.key,
|
|
|
|
api_username: admin.username
|
|
|
|
}
|
2014-09-22 19:06:19 -04:00
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
put "/admin/users/#{user_id}/approve.json", params: {
|
|
|
|
api_key: api_key.key,
|
|
|
|
api_username: admin.username
|
|
|
|
}
|
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
|