-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Get group -Create Group -Added transfer_project_to_group/unit test
- Loading branch information
Angus MacArthur
authored and
Izaak Alpert
committed
Apr 5, 2013
1 parent
f2ba111
commit 3b8513d
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class Gitlab::Client | ||
# Defines methods related to groups. | ||
module Groups | ||
|
||
def groups | ||
get("/groups") | ||
end | ||
|
||
def group(group_id) | ||
get("/groups/#{group_id}") | ||
end | ||
|
||
#Creates a new group | ||
# | ||
# @param [String] name | ||
# @param [String] path | ||
def create_group(name, path) | ||
body = {:name => name, :path => path} | ||
post("/groups", :body => body) | ||
end | ||
|
||
#Transfers a project to a group | ||
# | ||
# @param [Integer] group_id | ||
# @param [Integer] project_id | ||
def transfer_project_to_group(group_id, project_id) | ||
body = {:id => group_id, :project_id => project_id} | ||
post("/groups/#{group_id}/projects/#{project_id}", :body => body) | ||
end | ||
|
||
|
||
# Creates a new issue. | ||
# | ||
# @param [Integer, String] project The ID or code name of a project. | ||
# @param [String] title The title of an issue. | ||
# @param [Hash] options A customizable set of options. | ||
# @option options [String] :description The description of an issue. | ||
# @option options [Integer] :assignee_id The ID of a user to assign issue. | ||
# @option options [Integer] :milestone_id The ID of a milestone to assign issue. | ||
# @option options [String] :labels Comma-separated label names for an issue. | ||
# @return [Gitlab::ObjectifiedHash] Information about created issue. | ||
=begin | ||
def create_issue(project, title, options={}) | ||
body = {:title => title}.merge(options) | ||
post("/projects/#{project}/issues", :body => body) | ||
end | ||
=end | ||
|
||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{"id": 10, "name": "GitLab-Group", "path": "gitlab-group", "owner_id": 6, "projects": [ | ||
{ | ||
"id": 9, | ||
"name": "mojito", | ||
"description": null, | ||
"default_branch": "master", | ||
"owner": { | ||
"id": 6, | ||
"username": "jose", | ||
"email": "jose@abc.com", | ||
"name": "Jose Jose", | ||
"blocked": false, | ||
"created_at": "2013-02-06T06:54:06Z" | ||
}, | ||
"path": "mojito", | ||
"path_with_namespace": "gitlab-group/mojito", | ||
"issues_enabled": true, | ||
"merge_requests_enabled": true, | ||
"wall_enabled": true, | ||
"wiki_enabled": true, | ||
"created_at": "2013-02-06T16:59:15Z", | ||
"namespace": { | ||
"created_at": "2013-02-06T16:58:22Z", | ||
"id": 10, | ||
"name": "GitLab-Group", | ||
"owner_id": 6, | ||
"path": "gitlab-group", | ||
"updated_at": "2013-02-06T16:58:22Z" | ||
} | ||
}, | ||
{ | ||
"id": 10, | ||
"name": "gitlabhq", | ||
"description": null, | ||
"default_branch": null, | ||
"owner": { | ||
"id": 6, | ||
"username": "randx", | ||
"email": "randx@github.com", | ||
"name": "Dmitry Z", | ||
"blocked": false, | ||
"created_at": "2013-02-06T06:54:06Z" | ||
}, | ||
"path": "gitlabhq", | ||
"path_with_namespace": "gitlab-group/gitlabhq", | ||
"issues_enabled": true, | ||
"merge_requests_enabled": true, | ||
"wall_enabled": true, | ||
"wiki_enabled": true, | ||
"created_at": "2013-02-06T17:02:31Z", | ||
"namespace": { | ||
"created_at": "2013-02-06T16:58:22Z", | ||
"id": 10, | ||
"name": "GitLab-Group", | ||
"owner_id": 6, | ||
"path": "gitlab-group", | ||
"updated_at": "2013-02-06T16:58:22Z" | ||
} | ||
} | ||
]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id":3,"name":"Gitlab-Group","path":"gitlab-group","owner_id":1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[{"id": 3,"name": "ThreeGroup","path": "threegroup","owner_id": 1},{"id": 5,"name": "Five-Group","path": "five-group","owner_id": 2},{"id": 8,"name": "Eight Group","path": "eight-group","owner_id": 6} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require 'spec_helper' | ||
|
||
describe Gitlab::Client do | ||
describe ".groups" do | ||
before do | ||
stub_get("/groups", "groups") | ||
stub_get("/groups/3", "group") | ||
@group = Gitlab.group(3) | ||
@groups = Gitlab.groups | ||
end | ||
|
||
it "should get the correct resource" do | ||
a_get("/groups").should have_been_made | ||
a_get("/groups/3").should have_been_made | ||
end | ||
|
||
it "should return an array of Groups" do | ||
@groups.should be_an Array | ||
@groups.first.path.should == "threegroup" | ||
end | ||
end | ||
|
||
describe ".create_group" do | ||
before do | ||
stub_post("/groups", "group_create") | ||
@group = Gitlab.create_group('GitLab-Group', 'gitlab-path') | ||
end | ||
|
||
it "should get the correct resource" do | ||
a_post("/groups"). | ||
with(:body => {:path => 'gitlab-path', :name => 'GitLab-Group'}).should have_been_made | ||
end | ||
|
||
it "should return information about a created group" do | ||
@group.name.should == "Gitlab-Group" | ||
@group.path.should == "gitlab-group" | ||
end | ||
end | ||
|
||
|
||
|
||
describe ".transfer_project_to_group" do | ||
before do | ||
stub_post("/projects", "project") | ||
@project = Gitlab.create_project('Gitlab') | ||
stub_post("/groups", "group_create") | ||
@group = Gitlab.create_group('GitLab-Group', 'gitlab-path') | ||
|
||
stub_post("/groups/#{@group.id}/projects/#{@project.id}", "group_create") | ||
@group_transfer = Gitlab.transfer_project_to_group(@group.id,@project.id) | ||
end | ||
|
||
it "should post to the correct resource" do | ||
a_post("/groups/#{@group.id}/projects/#{@project.id}").with(:body => {:id => @group.id.to_s, :project_id => @project.id.to_s}).should have_been_made | ||
end | ||
|
||
it "should return information about the group" do | ||
@group_transfer.name.should == @group.name | ||
@group_transfer.path.should == @group.path | ||
@group_transfer.id.should == @group.id | ||
end | ||
end | ||
|
||
end |