Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
fa0cbb13
Commit
fa0cbb13
authored
Jan 30, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs and add a new one
parent
677b4db9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
28 deletions
+37
-28
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+13
-4
spec/lib/gitlab/diff/highlight_spec.rb
spec/lib/gitlab/diff/highlight_spec.rb
+24
-24
No files found.
spec/helpers/diff_helper_spec.rb
View file @
fa0cbb13
...
...
@@ -104,8 +104,7 @@ describe DiffHelper do
end
end
describe
'diff_line_content'
do
describe
'#diff_line_content'
do
it
'should return non breaking space when line is empty'
do
expect
(
diff_line_content
(
nil
)).
to
eq
(
' '
)
end
...
...
@@ -116,9 +115,19 @@ describe DiffHelper do
expect
(
diff_line_content
(
diff_file
.
diff_lines
.
first
.
type
)).
to
eq
(
'match'
)
expect
(
diff_file
.
diff_lines
.
first
.
new_pos
).
to
eq
(
6
)
end
end
describe
"#mark_inline_diffs"
do
let
(
:old_line
)
{
%{abc 'def'}
}
let
(
:new_line
)
{
%{abc "def"}
}
it
"returns strings with marked inline diffs"
do
marked_old_line
,
marked_new_line
=
mark_inline_diffs
(
old_line
,
new_line
)
it
'should return safe HTML'
do
expect
(
diff_line_content
(
diff_file
.
diff_lines
.
first
.
text
)).
to
be_html_safe
expect
(
marked_old_line
).
to
eq
(
"abc <span class='idiff left right'>'def'</span>"
)
expect
(
marked_old_line
).
to
be_html_safe
expect
(
marked_new_line
).
to
eq
(
"abc <span class='idiff left right'>"def"</span>"
)
expect
(
marked_new_line
).
to
be_html_safe
end
end
end
spec/lib/gitlab/diff/highlight_spec.rb
View file @
fa0cbb13
...
...
@@ -40,38 +40,38 @@ describe Gitlab::Diff::Highlight, lib: true do
end
end
context
"with diff lines"
do
let
(
:subject
)
{
Gitlab
::
Diff
::
Highlight
.
new
(
diff_file
.
diff_lines
).
highlight
}
context
"with diff lines"
do
let
(
:subject
)
{
Gitlab
::
Diff
::
Highlight
.
new
(
diff_file
.
diff_lines
).
highlight
}
it
'should return Gitlab::Diff::Line elements'
do
expect
(
subject
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
end
it
'should return Gitlab::Diff::Line elements'
do
expect
(
subject
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
end
it
'should not modify "match" lines'
do
expect
(
subject
[
0
].
text
).
to
eq
(
'@@ -6,12 +6,18 @@ module Popen'
)
expect
(
subject
[
22
].
text
).
to
eq
(
'@@ -19,6 +25,7 @@ module Popen'
)
end
it
'should not modify "match" lines'
do
expect
(
subject
[
0
].
text
).
to
eq
(
'@@ -6,12 +6,18 @@ module Popen'
)
expect
(
subject
[
22
].
text
).
to
eq
(
'@@ -19,6 +25,7 @@ module Popen'
)
end
it
'marks unchanged lines'
do
code
=
%Q{ def popen(cmd, path=nil)}
it
'marks unchanged lines'
do
code
=
%Q{ def popen(cmd, path=nil)}
expect
(
subject
[
2
].
text
).
to
eq
(
code
)
expect
(
subject
[
2
].
text
).
not_to
be_html_safe
end
expect
(
subject
[
2
].
text
).
to
eq
(
code
)
expect
(
subject
[
2
].
text
).
not_to
be_html_safe
end
it
'marks removed lines'
do
code
=
%Q{- raise "System commands must be given as an array of strings"}
it
'marks removed lines'
do
code
=
%Q{- raise "System commands must be given as an array of strings"}
expect
(
subject
[
4
].
text
).
to
eq
(
code
)
expect
(
subject
[
4
].
text
).
not_to
be_html_safe
end
expect
(
subject
[
4
].
text
).
to
eq
(
code
)
expect
(
subject
[
4
].
text
).
not_to
be_html_safe
end
it
'marks added lines'
do
code
=
%Q{+ raise <span class='idiff left right'>RuntimeError, </span>"System commands must be given as an array of strings"}
it
'marks added lines'
do
code
=
%Q{+ raise <span class='idiff left right'>RuntimeError, </span>"System commands must be given as an array of strings"}
expect
(
subject
[
5
].
text
).
to
eq
(
code
)
expect
(
subject
[
5
].
text
).
to
be_html_safe
end
expect
(
subject
[
5
].
text
).
to
eq
(
code
)
expect
(
subject
[
5
].
text
).
to
be_html_safe
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment