Commit c02f0808 authored by Sean McGivern's avatar Sean McGivern

Merge branch '26068_tasklist_issue' into 'master'

don’t count tasks that are not defined as list items correctly

Closes #26068

See merge request !8526
parents ac6e202f 816fad35
...@@ -11,8 +11,8 @@ module Taskable ...@@ -11,8 +11,8 @@ module Taskable
INCOMPLETE = 'incomplete'.freeze INCOMPLETE = 'incomplete'.freeze
ITEM_PATTERN = / ITEM_PATTERN = /
^ ^
\s*(?:[-+*]|(?:\d+\.))? # optional list prefix \s*(?:[-+*]|(?:\d+\.)) # list prefix required - task item has to be always in a list
\s* # optional whitespace prefix \s+ # whitespace prefix has to be always presented for a list item
(\[\s\]|\[[xX]\]) # checkbox (\[\s\]|\[[xX]\]) # checkbox
(\s.+) # followed by whitespace and some text. (\s.+) # followed by whitespace and some text.
/x /x
......
---
title: Don’t count tasks that are not defined as list items correctly
merge_request: 8526
author:
...@@ -72,6 +72,25 @@ shared_examples 'a Taskable' do ...@@ -72,6 +72,25 @@ shared_examples 'a Taskable' do
end end
end end
describe 'with tasks that are not formatted correctly' do
before do
subject.description = <<-EOT.strip_heredoc
[ ] task 1
[ ] task 2
- [ ]task 1
-[ ] task 2
EOT
end
it 'returns the correct task status' do
expect(subject.task_status).to match('0 of')
expect(subject.task_status).to match('0 tasks completed')
expect(subject.task_status_short).to match('0/')
expect(subject.task_status_short).to match('0 task')
end
end
describe 'with a complete task' do describe 'with a complete task' do
before do before do
subject.description = <<-EOT.strip_heredoc subject.description = <<-EOT.strip_heredoc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment