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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
9edf6f2f
Commit
9edf6f2f
authored
Sep 30, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for auth hash
parent
6c9ae03b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletion
+56
-1
lib/gitlab/oauth/auth_hash.rb
lib/gitlab/oauth/auth_hash.rb
+1
-1
spec/lib/gitlab/oauth/auth_hash_spec.rb
spec/lib/gitlab/oauth/auth_hash_spec.rb
+55
-0
No files found.
lib/gitlab/oauth/auth_hash.rb
View file @
9edf6f2f
...
...
@@ -21,7 +21,7 @@ module Gitlab
end
def
name
(
info
.
name
||
full_name
).
to_s
.
force_encoding
(
'utf-8'
)
(
info
.
try
(
:name
)
||
full_name
).
to_s
.
force_encoding
(
'utf-8'
)
end
def
full_name
...
...
spec/lib/gitlab/oauth/auth_hash_spec.rb
0 → 100644
View file @
9edf6f2f
require
'spec_helper'
describe
Gitlab
::
OAuth
::
AuthHash
do
let
(
:auth_hash
)
do
Gitlab
::
OAuth
::
AuthHash
.
new
(
double
({
provider:
'twitter'
,
uid:
uid
,
info:
double
(
info_hash
)
}))
end
let
(
:uid
)
{
'my-uid'
}
let
(
:email
)
{
'my-email@example.com'
}
let
(
:nickname
)
{
'my-nickname'
}
let
(
:info_hash
)
{
{
email:
email
,
nickname:
nickname
,
name:
'John'
,
first_name:
"John"
,
last_name:
"Who"
}
}
context
"defaults"
do
it
{
expect
(
auth_hash
.
provider
).
to
eql
'twitter'
}
it
{
expect
(
auth_hash
.
uid
).
to
eql
uid
}
it
{
expect
(
auth_hash
.
email
).
to
eql
email
}
it
{
expect
(
auth_hash
.
username
).
to
eql
nickname
}
it
{
expect
(
auth_hash
.
name
).
to
eql
"John"
}
it
{
expect
(
auth_hash
.
password
).
to_not
be_empty
}
end
context
"email not provided"
do
before
{
info_hash
.
delete
(
:email
)
}
it
"generates a temp email"
do
expect
(
auth_hash
.
email
).
to_not
be_empty
end
end
context
"username not provided"
do
before
{
info_hash
.
delete
(
:nickname
)
}
it
"takes the first part of the email as username"
do
expect
(
auth_hash
.
username
).
to
eql
"my-email"
end
end
context
"name not provided"
do
before
{
info_hash
.
delete
(
:name
)
}
it
"concats first and lastname as the name"
do
expect
(
auth_hash
.
name
).
to
eql
"John Who"
end
end
end
\ No newline at end of file
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