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
Boxiang Sun
gitlab-ce
Commits
2bbf75f2
Commit
2bbf75f2
authored
Oct 24, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start with tests
parent
cea2a8f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+60
-0
No files found.
spec/requests/api/commits_spec.rb
View file @
2bbf75f2
...
...
@@ -465,6 +465,66 @@ describe API::Commits do
end
end
describe
'GET /projects/:id/repository/commits/:sha/refs'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:tag
)
{
project
.
repository
.
find_tag
(
'v1.1.0'
)
}
let
(
:commit_id
)
{
tag
.
dereferenced_target
.
id
}
let
(
:route
)
{
"/projects/
#{
project_id
}
/repository/commits/
#{
commit_id
}
/refs"
}
context
'when ref does not exist'
do
let
(
:commit_id
)
{
'unknown'
}
it_behaves_like
'404 response'
do
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
let
(
:message
)
{
'404 Commit Not Found'
}
end
end
context
'when repository is disabled'
do
include_context
'disabled repository'
it_behaves_like
'403 response'
do
let
(
:request
)
{
get
api
(
route
,
current_user
)
}
end
end
context
'for a valid commit'
do
it
'returns all refs with no scope'
do
get
api
(
route
,
current_user
)
repo_refs
=
project
.
repository
.
branch_names_contains
(
commit_id
)
repo_refs
.
push
(
*
project
.
repository
.
tag_names_contains
(
commit_id
))
expect
(
json_response
.
map
{
|
refs
|
refs
[
'name'
]
}).
to
eq
(
repo_refs
)
end
it
'returns all refs'
do
get
api
(
route
,
current_user
),
type:
'all'
repo_refs
=
project
.
repository
.
branch_names_contains
(
commit_id
)
repo_refs
.
push
(
*
project
.
repository
.
tag_names_contains
(
commit_id
))
expect
(
json_response
.
map
{
|
refs
|
refs
[
'name'
]
}).
to
eq
(
repo_refs
)
end
it
'returns the branch refs'
do
get
api
(
route
,
current_user
),
type:
'branches'
repo_refs
=
project
.
repository
.
branch_names_contains
(
commit_id
)
expect
(
json_response
.
map
{
|
refs
|
refs
[
'name'
]
}).
to
eq
(
repo_refs
)
end
it
'returns the tag refs'
do
get
api
(
route
,
current_user
),
type:
'tags'
repo_refs
=
project
.
repository
.
tag_names_contains
(
commit_id
)
expect
(
json_response
.
map
{
|
refs
|
refs
[
'name'
]
}).
to
eq
(
repo_refs
)
end
end
end
describe
'GET /projects/:id/repository/commits/:sha'
do
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit_id
)
{
commit
.
id
}
...
...
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