Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Privacy
Imprint
Contact
Login methods
Sign in
Toggle navigation
Menu
Open sidebar
projects.thm.de
GitLab
Commits
1c9a41e0
Commit
1c9a41e0
authored
Feb 06, 2014
by
GitLab
Browse files
adding tests for the ssh keys feature
parent
b9d58c4c
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/controllers/profiles/keys_controller.rb
View file @
1c9a41e0
...
...
@@ -40,7 +40,7 @@ def get_keys
if
params
[
:username
].
present?
begin
user
=
User
.
find_by_username
(
params
[
:username
])
user
.
present?
?
(
render
:text
=>
user
.
all_ssh_keys
)
:
user
.
present?
?
(
render
:text
=>
user
.
all_ssh_keys
.
join
(
'\n'
)
)
:
(
render_404
and
return
)
rescue
=>
e
render
text:
e
.
message
...
...
app/models/user.rb
View file @
1c9a41e0
...
...
@@ -393,6 +393,6 @@ def with_defaults
end
def
all_ssh_keys
keys
.
collect
{
|
x
|
x
.
key
}
.
join
(
"
\n
"
)
keys
.
collect
{
|
x
|
x
.
key
}
end
end
spec/models/user_spec.rb
View file @
1c9a41e0
...
...
@@ -276,4 +276,16 @@
User
.
by_username_or_id
(
'bar'
).
should
be_nil
end
end
describe
'all_ssh_keys'
do
it
{
should
have_many
(
:keys
).
dependent
(
:destroy
)
}
it
"should have all ssh keys"
do
user
=
create
:user
key
=
create
:key
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD33bWLBxu48Sev9Fert1yzEO4WGcWglWF7K/AwblIUFselOt/QdOL9DSjpQGxLagO1s9wl53STIO8qGS4Ms0EJZyIXOEFMjFJ5xmjSy+S37By4sG7SsltQEHMxtbtFOaW5LV2wCrX+rUsRNqLMamZjgjcPO0/EgGCXIGMAYW4O7cwGZdXWYIhQ1Vwy+CsVMDdPkPgBXqK7nR/ey8KMs8ho5fMNgB5hBw/AL9fNGhRw3QTD6Q12Nkhl4VZES2EsZqlpNnJttnPdp847DUsT6yuLRlfiQfz5Cn9ysHFdXObMN5VYIiPFwHeYCZp1X2S4fDZooRE8uOLTfxWHPXwrhqSH"
,
user_id:
user
.
id
user
.
all_ssh_keys
.
should
include
(
key
.
key
)
end
end
end
spec/routing/routing_spec.rb
View file @
1c9a41e0
...
...
@@ -183,6 +183,11 @@
it
"to #destroy"
do
delete
(
"/profile/keys/1"
).
should
route_to
(
'profiles/keys#destroy'
,
id:
'1'
)
end
# get all the ssh-keys of a user
it
"to #get_keys"
do
get
(
"/foo.keys"
).
should
route_to
(
'profiles/keys#get_keys'
,
username:
'foo'
)
end
end
# dashboard GET /dashboard(.:format) dashboard#show
...
...
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