2014-10-27 10:08:37 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe DisableEmailInterceptor do
|
|
|
|
before do
|
|
|
|
ActionMailer::Base.register_interceptor(DisableEmailInterceptor)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not send emails' do
|
|
|
|
Gitlab.config.gitlab.stub(:email_enabled).and_return(false)
|
|
|
|
expect {
|
|
|
|
deliver_mail
|
|
|
|
}.not_to change(ActionMailer::Base.deliveries, :count)
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
2014-10-27 10:11:03 -04: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
|
2014-10-27 10:08:37 -04:00
|
|
|
Mail.class_variable_set(:@@delivery_interceptors, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def deliver_mail
|
|
|
|
key = create :personal_key
|
|
|
|
Notify.new_ssh_key_email(key.id)
|
|
|
|
end
|
|
|
|
end
|