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
c86b12bf
Commit
c86b12bf
authored
Feb 16, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Marks pending tasks for an user as done when he close the MR
parent
7bed6ee2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
1 deletion
+34
-1
app/services/merge_requests/close_service.rb
app/services/merge_requests/close_service.rb
+1
-0
app/services/task_service.rb
app/services/task_service.rb
+9
-1
spec/services/merge_requests/close_service_spec.rb
spec/services/merge_requests/close_service_spec.rb
+7
-0
spec/services/task_service_spec.rb
spec/services/task_service_spec.rb
+17
-0
No files found.
app/services/merge_requests/close_service.rb
View file @
c86b12bf
...
@@ -9,6 +9,7 @@ module MergeRequests
...
@@ -9,6 +9,7 @@ module MergeRequests
event_service
.
close_mr
(
merge_request
,
current_user
)
event_service
.
close_mr
(
merge_request
,
current_user
)
create_note
(
merge_request
)
create_note
(
merge_request
)
notification_service
.
close_mr
(
merge_request
,
current_user
)
notification_service
.
close_mr
(
merge_request
,
current_user
)
task_service
.
close_merge_request
(
merge_request
,
current_user
)
execute_hooks
(
merge_request
,
'close'
)
execute_hooks
(
merge_request
,
'close'
)
end
end
...
...
app/services/task_service.rb
View file @
c86b12bf
...
@@ -38,7 +38,15 @@ class TaskService
...
@@ -38,7 +38,15 @@ class TaskService
new_issuable
(
merge_request
,
current_user
)
new_issuable
(
merge_request
,
current_user
)
end
end
# When we reassign an merge request we should:
# When close a merge request we should:
#
# * mark all pending tasks related to the target for the current user as done
#
def
close_merge_request
(
merge_request
,
current_user
)
mark_as_done
(
merge_request
,
current_user
)
end
# When we reassign a merge request we should:
#
#
# * creates a pending task for new assignee if merge request is assigned
# * creates a pending task for new assignee if merge request is assigned
#
#
...
...
spec/services/merge_requests/close_service_spec.rb
View file @
c86b12bf
...
@@ -5,6 +5,9 @@ describe MergeRequests::CloseService, services: true do
...
@@ -5,6 +5,9 @@ describe MergeRequests::CloseService, services: true do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
assignee:
user2
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
assignee:
user2
)
}
let
(
:project
)
{
merge_request
.
project
}
let
(
:project
)
{
merge_request
.
project
}
let!
(
:pending_task
)
do
create
(
:pending_assigned_task
,
user:
user
,
project:
project
,
target:
merge_request
,
author:
user2
)
end
before
do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
...
@@ -41,6 +44,10 @@ describe MergeRequests::CloseService, services: true do
...
@@ -41,6 +44,10 @@ describe MergeRequests::CloseService, services: true do
note
=
@merge_request
.
notes
.
last
note
=
@merge_request
.
notes
.
last
expect
(
note
.
note
).
to
include
'Status changed to closed'
expect
(
note
.
note
).
to
include
'Status changed to closed'
end
end
it
'marks pending tasks as done'
do
expect
(
pending_task
.
reload
).
to
be_done
end
end
end
end
end
end
end
spec/services/task_service_spec.rb
View file @
c86b12bf
...
@@ -136,6 +136,23 @@ describe TaskService, services: true do
...
@@ -136,6 +136,23 @@ describe TaskService, services: true do
end
end
end
end
describe
'#close_merge_request'
do
let!
(
:first_pending_task
)
do
create
(
:pending_assigned_task
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
end
let!
(
:second_pending_task
)
do
create
(
:pending_assigned_task
,
user:
john_doe
,
project:
project
,
target:
mr_assigned
,
author:
author
)
end
it
'marks related pending tasks to the target for the user as done'
do
service
.
close_merge_request
(
mr_assigned
,
john_doe
)
expect
(
first_pending_task
.
reload
).
to
be_done
expect
(
second_pending_task
.
reload
).
to
be_done
end
end
describe
'#reassigned_merge_request'
do
describe
'#reassigned_merge_request'
do
it
'creates a pending task for new assignee'
do
it
'creates a pending task 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