Skip to content

Commit

Permalink
added apis for the admin of fork links
Browse files Browse the repository at this point in the history
  • Loading branch information
amacarthur committed Jul 9, 2013
1 parent 02a3212 commit 44a090d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/gitlab/client/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,29 @@ def edit_project_hook(project, id, url)
def delete_project_hook(project, id)
delete("/projects/#{project}/hooks/#{id}")
end

# Mark this project as forked from the other
#
# @example
# Gitlab.make_forked(42, 24)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] project The ID of the project it is forked from
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
def make_forked_from(project, forked_from_project)
post("/projects/#{project}/fork/#{forked_from_project}")
end

# Remove a forked_from relationship for a project.
#
# @example
# Gitlab.remove_forked(42)
#
# @param [Integer, String] project The ID or code name of a project.
# @param [Integer] project The ID of the project it is forked from
# @return [Gitlab::ObjectifiedHash] Information about the forked project.
def remove_forked(project)
delete("/projects/#{project}/fork")
end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/project_fork_link.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"created_at":"2013-07-03T13:51:48Z","forked_from_project_id":24,"forked_to_project_id":42,"id":1,"updated_at":"2013-07-03T13:51:48Z"}
31 changes: 31 additions & 0 deletions spec/gitlab/client/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,35 @@
@hook.url.should == "https://api.example.net/v1/webhooks/ci"
end
end

describe ".make_forked_from" do
before do
stub_post("/projects/42/fork/24", "project_fork_link")
@forked_project_link = Gitlab.make_forked_from(42, 24)
end

it "should get the correct resource" do
a_post("/projects/42/fork/24").should have_been_made
end

it "should return information about a forked project" do
@forked_project_link.forked_from_project_id.should == 24
@forked_project_link.forked_to_project_id.should == 42
end
end

describe ".remove_forked" do
before do
stub_delete("/projects/42/fork", "project_fork_link")
@forked_project_link = Gitlab.remove_forked(42)
end

it "should be sent to correct resource" do
a_delete("/projects/42/fork").should have_been_made
end

it "should return information about an unforked project" do
@forked_project_link.forked_to_project_id.should == 42
end
end
end

0 comments on commit 44a090d

Please sign in to comment.