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
d31a3873
Commit
d31a3873
authored
Nov 23, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve token strategy fallback and add more specs
parent
d1311119
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
app/models/concerns/token_authenticatable_strategies/base.rb
app/models/concerns/token_authenticatable_strategies/base.rb
+4
-0
spec/models/concerns/token_authenticatable_strategies/base_spec.rb
...ls/concerns/token_authenticatable_strategies/base_spec.rb
+26
-0
No files found.
app/models/concerns/token_authenticatable_strategies/base.rb
View file @
d31a3873
...
@@ -40,6 +40,10 @@ module TokenAuthenticatableStrategies
...
@@ -40,6 +40,10 @@ module TokenAuthenticatableStrategies
end
end
def
fallback?
def
fallback?
unless
options
[
:fallback
].
in?
([
true
,
false
,
nil
])
raise
ArgumentError
,
'fallback: needs to be a boolean value!'
end
options
[
:fallback
]
==
true
options
[
:fallback
]
==
true
end
end
...
...
spec/models/concerns/token_authenticatable_strategies/base_spec.rb
View file @
d31a3873
...
@@ -29,4 +29,30 @@ describe TokenAuthenticatableStrategies::Base do
...
@@ -29,4 +29,30 @@ describe TokenAuthenticatableStrategies::Base do
end
end
end
end
end
end
describe
'#fallback?'
do
context
'when fallback is set'
do
it
'recognizes fallback setting'
do
strategy
=
described_class
.
new
(
instance
,
field
,
fallback:
true
)
expect
(
strategy
.
fallback?
).
to
be
true
end
end
context
'when fallback is not a valid value'
do
it
'raises an error'
do
strategy
=
described_class
.
new
(
instance
,
field
,
fallback:
'something'
)
expect
{
strategy
.
fallback?
}.
to
raise_error
ArgumentError
end
end
context
'when fallback is not set'
do
it
'raises an error'
do
strategy
=
described_class
.
new
(
instance
,
field
,
{})
expect
(
strategy
.
fallback?
).
to
eq
false
end
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