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
dccd8b6e
Commit
dccd8b6e
authored
Jan 04, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Continue refactoring. Use repostory and team
parent
39ba934c
Changes
42
Hide whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
219 additions
and
179 deletions
+219
-179
app/contexts/notes/load_context.rb
app/contexts/notes/load_context.rb
+1
-1
app/contexts/test_hook_context.rb
app/contexts/test_hook_context.rb
+1
-1
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+3
-2
app/controllers/merge_requests_controller.rb
app/controllers/merge_requests_controller.rb
+2
-2
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+2
-1
app/controllers/services_controller.rb
app/controllers/services_controller.rb
+1
-1
app/controllers/team_members_controller.rb
app/controllers/team_members_controller.rb
+4
-5
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+3
-2
app/helpers/merge_requests_helper.rb
app/helpers/merge_requests_helper.rb
+1
-1
app/models/event.rb
app/models/event.rb
+7
-3
app/models/note.rb
app/models/note.rb
+1
-1
app/models/project.rb
app/models/project.rb
+10
-37
app/models/protected_branch.rb
app/models/protected_branch.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+9
-3
app/models/team.rb
app/models/team.rb
+71
-2
app/models/user.rb
app/models/user.rb
+1
-1
app/models/users_project.rb
app/models/users_project.rb
+16
-33
app/views/admin/projects/_form.html.haml
app/views/admin/projects/_form.html.haml
+1
-1
app/views/admin/projects/show.html.haml
app/views/admin/projects/show.html.haml
+5
-5
app/views/merge_requests/_form.html.haml
app/views/merge_requests/_form.html.haml
+2
-2
app/views/projects/_form.html.haml
app/views/projects/_form.html.haml
+3
-3
app/workers/post_receive.rb
app/workers/post_receive.rb
+1
-1
features/steps/admin/admin_groups.rb
features/steps/admin/admin_groups.rb
+1
-1
features/steps/dashboard/dashboard.rb
features/steps/dashboard/dashboard.rb
+2
-2
features/steps/dashboard/dashboard_issues.rb
features/steps/dashboard/dashboard_issues.rb
+1
-1
features/steps/dashboard/dashboard_merge_requests.rb
features/steps/dashboard/dashboard_merge_requests.rb
+2
-2
features/steps/dashboard/dashboard_search.rb
features/steps/dashboard/dashboard_search.rb
+1
-5
features/steps/group/group.rb
features/steps/group/group.rb
+1
-1
features/steps/project/project_team_management.rb
features/steps/project/project_team_management.rb
+3
-3
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+9
-5
features/steps/shared/project.rb
features/steps/shared/project.rb
+3
-3
lib/gitlab/backend/gitolite_config.rb
lib/gitlab/backend/gitolite_config.rb
+4
-4
lib/gitlab/markdown.rb
lib/gitlab/markdown.rb
+1
-1
lib/gitlab/satellite/merge_action.rb
lib/gitlab/satellite/merge_action.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+0
-16
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+14
-0
spec/models/system_hook_spec.rb
spec/models/system_hook_spec.rb
+2
-2
spec/models/team_spec.rb
spec/models/team_spec.rb
+12
-0
spec/models/users_project_spec.rb
spec/models/users_project_spec.rb
+5
-5
spec/requests/issues_spec.rb
spec/requests/issues_spec.rb
+1
-2
spec/requests/projects_spec.rb
spec/requests/projects_spec.rb
+4
-4
spec/support/stubbed_repository.rb
spec/support/stubbed_repository.rb
+6
-12
No files found.
app/contexts/notes/load_context.rb
View file @
dccd8b6e
...
@@ -9,7 +9,7 @@ module Notes
...
@@ -9,7 +9,7 @@ module Notes
@notes
=
case
target_type
@notes
=
case
target_type
when
"commit"
when
"commit"
project
.
commit_notes
(
project
.
commit
(
target_id
)).
fresh
.
limit
(
20
)
project
.
commit_notes
(
project
.
repository
.
commit
(
target_id
)).
fresh
.
limit
(
20
)
when
"issue"
when
"issue"
project
.
issues
.
find
(
target_id
).
notes
.
inc_author
.
fresh
.
limit
(
20
)
project
.
issues
.
find
(
target_id
).
notes
.
inc_author
.
fresh
.
limit
(
20
)
when
"merge_request"
when
"merge_request"
...
...
app/contexts/test_hook_context.rb
View file @
dccd8b6e
class
TestHookContext
<
BaseContext
class
TestHookContext
<
BaseContext
def
execute
def
execute
hook
=
project
.
hooks
.
find
(
params
[
:id
])
hook
=
project
.
hooks
.
find
(
params
[
:id
])
commits
=
project
.
commits
(
project
.
default_branch
,
nil
,
3
)
commits
=
project
.
repository
.
commits
(
project
.
default_branch
,
nil
,
3
)
data
=
project
.
post_receive_data
(
commits
.
last
.
id
,
commits
.
first
.
id
,
"refs/heads/
#{
project
.
default_branch
}
"
,
current_user
)
data
=
project
.
post_receive_data
(
commits
.
last
.
id
,
commits
.
first
.
id
,
"refs/heads/
#{
project
.
default_branch
}
"
,
current_user
)
hook
.
execute
(
data
)
hook
.
execute
(
data
)
end
end
...
...
app/controllers/admin/projects_controller.rb
View file @
dccd8b6e
...
@@ -10,6 +10,7 @@ class Admin::ProjectsController < AdminController
...
@@ -10,6 +10,7 @@ class Admin::ProjectsController < AdminController
end
end
def
show
def
show
@repository
=
@project
.
repository
@users
=
User
.
active
@users
=
User
.
active
@users
=
@users
.
not_in_project
(
@project
)
if
@project
.
users
.
present?
@users
=
@users
.
not_in_project
(
@project
)
if
@project
.
users
.
present?
@users
=
@users
.
all
@users
=
@users
.
all
...
@@ -19,7 +20,7 @@ class Admin::ProjectsController < AdminController
...
@@ -19,7 +20,7 @@ class Admin::ProjectsController < AdminController
end
end
def
team_update
def
team_update
@project
.
add_users_ids_to_team
(
params
[
:user_ids
],
params
[
:project_access
])
@project
.
team
.
add_users_ids
(
params
[
:user_ids
],
params
[
:project_access
])
redirect_to
[
:admin
,
@project
],
notice:
'Project was successfully updated.'
redirect_to
[
:admin
,
@project
],
notice:
'Project was successfully updated.'
end
end
...
@@ -36,7 +37,7 @@ class Admin::ProjectsController < AdminController
...
@@ -36,7 +37,7 @@ class Admin::ProjectsController < AdminController
def
destroy
def
destroy
# Delete team first in order to prevent multiple gitolite calls
# Delete team first in order to prevent multiple gitolite calls
@project
.
t
runcate_team
@project
.
t
eam
.
truncate
@project
.
destroy
@project
.
destroy
...
...
app/controllers/merge_requests_controller.rb
View file @
dccd8b6e
...
@@ -83,12 +83,12 @@ class MergeRequestsController < ProjectResourceController
...
@@ -83,12 +83,12 @@ class MergeRequestsController < ProjectResourceController
end
end
def
branch_from
def
branch_from
@commit
=
project
.
commit
(
params
[
:ref
])
@commit
=
@repository
.
commit
(
params
[
:ref
])
@commit
=
CommitDecorator
.
decorate
(
@commit
)
@commit
=
CommitDecorator
.
decorate
(
@commit
)
end
end
def
branch_to
def
branch_to
@commit
=
project
.
commit
(
params
[
:ref
])
@commit
=
@repository
.
commit
(
params
[
:ref
])
@commit
=
CommitDecorator
.
decorate
(
@commit
)
@commit
=
CommitDecorator
.
decorate
(
@commit
)
end
end
...
...
app/controllers/projects_controller.rb
View file @
dccd8b6e
...
@@ -2,6 +2,7 @@ require Rails.root.join('lib', 'gitlab', 'graph', 'json_builder')
...
@@ -2,6 +2,7 @@ require Rails.root.join('lib', 'gitlab', 'graph', 'json_builder')
class
ProjectsController
<
ProjectResourceController
class
ProjectsController
<
ProjectResourceController
skip_before_filter
:project
,
only:
[
:new
,
:create
]
skip_before_filter
:project
,
only:
[
:new
,
:create
]
skip_before_filter
:repository
,
only:
[
:new
,
:create
]
# Authorize
# Authorize
before_filter
:authorize_read_project!
,
except:
[
:index
,
:new
,
:create
]
before_filter
:authorize_read_project!
,
except:
[
:index
,
:new
,
:create
]
...
@@ -58,7 +59,7 @@ class ProjectsController < ProjectResourceController
...
@@ -58,7 +59,7 @@ class ProjectsController < ProjectResourceController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
do
format
.
html
do
unless
@project
.
empty_repo
?
if
@project
.
repository
&&
!
@project
.
repository
.
empty
?
@last_push
=
current_user
.
recent_push
(
@project
.
id
)
@last_push
=
current_user
.
recent_push
(
@project
.
id
)
render
:show
render
:show
else
else
...
...
app/controllers/services_controller.rb
View file @
dccd8b6e
...
@@ -26,7 +26,7 @@ class ServicesController < ProjectResourceController
...
@@ -26,7 +26,7 @@ class ServicesController < ProjectResourceController
end
end
def
test
def
test
commits
=
project
.
commits
(
project
.
default_branch
,
nil
,
3
)
commits
=
project
.
repository
.
commits
(
project
.
default_branch
,
nil
,
3
)
data
=
project
.
post_receive_data
(
commits
.
last
.
id
,
commits
.
first
.
id
,
"refs/heads/
#{
project
.
default_branch
}
"
,
current_user
)
data
=
project
.
post_receive_data
(
commits
.
last
.
id
,
commits
.
first
.
id
,
"refs/heads/
#{
project
.
default_branch
}
"
,
current_user
)
@service
=
project
.
gitlab_ci_service
@service
=
project
.
gitlab_ci_service
...
...
app/controllers/team_members_controller.rb
View file @
dccd8b6e
...
@@ -16,10 +16,9 @@ class TeamMembersController < ProjectResourceController
...
@@ -16,10 +16,9 @@ class TeamMembersController < ProjectResourceController
end
end
def
create
def
create
@project
.
add_users_ids_to_team
(
users
=
User
.
where
(
id:
params
[
:user_ids
])
params
[
:user_ids
],
params
[
:project_access
]
@project
.
team
<<
[
users
,
params
[
:project_access
]]
)
if
params
[
:redirect_to
]
if
params
[
:redirect_to
]
redirect_to
params
[
:redirect_to
]
redirect_to
params
[
:redirect_to
]
...
@@ -50,7 +49,7 @@ class TeamMembersController < ProjectResourceController
...
@@ -50,7 +49,7 @@ class TeamMembersController < ProjectResourceController
def
apply_import
def
apply_import
giver
=
Project
.
find
(
params
[
:source_project_id
])
giver
=
Project
.
find
(
params
[
:source_project_id
])
status
=
UsersProject
.
import_team
(
giver
,
project
)
status
=
@project
.
team
.
import
(
giver
)
notice
=
status
?
"Succesfully imported"
:
"Import failed"
notice
=
status
?
"Succesfully imported"
:
"Import failed"
redirect_to
project_team_members_path
(
project
),
notice:
notice
redirect_to
project_team_members_path
(
project
),
notice:
notice
...
...
app/helpers/application_helper.rb
View file @
dccd8b6e
...
@@ -53,7 +53,7 @@ module ApplicationHelper
...
@@ -53,7 +53,7 @@ module ApplicationHelper
def
last_commit
(
project
)
def
last_commit
(
project
)
if
project
.
repo_exists?
if
project
.
repo_exists?
time_ago_in_words
(
project
.
commit
.
committed_date
)
+
" ago"
time_ago_in_words
(
project
.
repository
.
commit
.
committed_date
)
+
" ago"
else
else
"Never"
"Never"
end
end
...
@@ -102,7 +102,7 @@ module ApplicationHelper
...
@@ -102,7 +102,7 @@ module ApplicationHelper
]
]
project_nav
=
[]
project_nav
=
[]
if
@project
&&
!
@project
.
new_record?
if
@project
&&
@project
.
repository
&&
@project
.
repository
.
root_ref
project_nav
=
[
project_nav
=
[
{
label:
"
#{
@project
.
name
}
Issues"
,
url:
project_issues_path
(
@project
)
},
{
label:
"
#{
@project
.
name
}
Issues"
,
url:
project_issues_path
(
@project
)
},
{
label:
"
#{
@project
.
name
}
Commits"
,
url:
project_commits_path
(
@project
,
@ref
||
@project
.
repository
.
root_ref
)
},
{
label:
"
#{
@project
.
name
}
Commits"
,
url:
project_commits_path
(
@project
,
@ref
||
@project
.
repository
.
root_ref
)
},
...
@@ -142,6 +142,7 @@ module ApplicationHelper
...
@@ -142,6 +142,7 @@ module ApplicationHelper
event
.
last_push_to_non_root?
&&
event
.
last_push_to_non_root?
&&
!
event
.
rm_ref?
&&
!
event
.
rm_ref?
&&
event
.
project
&&
event
.
project
&&
event
.
project
.
repository
&&
event
.
project
.
merge_requests_enabled
event
.
project
.
merge_requests_enabled
end
end
...
...
app/helpers/merge_requests_helper.rb
View file @
dccd8b6e
...
@@ -4,7 +4,7 @@ module MergeRequestsHelper
...
@@ -4,7 +4,7 @@ module MergeRequestsHelper
event
.
project
,
event
.
project
,
merge_request:
{
merge_request:
{
source_branch:
event
.
branch_name
,
source_branch:
event
.
branch_name
,
target_branch:
event
.
project
.
root_ref
,
target_branch:
event
.
project
.
r
epository
.
r
oot_ref
,
title:
event
.
branch_name
.
titleize
title:
event
.
branch_name
.
titleize
}
}
)
)
...
...
app/models/event.rb
View file @
dccd8b6e
...
@@ -204,7 +204,7 @@ class Event < ActiveRecord::Base
...
@@ -204,7 +204,7 @@ class Event < ActiveRecord::Base
# Max 20 commits from push DESC
# Max 20 commits from push DESC
def
commits
def
commits
@commits
||=
data
[
:commits
].
map
{
|
commit
|
project
.
commit
(
commit
[
:id
])
}.
reverse
@commits
||=
data
[
:commits
].
map
{
|
commit
|
repository
.
commit
(
commit
[
:id
])
}.
reverse
end
end
def
commits_count
def
commits_count
...
@@ -225,14 +225,18 @@ class Event < ActiveRecord::Base
...
@@ -225,14 +225,18 @@ class Event < ActiveRecord::Base
end
end
end
end
def
repository
project
.
repository
end
def
parent_commit
def
parent_commit
project
.
commit
(
commit_from
)
repository
.
commit
(
commit_from
)
rescue
=>
ex
rescue
=>
ex
nil
nil
end
end
def
last_commit
def
last_commit
project
.
commit
(
commit_to
)
repository
.
commit
(
commit_to
)
rescue
=>
ex
rescue
=>
ex
nil
nil
end
end
...
...
app/models/note.rb
View file @
dccd8b6e
...
@@ -71,7 +71,7 @@ class Note < ActiveRecord::Base
...
@@ -71,7 +71,7 @@ class Note < ActiveRecord::Base
# override to return commits, which are not active record
# override to return commits, which are not active record
def
noteable
def
noteable
if
for_commit?
if
for_commit?
project
.
commit
(
commit_id
)
project
.
repository
.
commit
(
commit_id
)
else
else
super
super
end
end
...
...
app/models/project.rb
View file @
dccd8b6e
...
@@ -166,7 +166,13 @@ class Project < ActiveRecord::Base
...
@@ -166,7 +166,13 @@ class Project < ActiveRecord::Base
end
end
def
repository
def
repository
@repository
||=
Repository
.
new
(
path_with_namespace
,
default_branch
)
if
path
@repository
||=
Repository
.
new
(
path_with_namespace
,
default_branch
)
else
nil
end
rescue
Grit
::
NoSuchPathError
nil
end
end
def
git_error?
def
git_error?
...
@@ -279,39 +285,6 @@ class Project < ActiveRecord::Base
...
@@ -279,39 +285,6 @@ class Project < ActiveRecord::Base
users_projects
.
find_by_user_id
(
user_id
)
users_projects
.
find_by_user_id
(
user_id
)
end
end
# Update multiple project users
# to same access role by user ids
def
update_users_ids_to_role
(
users_ids
,
access_role
)
UsersProject
.
bulk_update
(
self
,
users_ids
,
access_role
)
end
# Delete multiple users from project by user ids
def
delete_users_ids_from_team
(
users_ids
)
UsersProject
.
bulk_delete
(
self
,
users_ids
)
end
def
repository_readers
repository_members
[
UsersProject
::
REPORTER
]
end
def
repository_writers
repository_members
[
UsersProject
::
DEVELOPER
]
end
def
repository_masters
repository_members
[
UsersProject
::
MASTER
]
end
def
repository_members
keys
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
[]
}
UsersProject
.
select
(
"keys.identifier, project_access"
).
joins
(
user: :keys
).
where
(
project_id:
id
).
each
{
|
row
|
keys
[
row
.
project_access
]
<<
[
row
.
identifier
]
}
keys
[
UsersProject
::
REPORTER
]
+=
deploy_keys
.
pluck
(
:identifier
)
keys
end
def
transfer
(
new_namespace
)
def
transfer
(
new_namespace
)
Project
.
transaction
do
Project
.
transaction
do
old_namespace
=
namespace
old_namespace
=
namespace
...
@@ -441,7 +414,7 @@ class Project < ActiveRecord::Base
...
@@ -441,7 +414,7 @@ class Project < ActiveRecord::Base
#
#
def
post_receive_data
(
oldrev
,
newrev
,
ref
,
user
)
def
post_receive_data
(
oldrev
,
newrev
,
ref
,
user
)
push_commits
=
commits_between
(
oldrev
,
newrev
)
push_commits
=
repository
.
commits_between
(
oldrev
,
newrev
)
# Total commits count
# Total commits count
push_commits_count
=
push_commits
.
size
push_commits_count
=
push_commits
.
size
...
@@ -488,7 +461,7 @@ class Project < ActiveRecord::Base
...
@@ -488,7 +461,7 @@ class Project < ActiveRecord::Base
def
update_merge_requests
(
oldrev
,
newrev
,
ref
,
user
)
def
update_merge_requests
(
oldrev
,
newrev
,
ref
,
user
)
return
true
unless
ref
=~
/heads/
return
true
unless
ref
=~
/heads/
branch_name
=
ref
.
gsub
(
"refs/heads/"
,
""
)
branch_name
=
ref
.
gsub
(
"refs/heads/"
,
""
)
c_ids
=
self
.
commits_between
(
oldrev
,
newrev
).
map
(
&
:id
)
c_ids
=
self
.
repository
.
commits_between
(
oldrev
,
newrev
).
map
(
&
:id
)
# Update code for merge requests
# Update code for merge requests
mrs
=
self
.
merge_requests
.
opened
.
find_all_by_branch
(
branch_name
).
all
mrs
=
self
.
merge_requests
.
opened
.
find_all_by_branch
(
branch_name
).
all
...
@@ -510,7 +483,7 @@ class Project < ActiveRecord::Base
...
@@ -510,7 +483,7 @@ class Project < ActiveRecord::Base
end
end
def
empty_repo?
def
empty_repo?
!
repository
||
repository
.
empty
_repo
?
!
repository
||
repository
.
empty?
end
end
def
satellite
def
satellite
...
...
app/models/protected_branch.rb
View file @
dccd8b6e
...
@@ -26,6 +26,6 @@ class ProtectedBranch < ActiveRecord::Base
...
@@ -26,6 +26,6 @@ class ProtectedBranch < ActiveRecord::Base
end
end
def
commit
def
commit
project
.
commit
(
self
.
name
)
project
.
repository
.
commit
(
self
.
name
)
end
end
end
end
app/models/repository.rb
View file @
dccd8b6e
...
@@ -13,9 +13,11 @@ class Repository
...
@@ -13,9 +13,11 @@ class Repository
attr_accessor
:root_ref
attr_accessor
:root_ref
def
initialize
(
path_with_namespace
,
root_ref
=
'master'
)
def
initialize
(
path_with_namespace
,
root_ref
=
'master'
)
@root_ref
=
root_ref
@root_ref
=
root_ref
||
"master"
@path_with_namespace
=
path_with_namespace
@path_with_namespace
=
path_with_namespace
@repo
=
Grit
::
Repo
.
new
(
path_to_repo
)
# Init grit repo object
repo
end
end
def
raw
def
raw
...
@@ -26,6 +28,10 @@ class Repository
...
@@ -26,6 +28,10 @@ class Repository
@path_to_repo
||=
File
.
join
(
Gitlab
.
config
.
gitolite
.
repos_path
,
"
#{
path_with_namespace
}
.git"
)
@path_to_repo
||=
File
.
join
(
Gitlab
.
config
.
gitolite
.
repos_path
,
"
#{
path_with_namespace
}
.git"
)
end
end
def
repo
@repo
||=
Grit
::
Repo
.
new
(
path_to_repo
)
end
def
commit
(
commit_id
=
nil
)
def
commit
(
commit_id
=
nil
)
Commit
.
find_or_first
(
repo
,
commit_id
,
root_ref
)
Commit
.
find_or_first
(
repo
,
commit_id
,
root_ref
)
end
end
...
@@ -114,7 +120,7 @@ class Repository
...
@@ -114,7 +120,7 @@ class Repository
false
false
end
end
def
empty
_repo
?
def
empty?
!
has_commits?
!
has_commits?
end
end
...
...
app/models/team.rb
View file @
dccd8b6e
...
@@ -3,7 +3,22 @@ class Team
...
@@ -3,7 +3,22 @@ class Team
def
initialize
(
project
)
def
initialize
(
project
)
@project
=
project
@project
=
project
@roles
=
UsersProject
.
roles_hash
end
# Shortcut to add users
#
# Use:
# @team << [@user, :master]
# @team << [@users, :master]
#
def
<<
args
users
=
args
.
first
if
users
.
respond_to?
(
:each
)
add_users
(
users
,
args
.
second
)
else
add_user
(
users
,
args
.
second
)
end
end
end
def
add_user
(
user
,
access
)
def
add_user
(
user
,
access
)
...
@@ -14,7 +29,7 @@ class Team
...
@@ -14,7 +29,7 @@ class Team
add_users_ids
(
users
.
map
(
&
:id
),
access
)
add_users_ids
(
users
.
map
(
&
:id
),
access
)
end
end
def
add_users_ids
(
user
s
_ids
,
access
)
def
add_users_ids
(
user_ids
,
access
)
UsersProject
.
add_users_into_projects
(
UsersProject
.
add_users_into_projects
(
[
project
.
id
],
[
project
.
id
],
user_ids
,
user_ids
,
...
@@ -46,4 +61,58 @@ class Team
...
@@ -46,4 +61,58 @@ class Team
def
masters
def
masters
members
.
masters
.
map
(
&
:user
)
members
.
masters
.
map
(
&
:user
)
end
end
def
repository_readers
repository_members
[
UsersProject
::
REPORTER
]
end
def
repository_writers
repository_members
[
UsersProject
::
DEVELOPER
]
end
def
repository_masters
repository_members
[
UsersProject
::
MASTER
]
end
def
repository_members
keys
=
Hash
.
new
{
|
h
,
k
|
h
[
k
]
=
[]
}
UsersProject
.
select
(
"keys.identifier, project_access"
).
joins
(
user: :keys
).
where
(
project_id:
project
.
id
).
each
{
|
row
|
keys
[
row
.
project_access
]
<<
[
row
.
identifier
]
}
keys
[
UsersProject
::
REPORTER
]
+=
project
.
deploy_keys
.
pluck
(
:identifier
)
keys
end
def
import
(
source_project
)
target_project
=
project
source_team
=
source_project
.
users_projects
.
all
target_team
=
target_project
.
users_projects
.
all
target_user_ids
=
target_team
.
map
(
&
:user_id
)
source_team
.
reject!
do
|
tm
|
# Skip if user already present in team
target_user_ids
.
include?
(
tm
.
user_id
)
end
source_team
.
map!
do
|
tm
|
new_tm
=
tm
.
dup
new_tm
.
id
=
nil
new_tm
.
project_id
=
target_project
.
id
new_tm
.
skip_git
=
true
new_tm
end
UsersProject
.
transaction
do
source_team
.
each
do
|
tm
|
tm
.
save
end
target_project
.
update_repository
end
true
rescue
false
end
end
end
app/models/user.rb
View file @
dccd8b6e
...
@@ -188,7 +188,7 @@ class User < ActiveRecord::Base
...
@@ -188,7 +188,7 @@ class User < ActiveRecord::Base
# Team membership in personal projects
# Team membership in personal projects
def
tm_in_personal_projects
def
tm_in_personal_projects
personal_projects
.
users_projects
.
where
(
user_id:
self
.
id
)
UsersProject
.
where
(
project_id:
personal_projects
.
map
(
&
:id
),
user_id:
self
.
id
)
end
end
# Returns a string for use as a Gitolite user identifier
# Returns a string for use as a Gitolite user identifier
...
...
app/models/users_project.rb
View file @
dccd8b6e
...
@@ -48,10 +48,23 @@ class UsersProject < ActiveRecord::Base
...
@@ -48,10 +48,23 @@ class UsersProject < ActiveRecord::Base
# access can be an integer representing a access code
# access can be an integer representing a access code
# or symbol like :master representing role
# or symbol like :master representing role
#
#
# Ex.
# add_users_into_projects(
# project_ids,
# user_ids,
# UsersProject::MASTER
# )
#
# add_users_into_projects(
# project_ids,
# user_ids,
# :master
# )
#
def
add_users_into_projects
(
project_ids
,
user_ids
,
access
)
def
add_users_into_projects
(
project_ids
,
user_ids
,
access
)
project_access
=
if
@roles
.
has_key?
(
access
)
project_access
=
if
roles_hash
.
has_key?
(
access
)
@roles
[
access
]
roles_hash
[
access
]
elsif
@roles
.
values
.
include?
(
access
)
elsif
roles_hash
.
values
.
include?
(
access
.
to_i
)
access
access
else
else
raise
"Non valid access"
raise
"Non valid access"
...
@@ -93,36 +106,6 @@ class UsersProject < ActiveRecord::Base
...
@@ -93,36 +106,6 @@ class UsersProject < ActiveRecord::Base
truncate_teams
[
project
.
id
]
truncate_teams
[
project
.
id
]
end
end
def
import_team
(
source_project
,
target_project
)
source_team
=
source_project
.
users_projects
.
all
target_team
=
target_project
.
users_projects
.
all
target_user_ids
=
target_team
.
map
(
&
:user_id
)
source_team
.
reject!
do
|
tm
|
# Skip if user already present in team
target_user_ids
.
include?
(
tm
.
user_id
)
end
source_team
.
map!
do
|
tm
|
new_tm
=
tm
.
dup
new_tm
.
id
=
nil
new_tm
.
project_id
=
target_project
.
id
new_tm
.
skip_git
=
true
new_tm
end
UsersProject
.
transaction
do
source_team
.
each
do
|
tm
|
tm
.
save
end
target_project
.
update_repository
end
true
rescue
false
end
def
bulk_delete
(
project
,
user_ids
)
def
bulk_delete
(
project
,
user_ids
)
UsersProject
.
transaction
do
UsersProject
.
transaction
do
UsersProject
.
where
(
user_id:
user_ids
,
project_id:
project
.
id
).
each
do
|
users_project
|
UsersProject
.
where
(
user_id:
user_ids
,
project_id:
project
.
id
).
each
do
|
users_project
|
...
...
app/views/admin/projects/_form.html.haml
View file @
dccd8b6e
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
-
if
project
.
repo_exists?
-
if
project
.
repo_exists?
.clearfix
.clearfix
=
f
.
label
:default_branch
,
"Default Branch"
=
f
.
label
:default_branch
,
"Default Branch"
.input
=
f
.
select
(
:default_branch
,
project
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
.input
=
f
.
select
(
:default_branch
,
repository
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
%fieldset
.adv_settings
%fieldset
.adv_settings
%legend
Features:
%legend
Features:
...
...
app/views/admin/projects/show.html.haml
View file @
dccd8b6e
...
@@ -4,15 +4,15 @@
...
@@ -4,15 +4,15 @@
%i
.icon-edit
%i
.icon-edit
Edit
Edit
-
if
@
project
.
has_commits?
-
if
@
repository
.
has_commits?
-
if
!
@
project
.
has_post_receive_file?
-
if
!
@
repository
.
has_post_receive_file?
%br
%br
.alert.alert-error
.alert.alert-error
%span
%span
%strong
Project has commits but missing post-receive file.
%strong
Project has commits but missing post-receive file.
%br
%br
If you exported project manually - make a link of post-receive hook file from gitolite to project repository
If you exported project manually - make a link of post-receive hook file from gitolite to project repository
-
elsif
!
@
project
.
valid_post_receive_file?
-
elsif
!
@
repository
.
valid_post_receive_file?
%br
%br
.alert.alert-error
.alert.alert-error
%span
%span
...
@@ -76,7 +76,7 @@
...
@@ -76,7 +76,7 @@
%b
%b
FS Path:
FS Path:
%td
%td
%code
=
@
project
.
path_to_repo
%code
=
@
repository
.
path_to_repo
%tr
%tr
%td
%td
%b
%b
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
%b
%b
Post Receive File:
Post Receive File:
%td
%td
=
check_box_tag
:post_receive_file
,
1
,
@
project
.
has_post_receive_file?
,
disabled:
true
=
check_box_tag
:post_receive_file
,
1
,
@
repository
.
has_post_receive_file?
,
disabled:
true
%br
%br
%h5
%h5
...
...
app/views/merge_requests/_form.html.haml
View file @
dccd8b6e
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
.mr_branch_box
.mr_branch_box
%h5
From (Head Branch)
%h5
From (Head Branch)
.body
.body
.padded
=
f
.
select
(
:source_branch
,
@
project
.
heads
.
map
(
&
:name
),
{
include_blank:
"Select branch"
},
{
class:
'chosen span4'
})
.padded
=
f
.
select
(
:source_branch
,
@
repository
.
heads
.
map
(
&
:name
),
{
include_blank:
"Select branch"
},
{
class:
'chosen span4'
})
.mr_source_commit
.mr_source_commit
.span2
.span2
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
.mr_branch_box
.mr_branch_box
%h5
To (Base Branch)
%h5
To (Base Branch)
.body
.body
.padded
=
f
.
select
(
:target_branch
,
@
project
.
heads
.
map
(
&
:name
),
{
include_blank:
"Select branch"
},
{
class:
'chosen span4'
})
.padded
=
f
.
select
(
:target_branch
,
@
repository
.
heads
.
map
(
&
:name
),
{
include_blank:
"Select branch"
},
{
class:
'chosen span4'
})
.mr_target_commit
.mr_target_commit
%h4
.cdark
2. Fill info
%h4
.cdark
2. Fill info
...
...
app/views/projects/_form.html.haml
View file @
dccd8b6e
...
@@ -15,13 +15,13 @@
...
@@ -15,13 +15,13 @@
=
f
.
label
:path
do
=
f
.
label
:path
do
Repository
Repository
.controls
.controls
=
text_field_tag
:ppath
,
@
project
.
path_to_repo
,
class:
"xxlarge"
,
readonly:
true
=
text_field_tag
:ppath
,
@
repository
.
path_to_repo
,
class:
"xxlarge"
,
readonly:
true
-
unless
@
project
.
heads
.
empty?
-
unless
@
repository
.
heads
.
empty?
.clearfix
.clearfix
=
f
.
label
:default_branch
,
"Default Branch"
=
f
.
label
:default_branch
,
"Default Branch"
.input
=
f
.
select
(
:default_branch
,
@
project
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
.input
=
f
.
select
(
:default_branch
,
@
repository
.
heads
.
map
(
&
:name
),
{},
style:
"width:210px;"
)
%fieldset
.features
%fieldset
.features
%legend
Features:
%legend
Features:
...
...
app/workers/post_receive.rb
View file @
dccd8b6e
...
@@ -11,7 +11,7 @@ class PostReceive
...
@@ -11,7 +11,7 @@ class PostReceive
# Ignore push from non-gitlab users
# Ignore push from non-gitlab users
user
=
if
identifier
.
eql?
Gitlab
.
config
.
gitolite
.
admin_key
user
=
if
identifier
.
eql?
Gitlab
.
config
.
gitolite
.
admin_key
email
=
project
.
commit
(
newrev
).
author
.
email
rescue
nil
email
=
project
.
repository
.
commit
(
newrev
).
author
.
email
rescue
nil
User
.
find_by_email
(
email
)
if
email
User
.
find_by_email
(
email
)
if
email
elsif
/^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/
.
match
(
identifier
)
elsif
/^[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}$/
.
match
(
identifier
)
User
.
find_by_email
(
identifier
)
User
.
find_by_email
(
identifier
)
...
...
features/steps/admin/admin_groups.rb
View file @
dccd8b6e
...
@@ -16,7 +16,7 @@ class AdminGroups < Spinach::FeatureSteps
...
@@ -16,7 +16,7 @@ class AdminGroups < Spinach::FeatureSteps
@project
=
create
(
:project
,
group:
@group
)
@project
=
create
(
:project
,
group:
@group
)
@event
=
create
(
:closed_issue_event
,
project:
@project
)
@event
=
create
(
:closed_issue_event
,
project:
@project
)
@project
.
add_access
current_user
,
:admin
@project
.
team
<<
[
current_user
,
:master
]
end
end
And
'Create gitlab user "John"'
do
And
'Create gitlab user "John"'
do
...
...
features/steps/dashboard/dashboard.rb
View file @
dccd8b6e
...
@@ -61,7 +61,7 @@ class Dashboard < Spinach::FeatureSteps
...
@@ -61,7 +61,7 @@ class Dashboard < Spinach::FeatureSteps
And
'I own project "Shop"'
do
And
'I own project "Shop"'
do
@project
=
create
:project
,
name:
'Shop'
@project
=
create
:project
,
name:
'Shop'
@project
.
add_access
(
@user
,
:admin
)
@project
.
team
<<
[
@user
,
:master
]
end
end
And
'I have group with projects'
do
And
'I have group with projects'
do
...
@@ -69,7 +69,7 @@ class Dashboard < Spinach::FeatureSteps
...
@@ -69,7 +69,7 @@ class Dashboard < Spinach::FeatureSteps
@project
=
create
(
:project
,
group:
@group
)
@project
=
create
(
:project
,
group:
@group
)
@event
=
create
(
:closed_issue_event
,
project:
@project
)
@event
=
create
(
:closed_issue_event
,
project:
@project
)
@project
.
add_access
current_user
,
:admin
@project
.
team
<<
[
current_user
,
:master
]
end
end
And
'project "Shop" has push event'
do
And
'project "Shop" has push event'
do
...
...
features/steps/dashboard/dashboard_issues.rb
View file @
dccd8b6e
...
@@ -13,7 +13,7 @@ class DashboardIssues < Spinach::FeatureSteps
...
@@ -13,7 +13,7 @@ class DashboardIssues < Spinach::FeatureSteps
And
'I have assigned issues'
do
And
'I have assigned issues'
do
project
=
create
:project
project
=
create
:project
project
.
add_access
(
@user
,
:read
,
:write
)
project
.
team
<<
[
@user
,
:master
]
2
.
times
{
create
:issue
,
author:
@user
,
assignee:
@user
,
project:
project
}
2
.
times
{
create
:issue
,
author:
@user
,
assignee:
@user
,
project:
project
}
end
end
...
...
features/steps/dashboard/dashboard_merge_requests.rb
View file @
dccd8b6e
...
@@ -14,8 +14,8 @@ class DashboardMergeRequests < Spinach::FeatureSteps
...
@@ -14,8 +14,8 @@ class DashboardMergeRequests < Spinach::FeatureSteps
project1
=
create
:project
project1
=
create
:project
project2
=
create
:project
project2
=
create
:project
project1
.
add_access
(
@user
,
:read
,
:write
)
project1
.
team
<<
[
@user
,
:master
]
project2
.
add_access
(
@user
,
:read
,
:write
)
project2
.
team
<<
[
@user
,
:master
]
merge_request1
=
create
:merge_request
,
author:
@user
,
project:
project1
merge_request1
=
create
:merge_request
,
author:
@user
,
project:
project1
merge_request2
=
create
:merge_request
,
author:
@user
,
project:
project2
merge_request2
=
create
:merge_request
,
author:
@user
,
project:
project2
...
...
features/steps/dashboard/dashboard_search.rb
View file @
dccd8b6e
class
DashboardSearch
<
Spinach
::
FeatureSteps
class
DashboardSearch
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedAuthentication
include
SharedPaths
include
SharedPaths
include
SharedProject
Given
'I search for "Sho"'
do
Given
'I search for "Sho"'
do
fill_in
"dashboard_search"
,
with:
"Sho"
fill_in
"dashboard_search"
,
with:
"Sho"
...
@@ -11,11 +12,6 @@ class DashboardSearch < Spinach::FeatureSteps
...
@@ -11,11 +12,6 @@ class DashboardSearch < Spinach::FeatureSteps
page
.
should
have_link
"Shop"
page
.
should
have_link
"Shop"
end
end
And
'I own project "Shop"'
do
@project
=
create
(
:project
,
:name
=>
"Shop"
)
@project
.
add_access
(
@user
,
:admin
)
end
Given
'I search for "Contibuting"'
do
Given
'I search for "Contibuting"'
do
fill_in
"dashboard_search"
,
with:
"Contibuting"
fill_in
"dashboard_search"
,
with:
"Contibuting"
click_button
"Search"
click_button
"Search"
...
...
features/steps/group/group.rb
View file @
dccd8b6e
...
@@ -13,7 +13,7 @@ class Groups < Spinach::FeatureSteps
...
@@ -13,7 +13,7 @@ class Groups < Spinach::FeatureSteps
@project
=
create
(
:project
,
group:
@group
)
@project
=
create
(
:project
,
group:
@group
)
@event
=
create
(
:closed_issue_event
,
project:
@project
)
@event
=
create
(
:closed_issue_event
,
project:
@project
)
@project
.
add_access
current_user
,
:admin
@project
.
team
<<
[
current_user
,
:master
]
end
end
And
'I should see projects activity feed'
do
And
'I should see projects activity feed'
do
...
...
features/steps/project/project_team_management.rb
View file @
dccd8b6e
...
@@ -84,18 +84,18 @@ class ProjectTeamManagement < Spinach::FeatureSteps
...
@@ -84,18 +84,18 @@ class ProjectTeamManagement < Spinach::FeatureSteps
And
'"Sam" is "Shop" developer'
do
And
'"Sam" is "Shop" developer'
do
user
=
User
.
find_by_name
(
"Sam"
)
user
=
User
.
find_by_name
(
"Sam"
)
project
=
Project
.
find_by_name
(
"Shop"
)
project
=
Project
.
find_by_name
(
"Shop"
)
project
.
add_access
(
user
,
:write
)
project
.
team
<<
[
user
,
:developer
]
end
end
Given
'I own project "Website"'
do
Given
'I own project "Website"'
do
@project
=
create
(
:project
,
:name
=>
"Website"
)
@project
=
create
(
:project
,
:name
=>
"Website"
)
@project
.
add_access
(
@user
,
:admin
)
@project
.
team
<<
[
@user
,
:master
]
end
end
And
'"Mike" is "Website" reporter'
do
And
'"Mike" is "Website" reporter'
do
user
=
User
.
find_by_name
(
"Mike"
)
user
=
User
.
find_by_name
(
"Mike"
)
project
=
Project
.
find_by_name
(
"Website"
)
project
=
Project
.
find_by_name
(
"Website"
)
project
.
add_access
(
user
,
:read
)
project
.
team
<<
[
user
,
:reporter
]
end
end
And
'I click link "Import team from another project"'
do
And
'I click link "Import team from another project"'
do
...
...
features/steps/shared/paths.rb
View file @
dccd8b6e
...
@@ -114,15 +114,15 @@ module SharedPaths
...
@@ -114,15 +114,15 @@ module SharedPaths
end
end
Given
"I visit my project's files page"
do
Given
"I visit my project's files page"
do
visit
project_tree_path
(
@project
,
@project
.
root_ref
)
visit
project_tree_path
(
@project
,
root_ref
)
end
end
Given
"I visit my project's commits page"
do
Given
"I visit my project's commits page"
do
visit
project_commits_path
(
@project
,
@project
.
root_ref
,
{
limit:
5
})
visit
project_commits_path
(
@project
,
root_ref
,
{
limit:
5
})
end
end
Given
"I visit my project's commits page for a specific path"
do
Given
"I visit my project's commits page for a specific path"
do
visit
project_commits_path
(
@project
,
@project
.
root_ref
+
"/app/models/project.rb"
,
{
limit:
5
})
visit
project_commits_path
(
@project
,
root_ref
+
"/app/models/project.rb"
,
{
limit:
5
})
end
end
Given
'I visit my project\'s commits stats page'
do
Given
'I visit my project\'s commits stats page'
do
...
@@ -174,7 +174,7 @@ module SharedPaths
...
@@ -174,7 +174,7 @@ module SharedPaths
end
end
Given
'I visit project commits page'
do
Given
'I visit project commits page'
do
visit
project_commits_path
(
@project
,
@project
.
root_ref
,
{
limit:
5
})
visit
project_commits_path
(
@project
,
root_ref
,
{
limit:
5
})
end
end
Given
'I visit project commits page for stable branch'
do
Given
'I visit project commits page for stable branch'
do
...
@@ -182,7 +182,7 @@ module SharedPaths
...
@@ -182,7 +182,7 @@ module SharedPaths
end
end
Given
'I visit project source page'
do
Given
'I visit project source page'
do
visit
project_tree_path
(
@project
,
@project
.
root_ref
)
visit
project_tree_path
(
@project
,
root_ref
)
end
end
Given
'I visit blob file from repo'
do
Given
'I visit blob file from repo'
do
...
@@ -240,4 +240,8 @@ module SharedPaths
...
@@ -240,4 +240,8 @@ module SharedPaths
Given
'I visit project wiki page'
do
Given
'I visit project wiki page'
do
visit
project_wiki_path
(
@project
,
:index
)
visit
project_wiki_path
(
@project
,
:index
)
end
end
def
root_ref
@project
.
repository
.
root_ref
end
end
end
features/steps/shared/project.rb
View file @
dccd8b6e
...
@@ -4,13 +4,13 @@ module SharedProject
...
@@ -4,13 +4,13 @@ module SharedProject
# Create a project without caring about what it's called
# Create a project without caring about what it's called
And
"I own a project"
do
And
"I own a project"
do
@project
=
create
(
:project
)
@project
=
create
(
:project
)
@project
.
add_access
(
@user
,
:admin
)
@project
.
team
<<
[
@user
,
:master
]
end
end
# Create a specific project called "Shop"
# Create a specific project called "Shop"
And
'I own project "Shop"'
do
And
'I own project "Shop"'
do
@project
=
create
(
:project
,
:name
=>
"Shop"
)
@project
=
create
(
:project
,
name:
"Shop"
)
@project
.
add_access
(
@user
,
:admin
)
@project
.
team
<<
[
@user
,
:master
]
end
end
def
current_project
def
current_project
...
...
lib/gitlab/backend/gitolite_config.rb
View file @
dccd8b6e
...
@@ -82,7 +82,7 @@ module Gitlab
...
@@ -82,7 +82,7 @@ module Gitlab
end
end
def
destroy_project
(
project
)
def
destroy_project
(
project
)
FileUtils
.
rm_rf
(
project
.
path_to_repo
)
FileUtils
.
rm_rf
(
project
.
repository
.
path_to_repo
)
conf
.
rm_repo
(
project
.
path_with_namespace
)
conf
.
rm_repo
(
project
.
path_with_namespace
)
end
end
...
@@ -138,9 +138,9 @@ module Gitlab
...
@@ -138,9 +138,9 @@ module Gitlab
::
Gitolite
::
Config
::
Repo
.
new
(
repo_name
)
::
Gitolite
::
Config
::
Repo
.
new
(
repo_name
)
end
end
name_readers
=
project
.
repository_readers
name_readers
=
project
.
team
.
repository_readers
name_writers
=
project
.
repository_writers
name_writers
=
project
.
team
.
repository_writers
name_masters
=
project
.
repository_masters
name_masters
=
project
.
team
.
repository_masters
pr_br
=
project
.
protected_branches
.
map
(
&
:name
).
join
(
"$ "
)
pr_br
=
project
.
protected_branches
.
map
(
&
:name
).
join
(
"$ "
)
...
...
lib/gitlab/markdown.rb
View file @
dccd8b6e
...
@@ -170,7 +170,7 @@ module Gitlab
...
@@ -170,7 +170,7 @@ module Gitlab
end
end
def
reference_commit
(
identifier
)
def
reference_commit
(
identifier
)
if
@project
.
valid_repo?
&&
commit
=
@project
.
commit
(
identifier
)
if
@project
.
valid_repo?
&&
commit
=
@project
.
repository
.
commit
(
identifier
)
link_to
(
identifier
,
project_commit_path
(
@project
,
commit
),
html_options
.
merge
(
title:
CommitDecorator
.
new
(
commit
).
link_title
,
class:
"gfm gfm-commit
#{
html_options
[
:class
]
}
"
))
link_to
(
identifier
,
project_commit_path
(
@project
,
commit
),
html_options
.
merge
(
title:
CommitDecorator
.
new
(
commit
).
link_title
,
class:
"gfm gfm-commit
#{
html_options
[
:class
]
}
"
))
end
end
end
end
...
...
lib/gitlab/satellite/merge_action.rb
View file @
dccd8b6e
...
@@ -31,7 +31,7 @@ module Gitlab
...
@@ -31,7 +31,7 @@ module Gitlab
merge_repo
.
git
.
push
({
raise:
true
,
timeout:
true
},
:origin
,
merge_request
.
target_branch
)
merge_repo
.
git
.
push
({
raise:
true
,
timeout:
true
},
:origin
,
merge_request
.
target_branch
)
# remove source branch
# remove source branch
if
merge_request
.
should_remove_source_branch
&&
!
project
.
root_ref?
(
merge_request
.
source_branch
)
if
merge_request
.
should_remove_source_branch
&&
!
project
.
r
epository
.
r
oot_ref?
(
merge_request
.
source_branch
)
# will raise CommandFailed when push fails
# will raise CommandFailed when push fails
merge_repo
.
git
.
push
({
raise:
true
,
timeout:
true
},
:origin
,
":
#{
merge_request
.
source_branch
}
"
)
merge_repo
.
git
.
push
({
raise:
true
,
timeout:
true
},
:origin
,
":
#{
merge_request
.
source_branch
}
"
)
end
end
...
...
spec/models/project_spec.rb
View file @
dccd8b6e
...
@@ -75,35 +75,19 @@ describe Project do
...
@@ -75,35 +75,19 @@ describe Project do
end
end
describe
"Respond to"
do
describe
"Respond to"
do
it
{
should
respond_to
(
:public?
)
}
it
{
should
respond_to
(
:private?
)
}
it
{
should
respond_to
(
:url_to_repo
)
}
it
{
should
respond_to
(
:url_to_repo
)
}
it
{
should
respond_to
(
:path_to_repo
)
}
it
{
should
respond_to
(
:path_to_repo
)
}
it
{
should
respond_to
(
:valid_repo?
)
}
it
{
should
respond_to
(
:valid_repo?
)
}
it
{
should
respond_to
(
:repo_exists?
)
}
it
{
should
respond_to
(
:repo_exists?
)
}
# Repository Role
# Repository Role
it
{
should
respond_to
(
:tree
)
}
it
{
should
respond_to
(
:root_ref
)
}
it
{
should
respond_to
(
:repo
)
}
it
{
should
respond_to
(
:tags
)
}
it
{
should
respond_to
(
:commit
)
}
it
{
should
respond_to
(
:commits
)
}
it
{
should
respond_to
(
:commits_between
)
}
it
{
should
respond_to
(
:commits_with_refs
)
}
it
{
should
respond_to
(
:commits_since
)
}
it
{
should
respond_to
(
:commits_between
)
}
it
{
should
respond_to
(
:satellite
)
}
it
{
should
respond_to
(
:satellite
)
}
it
{
should
respond_to
(
:update_repository
)
}
it
{
should
respond_to
(
:update_repository
)
}
it
{
should
respond_to
(
:destroy_repository
)
}
it
{
should
respond_to
(
:destroy_repository
)
}
it
{
should
respond_to
(
:archive_repo
)
}
it
{
should
respond_to
(
:archive_repo
)
}
# Authority Role
# Authority Role
it
{
should
respond_to
(
:add_access
)
}
it
{
should
respond_to
(
:reset_access
)
}
it
{
should
respond_to
(
:reset_access
)
}
it
{
should
respond_to
(
:repository_writers
)
}
it
{
should
respond_to
(
:repository_masters
)
}
it
{
should
respond_to
(
:repository_readers
)
}
it
{
should
respond_to
(
:allow_read_for?
)
}
it
{
should
respond_to
(
:allow_read_for?
)
}
it
{
should
respond_to
(
:guest_access_for?
)
}
it
{
should
respond_to
(
:guest_access_for?
)
}
it
{
should
respond_to
(
:report_access_for?
)
}
it
{
should
respond_to
(
:report_access_for?
)
}
...
...
spec/models/repository_spec.rb
0 → 100644
View file @
dccd8b6e
describe
Repository
do
describe
"Respond to"
do
it
{
should
respond_to
(
:repo
)
}
it
{
should
respond_to
(
:tree
)
}
it
{
should
respond_to
(
:root_ref
)
}
it
{
should
respond_to
(
:tags
)
}
it
{
should
respond_to
(
:commit
)
}
it
{
should
respond_to
(
:commits
)
}
it
{
should
respond_to
(
:commits_between
)
}
it
{
should
respond_to
(
:commits_with_refs
)
}
it
{
should
respond_to
(
:commits_since
)
}
it
{
should
respond_to
(
:commits_between
)
}
end
end
spec/models/system_hook_spec.rb
View file @
dccd8b6e
...
@@ -56,7 +56,7 @@ describe SystemHook do
...
@@ -56,7 +56,7 @@ describe SystemHook do
user
=
create
(
:user
)
user
=
create
(
:user
)
project
=
create
(
:project
)
project
=
create
(
:project
)
with_resque
do
with_resque
do
project
.
add_access
(
user
,
:admin
)
project
.
team
<<
[
user
,
:master
]
end
end
WebMock
.
should
have_requested
(
:post
,
@system_hook
.
url
).
with
(
body:
/user_add_to_team/
).
once
WebMock
.
should
have_requested
(
:post
,
@system_hook
.
url
).
with
(
body:
/user_add_to_team/
).
once
end
end
...
@@ -64,7 +64,7 @@ describe SystemHook do
...
@@ -64,7 +64,7 @@ describe SystemHook do
it
"project_destroy hook"
do
it
"project_destroy hook"
do
user
=
create
(
:user
)
user
=
create
(
:user
)
project
=
create
(
:project
)
project
=
create
(
:project
)
project
.
add_access
(
user
,
:admin
)
project
.
team
<<
[
user
,
:master
]
with_resque
do
with_resque
do
project
.
users_projects
.
clear
project
.
users_projects
.
clear
end
end
...
...
spec/models/team_spec.rb
0 → 100644
View file @
dccd8b6e
describe
Team
do
describe
"Respond to"
do
it
{
should
respond_to
(
:developers
)
}
it
{
should
respond_to
(
:masters
)
}
it
{
should
respond_to
(
:reporters
)
}
it
{
should
respond_to
(
:guests
)
}
it
{
should
respond_to
(
:repository_writers
)
}
it
{
should
respond_to
(
:repository_masters
)
}
it
{
should
respond_to
(
:repository_readers
)
}
end
end
spec/models/users_project_spec.rb
View file @
dccd8b6e
...
@@ -48,10 +48,10 @@ describe UsersProject do
...
@@ -48,10 +48,10 @@ describe UsersProject do
@user_1
=
create
:user
@user_1
=
create
:user
@user_2
=
create
:user
@user_2
=
create
:user
@project_1
.
add_access
@user_1
,
:write
@project_1
.
team
<<
[
@user_1
,
:developer
]
@project_2
.
add_access
@user_2
,
:read
@project_2
.
team
<<
[
@user_2
,
:reporter
]
@status
=
UsersProject
.
import_team
(
@project_1
,
@project_2
)
@status
=
@project_2
.
team
.
import
(
@project_1
)
end
end
it
{
@status
.
should
be_true
}
it
{
@status
.
should
be_true
}
...
@@ -101,8 +101,8 @@ describe UsersProject do
...
@@ -101,8 +101,8 @@ describe UsersProject do
@user_1
=
create
:user
@user_1
=
create
:user
@user_2
=
create
:user
@user_2
=
create
:user
@project_1
.
add_access
@user_1
,
:write
@project_1
.
team
<<
[
@user_1
,
:developer
]
@project_2
.
add_access
@user_2
,
:read
@project_2
.
team
<<
[
@user_2
,
:reporter
]
UsersProject
.
truncate_teams
([
@project_1
.
id
,
@project_2
.
id
])
UsersProject
.
truncate_teams
([
@project_1
.
id
,
@project_2
.
id
])
end
end
...
...
spec/requests/issues_spec.rb
View file @
dccd8b6e
...
@@ -7,8 +7,7 @@ describe "Issues" do
...
@@ -7,8 +7,7 @@ describe "Issues" do
login_as
:user
login_as
:user
user2
=
create
(
:user
)
user2
=
create
(
:user
)
project
.
add_access
(
@user
,
:read
,
:write
)
project
.
team
<<
[[
@user
,
user2
],
:developer
]
project
.
add_access
(
user2
,
:read
,
:write
)
end
end
describe
"Edit issue"
do
describe
"Edit issue"
do
...
...
spec/requests/projects_spec.rb
View file @
dccd8b6e
...
@@ -6,7 +6,7 @@ describe "Projects" do
...
@@ -6,7 +6,7 @@ describe "Projects" do
describe
"GET /projects/show"
do
describe
"GET /projects/show"
do
before
do
before
do
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
.
add_access
(
@user
,
:read
)
@project
.
team
<<
[
@user
,
:reporter
]
visit
project_path
(
@project
)
visit
project_path
(
@project
)
end
end
...
@@ -19,7 +19,7 @@ describe "Projects" do
...
@@ -19,7 +19,7 @@ describe "Projects" do
describe
"GET /projects/:id/edit"
do
describe
"GET /projects/:id/edit"
do
before
do
before
do
@project
=
create
(
:project
)
@project
=
create
(
:project
)
@project
.
add_access
(
@user
,
:admin
,
:read
)
@project
.
team
<<
[
@user
,
:master
]
visit
edit_project_path
(
@project
)
visit
edit_project_path
(
@project
)
end
end
...
@@ -38,7 +38,7 @@ describe "Projects" do
...
@@ -38,7 +38,7 @@ describe "Projects" do
describe
"PUT /projects/:id"
do
describe
"PUT /projects/:id"
do
before
do
before
do
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
.
add_access
(
@user
,
:admin
,
:read
)
@project
.
team
<<
[
@user
,
:master
]
visit
edit_project_path
(
@project
)
visit
edit_project_path
(
@project
)
...
@@ -59,7 +59,7 @@ describe "Projects" do
...
@@ -59,7 +59,7 @@ describe "Projects" do
describe
"DELETE /projects/:id"
do
describe
"DELETE /projects/:id"
do
before
do
before
do
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
.
add_access
(
@user
,
:read
,
:admin
)
@project
.
team
<<
[
@user
,
:master
]
visit
edit_project_path
(
@project
)
visit
edit_project_path
(
@project
)
end
end
...
...
spec/support/stubbed_repository.rb
View file @
dccd8b6e
# Stubs out all Git repository access done by models so that specs can run
# Stubs out all Git repository access done by models so that specs can run
# against fake repositories without Grit complaining that they don't exist.
# against fake repositories without Grit complaining that they don't exist.
class
Project
class
Project
def
path_to_repo
if
new_record?
||
path
==
'newproject'
# There are a couple Project specs and features that expect the Project's
# path to be in the returned path, so let's patronize them.
Rails
.
root
.
join
(
'tmp'
,
'repositories'
,
path
)
else
# For everything else, just give it the path to one of our real seeded
# repos.
Rails
.
root
.
join
(
'tmp'
,
'repositories'
,
'gitlabhq'
)
end
end
def
satellite
def
satellite
FakeSatellite
.
new
FakeSatellite
.
new
end
end
...
@@ -27,3 +15,9 @@ class Project
...
@@ -27,3 +15,9 @@ class Project
end
end
end
end
end
end
class
Repository
def
repo
@repo
||=
Grit
::
Repo
.
new
(
Rails
.
root
.
join
(
'tmp'
,
'repositories'
,
'gitlabhq'
))
end
end
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