mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: Allow sending invites to staged users
This commit is contained in:
parent
f74ac826c5
commit
dde0fcc658
7 changed files with 79 additions and 20 deletions
|
@ -30,6 +30,18 @@ describe InviteRedeemer do
|
|||
expect(error).to be_present
|
||||
expect(error.record.errors[:password]).to be_present
|
||||
end
|
||||
|
||||
it "should unstage user" do
|
||||
staged_user = Fabricate(:staged, email: 'staged@account.com', active: true, username: 'staged1', name: 'Stage Name')
|
||||
user = InviteRedeemer.create_user_from_invite(Fabricate(:invite, email: 'staged@account.com'), 'walter', 'Walter White')
|
||||
|
||||
expect(user.id).to eq(staged_user.id)
|
||||
expect(user.username).to eq('walter')
|
||||
expect(user.name).to eq('Walter White')
|
||||
expect(user.active).to eq(false)
|
||||
expect(user.email).to eq('staged@account.com')
|
||||
expect(user.approved).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#redeem" do
|
||||
|
|
|
@ -178,6 +178,16 @@ describe Invite do
|
|||
|
||||
end
|
||||
|
||||
context 'a staged user' do
|
||||
it 'creates an invite for a staged user' do
|
||||
Fabricate(:staged, email: 'staged@account.com')
|
||||
invite = Invite.invite_by_email('staged@account.com', Fabricate(:coding_horror))
|
||||
|
||||
expect(invite).to be_valid
|
||||
expect(invite.email).to eq('staged@account.com')
|
||||
end
|
||||
end
|
||||
|
||||
context '.redeem' do
|
||||
|
||||
let(:invite) { Fabricate(:invite) }
|
||||
|
|
|
@ -1580,4 +1580,24 @@ describe User do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#unstage" do
|
||||
it "correctyl unstages a user" do
|
||||
staged_user = Fabricate(:staged, email: 'staged@account.com', active: true, username: 'staged1', name: 'Stage Name')
|
||||
params = { email: 'staged@account.com', active: true, username: 'unstaged1', name: 'Foo Bar' }
|
||||
user = User.unstage(params)
|
||||
|
||||
expect(user.id).to eq(staged_user.id)
|
||||
expect(user.username).to eq('unstaged1')
|
||||
expect(user.name).to eq('Foo Bar')
|
||||
expect(user.active).to eq(false)
|
||||
expect(user.email).to eq('staged@account.com')
|
||||
end
|
||||
|
||||
it "returns nil when the user cannot be unstaged" do
|
||||
Fabricate(:coding_horror)
|
||||
expect(User.unstage(email: 'jeff@somewhere.com')).to be_nil
|
||||
expect(User.unstage(email: 'no@account.com')).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue