Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
eaebc20e
Commit
eaebc20e
authored
Oct 28, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'disable_email_option' into 'master'
Disable email option Fixes #1569 See merge request !1222
parents
2a16bbd6
28c08775
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
0 deletions
+39
-0
config/gitlab.yml.example
config/gitlab.yml.example
+2
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
config/initializers/disable_email_interceptor.rb
config/initializers/disable_email_interceptor.rb
+2
-0
lib/disable_email_interceptor.rb
lib/disable_email_interceptor.rb
+8
-0
spec/lib/disable_email_interceptor_spec.rb
spec/lib/disable_email_interceptor_spec.rb
+26
-0
No files found.
config/gitlab.yml.example
View file @
eaebc20e
...
...
@@ -39,6 +39,8 @@ production: &base
# time_zone: 'UTC'
## Email settings
# Uncomment and set to false if you need to disable email sending from GitLab (default: true)
# email_enabled: true
# Email address used in the "From" field in mails sent by GitLab
email_from: example@example.com
...
...
config/initializers/1_settings.rb
View file @
eaebc20e
...
...
@@ -95,6 +95,7 @@ Settings.gitlab['https'] = false if Settings.gitlab['https'].nil?
Settings
.
gitlab
[
'port'
]
||=
Settings
.
gitlab
.
https
?
443
:
80
Settings
.
gitlab
[
'relative_url_root'
]
||=
ENV
[
'RAILS_RELATIVE_URL_ROOT'
]
||
''
Settings
.
gitlab
[
'protocol'
]
||=
Settings
.
gitlab
.
https
?
"https"
:
"http"
Settings
.
gitlab
[
'email_enabled'
]
||=
true
if
Settings
.
gitlab
[
'email_enabled'
].
nil?
Settings
.
gitlab
[
'email_from'
]
||=
"gitlab@
#{
Settings
.
gitlab
.
host
}
"
Settings
.
gitlab
[
'url'
]
||=
Settings
.
send
(
:build_gitlab_url
)
Settings
.
gitlab
[
'user'
]
||=
'git'
...
...
config/initializers/disable_email_interceptor.rb
0 → 100644
View file @
eaebc20e
# Interceptor in lib/disable_email_interceptor.rb
ActionMailer
::
Base
.
register_interceptor
(
DisableEmailInterceptor
)
unless
Gitlab
.
config
.
gitlab
.
email_enabled
lib/disable_email_interceptor.rb
0 → 100644
View file @
eaebc20e
# Read about interceptors in http://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
class
DisableEmailInterceptor
def
self
.
delivering_email
(
message
)
message
.
perform_deliveries
=
false
Rails
.
logger
.
info
"Emails disabled! Interceptor prevented sending mail
#{
message
.
subject
}
"
end
end
spec/lib/disable_email_interceptor_spec.rb
0 → 100644
View file @
eaebc20e
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment