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
80e30a92
Commit
80e30a92
authored
Jun 12, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add system note when user approves merge request
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
07703c22
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+4
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+16
-0
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+13
-0
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
80e30a92
...
...
@@ -200,7 +200,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
approve
@approval
=
@merge_request
.
approvals
.
new
@approval
.
user
=
current_user
@approval
.
save
if
@approval
.
save
SystemNoteService
.
approve_mr
(
@merge_request
,
current_user
)
end
redirect_to
merge_request_path
(
@merge_request
)
end
...
...
app/services/system_note_service.rb
View file @
80e30a92
...
...
@@ -255,6 +255,22 @@ class SystemNoteService
notes
.
count
>
0
end
# Called when the merge request is approved by user
#
# noteable - Noteable object
# user - User performing approve
#
# Example Note text:
#
# "Approved by @rspeicher"
#
# Returns the created Note object
def
self
.
approve_mr
(
noteable
,
user
)
body
=
"Approved by @
#{
user
.
username
}
"
create_note
(
noteable:
noteable
,
project:
noteable
.
project
,
author:
user
,
note:
body
)
end
private
def
self
.
create_note
(
args
=
{})
...
...
spec/services/system_note_service_spec.rb
View file @
80e30a92
...
...
@@ -442,4 +442,17 @@ describe SystemNoteService do
end
end
end
describe
'.approve_mr'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
subject
{
described_class
.
approve_mr
(
noteable
,
author
)
}
it_behaves_like
'a system note'
context
'when assignee added'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"Approved by @
#{
author
.
username
}
"
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