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
Jérome Perrin
gitlab-ce
Commits
839c3b19
Commit
839c3b19
authored
Sep 12, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/email_when_added_to_group' of /home/git/repositories/gitlab/gitlabhq
parents
069a6dfa
c1dd31cf
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
102 additions
and
13 deletions
+102
-13
app/mailers/emails/groups.rb
app/mailers/emails/groups.rb
+11
-0
app/mailers/emails/profile.rb
app/mailers/emails/profile.rb
+15
-0
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+0
-1
app/mailers/notify.rb
app/mailers/notify.rb
+2
-12
app/observers/users_group_observer.rb
app/observers/users_group_observer.rb
+9
-0
app/services/notification_service.rb
app/services/notification_service.rb
+8
-0
app/views/notify/group_access_granted_email.html.haml
app/views/notify/group_access_granted_email.html.haml
+5
-0
app/views/notify/group_access_granted_email.text.erb
app/views/notify/group_access_granted_email.text.erb
+4
-0
config/application.rb
config/application.rb
+1
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+20
-0
spec/observers/users_group_observer_spec.rb
spec/observers/users_group_observer_spec.rb
+27
-0
No files found.
app/mailers/emails/groups.rb
0 → 100644
View file @
839c3b19
module
Emails
module
Groups
def
group_access_granted_email
(
user_group_id
)
@membership
=
UsersGroup
.
find
(
user_group_id
)
@group
=
@membership
.
group
mail
(
to:
@membership
.
user
.
email
,
subject:
subject
(
"access to group was granted"
))
end
end
end
app/mailers/emails/profile.rb
0 → 100644
View file @
839c3b19
module
Emails
module
Profile
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
end
end
app/mailers/emails/projects.rb
View file @
839c3b19
...
...
@@ -7,7 +7,6 @@ module Emails
subject:
subject
(
"access to project was granted"
))
end
def
project_was_moved_email
(
project_id
,
user_id
)
@user
=
User
.
find
user_id
@project
=
Project
.
find
project_id
...
...
app/mailers/notify.rb
View file @
839c3b19
...
...
@@ -3,6 +3,8 @@ class Notify < ActionMailer::Base
include
Emails
::
MergeRequests
include
Emails
::
Notes
include
Emails
::
Projects
include
Emails
::
Profile
include
Emails
::
Groups
add_template_helper
ApplicationHelper
add_template_helper
GitlabMarkdownHelper
...
...
@@ -20,18 +22,6 @@ class Notify < ActionMailer::Base
delay_for
(
2
.
seconds
)
end
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
# Look up a User by their ID and return their email address
...
...
app/observers/users_group_observer.rb
0 → 100644
View file @
839c3b19
class
UsersGroupObserver
<
BaseObserver
def
after_create
(
membership
)
notification
.
new_group_member
(
membership
)
end
def
after_update
(
membership
)
notification
.
update_group_member
(
membership
)
end
end
app/services/notification_service.rb
View file @
839c3b19
...
...
@@ -148,6 +148,14 @@ class NotificationService
mailer
.
project_access_granted_email
(
users_project
.
id
)
end
def
new_group_member
(
users_group
)
mailer
.
group_access_granted_email
(
users_group
.
id
)
end
def
update_group_member
(
users_group
)
mailer
.
group_access_granted_email
(
users_group
.
id
)
end
protected
# Get project users with WATCH notification level
...
...
app/views/notify/group_access_granted_email.html.haml
0 → 100644
View file @
839c3b19
%p
=
"You have been granted
#{
@membership
.
human_access
}
access to group"
%p
=
link_to
group_url
(
@group
)
do
=
@group
.
name
app/views/notify/group_access_granted_email.text.erb
0 → 100644
View file @
839c3b19
You have been granted
<%=
@membership
.
human_access
%>
access to group
<%=
@group
.
name
%>
<%=
url_for
(
group_url
(
@group
))
%>
config/application.rb
View file @
839c3b19
...
...
@@ -32,6 +32,7 @@ module Gitlab
:project_observer
,
:system_hook_observer
,
:user_observer
,
:users_group_observer
,
:users_project_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
...
...
spec/mailers/notify_spec.rb
View file @
839c3b19
...
...
@@ -347,4 +347,24 @@ describe Notify do
end
end
end
describe
'group access changed'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:membership
)
{
create
(
:users_group
,
group:
group
,
user:
user
)
}
subject
{
Notify
.
group_access_granted_email
(
membership
.
id
)
}
it
'has the correct subject'
do
should
have_subject
/access to group was granted/
end
it
'contains name of project'
do
should
have_body_text
/
#{
group
.
name
}
/
end
it
'contains new user role'
do
should
have_body_text
/
#{
membership
.
human_access
}
/
end
end
end
spec/observers/users_group_observer_spec.rb
0 → 100644
View file @
839c3b19
require
'spec_helper'
describe
UsersGroupObserver
do
before
(
:each
)
{
enable_observers
}
after
(
:each
)
{
disable_observers
}
subject
{
UsersGroupObserver
.
instance
}
before
{
subject
.
stub
(
notification:
mock
(
'NotificationService'
).
as_null_object
)
}
describe
"#after_create"
do
it
"should send email to user"
do
subject
.
should_receive
(
:notification
)
create
(
:users_group
)
end
end
describe
"#after_update"
do
before
do
@membership
=
create
:users_group
end
it
"should send email to user"
do
subject
.
should_receive
(
:notification
)
@membership
.
update_attribute
(
:group_access
,
UsersGroup
::
MASTER
)
end
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