Commit 0b57c118 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'api/gitlab-ci' of /home/git/repositories/gitlab/gitlabhq

parents d71914ca d636ad49
v 6.3.0 v 6.3.0
- API for adding gitlab-ci service
- Init script now waits for pids to appear after (re)starting before reporting status (Rovanion Luckey) - Init script now waits for pids to appear after (re)starting before reporting status (Rovanion Luckey)
- Restyle project home page - Restyle project home page
- Grammar fixes - Grammar fixes
......
...@@ -71,5 +71,4 @@ class HipchatService < Service ...@@ -71,5 +71,4 @@ class HipchatService < Service
message message
end end
end end
...@@ -38,5 +38,6 @@ module API ...@@ -38,5 +38,6 @@ module API
mount ProjectSnippets mount ProjectSnippets
mount DeployKeys mount DeployKeys
mount ProjectHooks mount ProjectHooks
mount Services
end end
end end
...@@ -5,16 +5,6 @@ module API ...@@ -5,16 +5,6 @@ module API
before { authorize_admin_project } before { authorize_admin_project }
resource :projects do resource :projects do
helpers do
def handle_project_member_errors(errors)
if errors[:project_access].any?
error!(errors[:project_access], 422)
end
not_found!
end
end
# Get a specific project's keys # Get a specific project's keys
# #
# Example Request: # Example Request:
......
module API
# Projects API
class Services < Grape::API
before { authenticate! }
before { authorize_admin_project }
resource :projects do
# Set GitLab CI service for project
#
# Parameters:
# token (required) - CI project token
# project_url (required) - CI project url
#
# Example Request:
# PUT /projects/:id/services/gitlab-ci
put ":id/services/gitlab-ci" do
required_attributes! [:token, :project_url]
attrs = attributes_for_keys [:token, :project_url]
user_project.build_missing_services
if user_project.gitlab_ci_service.update_attributes(attrs.merge(active: true))
true
else
not_found!
end
end
# Delete GitLab CI service settings
#
# Example Request:
# DELETE /projects/:id/keys/:id
delete ":id/services/gitlab-ci" do
if user_project.gitlab_ci_service
user_project.gitlab_ci_service.destroy
end
end
end
end
end
require "spec_helper"
describe API::API do
include ApiHelpers
before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) }
let(:project) {create(:project_with_code, creator_id: user.id, namespace: user.namespace) }
describe "POST /projects/:id/services/gitlab-ci" do
it "should update gitlab-ci settings" do
put api("/projects/#{project.id}/services/gitlab-ci", user), token: 'secret-token', project_url: "http://ci.example.com/projects/1"
response.status.should == 200
end
it "should return if required fields missing" do
put api("/projects/#{project.id}/services/gitlab-ci", user), project_url: "http://ci.example.com/projects/1", active: true
response.status.should == 400
end
end
describe "DELETE /projects/:id/services/gitlab-ci" do
it "should update gitlab-ci settings" do
delete api("/projects/#{project.id}/services/gitlab-ci", user)
response.status.should == 200
project.gitlab_ci_service.should be_nil
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