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
52f8286a
Commit
52f8286a
authored
Jan 08, 2016
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update specs. #3945
parent
6282202e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
spec/lib/gitlab/diff/highlight_spec.rb
spec/lib/gitlab/diff/highlight_spec.rb
+15
-16
No files found.
spec/lib/gitlab/diff/highlight_spec.rb
View file @
52f8286a
...
@@ -6,24 +6,24 @@ describe Gitlab::Diff::Highlight, lib: true do
...
@@ -6,24 +6,24 @@ describe Gitlab::Diff::Highlight, lib: true do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
)
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
[
commit
.
parent
.
id
,
commit
.
id
],
project
.
repository
)
}
describe
'.process_diff_lines'
do
describe
'.process_diff_lines'
do
context
'when processing Gitlab::Diff::Line objects'
do
context
'when processing Gitlab::Diff::Line objects'
do
let
(
:diff_lines
)
{
Gitlab
::
Diff
::
Highlight
.
process_diff_lines
(
diff_file
.
new_path
,
diff_file
.
diff_lines
)
}
let
(
:diff_lines
)
{
Gitlab
::
Diff
::
Highlight
.
process_diff_lines
(
diff_file
)
}
it
'should return Gitlab::Diff::Line elements'
do
it
'should return Gitlab::Diff::Line elements'
do
expect
(
diff_lines
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
expect
(
diff_lines
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
end
end
it
'should highlight the code'
do
it
'should highlight the code'
do
code
=
%Q{
<span id="LC3" class="line">
<span class="k">def</span> <span class="nf">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="kp">nil</span><span class="p">)</span></span>
\n
}
code
=
%Q{
<span id="LC7" class="line">
<span class="k">def</span> <span class="nf">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="kp">nil</span><span class="p">)</span></span>
\n
}
expect
(
diff_lines
[
2
].
text
).
to
eq
(
code
)
expect
(
diff_lines
[
2
].
text
).
to
eq
(
code
)
end
end
it
'should
keep
the inline diff markup'
do
it
'should
not generate
the inline diff markup'
do
expect
(
diff_lines
[
5
].
text
).
to
match
(
Regexp
.
new
(
Regexp
.
escape
(
'<span class="idiff">RuntimeError, </span
>'
)))
expect
(
diff_lines
[
5
].
text
).
not_to
match
(
Regexp
.
new
(
Regexp
.
escape
(
'<span class="idiff"
>'
)))
end
end
it
'should not modify "match" lines'
do
it
'should not modify "match" lines'
do
...
@@ -31,19 +31,18 @@ describe Gitlab::Diff::Highlight, lib: true do
...
@@ -31,19 +31,18 @@ describe Gitlab::Diff::Highlight, lib: true do
expect
(
diff_lines
[
22
].
text
).
to
eq
(
'@@ -19,6 +25,7 @@ module Popen'
)
expect
(
diff_lines
[
22
].
text
).
to
eq
(
'@@ -19,6 +25,7 @@ module Popen'
)
end
end
end
end
end
context
'when processing raw lines'
do
describe
'.process_file'
do
let
(
:lines
)
{
[
"puts 'Hello'
\n
"
,
"# A comment"
]
}
let
(
:lines
)
do
let
(
:highlighted_lines
)
{
Gitlab
::
Diff
::
Highlight
.
process_diff_lines
(
'demo.rb'
,
lines
)
}
Gitlab
::
Diff
::
Highlight
.
process_file
(
project
.
repository
,
commit
.
id
,
'files/ruby/popen.rb'
)
it
'should highlight the code'
do
line_1
=
%Q{<span id="LC1" class="line"><span class="nb">puts</span> <span class="s1">'Hello'</span></span>
\n
}
line_2
=
%Q{<span id="LC2" class="line"><span class="c1"># A comment</span></span>}
expect
(
highlighted_lines
[
0
]).
to
eq
(
line_1
)
expect
(
highlighted_lines
[
1
]).
to
eq
(
line_2
)
end
end
end
it
'should properly highlight all the lines'
do
expect
(
lines
[
4
]).
to
eq
(
%Q{<span id="LC5" class="line"> <span class="kp">extend</span> <span class="nb">self</span></span>
\n
}
)
expect
(
lines
[
21
]).
to
eq
(
%Q{<span id="LC22" class="line"> <span class="k">unless</span> <span class="no">File</span><span class="p">.</span><span class="nf">directory?</span><span class="p">(</span><span class="n">path</span><span class="p">)</span></span>
\n
}
)
expect
(
lines
[
26
]).
to
eq
(
%Q{<span id="LC27" class="line"> <span class="vi">@cmd_status</span> <span class="o">=</span> <span class="mi">0</span></span>
\n
}
)
end
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