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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
a3cdaeef
Commit
a3cdaeef
authored
Mar 19, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor emails a bit. Add email on ssh key creation
parent
52d3fa19
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
141 additions
and
104 deletions
+141
-104
app/mailers/emails/issues.rb
app/mailers/emails/issues.rb
+25
-0
app/mailers/emails/merge_requests.rb
app/mailers/emails/merge_requests.rb
+16
-0
app/mailers/emails/notes.rb
app/mailers/emails/notes.rb
+31
-0
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+18
-0
app/mailers/notify.rb
app/mailers/notify.rb
+9
-104
app/observers/key_observer.rb
app/observers/key_observer.rb
+3
-0
app/views/notify/new_ssh_key_email.html.haml
app/views/notify/new_ssh_key_email.html.haml
+10
-0
app/views/notify/new_ssh_key_email.text.erb
app/views/notify/new_ssh_key_email.text.erb
+7
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+22
-0
No files found.
app/mailers/emails/issues.rb
0 → 100644
View file @
a3cdaeef
module
Emails
module
Issues
def
new_issue_email
(
issue_id
)
@issue
=
Issue
.
find
(
issue_id
)
@project
=
@issue
.
project
mail
(
to:
@issue
.
assignee_email
,
subject:
subject
(
"new issue #
#{
@issue
.
id
}
"
,
@issue
.
title
))
end
def
reassigned_issue_email
(
recipient_id
,
issue_id
,
previous_assignee_id
)
@issue
=
Issue
.
find
(
issue_id
)
@previous_assignee
||=
User
.
find
(
previous_assignee_id
)
@project
=
@issue
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"changed issue #
#{
@issue
.
id
}
"
,
@issue
.
title
))
end
def
issue_status_changed_email
(
recipient_id
,
issue_id
,
status
,
updated_by_user_id
)
@issue
=
Issue
.
find
issue_id
@issue_status
=
status
@project
=
@issue
.
project
@updated_by
=
User
.
find
updated_by_user_id
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"changed issue #
#{
@issue
.
id
}
"
,
@issue
.
title
))
end
end
end
app/mailers/emails/merge_requests.rb
0 → 100644
View file @
a3cdaeef
module
Emails
module
MergeRequests
def
new_merge_request_email
(
merge_request_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@project
=
@merge_request
.
project
mail
(
to:
@merge_request
.
assignee_email
,
subject:
subject
(
"new merge request !
#{
@merge_request
.
id
}
"
,
@merge_request
.
title
))
end
def
reassigned_merge_request_email
(
recipient_id
,
merge_request_id
,
previous_assignee_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@previous_assignee
||=
User
.
find
(
previous_assignee_id
)
@project
=
@merge_request
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"changed merge request !
#{
@merge_request
.
id
}
"
,
@merge_request
.
title
))
end
end
end
app/mailers/emails/notes.rb
0 → 100644
View file @
a3cdaeef
module
Emails
module
Notes
def
note_commit_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@commit
=
@note
.
noteable
@commit
=
CommitDecorator
.
decorate
(
@commit
)
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note for commit
#{
@commit
.
short_id
}
"
,
@commit
.
title
))
end
def
note_issue_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@issue
=
@note
.
noteable
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note for issue #
#{
@issue
.
id
}
"
))
end
def
note_merge_request_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@merge_request
=
@note
.
noteable
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note for merge request !
#{
@merge_request
.
id
}
"
))
end
def
note_wall_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note on wall"
))
end
end
end
app/mailers/emails/projects.rb
0 → 100644
View file @
a3cdaeef
module
Emails
module
Projects
def
project_access_granted_email
(
user_project_id
)
@users_project
=
UsersProject
.
find
user_project_id
@project
=
@users_project
.
project
mail
(
to:
@users_project
.
user
.
email
,
subject:
subject
(
"access to project was granted"
))
end
def
project_was_moved_email
(
user_project_id
)
@users_project
=
UsersProject
.
find
user_project_id
@project
=
@users_project
.
project
mail
(
to:
@users_project
.
user
.
email
,
subject:
subject
(
"project was moved"
))
end
end
end
app/mailers/notify.rb
View file @
a3cdaeef
class
Notify
<
ActionMailer
::
Base
include
Emails
::
Issues
include
Emails
::
MergeRequests
include
Emails
::
Notes
include
Emails
::
Projects
add_template_helper
ApplicationHelper
add_template_helper
GitlabMarkdownHelper
...
...
@@ -15,116 +19,17 @@ class Notify < ActionMailer::Base
delay_for
(
2
.
seconds
)
end
#
# Issue
#
def
new_issue_email
(
issue_id
)
@issue
=
Issue
.
find
(
issue_id
)
@project
=
@issue
.
project
mail
(
to:
@issue
.
assignee_email
,
subject:
subject
(
"new issue #
#{
@issue
.
id
}
"
,
@issue
.
title
))
end
def
reassigned_issue_email
(
recipient_id
,
issue_id
,
previous_assignee_id
)
@issue
=
Issue
.
find
(
issue_id
)
@previous_assignee
||=
User
.
find
(
previous_assignee_id
)
@project
=
@issue
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"changed issue #
#{
@issue
.
id
}
"
,
@issue
.
title
))
end
def
issue_status_changed_email
(
recipient_id
,
issue_id
,
status
,
updated_by_user_id
)
@issue
=
Issue
.
find
issue_id
@issue_status
=
status
@project
=
@issue
.
project
@updated_by
=
User
.
find
updated_by_user_id
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"changed issue #
#{
@issue
.
id
}
"
,
@issue
.
title
))
end
#
# Merge Request
#
def
new_merge_request_email
(
merge_request_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@project
=
@merge_request
.
project
mail
(
to:
@merge_request
.
assignee_email
,
subject:
subject
(
"new merge request !
#{
@merge_request
.
id
}
"
,
@merge_request
.
title
))
end
def
reassigned_merge_request_email
(
recipient_id
,
merge_request_id
,
previous_assignee_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@previous_assignee
||=
User
.
find
(
previous_assignee_id
)
@project
=
@merge_request
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"changed merge request !
#{
@merge_request
.
id
}
"
,
@merge_request
.
title
))
end
#
# Note
#
def
note_commit_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@commit
=
@note
.
noteable
@commit
=
CommitDecorator
.
decorate
(
@commit
)
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note for commit
#{
@commit
.
short_id
}
"
,
@commit
.
title
))
end
def
note_issue_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@issue
=
@note
.
noteable
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note for issue #
#{
@issue
.
id
}
"
))
end
def
note_merge_request_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@merge_request
=
@note
.
noteable
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note for merge request !
#{
@merge_request
.
id
}
"
))
end
def
note_wall_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@project
=
@note
.
project
mail
(
to:
recipient
(
recipient_id
),
subject:
subject
(
"note on wall"
))
end
#
# Project
#
def
project_access_granted_email
(
user_project_id
)
@users_project
=
UsersProject
.
find
user_project_id
@project
=
@users_project
.
project
mail
(
to:
@users_project
.
user
.
email
,
subject:
subject
(
"access to project was granted"
))
end
def
project_was_moved_email
(
user_project_id
)
@users_project
=
UsersProject
.
find
user_project_id
@project
=
@users_project
.
project
mail
(
to:
@users_project
.
user
.
email
,
subject:
subject
(
"project was moved"
))
end
#
# User
#
def
new_user_email
(
user_id
,
password
)
@user
=
User
.
find
(
user_id
)
@password
=
password
mail
(
to:
@user
.
email
,
subject:
subject
(
"Account was created for you"
))
end
def
new_ssh_key_email
(
key_id
)
@key
=
Key
.
find
(
key_id
)
@user
=
@key
.
user
mail
(
to:
@user
.
email
,
subject:
subject
(
"SSH key was added to your account"
))
end
private
...
...
app/observers/key_observer.rb
View file @
a3cdaeef
...
...
@@ -7,6 +7,9 @@ class KeyObserver < ActiveRecord::Observer
key
.
shell_id
,
key
.
key
)
# Notify about ssh key being added
Notify
.
delay
.
new_ssh_key_email
(
key
.
id
)
if
key
.
user
end
def
after_destroy
(
key
)
...
...
app/views/notify/new_ssh_key_email.html.haml
0 → 100644
View file @
a3cdaeef
%p
Hi
#{
@user
.
name
}
!
%p
A new public key was added to your account:
%p
title:
%code
=
@key
.
title
%p
If this key was added in error, you can remove here:
=
link_to
"SSH Keys"
,
keys_url
app/views/notify/new_ssh_key_email.text.erb
0 → 100644
View file @
a3cdaeef
Hi
<%=
@user
.
name
%>
!
A new public key was added to your account:
title..................
<%=
@key
.
title
%>
If this key was added in error, you can remove here:
<%=
keys_url
%>
spec/mailers/notify_spec.rb
View file @
a3cdaeef
...
...
@@ -70,6 +70,28 @@ describe Notify do
end
end
describe
'user added ssh key'
do
let
(
:key
)
{
create
(
:personal_key
)
}
subject
{
Notify
.
new_ssh_key_email
(
key
.
id
)
}
it
'is sent to the new user'
do
should
deliver_to
key
.
user
.
email
end
it
'has the correct subject'
do
should
have_subject
/^gitlab \| SSH key was added to your account$/i
end
it
'contains the new ssh key title'
do
should
have_body_text
/
#{
key
.
title
}
/
end
it
'includes a link to ssh keys page'
do
should
have_body_text
/
#{
keys_path
}
/
end
end
context
'for a project'
do
describe
'items that are assignable, the email'
do
let
(
:assignee
)
{
create
(
:user
,
email:
'assignee@example.com'
)
}
...
...
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