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
iv
gitlab-ce
Commits
7e168093
Commit
7e168093
authored
Aug 01, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix API branch specs
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
72053703
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
23 deletions
+25
-23
spec/requests/api/branches_spec.rb
spec/requests/api/branches_spec.rb
+25
-23
No files found.
spec/requests/api/branches_spec.rb
View file @
7e168093
...
@@ -9,6 +9,8 @@ describe API::API, api: true do
...
@@ -9,6 +9,8 @@ describe API::API, api: true do
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:master
)
{
create
(
:users_project
,
user:
user
,
project:
project
,
project_access:
UsersProject
::
MASTER
)
}
let!
(
:master
)
{
create
(
:users_project
,
user:
user
,
project:
project
,
project_access:
UsersProject
::
MASTER
)
}
let!
(
:guest
)
{
create
(
:users_project
,
user:
user2
,
project:
project
,
project_access:
UsersProject
::
GUEST
)
}
let!
(
:guest
)
{
create
(
:users_project
,
user:
user2
,
project:
project
,
project_access:
UsersProject
::
GUEST
)
}
let!
(
:branch_name
)
{
'feature'
}
let!
(
:branch_sha
)
{
'0b4bc9a49b562e85de7cc9e834518ea6828729b9'
}
describe
"GET /projects/:id/repository/branches"
do
describe
"GET /projects/:id/repository/branches"
do
it
"should return an array of project branches"
do
it
"should return an array of project branches"
do
...
@@ -21,11 +23,11 @@ describe API::API, api: true do
...
@@ -21,11 +23,11 @@ describe API::API, api: true do
describe
"GET /projects/:id/repository/branches/:branch"
do
describe
"GET /projects/:id/repository/branches/:branch"
do
it
"should return the branch information for a single branch"
do
it
"should return the branch information for a single branch"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'name'
].
should
==
'new_design'
json_response
[
'name'
].
should
==
branch_name
json_response
[
'commit'
][
'id'
].
should
==
'621491c677087aa243f165eab467bfdfbee00be1'
json_response
[
'commit'
][
'id'
].
should
==
branch_sha
json_response
[
'protected'
].
should
==
false
json_response
[
'protected'
].
should
==
false
end
end
...
@@ -42,11 +44,11 @@ describe API::API, api: true do
...
@@ -42,11 +44,11 @@ describe API::API, api: true do
describe
"PUT /projects/:id/repository/branches/:branch/protect"
do
describe
"PUT /projects/:id/repository/branches/:branch/protect"
do
it
"should protect a single branch"
do
it
"should protect a single branch"
do
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
/protect"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
/protect"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'name'
].
should
==
'new_design'
json_response
[
'name'
].
should
==
branch_name
json_response
[
'commit'
][
'id'
].
should
==
'621491c677087aa243f165eab467bfdfbee00be1'
json_response
[
'commit'
][
'id'
].
should
==
branch_sha
json_response
[
'protected'
].
should
==
true
json_response
[
'protected'
].
should
==
true
end
end
...
@@ -56,24 +58,24 @@ describe API::API, api: true do
...
@@ -56,24 +58,24 @@ describe API::API, api: true do
end
end
it
"should return a 403 error if guest"
do
it
"should return a 403 error if guest"
do
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
/protect"
,
user2
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
/protect"
,
user2
)
response
.
status
.
should
==
403
response
.
status
.
should
==
403
end
end
it
"should return success when protect branch again"
do
it
"should return success when protect branch again"
do
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
/protect"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
/protect"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
/protect"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
/protect"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
end
end
end
end
describe
"PUT /projects/:id/repository/branches/:branch/unprotect"
do
describe
"PUT /projects/:id/repository/branches/:branch/unprotect"
do
it
"should unprotect a single branch"
do
it
"should unprotect a single branch"
do
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
/unprotect"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
/unprotect"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'name'
].
should
==
'new_design'
json_response
[
'name'
].
should
==
branch_name
json_response
[
'commit'
][
'id'
].
should
==
'621491c677087aa243f165eab467bfdfbee00be1'
json_response
[
'commit'
][
'id'
].
should
==
branch_sha
json_response
[
'protected'
].
should
==
false
json_response
[
'protected'
].
should
==
false
end
end
...
@@ -83,8 +85,8 @@ describe API::API, api: true do
...
@@ -83,8 +85,8 @@ describe API::API, api: true do
end
end
it
"should return success when unprotect branch again"
do
it
"should return success when unprotect branch again"
do
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
/unprotect"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
/unprotect"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
/unprotect"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
/unprotect"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
end
end
end
end
...
@@ -92,19 +94,19 @@ describe API::API, api: true do
...
@@ -92,19 +94,19 @@ describe API::API, api: true do
describe
"POST /projects/:id/repository/branches"
do
describe
"POST /projects/:id/repository/branches"
do
it
"should create a new branch"
do
it
"should create a new branch"
do
post
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user
),
branch_name:
'new_design'
,
branch_name:
branch_name
,
ref:
'621491c677087aa243f165eab467bfdfbee00be1'
ref:
branch_sha
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'name'
].
should
==
'new_design'
json_response
[
'name'
].
should
==
branch_name
json_response
[
'commit'
][
'id'
].
should
==
'621491c677087aa243f165eab467bfdfbee00be1'
json_response
[
'commit'
][
'id'
].
should
==
branch_sha
end
end
it
"should deny for user without push access"
do
it
"should deny for user without push access"
do
post
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user2
),
post
api
(
"/projects/
#{
project
.
id
}
/repository/branches"
,
user2
),
branch_name:
'new_design'
,
branch_name:
branch_name
,
ref:
'621491c677087aa243f165eab467bfdfbee00be1'
ref:
branch_sha
response
.
status
.
should
==
403
response
.
status
.
should
==
403
end
end
...
@@ -114,13 +116,13 @@ describe API::API, api: true do
...
@@ -114,13 +116,13 @@ describe API::API, api: true do
before
{
Repository
.
any_instance
.
stub
(
rm_branch:
true
)
}
before
{
Repository
.
any_instance
.
stub
(
rm_branch:
true
)
}
it
"should remove branch"
do
it
"should remove branch"
do
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
end
end
it
"should remove protected branch"
do
it
"should remove protected branch"
do
project
.
protected_branches
.
create
(
name:
'new_design'
)
project
.
protected_branches
.
create
(
name:
branch_name
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
new_design
"
,
user
)
delete
api
(
"/projects/
#{
project
.
id
}
/repository/branches/
#{
branch_name
}
"
,
user
)
response
.
status
.
should
==
405
response
.
status
.
should
==
405
json_response
[
'message'
].
should
==
'Protected branch cant be removed'
json_response
[
'message'
].
should
==
'Protected branch cant be removed'
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