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
bf7ba36b
Commit
bf7ba36b
authored
Apr 26, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create notes for both issues when related
parent
d43f2fdc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
3 deletions
+59
-3
app/models/system_note_metadata.rb
app/models/system_note_metadata.rb
+1
-2
app/services/related_issues/create_service.rb
app/services/related_issues/create_service.rb
+11
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+15
-0
spec/services/related_issues/create_service_spec.rb
spec/services/related_issues/create_service_spec.rb
+16
-0
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+16
-0
No files found.
app/models/system_note_metadata.rb
View file @
bf7ba36b
...
...
@@ -2,8 +2,7 @@ class SystemNoteMetadata < ActiveRecord::Base
ICON_TYPES
=
%w[
commit description merge confidential visible label assignee cross_reference
title time_tracking branch milestone discussion task moved opened closed merged
outdated
approved unapproved
outdated approved unapproved relate
]
.
freeze
validates
:note
,
presence:
true
...
...
app/services/related_issues/create_service.rb
View file @
bf7ba36b
...
...
@@ -23,11 +23,21 @@ module RelatedIssues
def
create_related_issues!
RelatedIssue
.
transaction
do
referenced_issues
.
each
do
|
referenced_issue
|
RelatedIssue
.
create!
(
issue:
@issue
,
related_issue:
referenced_issue
)
relate_issues!
(
referenced_issue
)
create_notes!
(
referenced_issue
)
end
end
end
def
relate_issues!
(
referenced_issue
)
RelatedIssue
.
create!
(
issue:
@issue
,
related_issue:
referenced_issue
)
end
def
create_notes!
(
referenced_issue
)
SystemNoteService
.
relate_issue
(
@issue
,
referenced_issue
,
current_user
)
SystemNoteService
.
relate_issue
(
referenced_issue
,
@issue
,
current_user
)
end
def
referenced_issues
@referenced_issues
||=
begin
issue_references
=
params
[
:issue_references
]
...
...
app/services/system_note_service.rb
View file @
bf7ba36b
...
...
@@ -552,6 +552,21 @@ module SystemNoteService
create_note
(
NoteSummary
.
new
(
noteable
,
project
,
author
,
body
,
action:
'moved'
))
end
#
# noteable - Noteable object
# user - User performing approve
#
# Example Note text:
#
# "marked this issue as related to gitlab-ce#9001"
#
# Returns the created Note object
def
relate_issue
(
noteable
,
noteable_ref
,
user
)
body
=
"marked this issue as related to
#{
noteable_ref
.
to_reference
(
noteable
.
project
)
}
"
create_note
(
NoteSummary
.
new
(
noteable
,
noteable
.
project
,
user
,
body
,
action:
'relate'
))
end
# Called when the merge request is approved by user
#
# noteable - Noteable object
...
...
spec/services/related_issues/create_service_spec.rb
View file @
bf7ba36b
...
...
@@ -72,6 +72,22 @@ describe RelatedIssues::CreateService, service: true do
it
'returns success message with Issue references'
do
is_expected
.
to
eq
(
message:
"
#{
issue_a_ref
}
and
#{
another_project_issue_ref
}
were successfully related"
,
status: :success
)
end
it
'creates notes'
do
# First two-way relation notes
expect
(
SystemNoteService
).
to
receive
(
:relate_issue
)
.
with
(
issue
,
issue_a
,
user
)
expect
(
SystemNoteService
).
to
receive
(
:relate_issue
)
.
with
(
issue_a
,
issue
,
user
)
# Second two-way relation notes
expect
(
SystemNoteService
).
to
receive
(
:relate_issue
)
.
with
(
issue
,
another_project_issue
,
user
)
expect
(
SystemNoteService
).
to
receive
(
:relate_issue
)
.
with
(
another_project_issue
,
issue
,
user
)
subject
end
end
context
'when relation already exists'
do
...
...
spec/services/system_note_service_spec.rb
View file @
bf7ba36b
...
...
@@ -899,6 +899,22 @@ describe SystemNoteService, services: true do
end
end
describe
'.relate_issue'
do
let
(
:noteable_ref
)
{
create
(
:issue
)
}
subject
{
described_class
.
relate_issue
(
noteable
,
noteable_ref
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'relate'
}
end
context
'when issue marks another as related'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"marked this issue as related to
#{
noteable_ref
.
to_reference
(
project
)
}
"
end
end
end
describe
'.approve_mr'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
subject
{
described_class
.
approve_mr
(
noteable
,
author
)
}
...
...
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