Fix a frozen string error in lib/gitlab/utils.rb

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2018-12-10 16:08:42 +01:00
parent 80eebd8e33
commit f233c3bce0
No known key found for this signature in database
GPG Key ID: 98DFFD1C0C62B70B
3 changed files with 12 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
title: Fix a frozen string error in lib/gitlab/utils.rb
merge_request: 23690
author:
type: fixed

View File

@ -60,7 +60,7 @@ module Gitlab
# Converts newlines into HTML line break elements
def nlbr(str)
ActionView::Base.full_sanitizer.sanitize(str, tags: []).gsub(/\r?\n/, '<br>').html_safe
ActionView::Base.full_sanitizer.sanitize(+str, tags: []).gsub(/\r?\n/, '<br>').html_safe
end
def remove_line_breaks(str)

View File

@ -44,6 +44,12 @@ describe Gitlab::Utils do
end
end
describe '.nlbr' do
it 'replaces new lines with <br>' do
expect(described_class.nlbr("<b>hello</b>\n<i>world</i>".freeze)).to eq("hello<br>world")
end
end
describe '.remove_line_breaks' do
using RSpec::Parameterized::TableSyntax