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
Boxiang Sun
gitlab-ce
Commits
1f1c8094
Commit
1f1c8094
authored
Sep 03, 2012
by
Alex Denisov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
After commit instead of after_update
parent
c7cfe3d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
app/observers/users_project_observer.rb
app/observers/users_project_observer.rb
+8
-4
spec/observers/users_project_observer_spec.rb
spec/observers/users_project_observer_spec.rb
+4
-4
No files found.
app/observers/users_project_observer.rb
View file @
1f1c8094
class
UsersProjectObserver
<
ActiveRecord
::
Observer
def
after_create
(
users_project
)
Notify
.
project_access_granted_email
(
users_project
.
id
).
deliver
end
#def after_create(users_project)
#Notify.project_access_granted_email(users_project.id).deliver
#end
#def after_update(users_project)
#Notify.project_access_granted_email(users_project.id).deliver
#end
def
after_
update
(
users_project
)
def
after_
commit
(
users_project
)
Notify
.
project_access_granted_email
(
users_project
.
id
).
deliver
end
end
spec/observers/users_project_observer_spec.rb
View file @
1f1c8094
...
...
@@ -12,7 +12,7 @@ describe UsersProjectObserver do
describe
"#after_create"
do
it
"should called when UsersProject created"
do
subject
.
should_receive
(
:after_c
reate
)
subject
.
should_receive
(
:after_c
ommit
)
UsersProject
.
observers
.
enable
:users_project_observer
do
Factory
.
create
(
:users_project
,
project:
project
,
...
...
@@ -21,20 +21,20 @@ describe UsersProjectObserver do
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_c
reate
(
users_project
)
subject
.
after_c
ommit
(
users_project
)
end
end
describe
"#after_update"
do
it
"should called when UsersProject updated"
do
subject
.
should_receive
(
:after_
update
)
subject
.
should_receive
(
:after_
commit
)
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
)
subject
.
after_
commit
(
users_project
)
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