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
Jérome Perrin
gitlab-ce
Commits
a56ada0a
Commit
a56ada0a
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 issue
parent
e81061a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
0 deletions
+35
-0
app/services/issues/close_service.rb
app/services/issues/close_service.rb
+2
-0
app/services/task_service.rb
app/services/task_service.rb
+8
-0
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+8
-0
spec/services/task_service_spec.rb
spec/services/task_service_spec.rb
+17
-0
No files found.
app/services/issues/close_service.rb
View file @
a56ada0a
...
@@ -3,6 +3,7 @@ module Issues
...
@@ -3,6 +3,7 @@ module Issues
def
execute
(
issue
,
commit
=
nil
)
def
execute
(
issue
,
commit
=
nil
)
if
project
.
jira_tracker?
&&
project
.
jira_service
.
active
if
project
.
jira_tracker?
&&
project
.
jira_service
.
active
project
.
jira_service
.
execute
(
commit
,
issue
)
project
.
jira_service
.
execute
(
commit
,
issue
)
task_service
.
close_issue
(
issue
,
current_user
)
return
issue
return
issue
end
end
...
@@ -10,6 +11,7 @@ module Issues
...
@@ -10,6 +11,7 @@ module Issues
event_service
.
close_issue
(
issue
,
current_user
)
event_service
.
close_issue
(
issue
,
current_user
)
create_note
(
issue
,
commit
)
create_note
(
issue
,
commit
)
notification_service
.
close_issue
(
issue
,
current_user
)
notification_service
.
close_issue
(
issue
,
current_user
)
task_service
.
close_issue
(
issue
,
current_user
)
execute_hooks
(
issue
,
'close'
)
execute_hooks
(
issue
,
'close'
)
end
end
...
...
app/services/task_service.rb
View file @
a56ada0a
...
@@ -16,6 +16,14 @@ class TaskService
...
@@ -16,6 +16,14 @@ class TaskService
end
end
end
end
# When close an issue we should:
#
# * mark all pending tasks related to the target for the current user as done
#
def
close_issue
(
issue
,
current_user
)
mark_as_done
(
issue
,
current_user
)
end
# When we reassign an issue we should:
# When we reassign an issue we should:
#
#
# * creates a pending task for new assignee if issue is assigned
# * creates a pending task for new assignee if issue is assigned
...
...
spec/services/issues/close_service_spec.rb
View file @
a56ada0a
...
@@ -5,6 +5,9 @@ describe Issues::CloseService, services: true do
...
@@ -5,6 +5,9 @@ describe Issues::CloseService, services: true do
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
assignee:
user2
)
}
let
(
:issue
)
{
create
(
:issue
,
assignee:
user2
)
}
let
(
:project
)
{
issue
.
project
}
let
(
:project
)
{
issue
.
project
}
let!
(
:pending_task
)
do
create
(
:pending_assigned_task
,
user:
user
,
project:
project
,
target:
issue
,
author:
user2
)
end
before
do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
...
@@ -32,6 +35,10 @@ describe Issues::CloseService, services: true do
...
@@ -32,6 +35,10 @@ describe Issues::CloseService, services: true do
note
=
@issue
.
notes
.
last
note
=
@issue
.
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
context
"external issue tracker"
do
context
"external issue tracker"
do
...
@@ -42,6 +49,7 @@ describe Issues::CloseService, services: true do
...
@@ -42,6 +49,7 @@ describe Issues::CloseService, services: true do
it
{
expect
(
@issue
).
to
be_valid
}
it
{
expect
(
@issue
).
to
be_valid
}
it
{
expect
(
@issue
).
to
be_opened
}
it
{
expect
(
@issue
).
to
be_opened
}
it
{
expect
(
pending_task
.
reload
).
to
be_pending
}
end
end
end
end
end
end
spec/services/task_service_spec.rb
View file @
a56ada0a
...
@@ -31,6 +31,23 @@ describe TaskService, services: true do
...
@@ -31,6 +31,23 @@ describe TaskService, services: true do
end
end
end
end
describe
'#close_issue'
do
let!
(
:first_pending_task
)
do
create
(
:pending_assigned_task
,
user:
john_doe
,
project:
project
,
target:
assigned_issue
,
author:
author
)
end
let!
(
:second_pending_task
)
do
create
(
:pending_assigned_task
,
user:
john_doe
,
project:
project
,
target:
assigned_issue
,
author:
author
)
end
it
'marks related pending tasks to the target for the user as done'
do
service
.
close_issue
(
assigned_issue
,
john_doe
)
expect
(
first_pending_task
.
reload
.
done?
).
to
eq
true
expect
(
second_pending_task
.
reload
.
done?
).
to
eq
true
end
end
describe
'#reassigned_issue'
do
describe
'#reassigned_issue'
do
it
'creates a pending task for new assignee'
do
it
'creates a pending task for new assignee'
do
unassigned_issue
.
update_attribute
(
:assignee
,
john_doe
)
unassigned_issue
.
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