summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-28 13:36:28 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2014-10-28 13:36:28 +0000
commiteaebc20eba284a84fef17b2159f7eb6f87f2ff82 (patch)
treefd28b0c3e13b110c13c2e1dccf0ba2950298fe7a /spec
parent2a16bbd626fb95637e7da4103dc4e25f56ea3e1d (diff)
parent28c08775b3d1994d3a8c5057534c704ff9da4bae (diff)
downloadgitlab-ce-eaebc20eba284a84fef17b2159f7eb6f87f2ff82.tar.gz
Merge branch 'disable_email_option' into 'master'
Disable email option Fixes #1569 See merge request !1222
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/disable_email_interceptor_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/lib/disable_email_interceptor_spec.rb b/spec/lib/disable_email_interceptor_spec.rb
new file mode 100644
index 00000000000..8bf6ee2ed50
--- /dev/null
+++ b/spec/lib/disable_email_interceptor_spec.rb
@@ -0,0 +1,26 @@
+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
+ # 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