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
83233a4e
Commit
83233a4e
authored
Jun 04, 2018
by
Jan Provaznik
Committed by
Sean McGivern
Jun 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create system note on epic date change
parent
e4387485
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
5 deletions
+103
-5
ee/app/helpers/ee/system_note_helper.rb
ee/app/helpers/ee/system_note_helper.rb
+2
-1
ee/app/models/ee/system_note_metadata.rb
ee/app/models/ee/system_note_metadata.rb
+1
-1
ee/app/services/ee/issuable/common_system_notes_service.rb
ee/app/services/ee/issuable/common_system_notes_service.rb
+11
-0
ee/app/services/ee/system_note_service.rb
ee/app/services/ee/system_note_service.rb
+22
-0
ee/changelogs/unreleased/ee-epic-date-note.yml
ee/changelogs/unreleased/ee-epic-date-note.yml
+5
-0
ee/spec/services/ee/issuable/common_system_notes_service_spec.rb
.../services/ee/issuable/common_system_notes_service_spec.rb
+19
-0
ee/spec/services/system_note_service_spec.rb
ee/spec/services/system_note_service_spec.rb
+43
-3
No files found.
ee/app/helpers/ee/system_note_helper.rb
View file @
83233a4e
...
...
@@ -8,7 +8,8 @@ module EE
'epic_issue_moved'
=>
'issues'
,
'issue_added_to_epic'
=>
'epic'
,
'issue_removed_from_epic'
=>
'epic'
,
'issue_changed_epic'
=>
'epic'
'issue_changed_epic'
=>
'epic'
,
'epic_date_changed'
=>
'calendar'
}.
freeze
override
:system_note_icon_name
...
...
ee/app/models/ee/system_note_metadata.rb
View file @
83233a4e
...
...
@@ -5,7 +5,7 @@ module EE
EE_ICON_TYPES
=
%w[
weight approved unapproved relate unrelate
epic_issue_added issue_added_to_epic epic_issue_removed issue_removed_from_epic
epic_issue_moved issue_changed_epic
epic_issue_moved issue_changed_epic
epic_date_changed
]
.
freeze
override
:icon_types
...
...
ee/app/services/ee/issuable/common_system_notes_service.rb
View file @
83233a4e
...
...
@@ -8,10 +8,21 @@ module EE
def
execute
(
_issuable
,
_old_labels
)
super
handle_weight_change_note
handle_date_change_note
end
private
def
handle_date_change_note
if
issuable
.
previous_changes
.
include?
(
'start_date'
)
::
SystemNoteService
.
change_epic_date_note
(
issuable
,
current_user
,
'start date'
,
issuable
[
'start_date'
])
end
if
issuable
.
previous_changes
.
include?
(
'end_date'
)
::
SystemNoteService
.
change_epic_date_note
(
issuable
,
current_user
,
'finish date'
,
issuable
[
'end_date'
])
end
end
def
handle_weight_change_note
if
issuable
.
previous_changes
.
include?
(
'weight'
)
create_weight_change_note
...
...
ee/app/services/ee/system_note_service.rb
View file @
83233a4e
...
...
@@ -24,5 +24,27 @@ module EE
body
=
noteable
.
weight
?
"changed weight to **
#{
noteable
.
weight
}
**,"
:
'removed the weight'
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'weight'
))
end
# Called when the start or end date of an Issuable is changed
#
# noteable - Noteable object
# author - User performing the change
# date_type - 'start date' or 'finish date'
# date - New date
#
# Example Note text:
#
# "changed start date to FIXME"
#
# Returns the created Note object
def
change_epic_date_note
(
noteable
,
author
,
date_type
,
date
)
body
=
if
date
"changed
#{
date_type
}
to
#{
date
.
strftime
(
'%b %-d, %Y'
)
}
"
else
"removed the
#{
date_type
}
"
end
create_note
(
NoteSummary
.
new
(
noteable
,
nil
,
author
,
body
,
action:
'epic_date_changed'
))
end
end
end
ee/changelogs/unreleased/ee-epic-date-note.yml
0 → 100644
View file @
83233a4e
---
title
:
Create system note on epic date change.
merge_request
:
author
:
type
:
added
ee/spec/services/ee/issuable/common_system_notes_service_spec.rb
View file @
83233a4e
...
...
@@ -7,5 +7,24 @@ describe Issuable::CommonSystemNotesService do
describe
'#execute'
do
it_behaves_like
'system note creation'
,
{
weight:
5
},
'changed weight to **5**,'
context
'when issuable is an epic'
do
let
(
:timestamp
)
{
Time
.
now
}
let
(
:issuable
)
{
create
(
:epic
,
end_date:
timestamp
)
}
subject
{
described_class
.
new
(
nil
,
user
).
execute
(
issuable
,
[])}
before
do
issuable
.
assign_attributes
(
start_date:
timestamp
,
end_date:
nil
)
issuable
.
save
end
it
'creates 2 system notes with the correct content'
do
expect
{
subject
}.
to
change
{
Note
.
count
}.
from
(
0
).
to
(
2
)
expect
(
Note
.
first
.
note
).
to
match
(
"changed start date to
#{
timestamp
.
strftime
(
'%b %-d, %Y'
)
}
"
)
expect
(
Note
.
second
.
note
).
to
match
(
'removed the finish date'
)
end
end
end
end
ee/spec/services/system_note_service_spec.rb
View file @
83233a4e
...
...
@@ -21,20 +21,28 @@ describe SystemNoteService do
expect
(
subject
).
to
be_system
expect
(
subject
.
noteable
).
to
eq
expected_noteable
expect
(
subject
.
project
).
to
eq
project
expect
(
subject
.
author
).
to
eq
author
expect
(
subject
.
system_note_metadata
.
action
).
to
eq
(
action
)
expect
(
subject
.
system_note_metadata
.
commit_count
).
to
eq
(
commit_count
)
end
end
shared_examples_for
'a project system note'
do
it
'has the project attribute set'
do
expect
(
subject
.
project
).
to
eq
project
end
it_behaves_like
'a system note'
end
describe
'.change_weight_note'
do
context
'when weight changed'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
,
title:
'Lorem ipsum'
,
weight:
4
)
}
subject
{
described_class
.
change_weight_note
(
noteable
,
project
,
author
)
}
it_behaves_like
'a system note'
do
it_behaves_like
'a
project
system note'
do
let
(
:action
)
{
'weight'
}
end
...
...
@@ -48,7 +56,7 @@ describe SystemNoteService do
subject
{
described_class
.
change_weight_note
(
noteable
,
project
,
author
)
}
it_behaves_like
'a system note'
do
it_behaves_like
'a
project
system note'
do
let
(
:action
)
{
'weight'
}
end
...
...
@@ -57,4 +65,36 @@ describe SystemNoteService do
end
end
end
describe
'.change_epic_date_note'
do
let
(
:timestamp
)
{
Time
.
now
}
context
'when start date was changed'
do
let
(
:noteable
)
{
create
(
:epic
)
}
subject
{
described_class
.
change_epic_date_note
(
noteable
,
author
,
'start date'
,
timestamp
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'epic_date_changed'
}
end
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"changed start date to
#{
timestamp
.
strftime
(
'%b %-d, %Y'
)
}
"
end
end
context
'when start date was removed'
do
let
(
:noteable
)
{
create
(
:epic
,
start_date:
timestamp
)
}
subject
{
described_class
.
change_epic_date_note
(
noteable
,
author
,
'start date'
,
nil
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'epic_date_changed'
}
end
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'removed the start date'
end
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