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
5c25629a
Commit
5c25629a
authored
May 11, 2017
by
Kushal Pandya
Committed by
Filipa Lacerda
May 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix slash commands detection in comments
parent
344fee5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+1
-1
spec/javascripts/notes_spec.js
spec/javascripts/notes_spec.js
+19
-6
No files found.
app/assets/javascripts/notes.js
View file @
5c25629a
...
@@ -24,7 +24,7 @@ const normalizeNewlines = function(str) {
...
@@ -24,7 +24,7 @@ const normalizeNewlines = function(str) {
(
function
()
{
(
function
()
{
this
.
Notes
=
(
function
()
{
this
.
Notes
=
(
function
()
{
const
MAX_VISIBLE_COMMIT_LIST_COUNT
=
3
;
const
MAX_VISIBLE_COMMIT_LIST_COUNT
=
3
;
const
REGEX_SLASH_COMMANDS
=
/
\/\w
+/g
;
const
REGEX_SLASH_COMMANDS
=
/
^
\/\w
+/gm
;
Notes
.
interval
=
null
;
Notes
.
interval
=
null
;
...
...
spec/javascripts/notes_spec.js
View file @
5c25629a
...
@@ -376,13 +376,20 @@ import '~/notes';
...
@@ -376,13 +376,20 @@ import '~/notes';
this
.
notes
=
new
Notes
(
''
,
[]);
this
.
notes
=
new
Notes
(
''
,
[]);
});
});
it
(
'
should return true when comment
has slash commands
'
,
()
=>
{
it
(
'
should return true when comment
begins with a slash command
'
,
()
=>
{
const
sampleComment
=
'
/wip
/milestone %1.0 /merge
/unassign Merging this
'
;
const
sampleComment
=
'
/wip
\n
/milestone %1.0
\n
/merge
\n
/unassign Merging this
'
;
const
hasSlashCommands
=
this
.
notes
.
hasSlashCommands
(
sampleComment
);
const
hasSlashCommands
=
this
.
notes
.
hasSlashCommands
(
sampleComment
);
expect
(
hasSlashCommands
).
toBeTruthy
();
expect
(
hasSlashCommands
).
toBeTruthy
();
});
});
it
(
'
should return false when comment does NOT begin with a slash command
'
,
()
=>
{
const
sampleComment
=
'
Hey, /unassign Merging this
'
;
const
hasSlashCommands
=
this
.
notes
.
hasSlashCommands
(
sampleComment
);
expect
(
hasSlashCommands
).
toBeFalsy
();
});
it
(
'
should return false when comment does NOT have any slash commands
'
,
()
=>
{
it
(
'
should return false when comment does NOT have any slash commands
'
,
()
=>
{
const
sampleComment
=
'
Looking good, Awesome!
'
;
const
sampleComment
=
'
Looking good, Awesome!
'
;
const
hasSlashCommands
=
this
.
notes
.
hasSlashCommands
(
sampleComment
);
const
hasSlashCommands
=
this
.
notes
.
hasSlashCommands
(
sampleComment
);
...
@@ -392,14 +399,20 @@ import '~/notes';
...
@@ -392,14 +399,20 @@ import '~/notes';
});
});
describe
(
'
stripSlashCommands
'
,
()
=>
{
describe
(
'
stripSlashCommands
'
,
()
=>
{
const
REGEX_SLASH_COMMANDS
=
/
\/\w
+/g
;
it
(
'
should strip slash commands from the comment which begins with a slash command
'
,
()
=>
{
this
.
notes
=
new
Notes
();
const
sampleComment
=
'
/wip
\n
/milestone %1.0
\n
/merge
\n
/unassign Merging this
'
;
const
stripedComment
=
this
.
notes
.
stripSlashCommands
(
sampleComment
);
expect
(
stripedComment
).
not
.
toBe
(
sampleComment
);
});
it
(
'
should
strip slash commands from the comment
'
,
()
=>
{
it
(
'
should
NOT strip string that has slashes within
'
,
()
=>
{
this
.
notes
=
new
Notes
();
this
.
notes
=
new
Notes
();
const
sampleComment
=
'
/wip /milestone %1.0 /merge /unassign Merging this
'
;
const
sampleComment
=
'
http://127.0.0.1:3000/root/gitlab-shell/issues/1
'
;
const
stripedComment
=
this
.
notes
.
stripSlashCommands
(
sampleComment
);
const
stripedComment
=
this
.
notes
.
stripSlashCommands
(
sampleComment
);
expect
(
REGEX_SLASH_COMMANDS
.
test
(
stripedComment
)).
toBeFalsy
(
);
expect
(
stripedComment
).
toBe
(
sampleComment
);
});
});
});
});
...
...
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