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
a581942a
Commit
a581942a
authored
Oct 08, 2018
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create system notes for epic close and reopen
parent
e11f5a61
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
3 deletions
+42
-3
app/services/system_note_service.rb
app/services/system_note_service.rb
+1
-1
ee/app/services/epics/close_service.rb
ee/app/services/epics/close_service.rb
+1
-0
ee/app/services/epics/reopen_service.rb
ee/app/services/epics/reopen_service.rb
+9
-2
ee/changelogs/unreleased/7015-epic-states-notes.yml
ee/changelogs/unreleased/7015-epic-states-notes.yml
+5
-0
ee/spec/services/epics/close_service_spec.rb
ee/spec/services/epics/close_service_spec.rb
+13
-0
ee/spec/services/epics/reopen_service_spec.rb
ee/spec/services/epics/reopen_service_spec.rb
+13
-0
No files found.
app/services/system_note_service.rb
View file @
a581942a
...
...
@@ -212,7 +212,7 @@ module SystemNoteService
# "closed via bc17db76"
#
# Returns the created Note object
def
change_status
(
noteable
,
project
,
author
,
status
,
source
)
def
change_status
(
noteable
,
project
,
author
,
status
,
source
=
nil
)
body
=
status
.
dup
body
<<
" via
#{
source
.
gfm_reference
(
project
)
}
"
if
source
...
...
ee/app/services/epics/close_service.rb
View file @
a581942a
...
...
@@ -13,6 +13,7 @@ module Epics
def
close_epic
(
epic
)
if
epic
.
close
epic
.
update
(
closed_by:
current_user
)
SystemNoteService
.
change_status
(
epic
,
nil
,
current_user
,
epic
.
state
)
end
end
end
...
...
ee/app/services/epics/reopen_service.rb
View file @
a581942a
...
...
@@ -5,8 +5,15 @@ module Epics
def
execute
(
epic
)
return
epic
unless
can?
(
current_user
,
:update_epic
,
epic
)
epic
.
reopen
epic
reopen_epic
(
epic
)
end
private
def
reopen_epic
(
epic
)
if
epic
.
reopen
SystemNoteService
.
change_status
(
epic
,
nil
,
current_user
,
epic
.
state
)
end
end
end
end
ee/changelogs/unreleased/7015-epic-states-notes.yml
0 → 100644
View file @
a581942a
---
title
:
Create system notes for epic close and reopen
merge_request
:
7850
author
:
type
:
added
ee/spec/services/epics/close_service_spec.rb
View file @
a581942a
...
...
@@ -41,6 +41,15 @@ describe Epics::CloseService do
it
'changes closed_at'
do
expect
{
subject
.
execute
(
epic
)
}.
to
change
{
epic
.
closed_at
}
end
it
'creates a system note about epic close'
do
expect
{
subject
.
execute
(
epic
)
}.
to
change
{
epic
.
notes
.
count
}.
by
(
1
)
note
=
epic
.
notes
.
last
expect
(
note
.
note
).
to
eq
(
'closed'
)
expect
(
note
.
system_note_metadata
.
action
).
to
eq
(
'closed'
)
end
end
context
'when trying to close a closed epic'
do
...
...
@@ -59,6 +68,10 @@ describe Epics::CloseService do
it
'does not change closed_by'
do
expect
{
subject
.
execute
(
epic
)
}.
not_to
change
{
epic
.
closed_by
}
end
it
'does not create a system note'
do
expect
{
subject
.
execute
(
epic
)
}.
not_to
change
{
epic
.
notes
.
count
}
end
end
end
...
...
ee/spec/services/epics/reopen_service_spec.rb
View file @
a581942a
...
...
@@ -41,6 +41,15 @@ describe Epics::ReopenService do
it
'removes closed_at'
do
expect
{
subject
.
execute
(
epic
)
}.
to
change
{
epic
.
closed_at
}.
to
(
nil
)
end
it
'creates a system note about epic reopen'
do
expect
{
subject
.
execute
(
epic
)
}.
to
change
{
epic
.
notes
.
count
}.
by
(
1
)
note
=
epic
.
notes
.
last
expect
(
note
.
note
).
to
eq
(
'opened'
)
expect
(
note
.
system_note_metadata
.
action
).
to
eq
(
'opened'
)
end
end
context
'when trying to reopen an opened epic'
do
...
...
@@ -59,6 +68,10 @@ describe Epics::ReopenService do
it
'does not change closed_by'
do
expect
{
subject
.
execute
(
epic
)
}.
not_to
change
{
epic
.
closed_by
}
end
it
'does not create a system note'
do
expect
{
subject
.
execute
(
epic
)
}.
not_to
change
{
epic
.
notes
.
count
}
end
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