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
iv
gitlab-ce
Commits
d431e433
Commit
d431e433
authored
Jan 02, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix few bugs and tests after refactoring ownership logic
parent
00a1f5bc
Changes
19
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
58 additions
and
61 deletions
+58
-61
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+2
-2
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+1
-1
app/models/ability.rb
app/models/ability.rb
+2
-13
app/models/key.rb
app/models/key.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-1
app/models/user.rb
app/models/user.rb
+5
-0
app/roles/account.rb
app/roles/account.rb
+1
-1
app/views/admin/projects/index.html.haml
app/views/admin/projects/index.html.haml
+4
-1
app/views/admin/users/show.html.haml
app/views/admin/users/show.html.haml
+3
-3
app/views/profiles/show.html.haml
app/views/profiles/show.html.haml
+1
-1
lib/api/projects.rb
lib/api/projects.rb
+1
-1
spec/factories.rb
spec/factories.rb
+1
-1
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+1
-1
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+1
-1
spec/requests/api/milestones_spec.rb
spec/requests/api/milestones_spec.rb
+1
-1
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+1
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+27
-27
spec/requests/projects_spec.rb
spec/requests/projects_spec.rb
+3
-3
spec/spec_helper.rb
spec/spec_helper.rb
+1
-1
No files found.
app/controllers/admin/users_controller.rb
View file @
d431e433
...
@@ -9,7 +9,7 @@ class Admin::UsersController < AdminController
...
@@ -9,7 +9,7 @@ class Admin::UsersController < AdminController
def
show
def
show
@admin_user
=
User
.
find
(
params
[
:id
])
@admin_user
=
User
.
find
(
params
[
:id
])
@projects
=
if
@admin_user
.
projects
.
empty?
@projects
=
if
@admin_user
.
authorized_
projects
.
empty?
Project
Project
else
else
Project
.
without_user
(
@admin_user
)
Project
.
without_user
(
@admin_user
)
...
@@ -98,7 +98,7 @@ class Admin::UsersController < AdminController
...
@@ -98,7 +98,7 @@ class Admin::UsersController < AdminController
def
destroy
def
destroy
@admin_user
=
User
.
find
(
params
[
:id
])
@admin_user
=
User
.
find
(
params
[
:id
])
if
@admin_user
.
my_own
_projects
.
count
>
0
if
@admin_user
.
personal
_projects
.
count
>
0
redirect_to
admin_users_path
,
alert:
"User is a project owner and can't be removed."
and
return
redirect_to
admin_users_path
,
alert:
"User is a project owner and can't be removed."
and
return
end
end
@admin_user
.
destroy
@admin_user
.
destroy
...
...
app/helpers/namespaces_helper.rb
View file @
d431e433
module
NamespacesHelper
module
NamespacesHelper
def
namespaces_options
(
selected
=
:current_user
,
scope
=
:default
)
def
namespaces_options
(
selected
=
:current_user
,
scope
=
:default
)
groups
=
current_user
.
namespace
s
.
select
{
|
n
|
n
.
type
==
'Group'
}
groups
=
current_user
.
owned_group
s
.
select
{
|
n
|
n
.
type
==
'Group'
}
users
=
if
scope
==
:all
users
=
if
scope
==
:all
Namespace
.
root
Namespace
.
root
...
...
app/models/ability.rb
View file @
d431e433
...
@@ -29,20 +29,9 @@ class Ability
...
@@ -29,20 +29,9 @@ class Ability
rules
<<
project_guest_rules
rules
<<
project_guest_rules
end
end
if
project
.
namespace
# If user own project namespace
# (Ex. group owner or account owner)
if
project
.
namespace
.
owner
==
user
rules
<<
project_admin_rules
end
else
# For compatibility with global projects
# use projects.owner_id
if
project
.
owner
==
user
if
project
.
owner
==
user
rules
<<
project_admin_rules
rules
<<
project_admin_rules
end
end
end
rules
.
flatten
rules
.
flatten
end
end
...
...
app/models/key.rb
View file @
d431e433
...
@@ -73,7 +73,7 @@ class Key < ActiveRecord::Base
...
@@ -73,7 +73,7 @@ class Key < ActiveRecord::Base
if
is_deploy_key
if
is_deploy_key
[
project
]
[
project
]
else
else
user
.
projects
user
.
authorized_
projects
end
end
end
end
...
...
app/models/project.rb
View file @
d431e433
...
@@ -80,7 +80,7 @@ class Project < ActiveRecord::Base
...
@@ -80,7 +80,7 @@ class Project < ActiveRecord::Base
# Scopes
# Scopes
scope
:public_only
,
where
(
private_flag:
false
)
scope
:public_only
,
where
(
private_flag:
false
)
scope
:without_user
,
->
(
user
)
{
where
(
"id NOT IN (:ids)"
,
ids:
user
.
projects
.
map
(
&
:id
)
)
}
scope
:without_user
,
->
(
user
)
{
where
(
"id NOT IN (:ids)"
,
ids:
user
.
authorized_
projects
.
map
(
&
:id
)
)
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"id NOT IN (:ids)"
,
ids:
group
.
project_ids
)
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"id NOT IN (:ids)"
,
ids:
group
.
project_ids
)
}
scope
:in_namespace
,
->
(
namespace
)
{
where
(
namespace_id:
namespace
.
id
)
}
scope
:in_namespace
,
->
(
namespace
)
{
where
(
namespace_id:
namespace
.
id
)
}
scope
:sorted_by_activity
,
->
()
{
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
}
scope
:sorted_by_activity
,
->
()
{
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
}
...
...
app/models/user.rb
View file @
d431e433
...
@@ -187,4 +187,9 @@ class User < ActiveRecord::Base
...
@@ -187,4 +187,9 @@ class User < ActiveRecord::Base
(projects.namespace_id IS NULL AND projects.creator_id = :user_id)"
,
(projects.namespace_id IS NULL AND projects.creator_id = :user_id)"
,
namespaces:
namespaces
.
map
(
&
:id
),
user_id:
self
.
id
)
namespaces:
namespaces
.
map
(
&
:id
),
user_id:
self
.
id
)
end
end
# Team membership in personal projects
def
tm_in_personal_projects
personal_projects
.
users_projects
.
where
(
user_id:
self
.
id
)
end
end
end
app/roles/account.rb
View file @
d431e433
...
@@ -69,7 +69,7 @@ module Account
...
@@ -69,7 +69,7 @@ module Account
def
projects_limit_percent
def
projects_limit_percent
return
100
if
projects_limit
.
zero?
return
100
if
projects_limit
.
zero?
(
my_own
_projects
.
count
.
to_f
/
projects_limit
)
*
100
(
personal
_projects
.
count
.
to_f
/
projects_limit
)
*
100
end
end
def
recent_push
project_id
=
nil
def
recent_push
project_id
=
nil
...
...
app/views/admin/projects/index.html.haml
View file @
d431e433
...
@@ -28,7 +28,10 @@
...
@@ -28,7 +28,10 @@
%span
.monospace
=
project
.
path_with_namespace
+
".git"
%span
.monospace
=
project
.
path_with_namespace
+
".git"
%td
=
project
.
users_projects
.
count
%td
=
project
.
users_projects
.
count
%td
%td
=
link_to
project
.
chief
.
name
,
[
:admin
,
project
.
chief
]
-
if
project
.
owner
=
link_to
project
.
owner
.
name
,
[
:admin
,
project
.
owner
]
-
else
(deleted)
%td
=
last_commit
(
project
)
%td
=
last_commit
(
project
)
%td
=
link_to
'Edit'
,
edit_admin_project_path
(
project
),
id:
"edit_
#{
dom_id
(
project
)
}
"
,
class:
"btn small"
%td
=
link_to
'Edit'
,
edit_admin_project_path
(
project
),
id:
"edit_
#{
dom_id
(
project
)
}
"
,
class:
"btn small"
%td
.bgred
=
link_to
'Destroy'
,
[
:admin
,
project
],
confirm:
"REMOVE
#{
project
.
name
}
? Are you sure?"
,
method: :delete
,
class:
"btn small danger"
%td
.bgred
=
link_to
'Destroy'
,
[
:admin
,
project
],
confirm:
"REMOVE
#{
project
.
name
}
? Are you sure?"
,
method: :delete
,
class:
"btn small danger"
...
...
app/views/admin/users/show.html.haml
View file @
d431e433
...
@@ -106,8 +106,8 @@
...
@@ -106,8 +106,8 @@
%td
=
link_to
group
.
name
,
admin_group_path
(
group
)
%td
=
link_to
group
.
name
,
admin_group_path
(
group
)
-
if
@admin_user
.
projects
.
present?
-
if
@admin_user
.
p
ersonal_p
rojects
.
present?
%h5
Projects:
%h5
P
ersonal P
rojects:
%br
%br
%table
.zebra-striped
%table
.zebra-striped
...
@@ -118,7 +118,7 @@
...
@@ -118,7 +118,7 @@
%th
%th
%th
%th
-
@admin_user
.
users
_projects
.
each
do
|
tm
|
-
@admin_user
.
tm_in_personal
_projects
.
each
do
|
tm
|
-
project
=
tm
.
project
-
project
=
tm
.
project
%tr
%tr
%td
=
link_to
project
.
name_with_namespace
,
admin_project_path
(
project
)
%td
=
link_to
project
.
name_with_namespace
,
admin_project_path
(
project
)
...
...
app/views/profiles/show.html.haml
View file @
d431e433
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
%legend
%legend
Personal projects:
Personal projects:
%small
.right
%small
.right
%span
=
current_user
.
my_own
_projects
.
count
%span
=
current_user
.
personal
_projects
.
count
of
of
%span
=
current_user
.
projects_limit
%span
=
current_user
.
projects_limit
.padded
.padded
...
...
lib/api/projects.rb
View file @
d431e433
...
@@ -9,7 +9,7 @@ module Gitlab
...
@@ -9,7 +9,7 @@ module Gitlab
# Example Request:
# Example Request:
# GET /projects
# GET /projects
get
do
get
do
@projects
=
paginate
current_user
.
projects
@projects
=
paginate
current_user
.
authorized_
projects
present
@projects
,
with:
Entities
::
Project
present
@projects
,
with:
Entities
::
Project
end
end
...
...
spec/factories.rb
View file @
d431e433
...
@@ -37,7 +37,7 @@ FactoryGirl.define do
...
@@ -37,7 +37,7 @@ FactoryGirl.define do
end
end
factory
:namespace
do
factory
:namespace
do
sequence
(
:name
)
{
|
n
|
"
group
#{
n
}
"
}
sequence
(
:name
)
{
|
n
|
"
namespace
#{
n
}
"
}
path
{
name
.
downcase
.
gsub
(
/\s/
,
'_'
)
}
path
{
name
.
downcase
.
gsub
(
/\s/
,
'_'
)
}
owner
owner
end
end
...
...
spec/requests/api/issues_spec.rb
View file @
d431e433
...
@@ -4,7 +4,7 @@ describe Gitlab::API do
...
@@ -4,7 +4,7 @@ describe Gitlab::API do
include
ApiHelpers
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
let!
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
before
{
project
.
add_access
(
user
,
:read
)
}
before
{
project
.
add_access
(
user
,
:read
)
}
...
...
spec/requests/api/merge_requests_spec.rb
View file @
d431e433
...
@@ -4,7 +4,7 @@ describe Gitlab::API do
...
@@ -4,7 +4,7 @@ describe Gitlab::API do
include
ApiHelpers
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
author:
user
,
assignee:
user
,
project:
project
,
title:
"Test"
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
author:
user
,
assignee:
user
,
project:
project
,
title:
"Test"
)
}
before
{
project
.
add_access
(
user
,
:read
)
}
before
{
project
.
add_access
(
user
,
:read
)
}
...
...
spec/requests/api/milestones_spec.rb
View file @
d431e433
...
@@ -4,7 +4,7 @@ describe Gitlab::API do
...
@@ -4,7 +4,7 @@ describe Gitlab::API do
include
ApiHelpers
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let!
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
before
{
project
.
add_access
(
user
,
:read
)
}
before
{
project
.
add_access
(
user
,
:read
)
}
...
...
spec/requests/api/notes_spec.rb
View file @
d431e433
...
@@ -4,7 +4,7 @@ describe Gitlab::API do
...
@@ -4,7 +4,7 @@ describe Gitlab::API do
include
ApiHelpers
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let!
(
:issue
)
{
create
(
:issue
,
project:
project
,
author:
user
)
}
let!
(
:snippet
)
{
create
(
:snippet
,
project:
project
,
author:
user
)
}
let!
(
:snippet
)
{
create
(
:snippet
,
project:
project
,
author:
user
)
}
let!
(
:issue_note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
,
author:
user
)
}
let!
(
:issue_note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
,
author:
user
)
}
...
...
spec/requests/api/projects_spec.rb
View file @
d431e433
This diff is collapsed.
Click to expand it.
spec/requests/projects_spec.rb
View file @
d431e433
...
@@ -5,7 +5,7 @@ describe "Projects" do
...
@@ -5,7 +5,7 @@ describe "Projects" do
describe
"GET /projects/show"
do
describe
"GET /projects/show"
do
before
do
before
do
@project
=
create
(
:project
,
owner:
@user
)
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
.
add_access
(
@user
,
:read
)
@project
.
add_access
(
@user
,
:read
)
visit
project_path
(
@project
)
visit
project_path
(
@project
)
...
@@ -37,7 +37,7 @@ describe "Projects" do
...
@@ -37,7 +37,7 @@ describe "Projects" do
describe
"PUT /projects/:id"
do
describe
"PUT /projects/:id"
do
before
do
before
do
@project
=
create
(
:project
,
owner:
@user
)
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
.
add_access
(
@user
,
:admin
,
:read
)
@project
.
add_access
(
@user
,
:admin
,
:read
)
visit
edit_project_path
(
@project
)
visit
edit_project_path
(
@project
)
...
@@ -58,7 +58,7 @@ describe "Projects" do
...
@@ -58,7 +58,7 @@ describe "Projects" do
describe
"DELETE /projects/:id"
do
describe
"DELETE /projects/:id"
do
before
do
before
do
@project
=
create
(
:project
,
owner:
@user
)
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
.
add_access
(
@user
,
:read
,
:admin
)
@project
.
add_access
(
@user
,
:read
,
:admin
)
visit
edit_project_path
(
@project
)
visit
edit_project_path
(
@project
)
end
end
...
...
spec/spec_helper.rb
View file @
d431e433
...
@@ -38,7 +38,7 @@ RSpec.configure do |config|
...
@@ -38,7 +38,7 @@ RSpec.configure do |config|
stub_gitolite!
stub_gitolite!
# !!! Observers disabled by default in tests
# !!! Observers disabled by default in tests
ActiveRecord
::
Base
.
observers
.
disable
(
:all
)
#
ActiveRecord::Base.observers.disable(:all)
# ActiveRecord::Base.observers.enable(:all)
# ActiveRecord::Base.observers.enable(:all)
# Use tmp dir for FS manipulations
# Use tmp dir for FS manipulations
...
...
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