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
Jérome Perrin
gitlab-ce
Commits
c1903033
Commit
c1903033
authored
Sep 25, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs
parent
19a30595
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
0 deletions
+93
-0
spec/lib/gitlab/diff/diff_refs_spec.rb
spec/lib/gitlab/diff/diff_refs_spec.rb
+55
-0
spec/lib/gitlab/diff/position_spec.rb
spec/lib/gitlab/diff/position_spec.rb
+38
-0
No files found.
spec/lib/gitlab/diff/diff_refs_spec.rb
View file @
c1903033
...
...
@@ -3,6 +3,61 @@ require 'spec_helper'
describe
Gitlab
::
Diff
::
DiffRefs
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
describe
'#=='
do
let
(
:commit
)
{
project
.
commit
(
'1a0b36b3cdad1d2ee32457c102a8c0b7056fa863'
)
}
subject
{
commit
.
diff_refs
}
context
'when shas are missing'
do
let
(
:other
)
{
described_class
.
new
(
base_sha:
subject
.
base_sha
,
start_sha:
subject
.
start_sha
,
head_sha:
nil
)
}
it
'returns false'
do
expect
(
subject
).
not_to
eq
(
other
)
end
end
context
'when shas are equal'
do
let
(
:other
)
{
described_class
.
new
(
base_sha:
subject
.
base_sha
,
start_sha:
subject
.
start_sha
,
head_sha:
subject
.
head_sha
)
}
it
'returns true'
do
expect
(
subject
).
to
eq
(
other
)
end
end
context
'when shas are unequal'
do
let
(
:other
)
{
described_class
.
new
(
base_sha:
subject
.
base_sha
,
start_sha:
subject
.
start_sha
,
head_sha:
subject
.
head_sha
.
reverse
)
}
it
'returns false'
do
expect
(
subject
).
not_to
eq
(
other
)
end
end
context
'when shas are truncated'
do
context
'when sha prefixes are too short'
do
let
(
:other
)
{
described_class
.
new
(
base_sha:
subject
.
base_sha
[
0
,
4
],
start_sha:
subject
.
start_sha
[
0
,
4
],
head_sha:
subject
.
head_sha
[
0
,
4
])
}
it
'returns false'
do
expect
(
subject
).
not_to
eq
(
other
)
end
end
context
'when sha prefixes are equal'
do
let
(
:other
)
{
described_class
.
new
(
base_sha:
subject
.
base_sha
[
0
,
10
],
start_sha:
subject
.
start_sha
[
0
,
10
],
head_sha:
subject
.
head_sha
[
0
,
10
])
}
it
'returns true'
do
expect
(
subject
).
to
eq
(
other
)
end
end
context
'when sha prefixes are unequal'
do
let
(
:other
)
{
described_class
.
new
(
base_sha:
subject
.
base_sha
[
0
,
10
],
start_sha:
subject
.
start_sha
[
0
,
10
],
head_sha:
subject
.
head_sha
[
0
,
10
].
reverse
)
}
it
'returns false'
do
expect
(
subject
).
not_to
eq
(
other
)
end
end
end
end
describe
'#compare_in'
do
context
'with diff refs for the initial commit'
do
let
(
:commit
)
{
project
.
commit
(
'1a0b36b3cdad1d2ee32457c102a8c0b7056fa863'
)
}
...
...
spec/lib/gitlab/diff/position_spec.rb
View file @
c1903033
...
...
@@ -429,6 +429,44 @@ describe Gitlab::Diff::Position do
end
end
describe
'#=='
do
let
(
:commit
)
{
project
.
commit
(
"570e7b2abdd848b95f2f578043fc23bd6f6fd24d"
)
}
subject
do
described_class
.
new
(
old_path:
"files/ruby/popen.rb"
,
new_path:
"files/ruby/popen.rb"
,
old_line:
nil
,
new_line:
14
,
diff_refs:
commit
.
diff_refs
)
end
context
'when positions are equal'
do
let
(
:other
)
{
described_class
.
new
(
subject
.
to_h
)
}
it
'returns true'
do
expect
(
subject
).
to
eq
(
other
)
end
end
context
'when positions are equal, except for truncated shas'
do
let
(
:other
)
{
described_class
.
new
(
subject
.
to_h
.
merge
(
start_sha:
subject
.
start_sha
[
0
,
10
]))
}
it
'returns true'
do
expect
(
subject
).
to
eq
(
other
)
end
end
context
'when positions are unequal'
do
let
(
:other
)
{
described_class
.
new
(
subject
.
to_h
.
merge
(
start_sha:
subject
.
start_sha
.
reverse
))
}
it
'returns false'
do
expect
(
subject
).
not_to
eq
(
other
)
end
end
end
describe
"#to_json"
do
let
(
:hash
)
do
{
...
...
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