diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-28 06:09:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-28 06:09:58 +0300 |
commit | 61ae9de492194653156cdd6e2b528e1dec5c99b6 (patch) | |
tree | 48d4cb8d8ce54253bd48a69f6e6ecbd165d0cc45 /spec/services | |
parent | 533d1ccc9875370e8f296c3de7dfb9c0e6a5c512 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/users/registrations_build_service_spec.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/services/users/registrations_build_service_spec.rb b/spec/services/users/registrations_build_service_spec.rb new file mode 100644 index 00000000000..bc3718dbdb2 --- /dev/null +++ b/spec/services/users/registrations_build_service_spec.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Users::RegistrationsBuildService do + describe '#execute' do + let(:base_params) { build_stubbed(:user).slice(:first_name, :last_name, :username, :email, :password) } + let(:skip_param) { {} } + let(:params) { base_params.merge(skip_param) } + + subject(:service) { described_class.new(nil, params) } + + before do + stub_application_setting(signup_enabled?: true) + end + + context 'when automatic user confirmation is not enabled' do + before do + stub_application_setting(send_user_confirmation_email: true) + end + + context 'when skip_confirmation is true' do + let(:skip_param) { { skip_confirmation: true } } + + it 'confirms the user' do + expect(service.execute).to be_confirmed + end + end + + context 'when skip_confirmation is not set' do + it 'does not confirm the user' do + expect(service.execute).not_to be_confirmed + end + end + + context 'when skip_confirmation is false' do + let(:skip_param) { { skip_confirmation: false } } + + it 'does not confirm the user' do + expect(service.execute).not_to be_confirmed + end + end + end + + context 'when automatic user confirmation is enabled' do + before do + stub_application_setting(send_user_confirmation_email: false) + end + + context 'when skip_confirmation is true' do + let(:skip_param) { { skip_confirmation: true } } + + it 'confirms the user' do + expect(service.execute).to be_confirmed + end + end + + context 'when skip_confirmation is not set the application setting takes precedence' do + it 'confirms the user' do + expect(service.execute).to be_confirmed + end + end + + context 'when skip_confirmation is false the application setting takes precedence' do + let(:skip_param) { { skip_confirmation: false } } + + it 'confirms the user' do + expect(service.execute).to be_confirmed + end + end + end + end +end |