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
1c9a41e0
Commit
1c9a41e0
authored
Feb 06, 2014
by
GitLab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding tests for the ssh keys feature
parent
b9d58c4c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
app/controllers/profiles/keys_controller.rb
app/controllers/profiles/keys_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+12
-0
spec/routing/routing_spec.rb
spec/routing/routing_spec.rb
+5
-0
No files found.
app/controllers/profiles/keys_controller.rb
View file @
1c9a41e0
...
...
@@ -40,7 +40,7 @@ class Profiles::KeysController < ApplicationController
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 @@ class User < ActiveRecord::Base
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 @@ describe User do
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 @@ describe Profiles::KeysController, "routing" do
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