mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 23:20:33 +08:00
42 lines
937 B
Ruby
42 lines
937 B
Ruby
|
# encoding: UTF-8
|
||
|
|
||
|
require 'spec_helper'
|
||
|
|
||
|
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)
|
||
|
|
||
|
xhr :post, '/users',
|
||
|
name: 'bob',
|
||
|
username: 'bob',
|
||
|
password: 'strongpassword',
|
||
|
email: 'bob@bob.com',
|
||
|
api_key: api_key.key,
|
||
|
api_username: admin.username
|
||
|
|
||
|
user_id = JSON.parse(response.body)["user_id"]
|
||
|
user_id.should be > 0
|
||
|
|
||
|
# activate and approve
|
||
|
xhr :put, "/admin/users/#{user_id}/activate",
|
||
|
api_key: api_key.key,
|
||
|
api_username: admin.username
|
||
|
|
||
|
xhr :put, "/admin/users/#{user_id}/approve",
|
||
|
api_key: api_key.key,
|
||
|
api_username: admin.username
|
||
|
|
||
|
u = User.find(user_id)
|
||
|
u.active.should == true
|
||
|
u.approved.should == true
|
||
|
|
||
|
end
|
||
|
end
|
||
|
end
|