diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-19 18:07:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-19 18:07:48 +0000 |
commit | b5571e6e22cdacc81f78eff5943d68c8ba220fbb (patch) | |
tree | 3677b792f5afe0b4853cee59e166df961993b7e8 /spec/services/task_list_toggle_service_spec.rb | |
parent | f92a53a216e6e7d5037ac701efbee5628f91aa9a (diff) | |
download | gitlab-ce-b5571e6e22cdacc81f78eff5943d68c8ba220fbb.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/task_list_toggle_service_spec.rb')
-rw-r--r-- | spec/services/task_list_toggle_service_spec.rb | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/spec/services/task_list_toggle_service_spec.rb b/spec/services/task_list_toggle_service_spec.rb index a309951bbcb..82a5446dcb8 100644 --- a/spec/services/task_list_toggle_service_spec.rb +++ b/spec/services/task_list_toggle_service_spec.rb @@ -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 |