2013-10-29 10:39:46 -04:00
require " spec_helper "
2014-04-11 15:45:56 -04:00
describe API :: API , api : true do
2013-10-29 10:39:46 -04:00
include ApiHelpers
let ( :user ) { create ( :user ) }
2014-01-22 14:03:52 -05:00
let ( :project ) { create ( :project , creator_id : user . id , namespace : user . namespace ) }
2013-10-29 10:39:46 -04:00
describe " POST /projects/:id/services/gitlab-ci " do
it " should update gitlab-ci settings " do
2015-07-17 09:58:26 -04:00
put api ( " /projects/ #{ project . id } /services/gitlab-ci " , user ) , token : 'secrettoken' , project_url : " http://ci.example.com/projects/1 "
2013-10-29 10:39:46 -04:00
2015-02-12 13:17:35 -05:00
expect ( response . status ) . to eq ( 200 )
2013-10-29 10:39:46 -04:00
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
2015-02-12 13:17:35 -05:00
expect ( response . status ) . to eq ( 400 )
2013-10-29 10:39:46 -04:00
end
2015-07-17 11:03:15 -04:00
it " should return if the format of token is invalid " do
put api ( " /projects/ #{ project . id } /services/gitlab-ci " , user ) , token : 'token-with dashes and spaces%' , project_url : " http://ci.example.com/projects/1 " , active : true
expect ( response . status ) . to eq ( 404 )
end
it " should return if the format of token is invalid " do
put api ( " /projects/ #{ project . id } /services/gitlab-ci " , user ) , token : 'token-with dashes and spaces%' , project_url : " ftp://ci.example/projects/1 " , active : true
expect ( response . status ) . to eq ( 404 )
end
2013-10-29 10:39:46 -04:00
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 )
2015-02-12 13:17:35 -05:00
expect ( response . status ) . to eq ( 200 )
expect ( project . gitlab_ci_service ) . to be_nil
2013-10-29 10:39:46 -04:00
end
end
2014-10-14 13:07:34 -04:00
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'
2015-02-12 13:17:35 -05:00
expect ( response . status ) . to eq ( 200 )
expect ( project . hipchat_service ) . not_to be_nil
2014-10-14 13:07:34 -04:00
end
it 'should return if required fields missing' do
put api ( " /projects/ #{ project . id } /services/gitlab-ci " , user ) ,
token : 'secret-token' , active : true
2015-02-12 13:17:35 -05:00
expect ( response . status ) . to eq ( 400 )
2014-10-14 13:07:34 -04:00
end
end
describe 'DELETE /projects/:id/services/hipchat' do
it 'should delete hipchat settings' do
delete api ( " /projects/ #{ project . id } /services/hipchat " , user )
2015-02-12 13:17:35 -05:00
expect ( response . status ) . to eq ( 200 )
expect ( project . hipchat_service ) . to be_nil
2014-10-14 13:07:34 -04:00
end
end
2013-10-29 10:39:46 -04:00
end