2015-04-26 12:48:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe DisableEmailInterceptor do
|
2015-04-26 12:48:37 +05:30
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
Mail.register_interceptor(described_class)
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'does not send emails' do
|
2015-04-26 12:48:37 +05:30
|
|
|
allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false)
|
2015-09-11 14:41:01 +05:30
|
|
|
expect { deliver_mail }.not_to change(ActionMailer::Base.deliveries, :count)
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
# Removing interceptor from the list because unregister_interceptor is
|
|
|
|
# implemented in later version of mail gem
|
|
|
|
# See: https://github.com/mikel/mail/pull/705
|
2017-09-10 17:25:29 +05:30
|
|
|
Mail.unregister_interceptor(described_class)
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def deliver_mail
|
|
|
|
key = create :personal_key
|
|
|
|
Notify.new_ssh_key_email(key.id)
|
|
|
|
end
|
|
|
|
end
|