diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-04-21 15:55:54 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-05-16 14:56:32 -0300 |
commit | 71ca2de7aabf3191c4f486ca15a78a5b7f6abd94 (patch) | |
tree | f6520c7169d91aecaa3f9c3960cff11c29f5088f /spec | |
parent | 78a67fc48dab434b43a080e5b15491963656661a (diff) | |
download | gitlab-ce-71ca2de7aabf3191c4f486ca15a78a5b7f6abd94.tar.gz |
Toggle email signup confirmation in admin settings
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/registrations_controller_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb new file mode 100644 index 00000000000..b4ab767f73e --- /dev/null +++ b/spec/controllers/registrations_controller_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe RegistrationsController do + describe '#create' do + around(:each) do |example| + perform_enqueued_jobs do + example.run + end + end + + let(:user_params) { { "user"=> {"name"=>"new_user", "username"=>"new_username", "email"=>"new@user.com", "password"=>"Any_password"} } } + + context 'when skipping email confirmation' do + before { allow(current_application_settings).to receive(:skip_user_confirmation_email).and_return(true) } + + it 'logs user in directly' do + post(:create, user_params) + expect(ActionMailer::Base.deliveries.last).to be_nil + expect(subject.current_user).to be + end + end + + context 'when not skipping email confirmation' do + before { allow(current_application_settings).to receive(:skip_user_confirmation_email).and_return(false) } + + it 'does not authenticate user and sends confirmation email' do + post(:create, user_params) + expect(ActionMailer::Base.deliveries.last.to.first).to eq(user_params["user"]["email"]) + expect(subject.current_user).to be_nil + end + end + end +end |