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
Léo-Paul Géneau
gitlab-ce
Commits
c7e00aca
Commit
c7e00aca
authored
May 27, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better specs for Compare API
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
10ee137e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
lib/api/entities.rb
lib/api/entities.rb
+3
-1
spec/requests/api/repositories_spec.rb
spec/requests/api/repositories_spec.rb
+25
-9
No files found.
lib/api/entities.rb
View file @
c7e00aca
...
@@ -202,7 +202,9 @@ module API
...
@@ -202,7 +202,9 @@ module API
class
Compare
<
Grape
::
Entity
class
Compare
<
Grape
::
Entity
expose
:commit
,
using:
Entities
::
RepoCommit
do
|
compare
,
options
|
expose
:commit
,
using:
Entities
::
RepoCommit
do
|
compare
,
options
|
Commit
.
new
compare
.
commit
if
compare
.
commit
Commit
.
new
compare
.
commit
end
end
end
expose
:commits
,
using:
Entities
::
RepoCommit
do
|
compare
,
options
|
expose
:commits
,
using:
Entities
::
RepoCommit
do
|
compare
,
options
|
Commit
.
decorate
compare
.
commits
Commit
.
decorate
compare
.
commits
...
...
spec/requests/api/repositories_spec.rb
View file @
c7e00aca
...
@@ -114,25 +114,41 @@ describe API::API, api: true do
...
@@ -114,25 +114,41 @@ describe API::API, api: true do
end
end
describe
'GET /GET /projects/:id/repository/compare'
do
describe
'GET /GET /projects/:id/repository/compare'
do
it
"should compare
2
branches"
do
it
"should compare branches"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'master'
,
to:
'simple_merge_request'
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'master'
,
to:
'simple_merge_request'
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'commits'
].
s
ize
.
should
==
3
json_response
[
'commits'
].
s
hould
be_present
json_response
[
'diffs'
].
s
ize
.
should
==
1
json_response
[
'diffs'
].
s
hould
be_present
end
end
it
"should compare 2 commits"
do
it
"should compare tags"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'v1.0.1'
,
to:
'v1.0.2'
response
.
status
.
should
==
200
json_response
[
'commits'
].
should
be_present
json_response
[
'diffs'
].
should
be_present
end
it
"should compare commits"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'b1e6a9dbf1c85'
,
to:
'1e689bfba395'
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'b1e6a9dbf1c85'
,
to:
'1e689bfba395'
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'commits'
].
size
.
should
==
0
json_response
[
'commits'
].
should
be_empty
json_response
[
'diffs'
].
size
.
should
==
0
json_response
[
'diffs'
].
should
be_empty
json_response
[
'compare_same_ref'
].
should
be_false
end
end
it
"should compare
2 commits
"
do
it
"should compare
commits in reverse order
"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'1e689bfba395'
,
to:
'b1e6a9dbf1c85'
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'1e689bfba395'
,
to:
'b1e6a9dbf1c85'
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'commits'
].
size
.
should
==
4
json_response
[
'commits'
].
should
be_present
json_response
[
'diffs'
].
size
.
should
==
9
json_response
[
'diffs'
].
should
be_present
end
it
"should compare same refs"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/compare"
,
user
),
from:
'master'
,
to:
'master'
response
.
status
.
should
==
200
json_response
[
'commits'
].
should
be_empty
json_response
[
'diffs'
].
should
be_empty
json_response
[
'compare_same_ref'
].
should
be_true
end
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