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
Boxiang Sun
gitlab-ce
Commits
ca923d48
Commit
ca923d48
authored
Aug 03, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create system notes for group milestone changes
parent
149528f4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
21 deletions
+46
-21
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+1
-4
app/services/system_note_service.rb
app/services/system_note_service.rb
+2
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+40
-13
spec/support/issuable_shared_examples.rb
spec/support/issuable_shared_examples.rb
+3
-3
No files found.
app/services/issuable_base_service.rb
View file @
ca923d48
...
@@ -2,11 +2,8 @@ class IssuableBaseService < BaseService
...
@@ -2,11 +2,8 @@ class IssuableBaseService < BaseService
private
private
def
create_milestone_note
(
issuable
)
def
create_milestone_note
(
issuable
)
milestone
=
issuable
.
milestone
return
if
milestone
&&
milestone
.
is_group_milestone?
SystemNoteService
.
change_milestone
(
SystemNoteService
.
change_milestone
(
issuable
,
issuable
.
project
,
current_user
,
milestone
)
issuable
,
issuable
.
project
,
current_user
,
issuable
.
milestone
)
end
end
def
create_labels_note
(
issuable
,
old_labels
)
def
create_labels_note
(
issuable
,
old_labels
)
...
...
app/services/system_note_service.rb
View file @
ca923d48
...
@@ -142,7 +142,8 @@ module SystemNoteService
...
@@ -142,7 +142,8 @@ module SystemNoteService
#
#
# Returns the created Note object
# Returns the created Note object
def
change_milestone
(
noteable
,
project
,
author
,
milestone
)
def
change_milestone
(
noteable
,
project
,
author
,
milestone
)
body
=
milestone
.
nil?
?
'removed milestone'
:
"changed milestone to
#{
milestone
.
to_reference
(
project
)
}
"
format
=
milestone
&
.
is_group_milestone?
?
:name
:
:iid
body
=
milestone
.
nil?
?
'removed milestone'
:
"changed milestone to
#{
milestone
.
to_reference
(
project
,
format:
format
)
}
"
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'milestone'
))
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'milestone'
))
end
end
...
...
spec/services/system_note_service_spec.rb
View file @
ca923d48
...
@@ -3,7 +3,8 @@ require 'spec_helper'
...
@@ -3,7 +3,8 @@ require 'spec_helper'
describe
SystemNoteService
do
describe
SystemNoteService
do
include
Gitlab
::
Routing
include
Gitlab
::
Routing
let
(
:project
)
{
create
(
:project
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:author
)
{
create
(
:user
)
}
let
(
:author
)
{
create
(
:user
)
}
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue
)
{
noteable
}
let
(
:issue
)
{
noteable
}
...
@@ -242,6 +243,7 @@ describe SystemNoteService do
...
@@ -242,6 +243,7 @@ describe SystemNoteService do
end
end
describe
'.change_milestone'
do
describe
'.change_milestone'
do
context
'for a project milestone'
do
subject
{
described_class
.
change_milestone
(
noteable
,
project
,
author
,
milestone
)
}
subject
{
described_class
.
change_milestone
(
noteable
,
project
,
author
,
milestone
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
...
@@ -265,6 +267,31 @@ describe SystemNoteService do
...
@@ -265,6 +267,31 @@ describe SystemNoteService do
end
end
end
end
context
'for a group milestone'
do
subject
{
described_class
.
change_milestone
(
noteable
,
project
,
author
,
milestone
)
}
let
(
:milestone
)
{
create
(
:milestone
,
group:
group
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'milestone'
}
end
context
'when milestone added'
do
it
'sets the note text to use the milestone name'
do
expect
(
subject
.
note
).
to
eq
"changed milestone to
#{
milestone
.
to_reference
(
format: :name
)
}
"
end
end
context
'when milestone removed'
do
let
(
:milestone
)
{
nil
}
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'removed milestone'
end
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
)
}
...
...
spec/support/issuable_shared_examples.rb
View file @
ca923d48
...
@@ -21,15 +21,15 @@ shared_examples 'system notes for milestones' do
...
@@ -21,15 +21,15 @@ shared_examples 'system notes for milestones' do
create
(
:group_member
,
group:
group
,
user:
user
)
create
(
:group_member
,
group:
group
,
user:
user
)
end
end
it
'
does not create
system note'
do
it
'
creates a
system note'
do
expect
do
expect
do
update_issuable
(
milestone:
group_milestone
)
update_issuable
(
milestone:
group_milestone
)
end
.
not_to
change
{
Note
.
system
.
count
}
end
.
to
change
{
Note
.
system
.
count
}.
by
(
1
)
end
end
end
end
context
'project milestones'
do
context
'project milestones'
do
it
'creates system note'
do
it
'creates
a
system note'
do
expect
do
expect
do
update_issuable
(
milestone:
create
(
:milestone
))
update_issuable
(
milestone:
create
(
:milestone
))
end
.
to
change
{
Note
.
system
.
count
}.
by
(
1
)
end
.
to
change
{
Note
.
system
.
count
}.
by
(
1
)
...
...
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