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
6df22f72
Commit
6df22f72
authored
Nov 23, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rephrase some system notes to be compatible with new system note style
parent
d0c0c75c
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
169 additions
and
124 deletions
+169
-124
app/services/notification_service.rb
app/services/notification_service.rb
+0
-1
app/services/system_note_service.rb
app/services/system_note_service.rb
+43
-43
changelogs/unreleased/rephrase-system-notes.yml
changelogs/unreleased/rephrase-system-notes.yml
+4
-0
doc/api/notes.md
doc/api/notes.md
+1
-1
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+1
-1
features/steps/shared/issuable.rb
features/steps/shared/issuable.rb
+1
-1
spec/controllers/projects/milestones_controller_spec.rb
spec/controllers/projects/milestones_controller_spec.rb
+1
-1
spec/features/issues/move_spec.rb
spec/features/issues/move_spec.rb
+3
-3
spec/features/issues/new_branch_button_spec.rb
spec/features/issues/new_branch_button_spec.rb
+2
-2
spec/features/merge_requests/merge_when_build_succeeds_spec.rb
...features/merge_requests/merge_when_build_succeeds_spec.rb
+1
-1
spec/features/notes_on_merge_requests_spec.rb
spec/features/notes_on_merge_requests_spec.rb
+1
-1
spec/models/note_spec.rb
spec/models/note_spec.rb
+1
-1
spec/requests/api/notes_spec.rb
spec/requests/api/notes_spec.rb
+1
-1
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+1
-1
spec/services/issues/move_service_spec.rb
spec/services/issues/move_service_spec.rb
+3
-3
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+14
-14
spec/services/merge_requests/close_service_spec.rb
spec/services/merge_requests/close_service_spec.rb
+1
-1
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+1
-1
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
.../merge_requests/merge_when_build_succeeds_service_spec.rb
+2
-2
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+8
-8
spec/services/merge_requests/reopen_service_spec.rb
spec/services/merge_requests/reopen_service_spec.rb
+1
-1
spec/services/merge_requests/update_service_spec.rb
spec/services/merge_requests/update_service_spec.rb
+12
-12
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+66
-24
No files found.
app/services/notification_service.rb
View file @
6df22f72
...
...
@@ -171,7 +171,6 @@ class NotificationService
return
true
unless
note
.
noteable_type
.
present?
# ignore gitlab service messages
return
true
if
note
.
note
.
start_with?
(
'Status changed to closed'
)
return
true
if
note
.
cross_reference?
&&
note
.
system?
target
=
note
.
noteable
...
...
app/services/system_note_service.rb
View file @
6df22f72
...
...
@@ -21,7 +21,7 @@ module SystemNoteService
total_count
=
new_commits
.
length
+
existing_commits
.
length
commits_text
=
"
#{
total_count
}
commit"
.
pluralize
(
total_count
)
body
=
"
Added
#{
commits_text
}
:
\n\n
"
body
=
"
added
#{
commits_text
}
\n\n
"
body
<<
existing_commit_summary
(
noteable
,
existing_commits
,
oldrev
)
body
<<
new_commit_summary
(
new_commits
).
join
(
"
\n
"
)
body
<<
"
\n\n
[Compare with previous version](
#{
diff_comparison_url
(
noteable
,
project
,
oldrev
)
}
)"
...
...
@@ -38,13 +38,13 @@ module SystemNoteService
#
# Example Note text:
#
# "
Assignee removed
"
# "
removed assignee
"
#
# "
Re
assigned to @rspeicher"
# "assigned to @rspeicher"
#
# Returns the created Note object
def
change_assignee
(
noteable
,
project
,
author
,
assignee
)
body
=
assignee
.
nil?
?
'
Assignee removed'
:
"Re
assigned to
#{
assignee
.
to_reference
}
"
body
=
assignee
.
nil?
?
'
removed assignee'
:
"
assigned to
#{
assignee
.
to_reference
}
"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -59,11 +59,11 @@ module SystemNoteService
#
# Example Note text:
#
# "
A
dded ~1 and removed ~2 ~3 labels"
# "
a
dded ~1 and removed ~2 ~3 labels"
#
# "
A
dded ~4 label"
# "
a
dded ~4 label"
#
# "
R
emoved ~5 label"
# "
r
emoved ~5 label"
#
# Returns the created Note object
def
change_label
(
noteable
,
project
,
author
,
added_labels
,
removed_labels
)
...
...
@@ -85,7 +85,6 @@ module SystemNoteService
end
body
<<
' '
<<
'label'
.
pluralize
(
labels_count
)
body
=
body
.
capitalize
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -99,14 +98,13 @@ module SystemNoteService
#
# Example Note text:
#
# "
Milestone removed
"
# "
removed milestone
"
#
# "
Miletone changed
to 7.11"
# "
changed milestone
to 7.11"
#
# Returns the created Note object
def
change_milestone
(
noteable
,
project
,
author
,
milestone
)
body
=
'Milestone '
body
+=
milestone
.
nil?
?
'removed'
:
"changed to
#{
milestone
.
to_reference
(
project
)
}
"
body
=
milestone
.
nil?
?
'removed milestone'
:
"changed milestone to
#{
milestone
.
to_reference
(
project
)
}
"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -121,46 +119,46 @@ module SystemNoteService
#
# Example Note text:
#
# "
Status changed to
merged"
# "merged"
#
# "
Status changed to closed by
bc17db76"
# "
closed via
bc17db76"
#
# Returns the created Note object
def
change_status
(
noteable
,
project
,
author
,
status
,
source
)
body
=
"Status changed to
#{
status
}
"
body
<<
"
by
#{
source
.
gfm_reference
(
project
)
}
"
if
source
body
=
status
.
dup
body
<<
"
via
#{
source
.
gfm_reference
(
project
)
}
"
if
source
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
# Called when 'merge when build succeeds' is executed
def
merge_when_build_succeeds
(
noteable
,
project
,
author
,
last_commit
)
body
=
"
E
nabled an automatic merge when the build for
#{
last_commit
.
to_reference
(
project
)
}
succeeds"
body
=
"
e
nabled an automatic merge when the build for
#{
last_commit
.
to_reference
(
project
)
}
succeeds"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
# Called when 'merge when build succeeds' is canceled
def
cancel_merge_when_build_succeeds
(
noteable
,
project
,
author
)
body
=
'
C
anceled the automatic merge'
body
=
'
c
anceled the automatic merge'
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
def
remove_merge_request_wip
(
noteable
,
project
,
author
)
body
=
'
Unmarked this merge request
as a Work In Progress'
body
=
'
unmarked
as a Work In Progress'
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
def
add_merge_request_wip
(
noteable
,
project
,
author
)
body
=
'
Marked this merge request
as a **Work In Progress**'
body
=
'
marked
as a **Work In Progress**'
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
def
self
.
resolve_all_discussions
(
merge_request
,
project
,
author
)
body
=
"
R
esolved all discussions"
body
=
"
r
esolved all discussions"
create_note
(
noteable:
merge_request
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -174,7 +172,7 @@ module SystemNoteService
#
# Example Note text:
#
# "
Title changed
from **Old** to **New**"
# "
changed title
from **Old** to **New**"
#
# Returns the created Note object
def
change_title
(
noteable
,
project
,
author
,
old_title
)
...
...
@@ -185,7 +183,7 @@ module SystemNoteService
marked_old_title
=
Gitlab
::
Diff
::
InlineDiffMarker
.
new
(
old_title
).
mark
(
old_diffs
,
mode: :deletion
,
markdown:
true
)
marked_new_title
=
Gitlab
::
Diff
::
InlineDiffMarker
.
new
(
new_title
).
mark
(
new_diffs
,
mode: :addition
,
markdown:
true
)
body
=
"
Changed title: **
#{
marked_old_title
}
** →
**
#{
marked_new_title
}
**"
body
=
"
changed title from **
#{
marked_old_title
}
** to
**
#{
marked_new_title
}
**"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -197,11 +195,11 @@ module SystemNoteService
#
# Example Note text:
#
# "
M
ade the issue confidential"
# "
m
ade the issue confidential"
#
# Returns the created Note object
def
change_issue_confidentiality
(
issue
,
project
,
author
)
body
=
issue
.
confidential
?
'
Made the issue confidential'
:
'Made the issue visibl
e'
body
=
issue
.
confidential
?
'
made the issue confidential'
:
'made the issue visible to everyon
e'
create_note
(
noteable:
issue
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -216,11 +214,11 @@ module SystemNoteService
#
# Example Note text:
#
# "
Target branch changed
from `Old` to `New`"
# "
changed target branch
from `Old` to `New`"
#
# Returns the created Note object
def
change_branch
(
noteable
,
project
,
author
,
branch_type
,
old_branch
,
new_branch
)
body
=
"
#{
branch_type
}
branch changed from `
#{
old_branch
}
` to `
#{
new_branch
}
`"
.
capitalize
body
=
"
changed
#{
branch_type
}
branch from `
#{
old_branch
}
` to `
#{
new_branch
}
`"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -235,7 +233,7 @@ module SystemNoteService
#
# Example Note text:
#
# "
R
estored target branch `feature`"
# "
r
estored target branch `feature`"
#
# Returns the created Note object
def
change_branch_presence
(
noteable
,
project
,
author
,
branch_type
,
branch
,
presence
)
...
...
@@ -246,18 +244,18 @@ module SystemNoteService
'deleted'
end
body
=
"
#{
verb
}
#{
branch_type
}
branch `
#{
branch
}
`"
.
capitalize
body
=
"
#{
verb
}
#{
branch_type
}
branch `
#{
branch
}
`"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
# Called when a branch is created from the 'new branch' button on a issue
# Example note text:
#
# "
Star
ted branch `201-issue-branch-button`"
# "
crea
ted branch `201-issue-branch-button`"
def
new_issue_branch
(
issue
,
project
,
author
,
branch
)
link
=
url_helpers
.
namespace_project_compare_url
(
project
.
namespace
,
project
,
from:
project
.
default_branch
,
to:
branch
)
body
=
"
Star
ted branch [`
#{
branch
}
`](
#{
link
}
)"
body
=
"
crea
ted branch [`
#{
branch
}
`](
#{
link
}
)"
create_note
(
noteable:
issue
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -269,11 +267,11 @@ module SystemNoteService
#
# Example Note text:
#
# "
M
entioned in #1"
# "
m
entioned in #1"
#
# "
M
entioned in !2"
# "
m
entioned in !2"
#
# "
M
entioned in 54f7727c"
# "
m
entioned in 54f7727c"
#
# See cross_reference_note_content.
#
...
...
@@ -303,12 +301,12 @@ module SystemNoteService
end
def
cross_reference?
(
note_text
)
note_text
.
start_with?
(
cross_reference_note_prefix
)
note_text
=~
/\A
#{
cross_reference_note_prefix
}
/i
end
# Check if a cross-reference is disallowed
#
# This method prevents adding a "
M
entioned in !1" note on every single commit
# This method prevents adding a "
m
entioned in !1" note on every single commit
# in a merge request. Additionally, it prevents the creation of references to
# external issues (which would fail).
#
...
...
@@ -370,12 +368,12 @@ module SystemNoteService
#
# Example Note text:
#
# "
Soandso
marked the task Whatever as completed."
# "marked the task Whatever as completed."
#
# Returns the created Note object
def
change_task_status
(
noteable
,
project
,
author
,
new_task
)
status_label
=
new_task
.
complete?
?
Taskable
::
COMPLETED
:
Taskable
::
INCOMPLETE
body
=
"
M
arked the task **
#{
new_task
.
source
}
** as
#{
status_label
}
"
body
=
"
m
arked the task **
#{
new_task
.
source
}
** as
#{
status_label
}
"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -388,7 +386,7 @@ module SystemNoteService
#
# Example Note text:
#
# "
M
oved to some_namespace/project_new#11"
# "
m
oved to some_namespace/project_new#11"
#
# Returns the created Note object
def
noteable_moved
(
noteable
,
project
,
noteable_ref
,
author
,
direction
:)
...
...
@@ -397,7 +395,7 @@ module SystemNoteService
end
cross_reference
=
noteable_ref
.
to_reference
(
project
)
body
=
"
M
oved
#{
direction
}
#{
cross_reference
}
"
body
=
"
m
oved
#{
direction
}
#{
cross_reference
}
"
create_note
(
noteable:
noteable
,
project:
project
,
author:
author
,
note:
body
)
end
...
...
@@ -405,10 +403,12 @@ module SystemNoteService
def
notes_for_mentioner
(
mentioner
,
noteable
,
notes
)
if
mentioner
.
is_a?
(
Commit
)
notes
.
where
(
'note LIKE ?'
,
"
#{
cross_reference_note_prefix
}
%
#{
mentioner
.
to_reference
(
nil
)
}
"
)
text
=
"
#{
cross_reference_note_prefix
}
%
#{
mentioner
.
to_reference
(
nil
)
}
"
notes
.
where
(
'(note LIKE ? OR note LIKE ?)'
,
text
,
text
.
capitalize
)
else
gfm_reference
=
mentioner
.
gfm_reference
(
noteable
.
project
)
notes
.
where
(
note:
cross_reference_note_content
(
gfm_reference
))
text
=
cross_reference_note_content
(
gfm_reference
)
notes
.
where
(
note:
[
text
,
text
.
capitalize
])
end
end
...
...
@@ -417,7 +417,7 @@ module SystemNoteService
end
def
cross_reference_note_prefix
'
M
entioned in '
'
m
entioned in '
end
def
cross_reference_note_content
(
gfm_reference
)
...
...
changelogs/unreleased/rephrase-system-notes.yml
0 → 100644
View file @
6df22f72
---
title
:
Rephrase some system notes to be compatible with new system note style
merge_request
:
7692
author
:
doc/api/notes.md
View file @
6df22f72
...
...
@@ -21,7 +21,7 @@ Parameters:
[
{
"id"
:
302
,
"body"
:
"
Status changed to
closed"
,
"body"
:
"closed"
,
"attachment"
:
null
,
"author"
:
{
"id"
:
1
,
...
...
features/steps/project/merge_requests.rb
View file @
6df22f72
...
...
@@ -515,7 +515,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step
'I should see new target branch changes'
do
expect
(
page
).
to
have_content
'Request to merge fix into feature'
expect
(
page
).
to
have_content
'
Target branch changed
from merge-test to feature'
expect
(
page
).
to
have_content
'
changed target branch
from merge-test to feature'
wait_for_ajax
end
...
...
features/steps/shared/issuable.rb
View file @
6df22f72
...
...
@@ -179,7 +179,7 @@ module SharedIssuable
project
=
Project
.
find_by
(
name:
from_project_name
)
expect
(
page
).
to
have_content
(
user_name
)
expect
(
page
).
to
have_content
(
"
M
entioned in
#{
issuable
.
class
.
to_s
.
titleize
.
downcase
}
#{
issuable
.
to_reference
(
project
)
}
"
)
expect
(
page
).
to
have_content
(
"
m
entioned in
#{
issuable
.
class
.
to_s
.
titleize
.
downcase
}
#{
issuable
.
to_reference
(
project
)
}
"
)
end
def
expect_sidebar_content
(
content
)
...
...
spec/controllers/projects/milestones_controller_spec.rb
View file @
6df22f72
...
...
@@ -31,7 +31,7 @@ describe Projects::MilestonesController do
# Check system note left for milestone removal
last_note
=
project
.
issues
.
find
(
issue
.
id
).
notes
[
-
1
].
note
expect
(
last_note
).
to
eq
(
'
Milestone removed
'
)
expect
(
last_note
).
to
eq
(
'
removed milestone
'
)
end
end
end
spec/features/issues/move_spec.rb
View file @
6df22f72
...
...
@@ -27,7 +27,7 @@ feature 'issue move to another project' do
let!
(
:mr
)
{
create
(
:merge_request
,
source_project:
old_project
)
}
let
(
:new_project
)
{
create
(
:project
)
}
let
(
:new_project_search
)
{
create
(
:project
)
}
let
(
:text
)
{
'Text with !1'
}
let
(
:text
)
{
"Text with
#{
mr
.
to_reference
}
"
}
let
(
:cross_reference
)
{
old_project
.
to_reference
}
background
do
...
...
@@ -43,8 +43,8 @@ feature 'issue move to another project' do
expect
(
current_url
).
to
include
project_path
(
new_project
)
expect
(
page
).
to
have_content
(
"Text with
#{
cross_reference
}
!1
"
)
expect
(
page
).
to
have_content
(
"
Moved from
#{
cross_reference
}
#1
"
)
expect
(
page
).
to
have_content
(
"Text with
#{
cross_reference
}
#{
mr
.
to_reference
}
"
)
expect
(
page
).
to
have_content
(
"
moved from
#{
cross_reference
}#{
issue
.
to_reference
}
"
)
expect
(
page
).
to
have_content
(
issue
.
title
)
end
...
...
spec/features/issues/new_branch_button_spec.rb
View file @
6df22f72
...
...
@@ -20,12 +20,12 @@ feature 'Start new branch from an issue', feature: true do
context
"when there is a referenced merge request"
do
let!
(
:note
)
do
create
(
:note
,
:on_issue
,
:system
,
project:
project
,
noteable:
issue
,
note:
"
Mentioned in !
#{
referenced_mr
.
iid
}
"
)
note:
"
mentioned in
#{
referenced_mr
.
to_reference
}
"
)
end
let
(
:referenced_mr
)
do
create
(
:merge_request
,
:simple
,
source_project:
project
,
target_project:
project
,
description:
"Fixes #
#{
issue
.
iid
}
"
,
author:
user
)
description:
"Fixes
#
{
issue
.
to_reference
}
"
,
author:
user
)
end
before
do
...
...
spec/features/merge_requests/merge_when_build_succeeds_spec.rb
View file @
6df22f72
...
...
@@ -44,7 +44,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
expect
(
page
).
to
have_content
"The source branch will not be removed."
visit_merge_request
(
merge_request
)
# Needed to refresh the page
expect
(
page
).
to
have_content
/
Enabled an automatic merge when the build for [0-9a-f]
{8} succeeds/i
expect
(
page
).
to
have_content
/
enabled an automatic merge when the build for \h
{8} succeeds/i
end
end
end
...
...
spec/features/notes_on_merge_requests_spec.rb
View file @
6df22f72
...
...
@@ -141,7 +141,7 @@ describe 'Comments', feature: true do
let
(
:project2
)
{
create
(
:project
,
:private
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project2
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
source_branch:
'markdown'
)
}
let!
(
:note
)
{
create
(
:note_on_merge_request
,
:system
,
noteable:
merge_request
,
project:
project
,
note:
"
M
entioned in
#{
issue
.
to_reference
(
project
)
}
"
)
}
let!
(
:note
)
{
create
(
:note_on_merge_request
,
:system
,
noteable:
merge_request
,
project:
project
,
note:
"
m
entioned in
#{
issue
.
to_reference
(
project
)
}
"
)
}
it
'shows the system note'
do
login_as
:admin
...
...
spec/models/note_spec.rb
View file @
6df22f72
...
...
@@ -223,7 +223,7 @@ describe Note, models: true do
let
(
:note
)
do
create
:note
,
noteable:
ext_issue
,
project:
ext_proj
,
note:
"
M
entioned in issue
#{
private_issue
.
to_reference
(
ext_proj
)
}
"
,
note:
"
m
entioned in issue
#{
private_issue
.
to_reference
(
ext_proj
)
}
"
,
system:
true
end
...
...
spec/requests/api/notes_spec.rb
View file @
6df22f72
...
...
@@ -25,7 +25,7 @@ describe API::API, api: true do
let!
(
:cross_reference_note
)
do
create
:note
,
noteable:
ext_issue
,
project:
ext_proj
,
note:
"
M
entioned in issue
#{
private_issue
.
to_reference
(
ext_proj
)
}
"
,
note:
"
m
entioned in issue
#{
private_issue
.
to_reference
(
ext_proj
)
}
"
,
system:
true
end
...
...
spec/services/issues/close_service_spec.rb
View file @
6df22f72
...
...
@@ -62,7 +62,7 @@ describe Issues::CloseService, services: true do
it
'creates system note about issue reassign'
do
note
=
issue
.
notes
.
last
expect
(
note
.
note
).
to
include
"
Status changed to
closed"
expect
(
note
.
note
).
to
include
"closed"
end
it
'marks todos as done'
do
...
...
spec/services/issues/move_service_spec.rb
View file @
6df22f72
...
...
@@ -81,11 +81,11 @@ describe Issues::MoveService, services: true do
end
it
'adds system note to old issue at the end'
do
expect
(
old_issue
.
notes
.
last
.
note
).
to
match
/^Moved to/
expect
(
old_issue
.
notes
.
last
.
note
).
to
start_with
'moved to'
end
it
'adds system note to new issue at the end'
do
expect
(
new_issue
.
notes
.
last
.
note
).
to
match
/^Moved from/
expect
(
new_issue
.
notes
.
last
.
note
).
to
start_with
'moved from'
end
it
'closes old issue'
do
...
...
@@ -151,7 +151,7 @@ describe Issues::MoveService, services: true do
end
it
'adds a system note about move after rewritten notes'
do
expect
(
system_notes
.
last
.
note
).
to
match
/^
M
oved from/
expect
(
system_notes
.
last
.
note
).
to
match
/^
m
oved from/
end
it
'preserves orignal author of comment'
do
...
...
spec/services/issues/update_service_spec.rb
View file @
6df22f72
...
...
@@ -91,24 +91,24 @@ describe Issues::UpdateService, services: true do
end
it
'creates system note about issue reassign'
do
note
=
find_note
(
'
Re
assigned to'
)
note
=
find_note
(
'assigned to'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
include
"
Reassigned to
\@
#{
user2
.
usernam
e
}
"
expect
(
note
.
note
).
to
include
"
assigned to
#{
user2
.
to_referenc
e
}
"
end
it
'creates system note about issue label edit'
do
note
=
find_note
(
'
A
dded ~'
)
note
=
find_note
(
'
a
dded ~'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
include
"
Added ~
#{
label
.
id
}
label"
expect
(
note
.
note
).
to
include
"
added
#{
label
.
to_reference
}
label"
end
it
'creates system note about title change'
do
note
=
find_note
(
'
Changed title:
'
)
note
=
find_note
(
'
changed title
'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
eq
'
Changed title: **{-Old-} title** →
**{+New+} title**'
expect
(
note
.
note
).
to
eq
'
changed title from **{-Old-} title** to
**{+New+} title**'
end
end
end
...
...
@@ -128,10 +128,10 @@ describe Issues::UpdateService, services: true do
it
'creates system note about confidentiality change'
do
update_issue
(
confidential:
true
)
note
=
find_note
(
'
M
ade the issue confidential'
)
note
=
find_note
(
'
m
ade the issue confidential'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
eq
'
M
ade the issue confidential'
expect
(
note
.
note
).
to
eq
'
m
ade the issue confidential'
end
it
'executes confidential issue hooks'
do
...
...
@@ -269,8 +269,8 @@ describe Issues::UpdateService, services: true do
before
{
update_issue
(
description:
"- [x] Task 1
\n
- [X] Task 2"
)
}
it
'creates system note about task status change'
do
note1
=
find_note
(
'
M
arked the task **Task 1** as completed'
)
note2
=
find_note
(
'
M
arked the task **Task 2** as completed'
)
note1
=
find_note
(
'
m
arked the task **Task 1** as completed'
)
note2
=
find_note
(
'
m
arked the task **Task 2** as completed'
)
expect
(
note1
).
not_to
be_nil
expect
(
note2
).
not_to
be_nil
...
...
@@ -284,8 +284,8 @@ describe Issues::UpdateService, services: true do
end
it
'creates system note about task status change'
do
note1
=
find_note
(
'
M
arked the task **Task 1** as incomplete'
)
note2
=
find_note
(
'
M
arked the task **Task 2** as incomplete'
)
note1
=
find_note
(
'
m
arked the task **Task 1** as incomplete'
)
note2
=
find_note
(
'
m
arked the task **Task 2** as incomplete'
)
expect
(
note1
).
not_to
be_nil
expect
(
note2
).
not_to
be_nil
...
...
@@ -299,7 +299,7 @@ describe Issues::UpdateService, services: true do
end
it
'does not create a system note'
do
note
=
find_note
(
'
M
arked the task **Task 2** as incomplete'
)
note
=
find_note
(
'
m
arked the task **Task 2** as incomplete'
)
expect
(
note
).
to
be_nil
end
...
...
@@ -312,7 +312,7 @@ describe Issues::UpdateService, services: true do
end
it
'does not create a system note referencing the position the old item'
do
note
=
find_note
(
'
M
arked the task **Two** as incomplete'
)
note
=
find_note
(
'
m
arked the task **Two** as incomplete'
)
expect
(
note
).
to
be_nil
end
...
...
spec/services/merge_requests/close_service_spec.rb
View file @
6df22f72
...
...
@@ -42,7 +42,7 @@ describe MergeRequests::CloseService, services: true do
it
'creates system note about merge_request reassign'
do
note
=
@merge_request
.
notes
.
last
expect
(
note
.
note
).
to
include
'
Status changed to
closed'
expect
(
note
.
note
).
to
include
'closed'
end
it
'marks todos as done'
do
...
...
spec/services/merge_requests/merge_service_spec.rb
View file @
6df22f72
...
...
@@ -34,7 +34,7 @@ describe MergeRequests::MergeService, services: true do
it
'creates system note about merge_request merge'
do
note
=
merge_request
.
notes
.
last
expect
(
note
.
note
).
to
include
'
Status changed to
merged'
expect
(
note
.
note
).
to
include
'merged'
end
end
...
...
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
View file @
6df22f72
...
...
@@ -34,7 +34,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
it
'creates a system note'
do
note
=
merge_request
.
notes
.
last
expect
(
note
.
note
).
to
match
/
Enabled an automatic merge when the build for (\w+\/\w+@)?[0-9a-z]
{8}/
expect
(
note
.
note
).
to
match
/
enabled an automatic merge when the build for (\w+\/\w+@)?\h
{8}/
end
end
...
...
@@ -113,7 +113,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
it
'Posts a system note'
do
note
=
mr_merge_if_green_enabled
.
notes
.
last
expect
(
note
.
note
).
to
include
'
C
anceled the automatic merge'
expect
(
note
.
note
).
to
include
'
c
anceled the automatic merge'
end
end
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
6df22f72
...
...
@@ -76,10 +76,10 @@ describe MergeRequests::RefreshService, services: true do
reload_mrs
end
it
{
expect
(
@merge_request
.
notes
.
last
.
note
).
to
include
(
'
changed to
merged'
)
}
it
{
expect
(
@merge_request
.
notes
.
last
.
note
).
to
include
(
'merged'
)
}
it
{
expect
(
@merge_request
).
to
be_merged
}
it
{
expect
(
@fork_merge_request
).
to
be_merged
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'
changed to
merged'
)
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'merged'
)
}
it
{
expect
(
@build_failed_todo
).
to
be_done
}
it
{
expect
(
@fork_build_failed_todo
).
to
be_done
}
end
...
...
@@ -95,11 +95,11 @@ describe MergeRequests::RefreshService, services: true do
reload_mrs
end
it
{
expect
(
@merge_request
.
notes
.
last
.
note
).
to
include
(
'
changed to
merged'
)
}
it
{
expect
(
@merge_request
.
notes
.
last
.
note
).
to
include
(
'merged'
)
}
it
{
expect
(
@merge_request
).
to
be_merged
}
it
{
expect
(
@merge_request
.
diffs
.
size
).
to
be
>
0
}
it
{
expect
(
@fork_merge_request
).
to
be_merged
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'
changed to
merged'
)
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'merged'
)
}
it
{
expect
(
@build_failed_todo
).
to
be_done
}
it
{
expect
(
@fork_build_failed_todo
).
to
be_done
}
end
...
...
@@ -119,7 +119,7 @@ describe MergeRequests::RefreshService, services: true do
it
{
expect
(
@merge_request
.
notes
).
to
be_empty
}
it
{
expect
(
@merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'
A
dded 28 commits'
)
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'
a
dded 28 commits'
)
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
it
{
expect
(
@build_failed_todo
).
to
be_pending
}
it
{
expect
(
@fork_build_failed_todo
).
to
be_pending
}
...
...
@@ -146,7 +146,7 @@ describe MergeRequests::RefreshService, services: true do
reload_mrs
end
it
{
expect
(
@merge_request
.
notes
.
last
.
note
).
to
include
(
'
changed to
merged'
)
}
it
{
expect
(
@merge_request
.
notes
.
last
.
note
).
to
include
(
'merged'
)
}
it
{
expect
(
@merge_request
).
to
be_merged
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
.
notes
).
to
be_empty
}
...
...
@@ -169,8 +169,8 @@ describe MergeRequests::RefreshService, services: true do
expect
(
@merge_request
).
to
be_open
notes
=
@fork_merge_request
.
notes
.
reorder
(
:created_at
).
map
(
&
:note
)
expect
(
notes
[
0
]).
to
include
(
'
R
estored source branch `master`'
)
expect
(
notes
[
1
]).
to
include
(
'
A
dded 28 commits'
)
expect
(
notes
[
0
]).
to
include
(
'
r
estored source branch `master`'
)
expect
(
notes
[
1
]).
to
include
(
'
a
dded 28 commits'
)
expect
(
@fork_merge_request
).
to
be_open
end
end
...
...
spec/services/merge_requests/reopen_service_spec.rb
View file @
6df22f72
...
...
@@ -41,7 +41,7 @@ describe MergeRequests::ReopenService, services: true do
it
'creates system note about merge_request reopen'
do
note
=
merge_request
.
notes
.
last
expect
(
note
.
note
).
to
include
'
Status changed to
reopened'
expect
(
note
.
note
).
to
include
'reopened'
end
end
...
...
spec/services/merge_requests/update_service_spec.rb
View file @
6df22f72
...
...
@@ -79,31 +79,31 @@ describe MergeRequests::UpdateService, services: true do
end
it
'creates system note about merge_request reassign'
do
note
=
find_note
(
'
Re
assigned to'
)
note
=
find_note
(
'assigned to'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
include
"
Reassigned to
\@
#{
user2
.
usernam
e
}
"
expect
(
note
.
note
).
to
include
"
assigned to
#{
user2
.
to_referenc
e
}
"
end
it
'creates system note about merge_request label edit'
do
note
=
find_note
(
'
A
dded ~'
)
note
=
find_note
(
'
a
dded ~'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
include
"
Added ~
#{
label
.
id
}
label"
expect
(
note
.
note
).
to
include
"
added
#{
label
.
to_reference
}
label"
end
it
'creates system note about title change'
do
note
=
find_note
(
'
Changed title:
'
)
note
=
find_note
(
'
changed title
'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
eq
'
Changed title: **{-Old-} title** →
**{+New+} title**'
expect
(
note
.
note
).
to
eq
'
changed title from **{-Old-} title** to
**{+New+} title**'
end
it
'creates system note about branch change'
do
note
=
find_note
(
'
T
arget'
)
note
=
find_note
(
'
changed t
arget'
)
expect
(
note
).
not_to
be_nil
expect
(
note
.
note
).
to
eq
'
Target branch changed
from `master` to `target`'
expect
(
note
.
note
).
to
eq
'
changed target branch
from `master` to `target`'
end
context
'when not including source branch removal options'
do
...
...
@@ -258,8 +258,8 @@ describe MergeRequests::UpdateService, services: true do
before
{
update_merge_request
({
description:
"- [x] Task 1
\n
- [X] Task 2"
})
}
it
'creates system note about task status change'
do
note1
=
find_note
(
'
M
arked the task **Task 1** as completed'
)
note2
=
find_note
(
'
M
arked the task **Task 2** as completed'
)
note1
=
find_note
(
'
m
arked the task **Task 1** as completed'
)
note2
=
find_note
(
'
m
arked the task **Task 2** as completed'
)
expect
(
note1
).
not_to
be_nil
expect
(
note2
).
not_to
be_nil
...
...
@@ -273,8 +273,8 @@ describe MergeRequests::UpdateService, services: true do
end
it
'creates system note about task status change'
do
note1
=
find_note
(
'
M
arked the task **Task 1** as incomplete'
)
note2
=
find_note
(
'
M
arked the task **Task 2** as incomplete'
)
note1
=
find_note
(
'
m
arked the task **Task 1** as incomplete'
)
note2
=
find_note
(
'
m
arked the task **Task 2** as incomplete'
)
expect
(
note1
).
not_to
be_nil
expect
(
note2
).
not_to
be_nil
...
...
spec/services/system_note_service_spec.rb
View file @
6df22f72
...
...
@@ -50,7 +50,7 @@ describe SystemNoteService, services: true do
context
'without existing commits'
do
it
'adds a message header'
do
expect
(
note_lines
[
0
]).
to
eq
"
Added
#{
new_commits
.
size
}
commits:
"
expect
(
note_lines
[
0
]).
to
eq
"
added
#{
new_commits
.
size
}
commits
"
end
it
'adds a message line for each commit'
do
...
...
@@ -120,7 +120,7 @@ describe SystemNoteService, services: true do
context
'when assignee added'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
Re
assigned to @
#{
assignee
.
username
}
"
expect
(
subject
.
note
).
to
eq
"assigned to @
#{
assignee
.
username
}
"
end
end
...
...
@@ -128,7 +128,7 @@ describe SystemNoteService, services: true do
let
(
:assignee
)
{
nil
}
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'
Assignee removed
'
expect
(
subject
.
note
).
to
eq
'
removed assignee
'
end
end
end
...
...
@@ -147,7 +147,7 @@ describe SystemNoteService, services: true do
let
(
:removed
)
{
[]
}
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
A
dded ~
#{
labels
[
0
].
id
}
~
#{
labels
[
1
].
id
}
labels"
expect
(
subject
.
note
).
to
eq
"
a
dded ~
#{
labels
[
0
].
id
}
~
#{
labels
[
1
].
id
}
labels"
end
end
...
...
@@ -156,7 +156,7 @@ describe SystemNoteService, services: true do
let
(
:removed
)
{
labels
}
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
R
emoved ~
#{
labels
[
0
].
id
}
~
#{
labels
[
1
].
id
}
labels"
expect
(
subject
.
note
).
to
eq
"
r
emoved ~
#{
labels
[
0
].
id
}
~
#{
labels
[
1
].
id
}
labels"
end
end
...
...
@@ -165,7 +165,7 @@ describe SystemNoteService, services: true do
let
(
:removed
)
{
[
labels
[
1
]]
}
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
A
dded ~
#{
labels
[
0
].
id
}
and removed ~
#{
labels
[
1
].
id
}
labels"
expect
(
subject
.
note
).
to
eq
"
a
dded ~
#{
labels
[
0
].
id
}
and removed ~
#{
labels
[
1
].
id
}
labels"
end
end
end
...
...
@@ -179,7 +179,7 @@ describe SystemNoteService, services: true do
context
'when milestone added'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
Milestone changed
to
#{
milestone
.
to_reference
}
"
expect
(
subject
.
note
).
to
eq
"
changed milestone
to
#{
milestone
.
to_reference
}
"
end
end
...
...
@@ -187,7 +187,7 @@ describe SystemNoteService, services: true do
let
(
:milestone
)
{
nil
}
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'
Milestone removed
'
expect
(
subject
.
note
).
to
eq
'
removed milestone
'
end
end
end
...
...
@@ -204,13 +204,13 @@ describe SystemNoteService, services: true do
let
(
:source
)
{
double
(
'commit'
,
gfm_reference:
'commit 123456'
)
}
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
Status changed to
#{
status
}
by
commit 123456"
expect
(
subject
.
note
).
to
eq
"
#{
status
}
via
commit 123456"
end
end
context
'without a source'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"Status changed to
#{
status
}
"
expect
(
subject
.
note
).
to
eq
status
end
end
end
...
...
@@ -226,7 +226,7 @@ describe SystemNoteService, services: true do
it_behaves_like
'a system note'
it
"posts the Merge When Build Succeeds system note"
do
expect
(
subject
.
note
).
to
match
/
Enabled an automatic merge when the build for (\w+\/\w+@)?[0-9a-f]
{40} succeeds/
expect
(
subject
.
note
).
to
match
/
enabled an automatic merge when the build for (\w+\/\w+@)?\h
{40} succeeds/
end
end
...
...
@@ -240,7 +240,7 @@ describe SystemNoteService, services: true do
it_behaves_like
'a system note'
it
"posts the Merge When Build Succeeds system note"
do
expect
(
subject
.
note
).
to
eq
"
C
anceled the automatic merge"
expect
(
subject
.
note
).
to
eq
"
c
anceled the automatic merge"
end
end
...
...
@@ -252,7 +252,7 @@ describe SystemNoteService, services: true do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
Changed title: **{-Old title-}** →
**{+
#{
noteable
.
title
}
+}**"
to
eq
"
changed title from **{-Old title-}** to
**{+
#{
noteable
.
title
}
+}**"
end
end
end
...
...
@@ -264,7 +264,7 @@ describe SystemNoteService, services: true do
it_behaves_like
'a system note'
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
'
Made the issue visibl
e'
expect
(
subject
.
note
).
to
eq
'
made the issue visible to everyon
e'
end
end
end
...
...
@@ -278,7 +278,7 @@ describe SystemNoteService, services: true do
context
'when target branch name changed'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
Target branch changed
from `
#{
old_branch
}
` to `
#{
new_branch
}
`"
expect
(
subject
.
note
).
to
eq
"
changed target branch
from `
#{
old_branch
}
` to `
#{
new_branch
}
`"
end
end
end
...
...
@@ -290,7 +290,7 @@ describe SystemNoteService, services: true do
context
'when source branch deleted'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"
D
eleted source branch `feature`"
expect
(
subject
.
note
).
to
eq
"
d
eleted source branch `feature`"
end
end
end
...
...
@@ -302,7 +302,7 @@ describe SystemNoteService, services: true do
context
'when a branch is created from the new branch button'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
match
/\A
Star
ted branch [`1-mepmep`]/
expect
(
subject
.
note
).
to
match
/\A
crea
ted branch [`1-mepmep`]/
end
end
end
...
...
@@ -338,13 +338,13 @@ describe SystemNoteService, services: true do
let
(
:mentioner
)
{
project2
.
repository
.
commit
}
it
'references the mentioning commit'
do
expect
(
subject
.
note
).
to
eq
"
M
entioned in commit
#{
mentioner
.
to_reference
(
project
)
}
"
expect
(
subject
.
note
).
to
eq
"
m
entioned in commit
#{
mentioner
.
to_reference
(
project
)
}
"
end
end
context
'from non-Commit'
do
it
'references the mentioning object'
do
expect
(
subject
.
note
).
to
eq
"
M
entioned in issue
#{
mentioner
.
to_reference
(
project
)
}
"
expect
(
subject
.
note
).
to
eq
"
m
entioned in issue
#{
mentioner
.
to_reference
(
project
)
}
"
end
end
end
...
...
@@ -354,13 +354,13 @@ describe SystemNoteService, services: true do
let
(
:mentioner
)
{
project
.
repository
.
commit
}
it
'references the mentioning commit'
do
expect
(
subject
.
note
).
to
eq
"
M
entioned in commit
#{
mentioner
.
to_reference
}
"
expect
(
subject
.
note
).
to
eq
"
m
entioned in commit
#{
mentioner
.
to_reference
}
"
end
end
context
'from non-Commit'
do
it
'references the mentioning object'
do
expect
(
subject
.
note
).
to
eq
"
M
entioned in issue
#{
mentioner
.
to_reference
}
"
expect
(
subject
.
note
).
to
eq
"
m
entioned in issue
#{
mentioner
.
to_reference
}
"
end
end
end
...
...
@@ -370,7 +370,11 @@ describe SystemNoteService, services: true do
describe
'.cross_reference?'
do
it
'is truthy when text begins with expected text'
do
expect
(
described_class
.
cross_reference?
(
'Mentioned in something'
)).
to
be_truthy
expect
(
described_class
.
cross_reference?
(
'mentioned in something'
)).
to
be_truthy
end
it
'is truthy when text begins with legacy capitalized expected text'
do
expect
(
described_class
.
cross_reference?
(
'mentioned in something'
)).
to
be_truthy
end
it
'is falsey when text does not begin with expected text'
do
...
...
@@ -433,6 +437,19 @@ describe SystemNoteService, services: true do
expect
(
described_class
.
cross_reference_exists?
(
noteable
,
commit1
)).
to
be_falsey
end
context
'legacy capitalized cross reference'
do
before
do
# Mention issue (noteable) from commit0
system_note
=
described_class
.
cross_reference
(
noteable
,
commit0
,
author
)
system_note
.
update
(
note:
system_note
.
note
.
capitalize
)
end
it
'is truthy when already mentioned'
do
expect
(
described_class
.
cross_reference_exists?
(
noteable
,
commit0
)).
to
be_truthy
end
end
end
context
'commit from commit'
do
...
...
@@ -450,6 +467,19 @@ describe SystemNoteService, services: true do
expect
(
described_class
.
cross_reference_exists?
(
commit1
,
commit0
)).
to
be_falsey
end
context
'legacy capitalized cross reference'
do
before
do
# Mention commit1 from commit0
system_note
=
described_class
.
cross_reference
(
commit0
,
commit1
,
author
)
system_note
.
update
(
note:
system_note
.
note
.
capitalize
)
end
it
'is truthy when already mentioned'
do
expect
(
described_class
.
cross_reference_exists?
(
commit0
,
commit1
)).
to
be_truthy
end
end
end
context
'commit with cross-reference from fork'
do
...
...
@@ -465,6 +495,18 @@ describe SystemNoteService, services: true do
expect
(
described_class
.
cross_reference_exists?
(
noteable
,
commit2
)).
to
be
true
end
context
'legacy capitalized cross reference'
do
before
do
system_note
=
described_class
.
cross_reference
(
noteable
,
commit0
,
author2
)
system_note
.
update
(
note:
system_note
.
note
.
capitalize
)
end
it
'is true when a fork mentions an external issue'
do
expect
(
described_class
.
cross_reference_exists?
(
noteable
,
commit2
)).
to
be
true
end
end
end
end
...
...
@@ -498,7 +540,7 @@ describe SystemNoteService, services: true do
it_behaves_like
'cross project mentionable'
it
'notifies about noteable being moved to'
do
expect
(
subject
.
note
).
to
match
/
M
oved to/
expect
(
subject
.
note
).
to
match
/
m
oved to/
end
end
...
...
@@ -508,7 +550,7 @@ describe SystemNoteService, services: true do
it_behaves_like
'cross project mentionable'
it
'notifies about noteable being moved from'
do
expect
(
subject
.
note
).
to
match
/
M
oved from/
expect
(
subject
.
note
).
to
match
/
m
oved from/
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