gitlab 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.travis.yml +3 -1
  4. data/LICENSE.txt +1 -1
  5. data/README.md +9 -1
  6. data/lib/gitlab.rb +7 -7
  7. data/lib/gitlab/api.rb +1 -1
  8. data/lib/gitlab/client.rb +9 -7
  9. data/lib/gitlab/client/groups.rb +88 -0
  10. data/lib/gitlab/client/issues.rb +13 -16
  11. data/lib/gitlab/client/merge_requests.rb +67 -5
  12. data/lib/gitlab/client/milestones.rb +6 -8
  13. data/lib/gitlab/client/notes.rb +106 -0
  14. data/lib/gitlab/client/projects.rb +98 -17
  15. data/lib/gitlab/client/repositories.rb +4 -6
  16. data/lib/gitlab/client/snippets.rb +22 -15
  17. data/lib/gitlab/configuration.rb +2 -1
  18. data/lib/gitlab/error.rb +9 -0
  19. data/lib/gitlab/request.rb +25 -20
  20. data/lib/gitlab/version.rb +1 -1
  21. data/spec/fixtures/comment_merge_request.json +1 -0
  22. data/spec/fixtures/create_merge_request.json +1 -0
  23. data/spec/fixtures/error_already_exists.json +1 -0
  24. data/spec/fixtures/group.json +60 -0
  25. data/spec/fixtures/group_create.json +1 -0
  26. data/spec/fixtures/group_member.json +1 -0
  27. data/spec/fixtures/group_member_delete.json +1 -0
  28. data/spec/fixtures/group_members.json +1 -0
  29. data/spec/fixtures/groups.json +2 -0
  30. data/spec/fixtures/note.json +1 -0
  31. data/spec/fixtures/notes.json +1 -0
  32. data/spec/fixtures/project.json +1 -1
  33. data/spec/fixtures/project_delete_key.json +8 -0
  34. data/spec/fixtures/project_for_user.json +1 -0
  35. data/spec/fixtures/project_fork_link.json +1 -0
  36. data/spec/fixtures/project_key.json +6 -0
  37. data/spec/fixtures/project_keys.json +6 -0
  38. data/spec/fixtures/update_merge_request.json +1 -0
  39. data/spec/gitlab/client/groups_spec.rb +111 -0
  40. data/spec/gitlab/client/issues_spec.rb +2 -2
  41. data/spec/gitlab/client/merge_requests_spec.rb +57 -0
  42. data/spec/gitlab/client/notes_spec.rb +156 -0
  43. data/spec/gitlab/client/projects_spec.rb +97 -2
  44. data/spec/gitlab/client/users_spec.rb +20 -9
  45. data/spec/gitlab_spec.rb +7 -0
  46. data/spec/spec_helper.rb +2 -2
  47. metadata +55 -31
@@ -1,3 +1,3 @@
1
1
  module Gitlab
