2014-10-27 14:08:37 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe DisableEmailInterceptor do
|
2014-10-27 14:08:37 +00:00
|
|
|
before do
|
2016-06-10 08:34:27 +00:00
|
|
|
Mail.register_interceptor(DisableEmailInterceptor)
|
2014-10-27 14:08:37 +00:00
|
|
|
end
|
|
|
|
|
2016-08-01 15:00:44 +00:00
|
|
|
it 'does not send emails' do
|
2015-02-12 18:17:35 +00:00
|
|
|
allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false)
|
2015-06-22 20:00:54 +00:00
|
|
|
expect { deliver_mail }.not_to change(ActionMailer::Base.deliveries, :count)
|
2014-10-27 14:08:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
2014-10-27 14:11:03 +00:00
|
|
|
# Removing interceptor from the list because unregister_interceptor is
|
|
|
|
# implemented in later version of mail gem
|
|
|
|
# See: https://github.com/mikel/mail/pull/705
|
2016-06-10 08:34:27 +00:00
|
|
|
Mail.unregister_interceptor(DisableEmailInterceptor)
|
2014-10-27 14:08:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def deliver_mail
|
|
|
|
key = create :personal_key
|
|
|
|
Notify.new_ssh_key_email(key.id)
|
|
|
|
end
|
|
|
|
end
|