Commit c624b45b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'hipchat_api' of https://github.com/qwazerty/gitlabhq into qwazerty-hipchat_api

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Conflicts:
	CHANGELOG
parents 72abe9f6 62b322d7
v 7.5.0
- API: Add support for Hipchat (Kevin Houdebert)
v 7.4.0 v 7.4.0
- Refactored membership logic - Refactored membership logic
- Improve error reporting on users API (Julien Bianchi) - Improve error reporting on users API (Julien Bianchi)
......
# Services
## GitLab CI
### Edit GitLab CI service
Set GitLab CI service for a project.
```
PUT /projects/:id/services/gitlab-ci
```
Parameters:
- `token` (required) - CI project token
- `project_url` (required) - CI project url
### Delete GitLab CI service
Delete GitLab CI service settings for a project.
```
DELETE /projects/:id/services/gitlab-ci
```
## Hipchat
### Edit Hipchat service
Set Hipchat service for project.
```
PUT /projects/:id/services/hipchat
```
Parameters:
- `token` (required) - Hipchat token
- `room` (required) - Hipchat room name
### Delete Hipchat service
Delete Hipchat service for a project.
```
DELETE /projects/:id/services/hipchat
```
...@@ -28,7 +28,7 @@ module API ...@@ -28,7 +28,7 @@ module API
# Delete GitLab CI service settings # Delete GitLab CI service settings
# #
# Example Request: # Example Request:
# DELETE /projects/:id/keys/:id # DELETE /projects/:id/services/gitlab-ci
delete ":id/services/gitlab-ci" do delete ":id/services/gitlab-ci" do
if user_project.gitlab_ci_service if user_project.gitlab_ci_service
user_project.gitlab_ci_service.update_attributes( user_project.gitlab_ci_service.update_attributes(
...@@ -38,7 +38,41 @@ module API ...@@ -38,7 +38,41 @@ module API
) )
end end
end end
# Set Hipchat service for project
#
# Parameters:
# token (required) - Hipchat token
# room (required) - Hipchat room name
#
# Example Request:
# PUT /projects/:id/services/hipchat
put ':id/services/hipchat' do
required_attributes! [:token, :room]
attrs = attributes_for_keys [:token, :room]
user_project.build_missing_services
if user_project.hipchat_service.update_attributes(
attrs.merge(active: true))
true
else
not_found!
end end
end end
end
# Delete Hipchat service settings
#
# Example Request:
# DELETE /projects/:id/services/hipchat
delete ':id/services/hipchat' do
if user_project.hipchat_service
user_project.hipchat_service.update_attributes(
active: false,
token: nil,
room: nil
)
end
end
end
end
end
...@@ -27,4 +27,30 @@ describe API::API, api: true do ...@@ -27,4 +27,30 @@ describe API::API, api: true do
project.gitlab_ci_service.should be_nil project.gitlab_ci_service.should be_nil
end end
end end
describe 'PUT /projects/:id/services/hipchat' do
it 'should update hipchat settings' do
put api("/projects/#{project.id}/services/hipchat", user),
token: 'secret-token', room: 'test'
response.status.should == 200
project.hipchat_service.should_not be_nil
end
it 'should return if required fields missing' do
put api("/projects/#{project.id}/services/gitlab-ci", user),
token: 'secret-token', active: true
response.status.should == 400
end
end
describe 'DELETE /projects/:id/services/hipchat' do
it 'should delete hipchat settings' do
delete api("/projects/#{project.id}/services/hipchat", user)
response.status.should == 200
project.hipchat_service.should be_nil
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment