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
Kazuhiko Shiozaki
gitlab-ce
Commits
73f91da8
Commit
73f91da8
authored
Jun 17, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix project deletion and tests
parent
6d352790
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
40 deletions
+13
-40
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+1
-2
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+3
-2
spec/models/event_spec.rb
spec/models/event_spec.rb
+0
-22
spec/models/system_hook_spec.rb
spec/models/system_hook_spec.rb
+4
-3
spec/services/projects/create_service_spec.rb
spec/services/projects/create_service_spec.rb
+5
-11
No files found.
app/controllers/projects_controller.rb
View file @
73f91da8
...
...
@@ -98,8 +98,7 @@ class ProjectsController < ApplicationController
def
destroy
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
project
)
project
.
team
.
truncate
project
.
destroy
::
Projects
::
DestroyService
.
new
(
@project
,
current_user
,
{}).
execute
respond_to
do
|
format
|
format
.
html
{
redirect_to
root_path
}
...
...
app/services/projects/destroy_service.rb
View file @
73f91da8
module
Projects
class
Update
Service
<
BaseService
def
execute
(
role
=
:default
)
class
Destroy
Service
<
BaseService
def
execute
return
false
unless
can?
(
current_user
,
:remove_project
,
project
)
project
.
team
.
truncate
project
.
repository
.
expire_cache
unless
project
.
empty_repo?
if
project
.
destroy
...
...
spec/models/event_spec.rb
View file @
73f91da8
...
...
@@ -65,26 +65,4 @@ describe Event do
it
{
@event
.
branch_name
.
should
==
"master"
}
it
{
@event
.
author
.
should
==
@user
}
end
describe
'Team events'
do
let
(
:user_project
)
{
double
.
as_null_object
}
let
(
:observer
)
{
UsersProjectObserver
.
instance
}
before
{
Event
.
should_receive
:create
observer
.
stub
(
notification:
double
.
as_null_object
)
}
describe
"Joined project team"
do
it
"should create event"
do
observer
.
after_create
user_project
end
end
describe
"Left project team"
do
it
"should create event"
do
observer
.
after_destroy
user_project
end
end
end
end
spec/models/system_hook_spec.rb
View file @
73f91da8
...
...
@@ -25,13 +25,14 @@ describe SystemHook do
end
it
"project_create hook"
do
project
=
create
(
:project
)
Projects
::
CreateService
.
new
(
create
(
:user
),
name:
'empty'
).
execute
WebMock
.
should
have_requested
(
:post
,
@system_hook
.
url
).
with
(
body:
/project_create/
).
once
end
it
"project_destroy hook"
do
project
=
create
(
:project
)
project
.
destroy
user
=
create
(
:user
)
project
=
create
(
:empty_project
,
namespace:
user
.
namespace
)
Projects
::
DestroyService
.
new
(
project
,
user
,
{}).
execute
WebMock
.
should
have_requested
(
:post
,
@system_hook
.
url
).
with
(
body:
/project_destroy/
).
once
end
...
...
spec/services/projects/create_service_spec.rb
View file @
73f91da8
...
...
@@ -63,11 +63,8 @@ describe Projects::CreateService do
@settings
.
stub
(
:merge_requests
)
{
true
}
@settings
.
stub
(
:wiki
)
{
true
}
@settings
.
stub
(
:snippets
)
{
true
}
stub_const
(
"Settings"
,
Class
.
new
)
@restrictions
=
double
(
"restrictions"
)
@restrictions
.
stub
(
:restricted_visibility_levels
)
{
[]
}
Settings
.
stub_chain
(
:gitlab
).
and_return
(
@restrictions
)
Settings
.
stub_chain
(
:gitlab
,
:default_projects_features
).
and_return
(
@settings
)
Gitlab
.
config
.
gitlab
.
stub
(
restricted_visibility_levels:
[])
Gitlab
.
config
.
gitlab
.
stub
(
:default_projects_features
).
and_return
(
@settings
)
end
context
'should be public when setting is public'
do
...
...
@@ -106,11 +103,9 @@ describe Projects::CreateService do
@settings
.
stub
(
:wiki
)
{
true
}
@settings
.
stub
(
:snippets
)
{
true
}
@settings
.
stub
(
:visibility_level
)
{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
stub_const
(
"Settings"
,
Class
.
new
)
@restrictions
=
double
(
"restrictions"
)
@restrictions
.
stub
(
:restricted_visibility_levels
)
{
[
Gitlab
::
VisibilityLevel
::
PUBLIC
]
}
Settings
.
stub_chain
(
:gitlab
).
and_return
(
@restrictions
)
Settings
.
stub_chain
(
:gitlab
,
:default_projects_features
).
and_return
(
@settings
)
@restrictions
=
[
Gitlab
::
VisibilityLevel
::
PUBLIC
]
Gitlab
.
config
.
gitlab
.
stub
(
restricted_visibility_levels:
@restrictions
)
Gitlab
.
config
.
gitlab
.
stub
(
:default_projects_features
).
and_return
(
@settings
)
end
context
'should be private when option is public'
do
...
...
@@ -155,4 +150,3 @@ describe Projects::CreateService do
Projects
::
CreateService
.
new
(
user
,
opts
).
execute
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