From adb7be432c0c619d4a96f6207d50dd5b18071535 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 12 Feb 2019 23:08:10 +0000 Subject: [PATCH] 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 --- app/services/task_list_toggle_service.rb | 2 +- .../services/task_list_toggle_service_spec.rb | 32 +++++++++++++++---- 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 cfe187d9b12..d85abf4dce9 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

A paragraph

-
    -
  1. - Item 1 -
      -
    • - Sub-item 1 +
        +
      1. + Item 1 +
          +
        • + Sub-item 1
      +
        +
      • +

        loose list

        +

        with an embedded paragraph

        +
      • +
      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, -- GitLab