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
3c96d1f0
Commit
3c96d1f0
authored
Aug 27, 2012
by
Alex Denisov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send notification on update UserProject relation (access changed)
parent
aaeb3741
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
app/observers/users_project_observer.rb
app/observers/users_project_observer.rb
+4
-0
config/application.rb
config/application.rb
+1
-1
spec/observers/users_project_observer_spec.rb
spec/observers/users_project_observer_spec.rb
+15
-2
No files found.
app/observers/users_project_observer.rb
View file @
3c96d1f0
...
@@ -2,4 +2,8 @@ class UsersProjectObserver < ActiveRecord::Observer
...
@@ -2,4 +2,8 @@ class UsersProjectObserver < ActiveRecord::Observer
def
after_create
(
users_project
)
def
after_create
(
users_project
)
Notify
.
project_access_granted_email
(
users_project
.
id
).
deliver
Notify
.
project_access_granted_email
(
users_project
.
id
).
deliver
end
end
def
after_update
(
users_project
)
Notify
.
project_access_granted_email
(
users_project
.
id
).
deliver
end
end
end
config/application.rb
View file @
3c96d1f0
...
@@ -23,7 +23,7 @@ module Gitlab
...
@@ -23,7 +23,7 @@ module Gitlab
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# Activate observers that should always be running.
config
.
active_record
.
observers
=
:mailer_observer
,
:activity_observer
,
:project_observer
,
:key_observer
,
:issue_observer
,
:user_observer
,
:system_hook_observer
config
.
active_record
.
observers
=
:mailer_observer
,
:activity_observer
,
:project_observer
,
:key_observer
,
:issue_observer
,
:user_observer
,
:system_hook_observer
,
:users_project_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
...
...
spec/observers/users_project_observer_spec.rb
View file @
3c96d1f0
...
@@ -24,4 +24,17 @@ describe UsersProjectObserver do
...
@@ -24,4 +24,17 @@ describe UsersProjectObserver do
subject
.
after_create
(
users_project
)
subject
.
after_create
(
users_project
)
end
end
end
end
describe
"#after_update"
do
it
"should called when UsersProject updated"
do
subject
.
should_receive
(
:after_update
)
UsersProject
.
observers
.
enable
:users_project_observer
do
users_project
.
update_attribute
(
:project_access
,
40
)
end
end
it
"should send email to user"
do
Notify
.
should_receive
(
:project_access_granted_email
).
with
(
users_project
.
id
).
and_return
(
double
(
deliver:
true
))
subject
.
after_update
(
users_project
)
end
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