summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2019-02-12 23:08:10 +0000
committerRobert Speicher <rspeicher@gmail.com>2019-02-12 23:08:10 +0000
commit0f20c401d37354cb91ab66b6e220b95f2301dafb (patch)
tree574acce7d438ac5fc67d9b26b63180b898f7b39e
parenta58e92fc1b96c6967d160473d5c8dff17bf18775 (diff)
parentff71ac7217a8e5fa33c9ce8c46a5642c1d27f5e4 (diff)
downloadgitlab-ce-0f20c401d37354cb91ab66b6e220b95f2301dafb.tar.gz
Merge branch '57604-checking-a-box-in-an-issue-description-consistently-throws-an-error-on-11-8-0-rc2' into 'master'
Checking a box in an issue description consistently throws an error Closes #57604 See merge request gitlab-org/gitlab-ce!25174
-rw-r--r--app/services/task_list_toggle_service.rb2
-rw-r--r--spec/services/task_list_toggle_service_spec.rb32
2 files changed, 27 insertions, 7 deletions
diff --git a/app/services/task_list_toggle_service.rb b/app/services/task_list_toggle_service.rb
index af24bc0524c..f6602a35033 100644
--- a/app/services/task_list_toggle_service.rb
+++ b/app/services/task_list_toggle_service.rb
@@ -67,6 +67,6 @@ class TaskListToggleService
# When using CommonMark, we should be able to use the embedded `sourcepos` attribute to
# target the exact line in the DOM.
def get_html_checkbox(html)
- html.css(".task-list-item[data-sourcepos^='#{line_number}:'] > input.task-list-item-checkbox").first
+ html.css(".task-list-item[data-sourcepos^='#{line_number}:'] input.task-list-item-checkbox").first
end
end
diff --git a/spec/services/task_list_toggle_service_spec.rb b/spec/services/task_list_toggle_service_spec.rb
index 7c5480d382f..b1260cf740a 100644
--- a/spec/services/task_list_toggle_service_spec.rb
+++ b/spec/services/task_list_toggle_service_spec.rb
@@ -12,6 +12,10 @@ describe TaskListToggleService do
1. [X] Item 1
- [ ] Sub-item 1
+
+ - [ ] loose list
+
+ with an embedded paragraph
EOT
end
@@ -26,16 +30,22 @@ describe TaskListToggleService do
</li>
</ul>
<p data-sourcepos="4:1-4:11" dir="auto">A paragraph</p>
- <ol data-sourcepos="6:1-7:19" class="task-list" dir="auto">
- <li data-sourcepos="6:1-7:19" class="task-list-item">
- <input type="checkbox" class="task-list-item-checkbox" disabled checked> Item 1
- <ul data-sourcepos="7:4-7:19" class="task-list">
- <li data-sourcepos="7:4-7:19" class="task-list-item">
- <input type="checkbox" class="task-list-item-checkbox" disabled> Sub-item 1
+ <ol data-sourcepos="6:1-8:0" class="task-list" dir="auto">
+ <li data-sourcepos="6:1-8:0" class="task-list-item">
+ <input type="checkbox" class="task-list-item-checkbox" checked="" disabled=""> Item 1
+ <ul data-sourcepos="7:4-8:0" class="task-list">
+ <li data-sourcepos="7:4-8:0" class="task-list-item">
+ <input type="checkbox" class="task-list-item-checkbox" disabled=""> Sub-item 1
</li>
</ul>
</li>
</ol>
+ <ul data-sourcepos="9:1-11:28" class="task-list" dir="auto">
+ <li data-sourcepos="9:1-11:28" class="task-list-item">
+ <p data-sourcepos="9:3-9:16"><input type="checkbox" class="task-list-item-checkbox" disabled=""> loose list</p>
+ <p data-sourcepos="11:3-11:28">with an embedded paragraph</p>
+ </li>
+ </ul>
EOT
end
@@ -59,6 +69,16 @@ describe TaskListToggleService do
expect(toggler.updated_markdown_html).to include('disabled> Item 1')
end
+ it 'checks task in loose list' do
+ toggler = described_class.new(markdown, markdown_html,
+ toggle_as_checked: true,
+ line_source: '- [ ] loose list', line_number: 9)
+
+ expect(toggler.execute).to be_truthy
+ expect(toggler.updated_markdown.lines[8]).to eq "- [x] loose list\n"
+ expect(toggler.updated_markdown_html).to include('disabled checked> loose list')
+ end
+
it 'returns false if line_source does not match the text' do
toggler = described_class.new(markdown, markdown_html,
toggle_as_checked: false,