mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 11:34:43 +08:00
b8cbe51026
This conversion is done by Transpec 3.1.0 with the following command: transpec * 424 conversions from: obj.should to: expect(obj).to * 325 conversions from: == expected to: eq(expected) * 38 conversions from: obj.should_not to: expect(obj).not_to * 15 conversions from: =~ /pattern/ to: match(/pattern/) * 9 conversions from: it { should ... } to: it { is_expected.to ... } * 5 conversions from: lambda { }.should_not to: expect { }.not_to * 4 conversions from: lambda { }.should to: expect { }.to * 2 conversions from: -> { }.should to: expect { }.to * 2 conversions from: -> { }.should_not to: expect { }.not_to * 1 conversion from: === expected to: be === expected * 1 conversion from: =~ [1, 2] to: match_array([1, 2]) For more details: https://github.com/yujinakayama/transpec#supported-conversions
42 lines
951 B
Ruby
42 lines
951 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"]
|
|
expect(user_id).to 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)
|
|
expect(u.active).to eq(true)
|
|
expect(u.approved).to eq(true)
|
|
|
|
end
|
|
end
|
|
end
|