Открыть боковую панель
nt_test133
nt_project_uxpg8lvcuq8w
Коммиты
5c25629a
Коммит
5c25629a
создал
Май 11, 2017
по автору
Kushal Pandya
Зафиксировано автором
Filipa Lacerda
Май 11, 2017
Просмотр файлов
Fix slash commands detection in comments
владелец
344fee5a
Изменения
2
Скрыть пробелы
Построчно
Рядом
app/assets/javascripts/notes.js
Просмотр файла @
5c25629a
...
...
@@ -24,7 +24,7 @@ const normalizeNewlines = function(str) {
(
function
()
{
this
.
Notes
=
(
function
()
{
const
MAX_VISIBLE_COMMIT_LIST_COUNT
=
3
;
const
REGEX_SLASH_COMMANDS
=
/
\/\w
+/g
;
const
REGEX_SLASH_COMMANDS
=
/
^
\/\w
+/g
m
;
Notes
.
interval
=
null
;
...
...
spec/javascripts/notes_spec.js
Просмотр файла @
5c25629a
...
...
@@ -376,13 +376,20 @@ import '~/notes';
this
.
notes
=
new
Notes
(
''
,
[]);
});
it
(
'
should return true when comment
has
slash command
s
'
,
()
=>
{
const
sampleComment
=
'
/wip /milestone %1.0 /merge /unassign Merging this
'
;
it
(
'
should return true when comment
begins with a
slash command
'
,
()
=>
{
const
sampleComment
=
'
/wip
\n
/milestone %1.0
\n
/merge
\n
/unassign Merging this
'
;
const
hasSlashCommands
=
this
.
notes
.
hasSlashCommands
(
sampleComment
);
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
'
,
()
=>
{
const
sampleComment
=
'
Looking good, Awesome!
'
;
const
hasSlashCommands
=
this
.
notes
.
hasSlashCommands
(
sampleComment
);
...
...
@@ -392,14 +399,20 @@ import '~/notes';
});
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 s
lash commands from the comment
'
,
()
=>
{
it
(
'
should
NOT
strip s
tring that has slashes within
'
,
()
=>
{
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
);
expect
(
REGEX_SLASH_COMMANDS
.
test
(
stripedComment
)
)
.
toBe
Falsy
(
);
expect
(
stripedComment
).
toBe
(
sampleComment
);
});
});
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать