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
0df989ba
Commit
0df989ba
authored
Nov 16, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for token authenticable strategy factory method
parent
621071ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
app/models/concerns/token_authenticatable_strategies/base.rb
app/models/concerns/token_authenticatable_strategies/base.rb
+3
-3
spec/models/concerns/token_authenticatable_strategies/base_spec.rb
...ls/concerns/token_authenticatable_strategies/base_spec.rb
+32
-0
No files found.
app/models/concerns/token_authenticatable_strategies/base.rb
View file @
0df989ba
...
...
@@ -45,11 +45,11 @@ module TokenAuthenticatableStrategies
def
self
.
fabricate
(
instance
,
field
,
options
)
if
options
[
:digest
]
TokenAuthenticatableStrategies
::
Digest
.
new
(
instance
,
field
,
options
)
TokenAuthenticatableStrategies
::
Digest
.
new
(
instance
,
field
,
options
)
elsif
options
[
:encrypted
]
TokenAuthenticatableStrategies
::
Encrypted
.
new
(
instance
,
field
,
options
)
TokenAuthenticatableStrategies
::
Encrypted
.
new
(
instance
,
field
,
options
)
else
TokenAuthenticatableStrategies
::
Insecure
.
new
(
instance
,
field
,
options
)
TokenAuthenticatableStrategies
::
Insecure
.
new
(
instance
,
field
,
options
)
end
end
...
...
spec/models/concerns/token_authenticatable_strategies/base_spec.rb
0 → 100644
View file @
0df989ba
require
'spec_helper'
describe
TokenAuthenticatableStrategies
::
Base
do
let
(
:instance
)
{
double
(
:instance
)
}
let
(
:field
)
{
double
(
:field
)
}
describe
'.fabricate'
do
context
'when digest stragegy is specified'
do
it
'fabricates digest strategy object'
do
strategy
=
described_class
.
fabricate
(
instance
,
field
,
digest:
true
)
expect
(
strategy
).
to
be_a
TokenAuthenticatableStrategies
::
Digest
end
end
context
'when encrypted strategy is specified'
do
it
'fabricates encrypted strategy object'
do
strategy
=
described_class
.
fabricate
(
instance
,
field
,
encrypted:
true
)
expect
(
strategy
).
to
be_a
TokenAuthenticatableStrategies
::
Encrypted
end
end
context
'when no strategy is specified'
do
it
'fabricates insecure strategy object'
do
strategy
=
described_class
.
fabricate
(
instance
,
field
,
something:
true
)
expect
(
strategy
).
to
be_a
TokenAuthenticatableStrategies
::
Insecure
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