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
Léo-Paul Géneau
gitlab-ce
Commits
997dda50
Commit
997dda50
authored
Sep 09, 2018
by
Eva Kadlecová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system note when due date is changed
parent
120ce02e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
2 deletions
+57
-2
app/helpers/system_note_helper.rb
app/helpers/system_note_helper.rb
+2
-1
app/models/system_note_metadata.rb
app/models/system_note_metadata.rb
+1
-1
app/services/issuable/common_system_notes_service.rb
app/services/issuable/common_system_notes_service.rb
+5
-0
app/services/system_note_service.rb
app/services/system_note_service.rb
+20
-0
changelogs/unreleased/38208-due-dates-system-notes.yml
changelogs/unreleased/38208-due-dates-system-notes.yml
+5
-0
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+24
-0
No files found.
app/helpers/system_note_helper.rb
View file @
997dda50
...
@@ -21,7 +21,8 @@ module SystemNoteHelper
...
@@ -21,7 +21,8 @@ module SystemNoteHelper
'outdated'
=>
'pencil-square'
,
'outdated'
=>
'pencil-square'
,
'duplicate'
=>
'issue-duplicate'
,
'duplicate'
=>
'issue-duplicate'
,
'locked'
=>
'lock'
,
'locked'
=>
'lock'
,
'unlocked'
=>
'lock-open'
'unlocked'
=>
'lock-open'
,
'due_date'
=>
'calendar'
}.
freeze
}.
freeze
def
system_note_icon_name
(
note
)
def
system_note_icon_name
(
note
)
...
...
app/models/system_note_metadata.rb
View file @
997dda50
...
@@ -15,7 +15,7 @@ class SystemNoteMetadata < ActiveRecord::Base
...
@@ -15,7 +15,7 @@ class SystemNoteMetadata < ActiveRecord::Base
commit description merge confidential visible label assignee cross_reference
commit description merge confidential visible label assignee cross_reference
title time_tracking branch milestone discussion task moved
title time_tracking branch milestone discussion task moved
opened closed merged duplicate locked unlocked
opened closed merged duplicate locked unlocked
outdated tag
outdated tag
due_date
]
.
freeze
]
.
freeze
validates
:note
,
presence:
true
validates
:note
,
presence:
true
...
...
app/services/issuable/common_system_notes_service.rb
View file @
997dda50
...
@@ -17,6 +17,7 @@ module Issuable
...
@@ -17,6 +17,7 @@ module Issuable
create_labels_note
(
old_labels
)
if
issuable
.
labels
!=
old_labels
create_labels_note
(
old_labels
)
if
issuable
.
labels
!=
old_labels
create_discussion_lock_note
if
issuable
.
previous_changes
.
include?
(
'discussion_locked'
)
create_discussion_lock_note
if
issuable
.
previous_changes
.
include?
(
'discussion_locked'
)
create_milestone_note
if
issuable
.
previous_changes
.
include?
(
'milestone_id'
)
create_milestone_note
if
issuable
.
previous_changes
.
include?
(
'milestone_id'
)
create_due_date_note
if
issuable
.
previous_changes
.
include?
(
'due_date'
)
end
end
private
private
...
@@ -88,6 +89,10 @@ module Issuable
...
@@ -88,6 +89,10 @@ module Issuable
SystemNoteService
.
change_milestone
(
issuable
,
issuable
.
project
,
current_user
,
issuable
.
milestone
)
SystemNoteService
.
change_milestone
(
issuable
,
issuable
.
project
,
current_user
,
issuable
.
milestone
)
end
end
def
create_due_date_note
SystemNoteService
.
change_due_date
(
issuable
,
issuable
.
project
,
current_user
,
issuable
.
due_date
)
end
def
create_discussion_lock_note
def
create_discussion_lock_note
SystemNoteService
.
discussion_lock
(
issuable
,
current_user
)
SystemNoteService
.
discussion_lock
(
issuable
,
current_user
)
end
end
...
...
app/services/system_note_service.rb
View file @
997dda50
...
@@ -160,6 +160,26 @@ module SystemNoteService
...
@@ -160,6 +160,26 @@ module SystemNoteService
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'milestone'
))
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'milestone'
))
end
end
# Called when the due_date of a Noteable is changed
#
# noteable - Noteable object
# project - Project owning noteable
# author - User performing the change
# due_date - Due date being assigned, or nil
#
# Example Note text:
#
# "removed due date"
#
# "changed due date to September 20, 2018"
#
# Returns the created Note object
def
change_due_date
(
noteable
,
project
,
author
,
due_date
)
body
=
due_date
?
"changed due date to
#{
due_date
.
to_s
(
:long
)
}
"
:
'removed due date'
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'due_date'
))
end
# Called when the estimated time of a Noteable is changed
# Called when the estimated time of a Noteable is changed
#
#
# noteable - Noteable object
# noteable - Noteable object
...
...
changelogs/unreleased/38208-due-dates-system-notes.yml
0 → 100644
View file @
997dda50
---
title
:
Add system note when due date is changed
merge_request
:
author
:
Eva Kadlecova
type
:
added
spec/services/system_note_service_spec.rb
View file @
997dda50
...
@@ -288,6 +288,30 @@ describe SystemNoteService do
...
@@ -288,6 +288,30 @@ describe SystemNoteService do
end
end
end
end
describe
'.change_due_date'
do
subject
{
described_class
.
change_due_date
(
noteable
,
project
,
author
,
due_date
)
}
let
(
:due_date
)
{
Date
.
today
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'due_date'
}
end
context
'when due date added'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"changed due date to
#{
Date
.
today
.
to_s
(
:long
)
}
"
end
end
context
'when due date removed'
do
let
(
:due_date
)
{
nil
}
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'removed due date'
end
end
end
describe
'.change_status'
do
describe
'.change_status'
do
subject
{
described_class
.
change_status
(
noteable
,
project
,
author
,
status
,
source
)
}
subject
{
described_class
.
change_status
(
noteable
,
project
,
author
,
status
,
source
)
}
...
...
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