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
Léo-Paul Géneau
gitlab-ce
Commits
30e29bb9
Commit
30e29bb9
authored
Dec 10, 2015
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for `TokenAuthenticatable` concern
parent
d90d3db3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
spec/models/concerns/token_authenticatable_spec.rb
spec/models/concerns/token_authenticatable_spec.rb
+50
-0
No files found.
spec/models/concerns/token_authenticatable_spec.rb
0 → 100644
View file @
30e29bb9
require
'spec_helper'
shared_examples
'TokenAuthenticatable'
do
describe
'dynamically defined methods'
do
it
{
expect
(
described_class
).
to
be_private_method_defined
(
:generate_token_for
)
}
it
{
expect
(
described_class
).
to
respond_to
(
"find_by_
#{
token_field
}
"
)
}
it
{
is_expected
.
to
respond_to
(
"ensure_
#{
token_field
}
"
)
}
it
{
is_expected
.
to
respond_to
(
"reset_
#{
token_field
}
!"
)
}
end
end
describe
User
,
'TokenAuthenticatable'
do
let
(
:token_field
)
{
:authentication_token
}
it_behaves_like
'TokenAuthenticatable'
describe
'ensured authentication token'
do
subject
{
create
(
:user
).
send
(
token_field
)
}
it
{
is_expected
.
to
be_a
String
}
end
end
describe
ApplicationSetting
,
'TokenAuthenticatable'
do
let
(
:token_field
)
{
:runners_registration_token
}
it_behaves_like
'TokenAuthenticatable'
describe
'generating new token'
do
subject
{
described_class
.
new
}
let
(
:token
)
{
subject
.
send
(
token_field
)
}
context
'token is not generated yet'
do
it
{
expect
(
token
).
to
be
nil
}
end
context
'token is generated'
do
before
{
subject
.
send
(
"reset_
#{
token_field
}
!"
)
}
it
{
expect
(
token
).
to
be_a
String
}
end
end
describe
'multiple token fields'
do
before
do
described_class
.
send
(
:add_authentication_token_field
,
:yet_another_token
)
end
describe
'.token_fields'
do
subject
{
described_class
.
authentication_token_fields
}
it
{
is_expected
.
to
include
(
:runners_registration_token
,
:yet_another_token
)
}
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