2
- VERSION = "2.2.0"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -0,0 +1 @@
1
+ {"note":"Cool Merge Request!","author":{"id":1,"username":"jsmith","email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-07-11T01:32:18Z"}}
@@ -0,0 +1 @@
1
+ {"id":2,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}
@@ -0,0 +1 @@
1
+ {"message": "409 Already exists"}
@@ -0,0 +1,60 @@
1
+ {"id": 10, "name": "GitLab-Group", "path": "gitlab-group", "owner_id": 6, "projects": [
2
+ {
3
+ "id": 9,
4
+ "name": "mojito",
5
+ "description": null,
6
+ "default_branch": "master",
7
+ "owner": {
8
+ "id": 6,
9
+ "username": "jose",
10
+ "email": "jose@abc.com",
11
+ "name": "Jose Jose",
12
+ "blocked": false,
13
+ "created_at": "2013-02-06T06:54:06Z"
14
+ },
15
+ "path": "mojito",
16
+ "path_with_namespace": "gitlab-group/mojito",
17
+ "issues_enabled": true,
18
+ "merge_requests_enabled": true,
19
+ "wall_enabled": true,
20
+ "wiki_enabled": true,
21
+ "created_at": "2013-02-06T16:59:15Z",
22
+ "namespace": {
23
+ "created_at": "2013-02-06T16:58:22Z",
24
+ "id": 10,
25
+ "name": "GitLab-Group",
26
+ "owner_id": 6,
27
+ "path": "gitlab-group",
28
+ "updated_at": "2013-02-06T16:58:22Z"
29
+ }
30
+ },
31
+ {
32
+ "id": 10,
33
+ "name": "gitlabhq",
34
+ "description": null,
35
+ "default_branch": null,
36
+ "owner": {
37
+ "id": 6,
38
+ "username": "randx",
39
+ "email": "randx@github.com",
40
+ "name": "Dmitry Z",
41
+ "blocked": false,
42
+ "created_at": "2013-02-06T06:54:06Z"
43
+ },
44
+ "path": "gitlabhq",
45
+ "path_with_namespace": "gitlab-group/gitlabhq",
46
+ "issues_enabled": true,
47
+ "merge_requests_enabled": true,
48
+ "wall_enabled": true,
49
+ "wiki_enabled": true,
50
+ "created_at": "2013-02-06T17:02:31Z",
51
+ "namespace": {
52
+ "created_at": "2013-02-06T16:58:22Z",
53
+ "id": 10,
54
+ "name": "GitLab-Group",
55
+ "owner_id": 6,
56
+ "path": "gitlab-group",
57
+ "updated_at": "2013-02-06T16:58:22Z"
58
+ }
59
+ }
60
+ ]}
@@ -0,0 +1 @@
1
+ {"id":3,"name":"Gitlab-Group","path":"gitlab-group","owner_id":1}
@@ -0,0 +1 @@
1
+ {"id":2,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-09-04T18:15:30Z","access_level":10}
@@ -0,0 +1 @@
1
+ {"created_at":"2013-09-04T18:18:15Z","group_access":10,"group_id":3,"id":2,"notification_level":3,"updated_at":"2013-09-04T18:18:15Z","user_id":2}
@@ -0,0 +1 @@
1
+ [{"id":1,"username":"eraymond","email":"eraymond@local.host","name":"Edward Raymond","state":"active","created_at":"2013-08-30T16:16:22Z","access_level":50},{"id":1,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-08-30T16:16:22Z","access_level":50}]
@@ -0,0 +1,2 @@
1
+ [{"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}
2
+ ]
@@ -0,0 +1 @@
1
+ {"id":1201,"body":"The solution is rather tricky","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"created_at":"2012-11-27T19:16:44Z"}
@@ -0,0 +1 @@
1
+ [{"id":1201,"body":"The solution is rather tricky","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"created_at":"2012-11-27T19:16:44Z"},{"id":1207,"body":"I know, right?","author":{"id":1,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"created_at":"2012-11-27T19:58:21Z"}]
@@ -1 +1 @@
1
- {"id":3,"code":"gitlab","name":"Gitlab","description":null,"path":"gitlab","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"private":true,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:58Z"}
1
+ {"id":3,"code":"gitlab","name":"Gitlab","description":null,"path":"gitlab","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"public":false,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:58Z"}
@@ -0,0 +1,8 @@
1
+ {
2
+ "created_at": "2013-10-05T15:05:26Z",
3
+ "fingerprint": "5c:b5:e6:b0:f5:31:65:3f:a6:b5:59:86:32:cc:15:e1",
4
+ "id": 2,
5
+ "key": "ssh-rsa ...",
6
+ "updated_at": "2013-10-05T15:05:26Z",
7
+ "user_id": null
8
+ }
@@ -0,0 +1 @@
1
+ {"id":1,"code":"brute","name":"Brute","description":null,"path":"brute","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Owner","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"private":true,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:56Z"}
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,6 @@
1
+ {
2
+ "id": 2,
3
+ "title": "Key Title",
4
+ "key": "ssh-rsa ...",
5
+ "created_at": "2013-09-22T18:34:32Z"
6
+ }
@@ -0,0 +1,6 @@
1
+ [{
2
+ "id": 2,
3
+ "title": "Key Title",
4
+ "key": "ssh-rsa ...",
5
+ "created_at": "2013-09-22T18:34:32Z"
6
+ }]
@@ -0,0 +1 @@
1
+ {"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"A different new feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}
@@ -0,0 +1,111 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".groups" do
5
+ before do
6
+ stub_get("/groups", "groups")
7
+ stub_get("/groups/3", "group")
8
+ @group = Gitlab.group(3)
9
+ @groups = Gitlab.groups
10
+ end
11
+
12
+ it "should get the correct resource" do
13
+ a_get("/groups").should have_been_made
14
+ a_get("/groups/3").should have_been_made
15
+ end
16
+
17
+ it "should return an array of Groups" do
18
+ @groups.should be_an Array
19
+ @groups.first.path.should == "threegroup"
20
+ end
21
+ end
22
+
23
+ describe ".create_group" do
24
+ before do
25
+ stub_post("/groups", "group_create")
26
+ @group = Gitlab.create_group('GitLab-Group', 'gitlab-path')
27
+ end
28
+
29
+ it "should get the correct resource" do
30
+ a_post("/groups").
31
+ with(:body => {:path => 'gitlab-path', :name => 'GitLab-Group'}).should have_been_made
32
+ end
33
+
34
+ it "should return information about a created group" do
35
+ @group.name.should == "Gitlab-Group"
36
+ @group.path.should == "gitlab-group"
37
+ end
38
+ end
39
+
40
+ describe ".transfer_project_to_group" do
41
+ before do
42
+ stub_post("/projects", "project")
43
+ @project = Gitlab.create_project('Gitlab')
44
+ stub_post("/groups", "group_create")
45
+ @group = Gitlab.create_group('GitLab-Group', 'gitlab-path')
46
+
47
+ stub_post("/groups/#{@group.id}/projects/#{@project.id}", "group_create")
48
+ @group_transfer = Gitlab.transfer_project_to_group(@group.id,@project.id)
49
+ end
50
+
51
+ it "should post to the correct resource" do
52
+ 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
53
+ end
54
+
55
+ it "should return information about the group" do
56
+ @group_transfer.name.should == @group.name
57
+ @group_transfer.path.should == @group.path
58
+ @group_transfer.id.should == @group.id
59
+ end
60
+ end
61
+
62
+ describe ".group_members" do
63
+ before do
64
+ stub_get("/groups/3/members", "group_members")
65
+ @members = Gitlab.group_members(3)
66
+ end
67
+
68
+ it "should get the correct resource" do
69
+ a_get("/groups/3/members").should have_been_made
70
+ end
71
+
72
+ it "should return information about a group members" do
73
+ @members.should be_an Array
74
+ @members.size.should == 2
75
+ @members[1].name.should == "John Smith"
76
+ end
77
+ end
78
+
79
+ describe ".add_group_member" do
80
+ before do
81
+ stub_post("/groups/3/members", "group_member")
82
+ @member = Gitlab.add_group_member(3, 1, 40)
83
+ end
84
+
85
+ it "should get the correct resource" do
86
+ a_post("/groups/3/members").
87
+ with(:body => {:user_id => '1', :access_level => '40'}).should have_been_made
88
+ end
89
+
90
+ it "should return information about an added member" do
91
+ @member.name.should == "John Smith"
92
+ end
93
+ end
94
+
95
+ describe ".remove_group_member" do
96
+ before do
97
+ stub_delete("/groups/3/members/1", "group_member_delete")
98
+ @group = Gitlab.remove_group_member(3, 1)
99
+ end
100
+
101
+ it "should get the correct resource" do
102
+ a_delete("/groups/3/members/1").should have_been_made
103
+ end
104
+
105
+ it "should return information about the group the member was removed from" do
106
+ @group.group_id.should == 3
107
+ end
108
+ end
109
+
110
+
111
+ end
@@ -94,7 +94,7 @@ describe Gitlab::Client do
94
94
 
95
95
  it "should get the correct resource" do
96
96
  a_put("/projects/3/issues/33").
97
- with(:body => {:closed => '1'}).should have_been_made
97
+ with(:body => {:state_event => 'close'}).should have_been_made
98
98
  end
99
99
 
100
100
  it "should return information about an closed issue" do
@@ -111,7 +111,7 @@ describe Gitlab::Client do
111
111
 
112
112
  it "should get the correct resource" do
113
113
  a_put("/projects/3/issues/33").
114
- with(:body => {:closed => '0'}).should have_been_made
114
+ with(:body => {:state_event => 'reopen'}).should have_been_made
115
115
  end
116
116
 
117
117
  it "should return information about an reopened issue" do
@@ -32,4 +32,61 @@ describe Gitlab::Client do
32
32
  @merge_request.assignee.name.should == "Jack Smith"
33
33
  end
34
34
  end
35
+
36
+ describe ".create_merge_request" do
37
+ before do
38
+ stub_post("/projects/3/merge_requests", "create_merge_request")
39
+ end
40
+
41
+ it "should fail if it doesn't have a source_branch" do
42
+ expect {
43
+ Gitlab.create_merge_request(3, 'New merge request', :target_branch => 'master')
44
+ }.to raise_error Gitlab::Error::MissingAttributes
45
+ end
46
+
47
+ it "should fail if it doesn't have a target_branch" do
48
+ expect {
49
+ Gitlab.create_merge_request(3, 'New merge request', :source_branch => 'dev')
50
+ }.to raise_error Gitlab::Error::MissingAttributes
51
+ end
52
+
53
+ it "should return information about a merge request" do
54
+ @merge_request = Gitlab.create_merge_request(3, 'New feature',
55
+ :source_branch => 'api',
56
+ :target_branch => 'master'
57
+ )
58
+ @merge_request.project_id.should == 3
59
+ @merge_request.assignee.name.should == "Jack Smith"
60
+ @merge_request.title.should == 'New feature'
61
+ end
62
+ end
63
+
64
+ describe ".update_merge_request" do
65
+ before do
66
+ stub_put("/projects/3/merge_request/2", "update_merge_request")
67
+ @merge_request = Gitlab.update_merge_request(3, 2,
68
+ :assignee_id => '1',
69
+ :target_branch => 'master',
70
+ :title => 'A different new feature'
71
+ )
72
+ end
73
+
74
+ it "should return information about a merge request" do
75
+ @merge_request.project_id.should == 3
76
+ @merge_request.assignee.name.should == "Jack Smith"
77
+ @merge_request.title.should == 'A different new feature'
78
+ end
79
+ end
80
+
81
+ describe ".create_merge_request_comment" do
82
+ before do
83
+ stub_post("/projects/3/merge_request/2/comments", "comment_merge_request")
84
+ end
85
+
86
+ it "should return information about a merge request" do
87
+ @merge_request = Gitlab.create_merge_request_comment(3, 2, 'Cool Merge Request!')
88
+ @merge_request.note.should == 'Cool Merge Request!'
89
+ @merge_request.author.id == 1
90
+ end
91
+ end
35
92
  end
@@ -0,0 +1,156 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe "notes" do
5
+ context "when wall notes" do
6
+ before do
7
+ stub_get("/projects/3/notes", "notes")
8
+ @notes = Gitlab.notes(3)
9
+ end
10
+
11
+ it "should get the correct resource" do
12
+ a_get("/projects/3/notes").should have_been_made
13
+ end
14
+
15
+ it "should return an array of notes" do
16
+ @notes.should be_an Array
17
+ @notes.first.author.name.should == "John Smith"
18
+ end
19
+ end
20
+
21
+ context "when issue notes" do
22
+ before do
23
+ stub_get("/projects/3/issues/7/notes", "notes")
24
+ @notes = Gitlab.issue_notes(3, 7)
25
+ end
26
+
27
+ it "should get the correct resource" do
28
+ a_get("/projects/3/issues/7/notes").should have_been_made
29
+ end
30
+
31
+ it "should return an array of notes" do
32
+ @notes.should be_an Array
33
+ @notes.first.author.name.should == "John Smith"
34
+ end
35
+ end
36
+
37
+ context "when snippet notes" do
38
+ before do
39
+ stub_get("/projects/3/snippets/7/notes", "notes")
40
+ @notes = Gitlab.snippet_notes(3, 7)
41
+ end
42
+
43
+ it "should get the correct resource" do
44
+ a_get("/projects/3/snippets/7/notes").should have_been_made
45
+ end
46
+
47
+ it "should return an array of notes" do
48
+ @notes.should be_an Array
49
+ @notes.first.author.name.should == "John Smith"
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "note" do
55
+ context "when wall note" do
56
+ before do
57
+ stub_get("/projects/3/notes/1201", "note")
58
+ @note = Gitlab.note(3, 1201)
59
+ end
60
+
61
+ it "should get the correct resource" do
62
+ a_get("/projects/3/notes/1201").should have_been_made
63
+ end
64
+
65
+ it "should return information about a note" do
66
+ @note.body.should == "The solution is rather tricky"
67
+ @note.author.name.should == "John Smith"
68
+ end
69
+ end
70
+
71
+ context "when issue note" do
72
+ before do
73
+ stub_get("/projects/3/issues/7/notes/1201", "note")
74
+ @note = Gitlab.issue_note(3, 7, 1201)
75
+ end
76
+
77
+ it "should get the correct resource" do
78
+ a_get("/projects/3/issues/7/notes/1201").should have_been_made
79
+ end
80
+
81
+ it "should return information about a note" do
82
+ @note.body.should == "The solution is rather tricky"
83
+ @note.author.name.should == "John Smith"
84
+ end
85
+ end
86
+
87
+ context "when snippet note" do
88
+ before do
89
+ stub_get("/projects/3/snippets/7/notes/1201", "note")
90
+ @note = Gitlab.snippet_note(3, 7, 1201)
91
+ end
92
+
93
+ it "should get the correct resource" do
94
+ a_get("/projects/3/snippets/7/notes/1201").should have_been_made
95
+ end
96
+
97
+ it "should return information about a note" do
98
+ @note.body.should == "The solution is rather tricky"
99
+ @note.author.name.should == "John Smith"
100
+ end
101
+ end
102
+ end
103
+
104
+ describe "create note" do
105
+ context "when wall note" do
106
+ before do
107
+ stub_post("/projects/3/notes", "note")
108
+ @note = Gitlab.create_note(3, "The solution is rather tricky")
109
+ end
110
+
111
+ it "should get the correct resource" do
112
+ a_post("/projects/3/notes").
113
+ with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
114
+ end
115
+
116
+ it "should return information about a created note" do
117
+ @note.body.should == "The solution is rather tricky"
118
+ @note.author.name.should == "John Smith"
119
+ end
120
+ end
121
+
122
+ context "when issue note" do
123
+ before do
124
+ stub_post("/projects/3/issues/7/notes", "note")
125
+ @note = Gitlab.create_issue_note(3, 7, "The solution is rather tricky")
126
+ end
127
+
128
+ it "should get the correct resource" do
129
+ a_post("/projects/3/issues/7/notes").
130
+ with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
131
+ end
132
+
133
+ it "should return information about a created note" do
134
+ @note.body.should == "The solution is rather tricky"
135
+ @note.author.name.should == "John Smith"
136
+ end
137
+ end
138
+
139
+ context "when snippet note" do
140
+ before do
141
+ stub_post("/projects/3/snippets/7/notes", "note")
142
+ @note = Gitlab.create_snippet_note(3, 7, "The solution is rather tricky")
143
+ end
144
+
145
+ it "should get the correct resource" do
146
+ a_post("/projects/3/snippets/7/notes").
147
+ with(:body => {:body => 'The solution is rather tricky'}).should have_been_made
148
+ end
149
+
150
+ it "should return information about a created note" do
151
+ @note.body.should == "The solution is rather tricky"
152
+ @note.author.name.should == "John Smith"
153
+ end
154
+ end
155
+ end
156
+ end