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
2e719bda
Commit
2e719bda
authored
Aug 24, 2018
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't trigger project deletion hooks twice when removing a group
parent
a32a410f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
app/models/project.rb
app/models/project.rb
+2
-3
app/services/groups/destroy_service.rb
app/services/groups/destroy_service.rb
+4
-1
spec/services/groups/destroy_service_spec.rb
spec/services/groups/destroy_service_spec.rb
+8
-0
No files found.
app/models/project.rb
View file @
2e719bda
...
@@ -85,8 +85,7 @@ class Project < ActiveRecord::Base
...
@@ -85,8 +85,7 @@ class Project < ActiveRecord::Base
after_create
:create_project_feature
,
unless: :project_feature
after_create
:create_project_feature
,
unless: :project_feature
after_create
->
{
SiteStatistic
.
track
(
STATISTICS_ATTRIBUTE
)
}
after_create
->
{
SiteStatistic
.
track
(
STATISTICS_ATTRIBUTE
)
}
before_destroy
->
(
project
)
{
project
.
project_feature
}
# keep reference so we can untrack later
before_destroy
:untrack_site_statistics
after_destroy
:untrack_site_statistics
after_create
:create_ci_cd_settings
,
after_create
:create_ci_cd_settings
,
unless: :ci_cd_settings
,
unless: :ci_cd_settings
,
...
@@ -2095,7 +2094,7 @@ class Project < ActiveRecord::Base
...
@@ -2095,7 +2094,7 @@ class Project < ActiveRecord::Base
def
untrack_site_statistics
def
untrack_site_statistics
SiteStatistic
.
untrack
(
STATISTICS_ATTRIBUTE
)
SiteStatistic
.
untrack
(
STATISTICS_ATTRIBUTE
)
SiteStatistic
.
project_feature
.
untrack_statistics_for_deletion!
self
.
project_feature
.
untrack_statistics_for_deletion!
end
end
def
execute_rename_repository_hooks!
(
full_path_before
)
def
execute_rename_repository_hooks!
(
full_path_before
)
...
...
app/services/groups/destroy_service.rb
View file @
2e719bda
...
@@ -12,12 +12,15 @@ module Groups
...
@@ -12,12 +12,15 @@ module Groups
def
execute
def
execute
group
.
prepare_for_destroy
group
.
prepare_for_destroy
group
.
projects
.
each
do
|
project
|
group
.
projects
.
includes
(
:project_feature
).
each
do
|
project
|
# Execute the destruction of the models immediately to ensure atomic cleanup.
# Execute the destruction of the models immediately to ensure atomic cleanup.
success
=
::
Projects
::
DestroyService
.
new
(
project
,
current_user
).
execute
success
=
::
Projects
::
DestroyService
.
new
(
project
,
current_user
).
execute
raise
DestroyError
,
"Project
#{
project
.
id
}
can't be deleted"
unless
success
raise
DestroyError
,
"Project
#{
project
.
id
}
can't be deleted"
unless
success
end
end
# reload the relation to prevent triggering destroy hooks on the projects again
group
.
projects
.
reload
group
.
children
.
each
do
|
group
|
group
.
children
.
each
do
|
group
|
# This needs to be synchronous since the namespace gets destroyed below
# This needs to be synchronous since the namespace gets destroyed below
DestroyService
.
new
(
group
,
current_user
).
execute
DestroyService
.
new
(
group
,
current_user
).
execute
...
...
spec/services/groups/destroy_service_spec.rb
View file @
2e719bda
...
@@ -35,6 +35,14 @@ describe Groups::DestroyService do
...
@@ -35,6 +35,14 @@ describe Groups::DestroyService do
it
{
expect
(
NotificationSetting
.
unscoped
.
all
).
not_to
include
(
notification_setting
)
}
it
{
expect
(
NotificationSetting
.
unscoped
.
all
).
not_to
include
(
notification_setting
)
}
end
end
context
'site statistics'
do
it
'doesnt trigger project deletion hooks twice'
do
expect_any_instance_of
(
Project
).
to
receive
(
:untrack_site_statistics
).
once
destroy_group
(
group
,
user
,
async
)
end
end
context
'mattermost team'
do
context
'mattermost team'
do
let!
(
:chat_team
)
{
create
(
:chat_team
,
namespace:
group
)
}
let!
(
:chat_team
)
{
create
(
:chat_team
,
namespace:
group
)
}
...
...
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