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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b900f3f0
Commit
b900f3f0
authored
Mar 06, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test case for the available project keys
parent
dd0589f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
26 deletions
+17
-26
app/controllers/projects/protected_branches_controller.rb
app/controllers/projects/protected_branches_controller.rb
+0
-20
app/controllers/projects/settings/repository_controller.rb
app/controllers/projects/settings/repository_controller.rb
+6
-2
spec/presenters/projects/settings/deploy_keys_presenter_spec.rb
...resenters/projects/settings/deploy_keys_presenter_spec.rb
+11
-4
No files found.
app/controllers/projects/protected_branches_controller.rb
View file @
b900f3f0
...
...
@@ -58,27 +58,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
push_access_levels_attributes:
[
:access_level
,
:id
,
:user_id
,
:_destroy
,
:group_id
])
end
def
load_protected_branches
@protected_branches
=
@project
.
protected_branches
.
order
(
:name
).
page
(
params
[
:page
])
end
def
access_levels_options
{
push_access_levels:
{
roles:
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
,
before_divider:
true
}
},
},
merge_access_levels:
{
roles:
ProtectedBranch
::
MergeAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
,
before_divider:
true
}
},
},
selected_merge_access_levels:
@protected_branch
.
merge_access_levels
.
map
{
|
access_level
|
access_level
.
user_id
||
access_level
.
access_level
},
selected_push_access_levels:
@protected_branch
.
push_access_levels
.
map
{
|
access_level
|
access_level
.
user_id
||
access_level
.
access_level
}
}
end
def
load_gon_index
params
=
{
open_branches:
@project
.
open_branches
.
map
{
|
br
|
{
text:
br
.
name
,
id:
br
.
name
,
title:
br
.
name
}
}
}
params
.
merge!
(
current_project_id:
@project
.
id
)
if
@project
gon
.
push
(
params
.
merge
(
access_levels_options
))
end
end
app/controllers/projects/settings/repository_controller.rb
View file @
b900f3f0
...
...
@@ -34,8 +34,12 @@ module Projects
def
access_levels_options
{
push_access_levels:
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
}
},
merge_access_levels:
ProtectedBranch
::
MergeAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
}
},
push_access_levels:
{
roles:
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
,
before_divider:
true
}
},
},
merge_access_levels:
{
roles:
ProtectedBranch
::
MergeAccessLevel
.
human_access_levels
.
map
{
|
id
,
text
|
{
id:
id
,
text:
text
,
before_divider:
true
}
},
},
selected_merge_access_levels:
@protected_branch
.
merge_access_levels
.
map
{
|
access_level
|
access_level
.
user_id
||
access_level
.
access_level
},
selected_push_access_levels:
@protected_branch
.
push_access_levels
.
map
{
|
access_level
|
access_level
.
user_id
||
access_level
.
access_level
}
}
...
...
spec/presenters/projects/settings/deploy_keys_presenter_spec.rb
View file @
b900f3f0
...
...
@@ -36,20 +36,27 @@ describe Projects::Settings::DeployKeysPresenter do
end
describe
'#available_keys/#available_project_keys'
do
let
(
:other_deploy_key
)
{
create
(
:another_deploy_key
)
}
before
do
project_key
=
create
(
:deploy_keys_project
,
deploy_key:
other_deploy_key
)
project_key
.
project
.
add_developer
(
user
)
end
it
'returns the current available_keys'
do
expect
(
presenter
.
available_keys
).
to
be_empty
expect
(
presenter
.
available_keys
).
not_
to
be_empty
end
it
'returns the current available_project_keys'
do
expect
(
presenter
.
available_project_keys
).
to
be_empty
expect
(
presenter
.
available_project_keys
).
not_
to
be_empty
end
it
'returns false if any available_project_keys are enabled'
do
expect
(
presenter
.
any_available_project_keys_enabled?
).
to
eq
(
fals
e
)
expect
(
presenter
.
any_available_project_keys_enabled?
).
to
eq
(
tru
e
)
end
it
'returns the available_project_keys size'
do
expect
(
presenter
.
available_project_keys_size
).
to
eq
(
0
)
expect
(
presenter
.
available_project_keys_size
).
to
eq
(
1
)
end
it
'shows if there is an available key'
do
...
...
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