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
Léo-Paul Géneau
gitlab-ce
Commits
0fbaf95f
Commit
0fbaf95f
authored
Jun 05, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4155 from babatakao/selectable_master_project_deploy_keys
Selectable deploy keys contain master projects
parents
6cf6b45a
37a90d5f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
4 deletions
+29
-4
app/controllers/deploy_keys_controller.rb
app/controllers/deploy_keys_controller.rb
+1
-1
app/models/user.rb
app/models/user.rb
+4
-2
features/steps/project/deploy_keys.rb
features/steps/project/deploy_keys.rb
+1
-0
lib/api/projects.rb
lib/api/projects.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+22
-0
No files found.
app/controllers/deploy_keys_controller.rb
View file @
0fbaf95f
...
@@ -54,6 +54,6 @@ class DeployKeysController < ProjectResourceController
...
@@ -54,6 +54,6 @@ class DeployKeysController < ProjectResourceController
protected
protected
def
available_keys
def
available_keys
@available_keys
||=
current_user
.
owned
_deploy_keys
@available_keys
||=
current_user
.
accessible
_deploy_keys
end
end
end
end
app/models/user.rb
View file @
0fbaf95f
...
@@ -90,6 +90,8 @@ class User < ActiveRecord::Base
...
@@ -90,6 +90,8 @@ class User < ActiveRecord::Base
has_many
:personal_projects
,
through: :namespace
,
source: :projects
has_many
:personal_projects
,
through: :namespace
,
source: :projects
has_many
:projects
,
through: :users_projects
has_many
:projects
,
through: :users_projects
has_many
:master_projects
,
through: :users_projects
,
source: :project
,
conditions:
{
users_projects:
{
project_access:
UsersProject
::
MASTER
}
}
has_many
:own_projects
,
foreign_key: :creator_id
,
class_name:
'Project'
has_many
:own_projects
,
foreign_key: :creator_id
,
class_name:
'Project'
has_many
:owned_projects
,
through: :namespaces
,
source: :projects
has_many
:owned_projects
,
through: :namespaces
,
source: :projects
...
@@ -354,7 +356,7 @@ class User < ActiveRecord::Base
...
@@ -354,7 +356,7 @@ class User < ActiveRecord::Base
extern_uid
&&
provider
==
'ldap'
extern_uid
&&
provider
==
'ldap'
end
end
def
owned
_deploy_keys
def
accessible
_deploy_keys
DeployKey
.
in_projects
(
self
.
owned
_projects
).
uniq
DeployKey
.
in_projects
(
self
.
master
_projects
).
uniq
end
end
end
end
features/steps/project/deploy_keys.rb
View file @
0fbaf95f
...
@@ -35,6 +35,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
...
@@ -35,6 +35,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
step
'other project has deploy key'
do
step
'other project has deploy key'
do
@second_project
=
create
:project
,
namespace:
current_user
.
namespace
@second_project
=
create
:project
,
namespace:
current_user
.
namespace
@second_project
.
team
<<
[
current_user
,
:master
]
create
(
:deploy_keys_project
,
project:
@second_project
)
create
(
:deploy_keys_project
,
project:
@second_project
)
end
end
...
...
lib/api/projects.rb
View file @
0fbaf95f
...
@@ -439,7 +439,7 @@ module API
...
@@ -439,7 +439,7 @@ module API
end
end
# Check for available deploy keys in other projects
# Check for available deploy keys in other projects
key
=
current_user
.
owned
_deploy_keys
.
find_by_key
(
attrs
[
:key
])
key
=
current_user
.
accessible
_deploy_keys
.
find_by_key
(
attrs
[
:key
])
if
key
if
key
user_project
.
deploy_keys
<<
key
user_project
.
deploy_keys
<<
key
present
key
,
with:
Entities
::
SSHKey
present
key
,
with:
Entities
::
SSHKey
...
...
spec/models/user_spec.rb
View file @
0fbaf95f
...
@@ -106,11 +106,33 @@ describe User do
...
@@ -106,11 +106,33 @@ describe User do
ActiveRecord
::
Base
.
observers
.
enable
(
:user_observer
)
ActiveRecord
::
Base
.
observers
.
enable
(
:user_observer
)
@user
=
create
:user
@user
=
create
:user
@project
=
create
:project
,
namespace:
@user
.
namespace
@project
=
create
:project
,
namespace:
@user
.
namespace
@project_2
=
create
:project
# Grant MASTER access to the user
@project_3
=
create
:project
# Grant DEVELOPER access to the user
UsersProject
.
add_users_into_projects
(
[
@project_2
.
id
],
[
@user
.
id
],
UsersProject
::
MASTER
)
UsersProject
.
add_users_into_projects
(
[
@project_3
.
id
],
[
@user
.
id
],
UsersProject
::
DEVELOPER
)
end
end
it
{
@user
.
authorized_projects
.
should
include
(
@project
)
}
it
{
@user
.
authorized_projects
.
should
include
(
@project
)
}
it
{
@user
.
authorized_projects
.
should
include
(
@project_2
)
}
it
{
@user
.
authorized_projects
.
should
include
(
@project_3
)
}
it
{
@user
.
owned_projects
.
should
include
(
@project
)
}
it
{
@user
.
owned_projects
.
should
include
(
@project
)
}
it
{
@user
.
owned_projects
.
should_not
include
(
@project_2
)
}
it
{
@user
.
owned_projects
.
should_not
include
(
@project_3
)
}
it
{
@user
.
personal_projects
.
should
include
(
@project
)
}
it
{
@user
.
personal_projects
.
should
include
(
@project
)
}
it
{
@user
.
personal_projects
.
should_not
include
(
@project_2
)
}
it
{
@user
.
personal_projects
.
should_not
include
(
@project_3
)
}
# master_projects doesn't check creator/namespace.
# In real case the users_projects relation will certainly be assigned
# when the project is created.
it
{
@user
.
master_projects
.
should_not
include
(
@project
)
}
it
{
@user
.
master_projects
.
should
include
(
@project_2
)
}
it
{
@user
.
master_projects
.
should_not
include
(
@project_3
)
}
end
end
describe
'groups'
do
describe
'groups'
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