BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
cfc932ca
Commit
cfc932ca
authored
Nov 06, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jk-delete-epic-backport' into 'master'
Refactor issuable destroy action See merge request gitlab-org/gitlab-ce!15203
parents
a6fad00c
906d2f03
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
37 deletions
+24
-37
issuable_actions.rb
app/controllers/concerns/issuable_actions.rb
+6
-3
todo_service.rb
app/services/todo_service.rb
+3
-15
migrate_to_ghost_user_service.rb
app/services/users/migrate_to_ghost_user_service.rb
+11
-7
issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+1
-1
merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+1
-1
todo_service_spec.rb
spec/services/todo_service_spec.rb
+2
-10
No files found.
app/controllers/concerns/issuable_actions.rb
View file @
cfc932ca
...
@@ -57,12 +57,11 @@ module IssuableActions
...
@@ -57,12 +57,11 @@ module IssuableActions
def
destroy
def
destroy
issuable
.
destroy
issuable
.
destroy
destroy_method
=
"destroy_
#{
issuable
.
class
.
name
.
underscore
}
"
.
to_sym
TodoService
.
new
.
destroy_issuable
(
issuable
,
current_user
)
TodoService
.
new
.
public_send
(
destroy_method
,
issuable
,
current_user
)
# rubocop:disable GitlabSecurity/PublicSend
name
=
issuable
.
human_class_name
name
=
issuable
.
human_class_name
flash
[
:notice
]
=
"The
#{
name
}
was successfully deleted."
flash
[
:notice
]
=
"The
#{
name
}
was successfully deleted."
index_path
=
polymorphic_path
([
@project
.
namespace
.
becomes
(
Namespace
),
@projec
t
,
issuable
.
class
])
index_path
=
polymorphic_path
([
paren
t
,
issuable
.
class
])
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
index_path
}
format
.
html
{
redirect_to
index_path
}
...
@@ -164,4 +163,8 @@ module IssuableActions
...
@@ -164,4 +163,8 @@ module IssuableActions
def
update_service
def
update_service
raise
NotImplementedError
raise
NotImplementedError
end
end
def
parent
@project
||
@group
end
end
end
app/services/todo_service.rb
View file @
cfc932ca
...
@@ -31,12 +31,12 @@ class TodoService
...
@@ -31,12 +31,12 @@ class TodoService
mark_pending_todos_as_done
(
issue
,
current_user
)
mark_pending_todos_as_done
(
issue
,
current_user
)
end
end
# When we destroy an issue we should:
# When we destroy an issu
abl
e we should:
#
#
# * refresh the todos count cache for the current user
# * refresh the todos count cache for the current user
#
#
def
destroy_issu
e
(
issue
,
current_
user
)
def
destroy_issu
able
(
issuable
,
user
)
destroy_issuable
(
issue
,
current_user
)
user
.
update_todos_count_cache
end
end
# When we reassign an issue we should:
# When we reassign an issue we should:
...
@@ -72,14 +72,6 @@ class TodoService
...
@@ -72,14 +72,6 @@ class TodoService
mark_pending_todos_as_done
(
merge_request
,
current_user
)
mark_pending_todos_as_done
(
merge_request
,
current_user
)
end
end
# When we destroy a merge request we should:
#
# * refresh the todos count cache for the current user
#
def
destroy_merge_request
(
merge_request
,
current_user
)
destroy_issuable
(
merge_request
,
current_user
)
end
# When we reassign a merge request we should:
# When we reassign a merge request we should:
#
#
# * creates a pending todo for new assignee if merge request is assigned
# * creates a pending todo for new assignee if merge request is assigned
...
@@ -234,10 +226,6 @@ class TodoService
...
@@ -234,10 +226,6 @@ class TodoService
create_mention_todos
(
issuable
.
project
,
issuable
,
author
,
nil
,
skip_users
)
create_mention_todos
(
issuable
.
project
,
issuable
,
author
,
nil
,
skip_users
)
end
end
def
destroy_issuable
(
issuable
,
user
)
user
.
update_todos_count_cache
end
def
toggling_tasks?
(
issuable
)
def
toggling_tasks?
(
issuable
)
issuable
.
previous_changes
.
include?
(
'description'
)
&&
issuable
.
previous_changes
.
include?
(
'description'
)
&&
issuable
.
tasks?
&&
issuable
.
updated_tasks
.
any?
issuable
.
tasks?
&&
issuable
.
updated_tasks
.
any?
...
...
app/services/users/migrate_to_ghost_user_service.rb
View file @
cfc932ca
...
@@ -25,7 +25,7 @@ module Users
...
@@ -25,7 +25,7 @@ module Users
user
.
block
user
.
block
# Reverse the user block if record migration fails
# Reverse the user block if record migration fails
if
!
migrate_records
&&
transition
if
!
migrate_records
_in_transaction
&&
transition
transition
.
rollback
transition
.
rollback
user
.
save!
user
.
save!
end
end
...
@@ -36,18 +36,22 @@ module Users
...
@@ -36,18 +36,22 @@ module Users
private
private
def
migrate_records
def
migrate_records
_in_transaction
user
.
transaction
(
requires_new:
true
)
do
user
.
transaction
(
requires_new:
true
)
do
@ghost_user
=
User
.
ghost
@ghost_user
=
User
.
ghost
migrate_issues
migrate_records
migrate_merge_requests
migrate_notes
migrate_abuse_reports
migrate_award_emojis
end
end
end
end
def
migrate_records
migrate_issues
migrate_merge_requests
migrate_notes
migrate_abuse_reports
migrate_award_emojis
end
def
migrate_issues
def
migrate_issues
user
.
issues
.
update_all
(
author_id:
ghost_user
.
id
)
user
.
issues
.
update_all
(
author_id:
ghost_user
.
id
)
Issue
.
where
(
last_edited_by_id:
user
.
id
).
update_all
(
last_edited_by_id:
ghost_user
.
id
)
Issue
.
where
(
last_edited_by_id:
user
.
id
).
update_all
(
last_edited_by_id:
ghost_user
.
id
)
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
cfc932ca
...
@@ -861,7 +861,7 @@ describe Projects::IssuesController do
...
@@ -861,7 +861,7 @@ describe Projects::IssuesController do
end
end
it
'delegates the update of the todos count cache to TodoService'
do
it
'delegates the update of the todos count cache to TodoService'
do
expect_any_instance_of
(
TodoService
).
to
receive
(
:destroy_issue
).
with
(
issue
,
owner
).
once
expect_any_instance_of
(
TodoService
).
to
receive
(
:destroy_issu
abl
e
).
with
(
issue
,
owner
).
once
delete
:destroy
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
issue
.
iid
delete
:destroy
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
issue
.
iid
end
end
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
cfc932ca
...
@@ -456,7 +456,7 @@ describe Projects::MergeRequestsController do
...
@@ -456,7 +456,7 @@ describe Projects::MergeRequestsController do
end
end
it
'delegates the update of the todos count cache to TodoService'
do
it
'delegates the update of the todos count cache to TodoService'
do
expect_any_instance_of
(
TodoService
).
to
receive
(
:destroy_
merge_request
).
with
(
merge_request
,
owner
).
once
expect_any_instance_of
(
TodoService
).
to
receive
(
:destroy_
issuable
).
with
(
merge_request
,
owner
).
once
delete
:destroy
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
merge_request
.
iid
delete
:destroy
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
merge_request
.
iid
end
end
...
...
spec/services/todo_service_spec.rb
View file @
cfc932ca
...
@@ -248,11 +248,11 @@ describe TodoService do
...
@@ -248,11 +248,11 @@ describe TodoService do
end
end
end
end
describe
'#destroy_issue'
do
describe
'#destroy_issu
abl
e'
do
it
'refresh the todos count cache for the user'
do
it
'refresh the todos count cache for the user'
do
expect
(
john_doe
).
to
receive
(
:update_todos_count_cache
).
and_call_original
expect
(
john_doe
).
to
receive
(
:update_todos_count_cache
).
and_call_original
service
.
destroy_issue
(
issue
,
john_doe
)
service
.
destroy_issu
abl
e
(
issue
,
john_doe
)
end
end
end
end
...
@@ -643,14 +643,6 @@ describe TodoService do
...
@@ -643,14 +643,6 @@ describe TodoService do
end
end
end
end
describe
'#destroy_merge_request'
do
it
'refresh the todos count cache for the user'
do
expect
(
john_doe
).
to
receive
(
:update_todos_count_cache
).
and_call_original
service
.
destroy_merge_request
(
mr_assigned
,
john_doe
)
end
end
describe
'#reassigned_merge_request'
do
describe
'#reassigned_merge_request'
do
it
'creates a pending todo for new assignee'
do
it
'creates a pending todo for new assignee'
do
mr_unassigned
.
update_attribute
(
:assignee
,
john_doe
)
mr_unassigned
.
update_attribute
(
:assignee
,
john_doe
)
...
...
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