debian-mirror-gitlab/spec/lib/disable_email_interceptor_spec.rb

25 lines
701 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
require 'spec_helper'
2015-12-23 02:04:40 +05:30
describe DisableEmailInterceptor, lib: true do
2015-04-26 12:48:37 +05:30
before do
ActionMailer::Base.register_interceptor(DisableEmailInterceptor)
end
it 'should not send emails' do
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
Mail.class_variable_set(:@@delivery_interceptors, [])
end
def deliver_mail
key = create :personal_key
Notify.new_ssh_key_email(key.id)
end
end