Merge branch 'master' into fixes/api
Conflicts: spec/requests/api/projects_spec.rb
This commit is contained in:
commit
eefb27f5ae
134 changed files with 1116 additions and 859 deletions
|
@ -54,14 +54,24 @@ describe Gitlab::API do
|
|||
end
|
||||
end
|
||||
|
||||
describe "PUT /projects/:id/issues/:issue_id" do
|
||||
describe "PUT /projects/:id/issues/:issue_id to update only title" do
|
||||
it "should update a project issue" do
|
||||
put api("/projects/#{project.id}/issues/#{issue.id}", user),
|
||||
title: 'updated title', labels: 'label2', closed: 1
|
||||
title: 'updated title'
|
||||
response.status.should == 200
|
||||
|
||||
json_response['title'].should == 'updated title'
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /projects/:id/issues/:issue_id to update state and label" do
|
||||
it "should update a project issue" do
|
||||
put api("/projects/#{project.id}/issues/#{issue.id}", user),
|
||||
labels: 'label2', state_event: "close"
|
||||
response.status.should == 200
|
||||
|
||||
json_response['labels'].should == ['label2']
|
||||
json_response['closed'].should be_true
|
||||
json_response['state'].should eq "closed"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -66,6 +66,23 @@ describe Gitlab::API do
|
|||
end
|
||||
end
|
||||
|
||||
describe "PUT /projects/:id/merge_request/:merge_request_id to close MR" do
|
||||
it "should return merge_request" do
|
||||
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "close"
|
||||
response.status.should == 200
|
||||
json_response['state'].should == 'closed'
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /projects/:id/merge_request/:merge_request_id to merge MR" do
|
||||
it "should return merge_request" do
|
||||
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "merge"
|
||||
response.status.should == 200
|
||||
json_response['state'].should == 'merged'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe "PUT /projects/:id/merge_request/:merge_request_id" do
|
||||
it "should return merge_request" do
|
||||
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), title: "New title"
|
||||
|
|
|
@ -68,4 +68,14 @@ describe Gitlab::API do
|
|||
response.status.should == 404
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /projects/:id/milestones/:milestone_id to close milestone" do
|
||||
it "should update a project milestone" do
|
||||
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
|
||||
state_event: 'close'
|
||||
response.status.should == 200
|
||||
|
||||
json_response['state'].should == 'closed'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,6 +33,20 @@ describe Gitlab::API do
|
|||
end
|
||||
|
||||
describe "POST /projects" do
|
||||
context "maximum number of projects reached" do
|
||||
before do
|
||||
(1..user2.projects_limit).each do |project|
|
||||
post api("/projects", user2), name: "foo#{project}"
|
||||
end
|
||||
end
|
||||
|
||||
it "should not create new project" do
|
||||
expect {
|
||||
post api("/projects", user2), name: 'foo'
|
||||
}.to change {Project.count}.by(0)
|
||||
end
|
||||
end
|
||||
|
||||
it "should create new project without path" do
|
||||
expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1)
|
||||
end
|
||||
|
@ -46,6 +60,12 @@ describe Gitlab::API do
|
|||
response.status.should == 400
|
||||
end
|
||||
|
||||
it "should create last project before reaching project limit" do
|
||||
(1..user2.projects_limit-1).each { |p| post api("/projects", user2), name: "foo#{p}" }
|
||||
post api("/projects", user2), name: "foo"
|
||||
response.status.should == 201
|
||||
end
|
||||
|
||||
it "should respond with 201 on success" do
|
||||
post api("/projects", user), name: 'foo'
|
||||
response.status.should == 201
|
||||
|
@ -314,22 +334,44 @@ describe Gitlab::API do
|
|||
end
|
||||
|
||||
describe "GET /projects/:id/hooks" do
|
||||
it "should return project hooks" do
|
||||
get api("/projects/#{project.id}/hooks", user)
|
||||
context "authorized user" do
|
||||
it "should return project hooks" do
|
||||
get api("/projects/#{project.id}/hooks", user)
|
||||
response.status.should == 200
|
||||
|
||||
response.status.should == 200
|
||||
json_response.should be_an Array
|
||||
json_response.count.should == 1
|
||||
json_response.first['url'].should == "http://example.com"
|
||||
end
|
||||
end
|
||||
|
||||
json_response.should be_an Array
|
||||
json_response.count.should == 1
|
||||
json_response.first['url'].should == "http://example.com"
|
||||
context "unauthorized user" do
|
||||
it "should not access project hooks" do
|
||||
get api("/projects/#{project.id}/hooks", user3)
|
||||
response.status.should == 403
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /projects/:id/hooks/:hook_id" do
|
||||
it "should return a project hook" do
|
||||
get api("/projects/#{project.id}/hooks/#{hook.id}", user)
|
||||
response.status.should == 200
|
||||
json_response['url'].should == hook.url
|
||||
context "authorized user" do
|
||||
it "should return a project hook" do
|
||||
get api("/projects/#{project.id}/hooks/#{hook.id}", user)
|
||||
response.status.should == 200
|
||||
json_response['url'].should == hook.url
|
||||
end
|
||||
|
||||
it "should return a 404 error if hook id is not available" do
|
||||
get api("/projects/#{project.id}/hooks/1234", user)
|
||||
response.status.should == 404
|
||||
end
|
||||
end
|
||||
|
||||
context "unauthorized user" do
|
||||
it "should not access an existing hook" do
|
||||
get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
|
||||
response.status.should == 403
|
||||
end
|
||||
end
|
||||
|
||||
it "should return a 404 error if hook id is not available" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue