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
91776d93
Commit
91776d93
authored
Dec 17, 2019
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust task regex to detect task in list item
that has no text
parent
610aa44c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
7 deletions
+52
-7
app/models/concerns/taskable.rb
app/models/concerns/taskable.rb
+5
-5
changelogs/unreleased/27296-incorrect-task-list-checked-with-embedded-subtasks.yml
...96-incorrect-task-list-checked-with-embedded-subtasks.yml
+5
-0
spec/services/task_list_toggle_service_spec.rb
spec/services/task_list_toggle_service_spec.rb
+42
-2
No files found.
app/models/concerns/taskable.rb
View file @
91776d93
...
...
@@ -15,11 +15,11 @@ module Taskable
INCOMPLETE_PATTERN
=
/(\[[\s]\])/
.
freeze
ITEM_PATTERN
=
%r{
^
(?:(?:>
\s
{0,4})*) # optional blockquote characters
\s
*(?:[-+*]|(?:
\d
+
\.
)) # list prefix
required - task item has to be always in a list
\s
+ # whitespace prefix has to be always presented for a list item
(
\[\s\]
|
\[
[xX]
\]
) # checkbox
(
\s
.+) # followed by whitespace and some text.
(?:(?:>
\s
{0,4})*)
# optional blockquote characters
(?:
\s
*(?:[-+*]|(?:
\d
+
\.
)))+ # list prefix (one or more)
required - task item has to be always in a list
\s
+
# whitespace prefix has to be always presented for a list item
(
\[\s\]
|
\[
[xX]
\]
)
# checkbox
(
\s
.+)
# followed by whitespace and some text.
}x
.
freeze
def
self
.
get_tasks
(
content
)
...
...
changelogs/unreleased/27296-incorrect-task-list-checked-with-embedded-subtasks.yml
0 → 100644
View file @
91776d93
---
title
:
Properly check a task embedded in a list with no text
merge_request
:
21947
author
:
type
:
fixed
spec/services/task_list_toggle_service_spec.rb
View file @
91776d93
...
...
@@ -121,7 +121,7 @@ describe TaskListToggleService do
> * [x] Task 2
EOT
markdown_html
=
Banzai
::
Pipeline
::
FullPipeline
.
call
(
markdown
,
project:
nil
)[
:output
].
to_html
markdown_html
=
parse_markdown
(
markdown
)
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggle_as_checked:
true
,
line_source:
'> > * [ ] Task 1'
,
line_number:
1
)
...
...
@@ -142,7 +142,7 @@ describe TaskListToggleService do
* [x] Task 2
EOT
markdown_html
=
Banzai
::
Pipeline
::
FullPipeline
.
call
(
markdown
,
project:
nil
)[
:output
].
to_html
markdown_html
=
parse_markdown
(
markdown
)
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggle_as_checked:
true
,
line_source:
'* [ ] Task 1'
,
line_number:
5
)
...
...
@@ -151,4 +151,44 @@ describe TaskListToggleService do
expect
(
toggler
.
updated_markdown
.
lines
[
4
]).
to
eq
"* [x] Task 1
\n
"
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled checked> Task 1'
)
end
context
'when clicking an embedded subtask'
do
it
'properly handles it inside an unordered list'
do
markdown
=
<<-
EOT
.
strip_heredoc
- - [ ] Task 1
- [x] Task 2
EOT
markdown_html
=
parse_markdown
(
markdown
)
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggle_as_checked:
true
,
line_source:
'- - [ ] Task 1'
,
line_number:
1
)
expect
(
toggler
.
execute
).
to
be_truthy
expect
(
toggler
.
updated_markdown
.
lines
[
0
]).
to
eq
"- - [x] Task 1
\n
"
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled checked> Task 1'
)
end
it
'properly handles it inside an ordered list'
do
markdown
=
<<-
EOT
.
strip_heredoc
1. - [ ] Task 1
- [x] Task 2
EOT
markdown_html
=
parse_markdown
(
markdown
)
toggler
=
described_class
.
new
(
markdown
,
markdown_html
,
toggle_as_checked:
true
,
line_source:
'1. - [ ] Task 1'
,
line_number:
1
)
expect
(
toggler
.
execute
).
to
be_truthy
expect
(
toggler
.
updated_markdown
.
lines
[
0
]).
to
eq
"1. - [x] Task 1
\n
"
expect
(
toggler
.
updated_markdown_html
).
to
include
(
'disabled checked> Task 1'
)
end
end
def
parse_markdown
(
markdown
)
Banzai
::
Pipeline
::
FullPipeline
.
call
(
markdown
,
project:
nil
)[
:output
].
to_html
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