Fix invited-without-approval-bypass not being asked for a textual reason (#40332)
This commit is contained in:
1 parent
f9655d3c62
commit
c07eb2f9cc
4 files changed
+117
-91
No files matched your search
@@ -261,94 +261,6 @@ RSpec.describe Auth::RegistrationsController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with Approval-based registrations without invite' do
|
||||
subject do
|
||||
Setting.registrations_mode = 'approved'
|
||||
request.headers['Accept-Language'] = accept_language
|
||||
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
|
||||
end
|
||||
|
||||
it 'redirects to setup and creates user' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to redirect_to auth_setup_path
|
||||
|
||||
expect(User.find_by(email: 'test@example.com'))
|
||||
.to be_present
|
||||
.and have_attributes(
|
||||
locale: eq(accept_language),
|
||||
approved: be(false)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with Approval-based registrations with expired invite' do
|
||||
subject do
|
||||
Setting.registrations_mode = 'approved'
|
||||
request.headers['Accept-Language'] = accept_language
|
||||
invite = Fabricate(:invite, max_uses: nil, expires_at: 1.hour.ago)
|
||||
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
|
||||
end
|
||||
|
||||
it 'redirects to setup and creates user' do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to auth_setup_path
|
||||
|
||||
expect(User.find_by(email: 'test@example.com'))
|
||||
.to be_present
|
||||
.and have_attributes(
|
||||
locale: eq(accept_language),
|
||||
approved: be(false)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with Approval-based registrations with valid invite and required invite text' do
|
||||
subject do
|
||||
Setting.registrations_mode = 'approved'
|
||||
Setting.require_invite_text = true
|
||||
request.headers['Accept-Language'] = accept_language
|
||||
invite = Fabricate(:invite, user: inviter, max_uses: nil, expires_at: 1.hour.from_now)
|
||||
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } }
|
||||
end
|
||||
|
||||
let!(:inviter) { Fabricate(:user, confirmed_at: 2.days.ago) }
|
||||
|
||||
it 'redirects to setup and creates user in a non-approved state' do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to auth_setup_path
|
||||
|
||||
expect(User.find_by(email: 'test@example.com'))
|
||||
.to be_present
|
||||
.and have_attributes(
|
||||
locale: eq(accept_language),
|
||||
approved: be(false)
|
||||
)
|
||||
end
|
||||
|
||||
context 'when the inviting user has the permission to bypass approval' do
|
||||
before do
|
||||
inviter.role.update!(permissions: inviter.role.permissions | UserRole::FLAGS[:invite_bypass_approval])
|
||||
end
|
||||
|
||||
it 'redirects to setup and creates user in an approved state' do
|
||||
subject
|
||||
|
||||
expect(response).to redirect_to auth_setup_path
|
||||
|
||||
expect(User.find_by(email: 'test@example.com'))
|
||||
.to be_present
|
||||
.and have_attributes(
|
||||
locale: eq(accept_language),
|
||||
approved: be(true)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an already taken username' do
|
||||
subject do
|
||||
Setting.registrations_mode = 'open'
|
||||
|
||||
Reference in new issue
Block a user