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
Jérome Perrin
gitlab-ce
Commits
cea0996a
Commit
cea0996a
authored
Feb 14, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into task_list_refactor
parents
6059fdef
e5f446b7
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
127 additions
and
61 deletions
+127
-61
app/models/user.rb
app/models/user.rb
+6
-1
changelogs/unreleased/27480-deploy_keys_should_not_show_up_in_users_keys_list.yml
...480-deploy_keys_should_not_show_up_in_users_keys_list.yml
+4
-0
changelogs/unreleased/merge-request-tabs-fixture.yml
changelogs/unreleased/merge-request-tabs-fixture.yml
+4
-0
changelogs/unreleased/quick-submit-fixture.yml
changelogs/unreleased/quick-submit-fixture.yml
+4
-0
spec/controllers/profiles/keys_controller_spec.rb
spec/controllers/profiles/keys_controller_spec.rb
+9
-10
spec/factories/keys.rb
spec/factories/keys.rb
+5
-2
spec/javascripts/behaviors/quick_submit_spec.js
spec/javascripts/behaviors/quick_submit_spec.js
+28
-18
spec/javascripts/fixtures/behaviors/quick_submit.html.haml
spec/javascripts/fixtures/behaviors/quick_submit.html.haml
+0
-6
spec/javascripts/fixtures/merge_request_tabs.html.haml
spec/javascripts/fixtures/merge_request_tabs.html.haml
+0
-22
spec/javascripts/fixtures/merge_requests.rb
spec/javascripts/fixtures/merge_requests.rb
+36
-0
spec/javascripts/merge_request_tabs_spec.js
spec/javascripts/merge_request_tabs_spec.js
+2
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+29
-0
No files found.
app/models/user.rb
View file @
cea0996a
...
...
@@ -51,7 +51,12 @@ class User < ActiveRecord::Base
has_one
:namespace
,
->
{
where
type:
nil
},
dependent: :destroy
,
foreign_key: :owner_id
# Profile
has_many
:keys
,
dependent: :destroy
has_many
:keys
,
->
do
type
=
Key
.
arel_table
[
:type
]
where
(
type
.
not_eq
(
'DeployKey'
).
or
(
type
.
eq
(
nil
)))
end
,
dependent: :destroy
has_many
:deploy_keys
,
->
{
where
(
type:
'DeployKey'
)
},
dependent: :destroy
has_many
:emails
,
dependent: :destroy
has_many
:personal_access_tokens
,
dependent: :destroy
has_many
:identities
,
dependent: :destroy
,
autosave:
true
...
...
changelogs/unreleased/27480-deploy_keys_should_not_show_up_in_users_keys_list.yml
0 → 100644
View file @
cea0996a
---
title
:
Do not display deploy keys in user's own ssh keys list
merge_request
:
9024
author
:
changelogs/unreleased/merge-request-tabs-fixture.yml
0 → 100644
View file @
cea0996a
---
title
:
Replace static fixture for merge_request_tabs_spec.js
merge_request
:
9172
author
:
winniehell
changelogs/unreleased/quick-submit-fixture.yml
0 → 100644
View file @
cea0996a
---
title
:
Replace static fixture for behaviors/quick_submit_spec.js
merge_request
:
9086
author
:
winniehell
spec/controllers/profiles/keys_controller_spec.rb
View file @
cea0996a
...
...
@@ -42,10 +42,9 @@ describe Profiles::KeysController do
end
describe
"user with keys"
do
before
do
user
.
keys
<<
create
(
:key
)
user
.
keys
<<
create
(
:another_key
)
end
let!
(
:key
)
{
create
(
:key
,
user:
user
)
}
let!
(
:another_key
)
{
create
(
:another_key
,
user:
user
)
}
let!
(
:deploy_key
)
{
create
(
:deploy_key
,
user:
user
)
}
it
"does generally work"
do
get
:get_keys
,
username:
user
.
username
...
...
@@ -53,16 +52,16 @@ describe Profiles::KeysController do
expect
(
response
).
to
be_success
end
it
"renders all keys separated with a new line"
do
it
"renders all
non deploy
keys separated with a new line"
do
get
:get_keys
,
username:
user
.
username
expect
(
response
.
body
).
not_to
eq
(
""
)
expect
(
response
.
body
).
not_to
eq
(
''
)
expect
(
response
.
body
).
to
eq
(
user
.
all_ssh_keys
.
join
(
"
\n
"
))
# Unique part of key 1
expect
(
response
.
body
).
to
match
(
/PWx6WM4lhHNedGfBpPJNPpZ/
)
# Key 2
expect
(
response
.
body
).
to
match
(
/AQDmTillFzNTrrGgwaCKaSj/
)
expect
(
response
.
body
).
to
include
(
key
.
key
.
sub
(
' dummy@gitlab.com'
,
''
))
expect
(
response
.
body
).
to
include
(
another_key
.
key
)
expect
(
response
.
body
).
not_to
include
(
deploy_key
.
key
)
end
it
"does not render the comment of the key"
do
...
...
spec/factories/keys.rb
View file @
cea0996a
...
...
@@ -2,10 +2,13 @@ FactoryGirl.define do
factory
:key
do
title
key
do
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0= dummy@gitlab.com"
'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0= dummy@gitlab.com'
end
factory
:deploy_key
,
class:
'DeployKey'
do
key
do
'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFf6RYK3qu/RKF/3ndJmL5xgMLp3O96x8lTay+QGZ0+9FnnAXMdUqBq/ZU6d/gyMB4IaW3nHzM1w049++yAB6UPCzMB8Uo27K5/jyZCtj7Vm9PFNjF/8am1kp46c/SeYicQgQaSBdzIW3UDEa1Ef68qroOlvpi9PYZ/tA7M0YP0K5PXX+E36zaIRnJVMPT3f2k+GnrxtjafZrwFdpOP/Fol5BQLBgcsyiU+LM1SuaCrzd8c9vyaTA1CxrkxaZh+buAi0PmdDtaDrHd42gqZkXCKavyvgM5o2CkQ5LJHCgzpXy05qNFzmThBSkb+XtoxbyagBiGbVZtSVow6Xa7qewz'
end
end
factory
:personal_key
do
...
...
@@ -14,7 +17,7 @@ FactoryGirl.define do
factory
:another_key
do
key
do
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ"
'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ'
end
factory
:another_deploy_key
,
class:
'DeployKey'
do
...
...
spec/javascripts/behaviors/quick_submit_spec.js
View file @
cea0996a
...
...
@@ -5,73 +5,83 @@ require('~/behaviors/quick_submit');
(
function
()
{
describe
(
'
Quick Submit behavior
'
,
function
()
{
var
keydownEvent
;
preloadFixtures
(
'
static/behaviors/quick_submit
.html.raw
'
);
preloadFixtures
(
'
issues/open-issue
.html.raw
'
);
beforeEach
(
function
()
{
loadFixtures
(
'
static/behaviors/quick_submit
.html.raw
'
);
loadFixtures
(
'
issues/open-issue
.html.raw
'
);
$
(
'
form
'
).
submit
(
function
(
e
)
{
// Prevent a form submit from moving us off the testing page
return
e
.
preventDefault
();
});
return
this
.
spies
=
{
this
.
spies
=
{
submit
:
spyOnEvent
(
'
form
'
,
'
submit
'
)
};
this
.
textarea
=
$
(
'
.js-quick-submit textarea
'
).
first
();
});
it
(
'
does not respond to other keyCodes
'
,
function
()
{
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
keyCode
:
32
}));
return
expect
(
this
.
spies
.
submit
).
not
.
toHaveBeenTriggered
();
});
it
(
'
does not respond to Enter alone
'
,
function
()
{
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
ctrlKey
:
false
,
metaKey
:
false
}));
return
expect
(
this
.
spies
.
submit
).
not
.
toHaveBeenTriggered
();
});
it
(
'
does not respond to repeated events
'
,
function
()
{
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
repeat
:
true
}));
return
expect
(
this
.
spies
.
submit
).
not
.
toHaveBeenTriggered
();
});
it
(
'
disables submit buttons
'
,
function
()
{
$
(
'
textarea
'
).
trigger
(
keydownEvent
());
expect
(
$
(
'
input[type=submit]
'
)).
toBeDisabled
();
return
expect
(
$
(
'
button[type=submit]
'
)).
toBeDisabled
();
it
(
'
disables input of type submit
'
,
function
()
{
const
submitButton
=
$
(
'
.js-quick-submit input[type=submit]
'
);
this
.
textarea
.
trigger
(
keydownEvent
());
expect
(
submitButton
).
toBeDisabled
();
});
it
(
'
disables button of type submit
'
,
function
()
{
// button doesn't exist in fixture, add it manually
const
submitButton
=
$
(
'
<button type="submit">Submit it</button>
'
);
submitButton
.
insertAfter
(
this
.
textarea
);
this
.
textarea
.
trigger
(
keydownEvent
());
expect
(
submitButton
).
toBeDisabled
();
});
// We cannot stub `navigator.userAgent` for CI's `rake karma` task, so we'll
// only run the tests that apply to the current platform
if
(
navigator
.
userAgent
.
match
(
/Macintosh/
))
{
it
(
'
responds to Meta+Enter
'
,
function
()
{
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
());
this
.
textarea
.
trigger
(
keydownEvent
());
return
expect
(
this
.
spies
.
submit
).
toHaveBeenTriggered
();
});
it
(
'
excludes other modifier keys
'
,
function
()
{
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
altKey
:
true
}));
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
ctrlKey
:
true
}));
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
shiftKey
:
true
}));
return
expect
(
this
.
spies
.
submit
).
not
.
toHaveBeenTriggered
();
});
}
else
{
it
(
'
responds to Ctrl+Enter
'
,
function
()
{
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
());
this
.
textarea
.
trigger
(
keydownEvent
());
return
expect
(
this
.
spies
.
submit
).
toHaveBeenTriggered
();
});
it
(
'
excludes other modifier keys
'
,
function
()
{
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
altKey
:
true
}));
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
metaKey
:
true
}));
$
(
'
input.quick-submit-input
'
)
.
trigger
(
keydownEvent
({
this
.
textarea
.
trigger
(
keydownEvent
({
shiftKey
:
true
}));
return
expect
(
this
.
spies
.
submit
).
not
.
toHaveBeenTriggered
();
...
...
spec/javascripts/fixtures/behaviors/quick_submit.html.haml
deleted
100644 → 0
View file @
6059fdef
%form
.js-quick-submit
{
action:
'/foo'
}
%input
{
type:
'text'
,
class:
'quick-submit-input'
}
%textarea
%input
{
type:
'submit'
}
Submit
%button
.btn
{
type:
'submit'
}
Submit
spec/javascripts/fixtures/merge_request_tabs.html.haml
deleted
100644 → 0
View file @
6059fdef
%ul
.nav.nav-tabs.merge-request-tabs
%li
.notes-tab
%a
{
href:
'/foo/bar/merge_requests/1'
,
data:
{
target:
'div#notes'
,
action:
'notes'
,
toggle:
'tab'
}}
Discussion
%li
.commits-tab
%a
{
href:
'/foo/bar/merge_requests/1/commits'
,
data:
{
target:
'div#commits'
,
action:
'commits'
,
toggle:
'tab'
}}
Commits
%li
.diffs-tab
%a
{
href:
'/foo/bar/merge_requests/1/diffs'
,
data:
{
target:
'div#diffs'
,
action:
'diffs'
,
toggle:
'tab'
}}
Diffs
.tab-content
#notes
.notes.tab-pane
Notes Content
#commits
.commits.tab-pane
Commits Content
#diffs
.diffs.tab-pane
Diffs Content
.mr-loading-status
.loading
Loading Animation
spec/javascripts/fixtures/merge_requests.rb
0 → 100644
View file @
cea0996a
require
'spec_helper'
describe
Projects
::
MergeRequestsController
,
'(JavaScript fixtures)'
,
type: :controller
do
include
JavaScriptFixturesHelpers
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:namespace
)
{
create
(
:namespace
,
name:
'frontend-fixtures'
)}
let
(
:project
)
{
create
(
:project
,
namespace:
namespace
,
path:
'merge-requests-project'
)
}
render_views
before
(
:all
)
do
clean_frontend_fixtures
(
'merge_requests/'
)
end
before
(
:each
)
do
sign_in
(
admin
)
end
it
'merge_requests/merge_request_with_task_list.html.raw'
do
|
example
|
merge_request
=
create
(
:merge_request
,
:with_diffs
,
source_project:
project
,
target_project:
project
,
description:
'- [ ] Task List Item'
)
render_merge_request
(
example
.
description
,
merge_request
)
end
private
def
render_merge_request
(
fixture_file_name
,
merge_request
)
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
merge_request
.
to_param
expect
(
response
).
to
be_success
store_frontend_fixture
(
response
,
fixture_file_name
)
end
end
spec/javascripts/merge_request_tabs_spec.js
View file @
cea0996a
...
...
@@ -25,7 +25,7 @@ require('vendor/jquery.scrollTo');
};
$
.
extend
(
stubLocation
,
defaults
,
stubs
||
{});
};
preloadFixtures
(
'
static/merge_request_tabs
.html.raw
'
);
preloadFixtures
(
'
merge_requests/merge_request_with_task_list
.html.raw
'
);
beforeEach
(
function
()
{
this
.
class
=
new
gl
.
MergeRequestTabs
({
stubLocation
:
stubLocation
});
...
...
@@ -41,7 +41,7 @@ require('vendor/jquery.scrollTo');
describe
(
'
#activateTab
'
,
function
()
{
beforeEach
(
function
()
{
spyOn
(
$
,
'
ajax
'
).
and
.
callFake
(
function
()
{});
loadFixtures
(
'
static/merge_request_tabs
.html.raw
'
);
loadFixtures
(
'
merge_requests/merge_request_with_task_list
.html.raw
'
);
this
.
subject
=
this
.
class
.
activateTab
;
});
it
(
'
shows the first tab when action is show
'
,
function
()
{
...
...
spec/models/user_spec.rb
View file @
cea0996a
...
...
@@ -19,6 +19,7 @@ describe User, models: true do
it
{
is_expected
.
to
have_many
(
:project_members
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:groups
)
}
it
{
is_expected
.
to
have_many
(
:keys
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:deploy_keys
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:events
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:recent_events
).
class_name
(
'Event'
)
}
it
{
is_expected
.
to
have_many
(
:issues
).
dependent
(
:destroy
)
}
...
...
@@ -303,6 +304,34 @@ describe User, models: true do
end
end
shared_context
'user keys'
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:key
)
{
create
(
:key
,
user:
user
)
}
let!
(
:deploy_key
)
{
create
(
:deploy_key
,
user:
user
)
}
end
describe
'#keys'
do
include_context
'user keys'
context
'with key and deploy key stored'
do
it
'returns stored key, but not deploy_key'
do
expect
(
user
.
keys
).
to
include
key
expect
(
user
.
keys
).
not_to
include
deploy_key
end
end
end
describe
'#deploy_keys'
do
include_context
'user keys'
context
'with key and deploy key stored'
do
it
'returns stored deploy key, but not normal key'
do
expect
(
user
.
deploy_keys
).
to
include
deploy_key
expect
(
user
.
deploy_keys
).
not_to
include
key
end
end
end
describe
'#confirm'
do
before
do
allow_any_instance_of
(
ApplicationSetting
).
to
receive
(
:send_user_confirmation_email
).
and_return
(
true
)
...
...
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