Skip to content
Snippets Groups Projects
Verified Commit 1ebba30a authored by Justin Ho Tuan Duong's avatar Justin Ho Tuan Duong Committed by GitLab
Browse files

Merge branch 'mallocke/remove_is_todo_kwarg' into 'master'

Remove first_line_in_markdown is_todo kwarg

See merge request !149193



Merged-by: default avatarJustin Ho Tuan Duong <hduong@gitlab.com>
Approved-by: default avatarMadelein van Niekerk <mvanniekerk@gitlab.com>
Approved-by: default avatarJustin Ho Tuan Duong <hduong@gitlab.com>
Approved-by: default avatarAaron Huntsman <ahuntsman@gitlab.com>
Co-authored-by: default avatarMalcolm Locke <mlocke@gitlab.com>
parents 3346cf7b dd5d8109
No related branches found
No related tags found
1 merge request!149193Remove first_line_in_markdown is_todo kwarg
Pipeline #1250182527 passed
......@@ -59,7 +59,7 @@ def link_to_html(redacted, url, html_options = {})
# as Markdown. HTML tags in the parsed output are not counted toward the
# +max_chars+ limit. If the length limit falls within a tag's contents, then
# the tag contents are truncated without removing the closing tag.
def first_line_in_markdown(object, attribute, max_chars = nil, is_todo: false, **options)
def first_line_in_markdown(object, attribute, max_chars = nil, **options)
md = markdown_field(object, attribute, options.merge(post_process: false))
return unless md.present?
......
......@@ -45,7 +45,7 @@
\.
- if todo.note.present?
%span.action-description<
= first_line_in_markdown(todo, :body, 125, is_todo: true, project: todo.project, group: todo.group)
= first_line_in_markdown(todo, :body, 125, project: todo.project, group: todo.group)
= render_if_exists "dashboard/todos/review_summary", local_assigns: { todo: todo }
......
......@@ -449,21 +449,21 @@
object = create_object('Text with `inline code`')
expected = 'Text with <code>inline code</code>'
expect(helper.first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)).to match(expected)
expect(helper.first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
end
it 'truncates the text with multiple paragraphs' do
object = create_object("Paragraph 1\n\nParagraph 2")
expected = 'Paragraph 1...'
expect(helper.first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)).to match(expected)
expect(helper.first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
end
it 'displays the first line of a code block' do
object = create_object("```\nCode block\nwith two lines\n```")
expected = %r{<pre.+><code><span class="line" lang="plaintext">Code block\.\.\.</span></code></pre>}
expect(helper.first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)).to match(expected)
expect(helper.first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
end
it 'truncates a single long line of text' do
......@@ -471,7 +471,7 @@
object = create_object(text * 4)
expected = (text * 2).sub(/.{3}/, '...')
expect(helper.first_line_in_markdown(object, attribute, 150, is_todo: true, project: project)).to match(expected)
expect(helper.first_line_in_markdown(object, attribute, 150, project: project)).to match(expected)
end
it 'preserves code color scheme' do
......@@ -480,12 +480,12 @@
"<code><span class=\"line\" lang=\"ruby\"><span class=\"k\">def</span> <span class=\"nf\">test</span>...</span>" \
"</code></pre>\n"
expect(helper.first_line_in_markdown(object, attribute, 150, is_todo: true, project: project)).to eq(expected)
expect(helper.first_line_in_markdown(object, attribute, 150, project: project)).to eq(expected)
end
it 'removes any images' do
object = create_object("![ImageTest](/uploads/test.png)")
text = helper.first_line_in_markdown(object, attribute, 150, is_todo: true, project: project)
text = helper.first_line_in_markdown(object, attribute, 150, project: project)
expect(text).not_to match('<img')
expect(text).not_to match('<a')
......@@ -511,7 +511,7 @@ def create_and_format_label(project)
create(:label, title: 'label_1', project: project)
object = create_object(label_title, project: project)
helper.first_line_in_markdown(object, attribute, 150, is_todo: true, project: project)
helper.first_line_in_markdown(object, attribute, 150, project: project)
end
it 'preserves style attribute for a label that can be accessed by current_user' do
......@@ -535,7 +535,7 @@ def create_and_format_label(project)
html = '<i></i> <strong>strong</strong><em>em</em><b>b</b>'
object = create_object(html)
result = helper.first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)
result = helper.first_line_in_markdown(object, attribute, 100, project: project)
expect(result).to include(html)
end
......@@ -544,7 +544,7 @@ def create_and_format_label(project)
object = create_object("hello \n\n [Test](README.md)")
expect do
helper.first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)
helper.first_line_in_markdown(object, attribute, 100, project: project)
end.not_to change { Gitlab::GitalyClient.get_request_count }
end
......@@ -552,7 +552,7 @@ def create_and_format_label(project)
html = 'This a cool [website](https://gitlab.com/).'
object = create_object(html)
result = helper.first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)
result = helper.first_line_in_markdown(object, attribute, 100, project: project)
expect(result).to include('This a cool website.')
end
......@@ -562,7 +562,7 @@ def create_and_format_label(project)
html = "Please have a look, @#{user.username} @#{another_user.username}!"
object = create_object(html)
result = helper.first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)
result = helper.first_line_in_markdown(object, attribute, 100, project: project)
links = Nokogiri::HTML.parse(result).css('//a')
expect(links[0].classes).to include('current-user')
......@@ -579,7 +579,7 @@ def create_and_format_label(project)
html = "Please have a look, @#{user.username} @#{another_user.username}!"
object = create_object(html)
result = helper.first_line_in_markdown(object, attribute, 100, is_todo: true, project: project)
result = helper.first_line_in_markdown(object, attribute, 100, project: project)
links = Nokogiri::HTML.parse(result).css('//a')
expect(links[0].classes).not_to include('current-user')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment