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
3dadb1f8
Commit
3dadb1f8
authored
Feb 04, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow SshHostKey.find_by to accept string keys
parent
2b0f4df0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
app/models/ssh_host_key.rb
app/models/ssh_host_key.rb
+1
-0
spec/models/ssh_host_key_spec.rb
spec/models/ssh_host_key_spec.rb
+23
-0
No files found.
app/models/ssh_host_key.rb
View file @
3dadb1f8
...
@@ -26,6 +26,7 @@ class SshHostKey
...
@@ -26,6 +26,7 @@ class SshHostKey
self
.
reactive_cache_lifetime
=
10
.
minutes
self
.
reactive_cache_lifetime
=
10
.
minutes
def
self
.
find_by
(
opts
=
{})
def
self
.
find_by
(
opts
=
{})
opts
=
HashWithIndifferentAccess
.
new
(
opts
)
return
nil
unless
opts
.
key?
(
:id
)
return
nil
unless
opts
.
key?
(
:id
)
project_id
,
url
=
opts
[
:id
].
split
(
':'
,
2
)
project_id
,
url
=
opts
[
:id
].
split
(
':'
,
2
)
...
...
spec/models/ssh_host_key_spec.rb
View file @
3dadb1f8
...
@@ -56,6 +56,29 @@ describe SshHostKey do
...
@@ -56,6 +56,29 @@ describe SshHostKey do
end
end
end
end
describe
'.find_by'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:url
)
{
'ssh://invalid.invalid:2222'
}
let
(
:finding_id
)
{
[
project
.
id
,
url
].
join
(
':'
)
}
it
'accepts a string key'
do
result
=
described_class
.
find_by
(
'id'
=>
finding_id
)
expect
(
result
).
to
be_a
(
described_class
)
expect
(
result
.
project
).
to
eq
(
project
)
expect
(
result
.
url
.
to_s
).
to
eq
(
url
)
end
it
'accepts a symbol key'
do
result
=
described_class
.
find_by
(
id:
finding_id
)
expect
(
result
).
to
be_a
(
described_class
)
expect
(
result
.
project
).
to
eq
(
project
)
expect
(
result
.
url
.
to_s
).
to
eq
(
url
)
end
end
describe
'#fingerprints'
,
:use_clean_rails_memory_store_caching
do
describe
'#fingerprints'
,
:use_clean_rails_memory_store_caching
do
it
'returns an array of indexed fingerprints when the cache is filled'
do
it
'returns an array of indexed fingerprints when the cache is filled'
do
stub_reactive_cache
(
ssh_host_key
,
known_hosts:
known_hosts
)
stub_reactive_cache
(
ssh_host_key
,
known_hosts:
known_hosts
)
...
...
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