Commit bd1b15ec294171af5146ebfdcc5c521fa293fae4

Authored by Dmitriy Zaporozhets
2 parents 2ab2d60b 8f3701ef

Merge branch 'branch-via-api' into 'master'

Refactor branches API

Preparing for new feature: Create branches via API
doc/api/README.md
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 + [Repositories](repositories.md) 9 + [Repositories](repositories.md)
10 + [Repository Files](repository_files.md) 10 + [Repository Files](repository_files.md)
11 + [Commits](commits.md) 11 + [Commits](commits.md)
  12 ++ [Branches](branches.md)
12 + [Merge Requests](merge_requests.md) 13 + [Merge Requests](merge_requests.md)
13 + [Issues](issues.md) 14 + [Issues](issues.md)
14 + [Milestones](milestones.md) 15 + [Milestones](milestones.md)
doc/api/branches.md 0 → 100644
@@ -0,0 +1,167 @@ @@ -0,0 +1,167 @@
  1 +# Branches
  2 +
  3 +## List repository branches
  4 +
  5 +Get a list of repository branches from a project, sorted by name alphabetically.
  6 +
  7 +```
  8 +GET /projects/:id/repository/branches
  9 +```
  10 +
  11 +Parameters:
  12 +
  13 ++ `id` (required) - The ID of a project
  14 +
  15 +```json
  16 +[
  17 + {
  18 + "name": "master",
  19 + "commit": {
  20 + "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
  21 + "parents": [
  22 + {
  23 + "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"
  24 + }
  25 + ],
  26 + "tree": "46e82de44b1061621357f24c05515327f2795a95",
  27 + "message": "add projects API",
  28 + "author": {
  29 + "name": "John Smith",
  30 + "email": "john@example.com"
  31 + },
  32 + "committer": {
  33 + "name": "John Smith",
  34 + "email": "john@example.com"
  35 + },
  36 + "authored_date": "2012-06-27T05:51:39-07:00",
  37 + "committed_date": "2012-06-28T03:44:20-07:00"
  38 + },
  39 + "protected": true
  40 + }
  41 +]
  42 +```
  43 +
  44 +
  45 +## Get single repository branch
  46 +
  47 +Get a single project repository branch.
  48 +
  49 +```
  50 +GET /projects/:id/repository/branches/:branch
  51 +```
  52 +
  53 +Parameters:
  54 +
  55 ++ `id` (required) - The ID of a project
  56 ++ `branch` (required) - The name of the branch
  57 +
  58 +```json
  59 +{
  60 + "name": "master",
  61 + "commit": {
  62 + "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
  63 + "parents": [
  64 + {
  65 + "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"
  66 + }
  67 + ],
  68 + "tree": "46e82de44b1061621357f24c05515327f2795a95",
  69 + "message": "add projects API",
  70 + "author": {
  71 + "name": "John Smith",
  72 + "email": "john@example.com"
  73 + },
  74 + "committer": {
  75 + "name": "John Smith",
  76 + "email": "john@example.com"
  77 + },
  78 + "authored_date": "2012-06-27T05:51:39-07:00",
  79 + "committed_date": "2012-06-28T03:44:20-07:00"
  80 + },
  81 + "protected": true
  82 +}
  83 +```
  84 +
  85 +
  86 +## Protect repository branch
  87 +
  88 +Protects a single project repository branch. This is an idempotent function, protecting an already
  89 +protected repository branch still returns a `200 Ok` status code.
  90 +
  91 +```
  92 +PUT /projects/:id/repository/branches/:branch/protect
  93 +```
  94 +
  95 +Parameters:
  96 +
  97 ++ `id` (required) - The ID of a project
  98 ++ `branch` (required) - The name of the branch
  99 +
  100 +```json
  101 +{
  102 + "name": "master",
  103 + "commit": {
  104 + "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
  105 + "parents": [
  106 + {
  107 + "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"
  108 + }
  109 + ],
  110 + "tree": "46e82de44b1061621357f24c05515327f2795a95",
  111 + "message": "add projects API",
  112 + "author": {
  113 + "name": "John Smith",
  114 + "email": "john@example.com"
  115 + },
  116 + "committer": {
  117 + "name": "John Smith",
  118 + "email": "john@example.com"
  119 + },
  120 + "authored_date": "2012-06-27T05:51:39-07:00",
  121 + "committed_date": "2012-06-28T03:44:20-07:00"
  122 + },
  123 + "protected": true
  124 +}
  125 +```
  126 +
  127 +
  128 +## Unprotect repository branch
  129 +
  130 +Unprotects a single project repository branch. This is an idempotent function, unprotecting an already
  131 +unprotected repository branch still returns a `200 Ok` status code.
  132 +
  133 +```
  134 +PUT /projects/:id/repository/branches/:branch/unprotect
  135 +```
  136 +
  137 +Parameters:
  138 +
  139 ++ `id` (required) - The ID of a project
  140 ++ `branch` (required) - The name of the branch
  141 +
  142 +```json
  143 +{
  144 + "name": "master",
  145 + "commit": {
  146 + "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
  147 + "parents": [
  148 + {
  149 + "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"
  150 + }
  151 + ],
  152 + "tree": "46e82de44b1061621357f24c05515327f2795a95",
  153 + "message": "add projects API",
  154 + "author": {
  155 + "name": "John Smith",
  156 + "email": "john@example.com"
  157 + },
  158 + "committer": {
  159 + "name": "John Smith",
  160 + "email": "john@example.com"
  161 + },
  162 + "authored_date": "2012-06-27T05:51:39-07:00",
  163 + "committed_date": "2012-06-28T03:44:20-07:00"
  164 + },
  165 + "protected": false
  166 +}
  167 +```
doc/api/repositories.md
1 -## List repository branches  
2 -  
3 -Get a list of repository branches from a project, sorted by name alphabetically.  
4 -  
5 -```  
6 -GET /projects/:id/repository/branches  
7 -```  
8 -  
9 -Parameters:  
10 -  
11 -+ `id` (required) - The ID of a project  
12 -  
13 -```json  
14 -[  
15 - {  
16 - "name": "master",  
17 - "commit": {  
18 - "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",  
19 - "parents": [  
20 - {  
21 - "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"  
22 - }  
23 - ],  
24 - "tree": "46e82de44b1061621357f24c05515327f2795a95",  
25 - "message": "add projects API",  
26 - "author": {  
27 - "name": "John Smith",  
28 - "email": "john@example.com"  
29 - },  
30 - "committer": {  
31 - "name": "John Smith",  
32 - "email": "john@example.com"  
33 - },  
34 - "authored_date": "2012-06-27T05:51:39-07:00",  
35 - "committed_date": "2012-06-28T03:44:20-07:00"  
36 - },  
37 - "protected": true  
38 - }  
39 -]  
40 -```  
41 -  
42 -  
43 -## Get single repository branch  
44 -  
45 -Get a single project repository branch.  
46 -  
47 -```  
48 -GET /projects/:id/repository/branches/:branch  
49 -```  
50 -  
51 -Parameters:  
52 -  
53 -+ `id` (required) - The ID of a project  
54 -+ `branch` (required) - The name of the branch  
55 -  
56 -```json  
57 -{  
58 - "name": "master",  
59 - "commit": {  
60 - "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",  
61 - "parents": [  
62 - {  
63 - "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"  
64 - }  
65 - ],  
66 - "tree": "46e82de44b1061621357f24c05515327f2795a95",  
67 - "message": "add projects API",  
68 - "author": {  
69 - "name": "John Smith",  
70 - "email": "john@example.com"  
71 - },  
72 - "committer": {  
73 - "name": "John Smith",  
74 - "email": "john@example.com"  
75 - },  
76 - "authored_date": "2012-06-27T05:51:39-07:00",  
77 - "committed_date": "2012-06-28T03:44:20-07:00"  
78 - },  
79 - "protected": true  
80 -}  
81 -```  
82 -  
83 -  
84 -## Protect repository branch  
85 -  
86 -Protects a single project repository branch. This is an idempotent function, protecting an already  
87 -protected repository branch still returns a `200 Ok` status code.  
88 -  
89 -```  
90 -PUT /projects/:id/repository/branches/:branch/protect  
91 -```  
92 -  
93 -Parameters:  
94 -  
95 -+ `id` (required) - The ID of a project  
96 -+ `branch` (required) - The name of the branch  
97 -  
98 -```json  
99 -{  
100 - "name": "master",  
101 - "commit": {  
102 - "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",  
103 - "parents": [  
104 - {  
105 - "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"  
106 - }  
107 - ],  
108 - "tree": "46e82de44b1061621357f24c05515327f2795a95",  
109 - "message": "add projects API",  
110 - "author": {  
111 - "name": "John Smith",  
112 - "email": "john@example.com"  
113 - },  
114 - "committer": {  
115 - "name": "John Smith",  
116 - "email": "john@example.com"  
117 - },  
118 - "authored_date": "2012-06-27T05:51:39-07:00",  
119 - "committed_date": "2012-06-28T03:44:20-07:00"  
120 - },  
121 - "protected": true  
122 -}  
123 -```  
124 -  
125 -  
126 -## Unprotect repository branch  
127 -  
128 -Unprotects a single project repository branch. This is an idempotent function, unprotecting an already  
129 -unprotected repository branch still returns a `200 Ok` status code.  
130 -  
131 -```  
132 -PUT /projects/:id/repository/branches/:branch/unprotect  
133 -```  
134 -  
135 -Parameters:  
136 -  
137 -+ `id` (required) - The ID of a project  
138 -+ `branch` (required) - The name of the branch  
139 -  
140 -```json  
141 -{  
142 - "name": "master",  
143 - "commit": {  
144 - "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",  
145 - "parents": [  
146 - {  
147 - "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8"  
148 - }  
149 - ],  
150 - "tree": "46e82de44b1061621357f24c05515327f2795a95",  
151 - "message": "add projects API",  
152 - "author": {  
153 - "name": "John Smith",  
154 - "email": "john@example.com"  
155 - },  
156 - "committer": {  
157 - "name": "John Smith",  
158 - "email": "john@example.com"  
159 - },  
160 - "authored_date": "2012-06-27T05:51:39-07:00",  
161 - "committed_date": "2012-06-28T03:44:20-07:00"  
162 - },  
163 - "protected": false  
164 -}  
165 -```  
166 -  
167 -  
168 ## List project repository tags 1 ## List project repository tags
169 2
170 Get a list of repository tags from a project, sorted by name in reverse alphabetical order. 3 Get a list of repository tags from a project, sorted by name in reverse alphabetical order.
lib/api/api.rb
@@ -45,5 +45,6 @@ module API @@ -45,5 +45,6 @@ module API
45 mount Files 45 mount Files
46 mount Commits 46 mount Commits
47 mount Namespaces 47 mount Namespaces
  48 + mount Branches
48 end 49 end
49 end 50 end
lib/api/branches.rb 0 → 100644
@@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
  1 +require 'mime/types'
  2 +
  3 +module API
  4 + # Projects API
  5 + class Branches < Grape::API
  6 + before { authenticate! }
  7 + before { authorize! :download_code, user_project }
  8 +
  9 + resource :projects do
  10 + # Get a project repository branches
  11 + #
  12 + # Parameters:
  13 + # id (required) - The ID of a project
  14 + # Example Request:
  15 + # GET /projects/:id/repository/branches
  16 + get ":id/repository/branches" do
  17 + present user_project.repo.heads.sort_by(&:name), with: Entities::RepoObject, project: user_project
  18 + end
  19 +
  20 + # Get a single branch
  21 + #
  22 + # Parameters:
  23 + # id (required) - The ID of a project
  24 + # branch (required) - The name of the branch
  25 + # Example Request:
  26 + # GET /projects/:id/repository/branches/:branch
  27 + get ":id/repository/branches/:branch" do
  28 + @branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
  29 + not_found!("Branch does not exist") if @branch.nil?
  30 + present @branch, with: Entities::RepoObject, project: user_project
  31 + end
  32 +
  33 + # Protect a single branch
  34 + #
  35 + # Parameters:
  36 + # id (required) - The ID of a project
  37 + # branch (required) - The name of the branch
  38 + # Example Request:
  39 + # PUT /projects/:id/repository/branches/:branch/protect
  40 + put ":id/repository/branches/:branch/protect" do
  41 + authorize_admin_project
  42 +
  43 + @branch = user_project.repository.find_branch(params[:branch])
  44 + not_found! unless @branch
  45 + protected_branch = user_project.protected_branches.find_by(name: @branch.name)
  46 + user_project.protected_branches.create(name: @branch.name) unless protected_branch
  47 +
  48 + present @branch, with: Entities::RepoObject, project: user_project
  49 + end
  50 +
  51 + # Unprotect a single branch
  52 + #
  53 + # Parameters:
  54 + # id (required) - The ID of a project
  55 + # branch (required) - The name of the branch
  56 + # Example Request:
  57 + # PUT /projects/:id/repository/branches/:branch/unprotect
  58 + put ":id/repository/branches/:branch/unprotect" do
  59 + authorize_admin_project
  60 +
  61 + @branch = user_project.repository.find_branch(params[:branch])
  62 + not_found! unless @branch
  63 + protected_branch = user_project.protected_branches.find_by(name: @branch.name)
  64 + protected_branch.destroy if protected_branch
  65 +
  66 + present @branch, with: Entities::RepoObject, project: user_project
  67 + end
  68 + end
  69 + end
  70 +end
lib/api/commits.rb
1 require 'mime/types' 1 require 'mime/types'
2 2
3 module API 3 module API
4 - # Projects API 4 + # Projects commits API
5 class Commits < Grape::API 5 class Commits < Grape::API
6 before { authenticate! } 6 before { authenticate! }
7 before { authorize! :download_code, user_project } 7 before { authorize! :download_code, user_project }
8 8
9 resource :projects do 9 resource :projects do
10 - helpers do  
11 - def handle_project_member_errors(errors)  
12 - if errors[:project_access].any?  
13 - error!(errors[:project_access], 422)  
14 - end  
15 - not_found!  
16 - end  
17 - end  
18 -  
19 # Get a project repository commits 10 # Get a project repository commits
20 # 11 #
21 # Parameters: 12 # Parameters:
lib/api/repositories.rb
@@ -15,66 +15,6 @@ module API @@ -15,66 +15,6 @@ module API
15 not_found! 15 not_found!
16 end 16 end
17 end 17 end
18 -  
19 - # Get a project repository branches  
20 - #  
21 - # Parameters:  
22 - # id (required) - The ID of a project  
23 - # Example Request:  
24 - # GET /projects/:id/repository/branches  
25 - get ":id/repository/branches" do  
26 - present user_project.repo.heads.sort_by(&:name), with: Entities::RepoObject, project: user_project  
27 - end  
28 -  
29 - # Get a single branch  
30 - #  
31 - # Parameters:  
32 - # id (required) - The ID of a project  
33 - # branch (required) - The name of the branch  
34 - # Example Request:  
35 - # GET /projects/:id/repository/branches/:branch  
36 - get ":id/repository/branches/:branch" do  
37 - @branch = user_project.repo.heads.find { |item| item.name == params[:branch] }  
38 - not_found!("Branch does not exist") if @branch.nil?  
39 - present @branch, with: Entities::RepoObject, project: user_project  
40 - end  
41 -  
42 - # Protect a single branch  
43 - #  
44 - # Parameters:  
45 - # id (required) - The ID of a project  
46 - # branch (required) - The name of the branch  
47 - # Example Request:  
48 - # PUT /projects/:id/repository/branches/:branch/protect  
49 - put ":id/repository/branches/:branch/protect" do  
50 - authorize_admin_project  
51 -  
52 - @branch = user_project.repository.find_branch(params[:branch])  
53 - not_found! unless @branch  
54 - protected_branch = user_project.protected_branches.find_by(name: @branch.name)  
55 - user_project.protected_branches.create(name: @branch.name) unless protected_branch  
56 -  
57 - present @branch, with: Entities::RepoObject, project: user_project  
58 - end  
59 -  
60 - # Unprotect a single branch  
61 - #  
62 - # Parameters:  
63 - # id (required) - The ID of a project  
64 - # branch (required) - The name of the branch  
65 - # Example Request:  
66 - # PUT /projects/:id/repository/branches/:branch/unprotect  
67 - put ":id/repository/branches/:branch/unprotect" do  
68 - authorize_admin_project  
69 -  
70 - @branch = user_project.repository.find_branch(params[:branch])  
71 - not_found! unless @branch  
72 - protected_branch = user_project.protected_branches.find_by(name: @branch.name)  
73 - protected_branch.destroy if protected_branch  
74 -  
75 - present @branch, with: Entities::RepoObject, project: user_project  
76 - end  
77 -  
78 # Get a project repository tags 18 # Get a project repository tags
79 # 19 #
80 # Parameters: 20 # Parameters:
spec/requests/api/branches_spec.rb 0 → 100644
@@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
  1 +require 'spec_helper'
  2 +require 'mime/types'
  3 +
  4 +describe API::API do
  5 + include ApiHelpers
  6 + before(:each) { enable_observers }
  7 + after(:each) {disable_observers}
  8 +
  9 + let(:user) { create(:user) }
  10 + let(:user2) { create(:user) }
  11 + let!(:project) { create(:project, creator_id: user.id) }
  12 + let!(:master) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) }
  13 + let!(:guest) { create(:users_project, user: user2, project: project, project_access: UsersProject::GUEST) }
  14 +
  15 + describe "GET /projects/:id/repository/branches" do
  16 + it "should return an array of project branches" do
  17 + get api("/projects/#{project.id}/repository/branches", user)
  18 + response.status.should == 200
  19 + json_response.should be_an Array
  20 + json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name
  21 + end
  22 + end
  23 +
  24 + describe "GET /projects/:id/repository/branches/:branch" do
  25 + it "should return the branch information for a single branch" do
  26 + get api("/projects/#{project.id}/repository/branches/new_design", user)
  27 + response.status.should == 200
  28 +
  29 + json_response['name'].should == 'new_design'
  30 + json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1'
  31 + json_response['protected'].should == false
  32 + end
  33 +
  34 + it "should return a 403 error if guest" do
  35 + get api("/projects/#{project.id}/repository/branches", user2)
  36 + response.status.should == 403
  37 + end
  38 +
  39 + it "should return a 404 error if branch is not available" do
  40 + get api("/projects/#{project.id}/repository/branches/unknown", user)
  41 + response.status.should == 404
  42 + end
  43 + end
  44 +
  45 + describe "PUT /projects/:id/repository/branches/:branch/protect" do
  46 + it "should protect a single branch" do
  47 + put api("/projects/#{project.id}/repository/branches/new_design/protect", user)
  48 + response.status.should == 200
  49 +
  50 + json_response['name'].should == 'new_design'
  51 + json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1'
  52 + json_response['protected'].should == true
  53 + end
  54 +
  55 + it "should return a 404 error if branch not found" do
  56 + put api("/projects/#{project.id}/repository/branches/unknown/protect", user)
  57 + response.status.should == 404
  58 + end
  59 +
  60 + it "should return a 403 error if guest" do
  61 + put api("/projects/#{project.id}/repository/branches/new_design/protect", user2)
  62 + response.status.should == 403
  63 + end
  64 +
  65 + it "should return success when protect branch again" do
  66 + put api("/projects/#{project.id}/repository/branches/new_design/protect", user)
  67 + put api("/projects/#{project.id}/repository/branches/new_design/protect", user)
  68 + response.status.should == 200
  69 + end
  70 + end
  71 +
  72 + describe "PUT /projects/:id/repository/branches/:branch/unprotect" do
  73 + it "should unprotect a single branch" do
  74 + put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user)
  75 + response.status.should == 200
  76 +
  77 + json_response['name'].should == 'new_design'
  78 + json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1'
  79 + json_response['protected'].should == false
  80 + end
  81 +
  82 + it "should return success when unprotect branch" do
  83 + put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user)
  84 + response.status.should == 404
  85 + end
  86 +
  87 + it "should return success when unprotect branch again" do
  88 + put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user)
  89 + put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user)
  90 + response.status.should == 200
  91 + end
  92 + end
  93 +
  94 +
  95 +end
spec/requests/api/repositories_spec.rb
@@ -14,86 +14,6 @@ describe API::API do @@ -14,86 +14,6 @@ describe API::API do
14 14
15 before { project.team << [user, :reporter] } 15 before { project.team << [user, :reporter] }
16 16
17 -  
18 - describe "GET /projects/:id/repository/branches" do  
19 - it "should return an array of project branches" do  
20 - get api("/projects/#{project.id}/repository/branches", user)  
21 - response.status.should == 200  
22 - json_response.should be_an Array  
23 - json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name  
24 - end  
25 - end  
26 -  
27 - describe "GET /projects/:id/repository/branches/:branch" do  
28 - it "should return the branch information for a single branch" do  
29 - get api("/projects/#{project.id}/repository/branches/new_design", user)  
30 - response.status.should == 200  
31 -  
32 - json_response['name'].should == 'new_design'  
33 - json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1'  
34 - json_response['protected'].should == false  
35 - end  
36 -  
37 - it "should return a 403 error if guest" do  
38 - get api("/projects/#{project.id}/repository/branches", user2)  
39 - response.status.should == 403  
40 - end  
41 -  
42 - it "should return a 404 error if branch is not available" do  
43 - get api("/projects/#{project.id}/repository/branches/unknown", user)  
44 - response.status.should == 404  
45 - end  
46 - end  
47 -  
48 - describe "PUT /projects/:id/repository/branches/:branch/protect" do  
49 - it "should protect a single branch" do  
50 - put api("/projects/#{project.id}/repository/branches/new_design/protect", user)  
51 - response.status.should == 200  
52 -  
53 - json_response['name'].should == 'new_design'  
54 - json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1'  
55 - json_response['protected'].should == true  
56 - end  
57 -  
58 - it "should return a 404 error if branch not found" do  
59 - put api("/projects/#{project.id}/repository/branches/unknown/protect", user)  
60 - response.status.should == 404  
61 - end  
62 -  
63 - it "should return a 403 error if guest" do  
64 - put api("/projects/#{project.id}/repository/branches/new_design/protect", user2)  
65 - response.status.should == 403  
66 - end  
67 -  
68 - it "should return success when protect branch again" do  
69 - put api("/projects/#{project.id}/repository/branches/new_design/protect", user)  
70 - put api("/projects/#{project.id}/repository/branches/new_design/protect", user)  
71 - response.status.should == 200  
72 - end  
73 - end  
74 -  
75 - describe "PUT /projects/:id/repository/branches/:branch/unprotect" do  
76 - it "should unprotect a single branch" do  
77 - put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user)  
78 - response.status.should == 200  
79 -  
80 - json_response['name'].should == 'new_design'  
81 - json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1'  
82 - json_response['protected'].should == false  
83 - end  
84 -  
85 - it "should return success when unprotect branch" do  
86 - put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user)  
87 - response.status.should == 404  
88 - end  
89 -  
90 - it "should return success when unprotect branch again" do  
91 - put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user)  
92 - put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user)  
93 - response.status.should == 200  
94 - end  
95 - end  
96 -  
97 describe "GET /projects/:id/repository/tags" do 17 describe "GET /projects/:id/repository/tags" do
98 it "should return an array of project tags" do 18 it "should return an array of project tags" do
99 get api("/projects/#{project.id}/repository/tags", user) 19 get api("/projects/#{project.id}/repository/tags", user)