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
Tatuya Kamada
gitlab-ce
Commits
cb2be3ce
Commit
cb2be3ce
authored
Sep 19, 2012
by
Gabor Liptak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't email omniauth created users
parent
560b1ac5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
app/observers/user_observer.rb
app/observers/user_observer.rb
+3
-2
spec/observers/user_observer_spec.rb
spec/observers/user_observer_spec.rb
+10
-2
No files found.
app/observers/user_observer.rb
View file @
cb2be3ce
class
UserObserver
<
ActiveRecord
::
Observer
def
after_create
(
user
)
log_info
(
"User
\"
#{
user
.
name
}
\"
(
#{
user
.
email
}
) was created"
)
unless
user
.
extern_uid?
Notify
.
new_user_email
(
user
.
id
,
user
.
password
).
deliver
end
end
def
after_destroy
user
log_info
(
"User
\"
#{
user
.
name
}
\"
(
#{
user
.
email
}
) was removed"
)
...
...
spec/observers/user_observer_spec.rb
View file @
cb2be3ce
...
...
@@ -13,17 +13,25 @@ describe UserObserver do
end
context
'when a new user is created'
do
let
(
:user
)
{
double
(
:user
,
id:
42
,
password:
'P@ssword!'
,
name:
'John'
,
email:
'u@mail.local'
)
}
let
(
:notification
)
{
double
:notification
}
it
'sends an email'
do
it
'sends an email unless external'
do
user
=
double
(
:user
,
id:
42
,
password:
'P@ssword!'
,
name:
'John'
,
email:
'u@mail.local'
,
extern_uid?:
false
)
notification
.
should_receive
(
:deliver
)
Notify
.
should_receive
(
:new_user_email
).
with
(
user
.
id
,
user
.
password
).
and_return
(
notification
)
subject
.
after_create
(
user
)
end
it
'no email for external'
do
user
=
double
(
:user
,
id:
42
,
password:
'P@ssword!'
,
name:
'John'
,
email:
'u@mail.local'
,
extern_uid?:
true
)
Notify
.
should_not_receive
(
:new_user_email
)
subject
.
after_create
(
user
)
end
it
'trigger logger'
do
user
=
double
(
:user
,
id:
42
,
password:
'P@ssword!'
,
name:
'John'
,
email:
'u@mail.local'
,
extern_uid?:
false
)
Gitlab
::
AppLogger
.
should_receive
(
:info
)
subject
.
after_create
(
user
)
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