gitlab-org--gitlab-foss/spec/lib/disable_email_interceptor_spec.rb

25 lines
657 B
Ruby
Raw Normal View History

2014-10-27 10:08:37 -04:00
require 'spec_helper'
describe DisableEmailInterceptor do
2014-10-27 10:08:37 -04:00
before do
Mail.register_interceptor(described_class)
2014-10-27 10:08:37 -04:00
end
it 'does not send emails' do
allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false)
2015-06-22 16:00:54 -04:00
expect { deliver_mail }.not_to change(ActionMailer::Base.deliveries, :count)
2014-10-27 10:08:37 -04:00
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
Mail.unregister_interceptor(described_class)
2014-10-27 10:08:37 -04:00
end
def deliver_mail
key = create :personal_key
Notify.new_ssh_key_email(key.id)
end
end