summaryrefslogtreecommitdiff
path: root/app/helpers/diff_helper.rb
diff options
context:
space:
mode:
authorRubén Dávila <rdavila84@gmail.com>2016-01-13 11:39:15 -0500
committerRubén Dávila <rdavila84@gmail.com>2016-01-13 11:39:15 -0500
commit0f0af19139db71255934e9a7a5b5cd86420b7186 (patch)
tree61b8a2b9610e6a1d47fbb5dc3a4b97bcbd1d6bc7 /app/helpers/diff_helper.rb
parent48c45ba9a8a9a5536a3d501e40536cc5b73062a1 (diff)
downloadgitlab-ce-0f0af19139db71255934e9a7a5b5cd86420b7186.tar.gz
Little refactor for usage of html_safe. #3945
Diffstat (limited to 'app/helpers/diff_helper.rb')
-rw-r--r--app/helpers/diff_helper.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 0ec532a9a90..d49e22e8c84 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -1,4 +1,6 @@
module DiffHelper
+ BLANK_SPACE = "&nbsp;".html_safe
+
def diff_view
params[:view] == 'parallel' ? 'parallel' : 'inline'
end
@@ -83,7 +85,7 @@ module DiffHelper
elsif next_type == 'old' || next_type.nil?
# Left side has text removed, right side doesn't have any change
# No next line code, no new line number, no new line text
- line = [type, line_old, full_line, line_code, next_type, nil, "&nbsp;", nil]
+ line = [type, line_old, full_line, line_code, next_type, nil, BLANK_SPACE, nil]
lines.push(line)
end
elsif type == 'new'
@@ -93,7 +95,7 @@ module DiffHelper
next
else
# Change is only on the right side, left side has no change
- line = [nil, nil, "&nbsp;", line_code, type, line_new, full_line, line_code]
+ line = [nil, nil, BLANK_SPACE, line_code, type, line_new, full_line, line_code]
lines.push(line)
end
end
@@ -113,8 +115,7 @@ module DiffHelper
if line.blank?
" &nbsp;".html_safe
else
- # Return line if it isn't a String, it helps when it's Numeric
- line.is_a?(String) ? line.html_safe : line
+ line.html_safe
end
end