gitlab 2.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 (51) hide show
  1. data/.gitignore +17 -0
  2. data/.travis.yml +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +24 -0
  5. data/README.md +64 -0
  6. data/Rakefile +9 -0
  7. data/gitlab.gemspec +25 -0
  8. data/lib/gitlab.rb +29 -0
  9. data/lib/gitlab/api.rb +17 -0
  10. data/lib/gitlab/client.rb +13 -0
  11. data/lib/gitlab/client/issues.rb +69 -0
  12. data/lib/gitlab/client/milestones.rb +59 -0
  13. data/lib/gitlab/client/projects.rb +155 -0
  14. data/lib/gitlab/client/repositories.rb +67 -0
  15. data/lib/gitlab/client/snippets.rb +64 -0
  16. data/lib/gitlab/client/users.rb +89 -0
  17. data/lib/gitlab/configuration.rb +38 -0
  18. data/lib/gitlab/error.rb +33 -0
  19. data/lib/gitlab/objectified_hash.rb +18 -0
  20. data/lib/gitlab/request.rb +73 -0
  21. data/lib/gitlab/version.rb +3 -0
  22. data/spec/fixtures/issue.json +1 -0
  23. data/spec/fixtures/issues.json +1 -0
  24. data/spec/fixtures/key.json +1 -0
  25. data/spec/fixtures/keys.json +1 -0
  26. data/spec/fixtures/milestone.json +1 -0
  27. data/spec/fixtures/milestones.json +1 -0
  28. data/spec/fixtures/project.json +1 -0
  29. data/spec/fixtures/project_branch.json +1 -0
  30. data/spec/fixtures/project_branches.json +1 -0
  31. data/spec/fixtures/project_commits.json +1 -0
  32. data/spec/fixtures/project_hook.json +1 -0
  33. data/spec/fixtures/project_hooks.json +1 -0
  34. data/spec/fixtures/project_issues.json +1 -0
  35. data/spec/fixtures/project_tags.json +1 -0
  36. data/spec/fixtures/projects.json +1 -0
  37. data/spec/fixtures/session.json +1 -0
  38. data/spec/fixtures/snippet.json +1 -0
  39. data/spec/fixtures/team_member.json +1 -0
  40. data/spec/fixtures/team_members.json +1 -0
  41. data/spec/fixtures/user.json +1 -0
  42. data/spec/fixtures/users.json +1 -0
  43. data/spec/gitlab/client/issues_spec.rb +88 -0
  44. data/spec/gitlab/client/milestones_spec.rb +66 -0
  45. data/spec/gitlab/client/projects_spec.rb +177 -0
  46. data/spec/gitlab/client/repositories_spec.rb +73 -0
  47. data/spec/gitlab/client/snippets_spec.rb +69 -0
  48. data/spec/gitlab/client/users_spec.rb +129 -0
  49. data/spec/gitlab_spec.rb +49 -0
  50. data/spec/spec_helper.rb +63 -0
  51. metadata +194 -0
@@ -0,0 +1 @@
1
+ [{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z","access_level":40},{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":20},{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":6,"email":"faye.watsica@rohanwalter.com","name":"Ambrose Hansen","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":7,"email":"maida@walshtorp.name","name":"Alana Hahn","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":20}]
@@ -0,0 +1 @@
1
+ {"id":1,"email":"john@example.com","name":"John Smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"}
@@ -0,0 +1 @@
1
+ [{"id":1,"email":"john@example.com","name":"John Smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"},{"id":2,"email":"jack@example.com","name":"Jack Smith","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":6,"email":"faye.watsica@rohanwalter.com","name":"Ambrose Hansen","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":7,"email":"maida@walshtorp.name","name":"Alana Hahn","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"}]
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".issues" do
5
+ context "with project ID passed" do
6
+ before do
7
+ stub_get("/projects/3/issues", "project_issues")
8
+ @issues = Gitlab.issues(3)
9
+ end
10
+
11
+ it "should get the correct resource" do
12
+ a_get("/projects/3/issues").should have_been_made
13
+ end
14
+
15
+ it "should return an array of project's issues" do
16
+ @issues.should be_an Array
17
+ @issues.first.project_id.should == 3
18
+ end
19
+ end
20
+
21
+ context "without project ID passed" do
22
+ before do
23
+ stub_get("/issues", "issues")
24
+ @issues = Gitlab.issues
25
+ end
26
+
27
+ it "should get the correct resource" do
28
+ a_get("/issues").should have_been_made
29
+ end
30
+
31
+ it "should return an array of user's issues" do
32
+ @issues.should be_an Array
33
+ @issues.first.closed.should be_false
34
+ @issues.first.author.name.should == "John Smith"
35
+ end
36
+ end
37
+ end
38
+
39
+ describe ".issue" do
40
+ before do
41
+ stub_get("/projects/3/issues/33", "issue")
42
+ @issue = Gitlab.issue(3, 33)
43
+ end
44
+
45
+ it "should get the correct resource" do
46
+ a_get("/projects/3/issues/33").should have_been_made
47
+ end
48
+
49
+ it "should return information about an issue" do
50
+ @issue.project_id.should == 3
51
+ @issue.assignee.name.should == "Jack Smith"
52
+ end
53
+ end
54
+
55
+ describe ".create_issue" do
56
+ before do
57
+ stub_post("/projects/3/issues", "issue")
58
+ @issue = Gitlab.create_issue(3, 'title')
59
+ end
60
+
61
+ it "should get the correct resource" do
62
+ a_post("/projects/3/issues").
63
+ with(:body => {:title => 'title'}).should have_been_made
64
+ end
65
+
66
+ it "should return information about a created issue" do
67
+ @issue.project_id.should == 3
68
+ @issue.assignee.name.should == "Jack Smith"
69
+ end
70
+ end
71
+
72
+ describe ".edit_issue" do
73
+ before do
74
+ stub_put("/projects/3/issues/33", "issue")
75
+ @issue = Gitlab.edit_issue(3, 33, :title => 'title')
76
+ end
77
+
78
+ it "should get the correct resource" do
79
+ a_put("/projects/3/issues/33").
80
+ with(:body => {:title => 'title'}).should have_been_made
81
+ end
82
+
83
+ it "should return information about an edited issue" do
84
+ @issue.project_id.should == 3
85
+ @issue.assignee.name.should == "Jack Smith"
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".milestones" do
5
+ before do
6
+ stub_get("/projects/3/milestones", "milestones")
7
+ @milestones = Gitlab.milestones(3)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ a_get("/projects/3/milestones").should have_been_made
12
+ end
13
+
14
+ it "should return an array of project's milestones" do
15
+ @milestones.should be_an Array
16
+ @milestones.first.project_id.should == 3
17
+ end
18
+ end
19
+
20
+ describe ".milestone" do
21
+ before do
22
+ stub_get("/projects/3/milestones/1", "milestone")
23
+ @milestone = Gitlab.milestone(3, 1)
24
+ end
25
+
26
+ it "should get the correct resource" do
27
+ a_get("/projects/3/milestones/1").should have_been_made
28
+ end
29
+
30
+ it "should return information about a milestone" do
31
+ @milestone.project_id.should == 3
32
+ end
33
+ end
34
+
35
+ describe ".create_milestone" do
36
+ before do
37
+ stub_post("/projects/3/milestones", "milestone")
38
+ @milestone = Gitlab.create_milestone(3, 'title')
39
+ end
40
+
41
+ it "should get the correct resource" do
42
+ a_post("/projects/3/milestones").
43
+ with(:body => {:title => 'title'}).should have_been_made
44
+ end
45
+
46
+ it "should return information about a created milestone" do
47
+ @milestone.project_id.should == 3
48
+ end
49
+ end
50
+
51
+ describe ".edit_milestone" do
52
+ before do
53
+ stub_put("/projects/3/milestones/33", "milestone")
54
+ @milestone = Gitlab.edit_milestone(3, 33, :title => 'title')
55
+ end
56
+
57
+ it "should get the correct resource" do
58
+ a_put("/projects/3/milestones/33").
59
+ with(:body => {:title => 'title'}).should have_been_made
60
+ end
61
+
62
+ it "should return information about an edited milestone" do
63
+ @milestone.project_id.should == 3
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,177 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".projects" do
5
+ before do
6
+ stub_get("/projects", "projects")
7
+ @projects = Gitlab.projects
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ a_get("/projects").should have_been_made
12
+ end
13
+
14
+ it "should return an array of projects" do
15
+ @projects.should be_an Array
16
+ @projects.first.name.should == "Brute"
17
+ @projects.first.owner.name.should == "John Smith"
18
+ end
19
+ end
20
+
21
+ describe ".project" do
22
+ before do
23
+ stub_get("/projects/3", "project")
24
+ @project = Gitlab.project(3)
25
+ end
26
+
27
+ it "should get the correct resource" do
28
+ a_get("/projects/3").should have_been_made
29
+ end
30
+
31
+ it "should return information about a project" do
32
+ @project.name.should == "Gitlab"
33
+ @project.owner.name.should == "John Smith"
34
+ end
35
+ end
36
+
37
+ describe ".create_project" do
38
+ before do
39
+ stub_post("/projects", "project")
40
+ @project = Gitlab.create_project('Gitlab')
41
+ end
42
+
43
+ it "should get the correct resource" do
44
+ a_post("/projects").should have_been_made
45
+ end
46
+
47
+ it "should return information about a created project" do
48
+ @project.name.should == "Gitlab"
49
+ @project.owner.name.should == "John Smith"
50
+ end
51
+ end
52
+
53
+ describe ".team_members" do
54
+ before do
55
+ stub_get("/projects/3/members", "team_members")
56
+ @team_members = Gitlab.team_members(3)
57
+ end
58
+
59
+ it "should get the correct resource" do
60
+ a_get("/projects/3/members").should have_been_made
61
+ end
62
+
63
+ it "should return an array of team members" do
64
+ @team_members.should be_an Array
65
+ @team_members.first.name.should == "John Smith"
66
+ end
67
+ end
68
+
69
+ describe ".team_member" do
70
+ before do
71
+ stub_get("/projects/3/members/1", "team_member")
72
+ @team_member = Gitlab.team_member(3, 1)
73
+ end
74
+
75
+ it "should get the correct resource" do
76
+ a_get("/projects/3/members/1").should have_been_made
77
+ end
78
+
79
+ it "should return information about a team member" do
80
+ @team_member.name.should == "John Smith"
81
+ end
82
+ end
83
+
84
+ describe ".add_team_member" do
85
+ before do
86
+ stub_post("/projects/3/members/1", "team_member")
87
+ @team_member = Gitlab.add_team_member(3, 1, 40)
88
+ end
89
+
90
+ it "should get the correct resource" do
91
+ a_post("/projects/3/members/1").
92
+ with(:body => {:access_level => '40'}).should have_been_made
93
+ end
94
+
95
+ it "should return information about an added team member" do
96
+ @team_member.name.should == "John Smith"
97
+ end
98
+ end
99
+
100
+ describe ".edit_team_member" do
101
+ before do
102
+ stub_put("/projects/3/members/1", "team_member")
103
+ @team_member = Gitlab.edit_team_member(3, 1, 40)
104
+ end
105
+
106
+ it "should get the correct resource" do
107
+ a_put("/projects/3/members/1").
108
+ with(:body => {:access_level => '40'}).should have_been_made
109
+ end
110
+
111
+ it "should return information about an edited team member" do
112
+ @team_member.name.should == "John Smith"
113
+ end
114
+ end
115
+
116
+ describe ".remove_team_member" do
117
+ before do
118
+ stub_delete("/projects/3/members/1", "team_member")
119
+ @team_member = Gitlab.remove_team_member(3, 1)
120
+ end
121
+
122
+ it "should get the correct resource" do
123
+ a_delete("/projects/3/members/1").should have_been_made
124
+ end
125
+
126
+ it "should return information about a removed team member" do
127
+ @team_member.name.should == "John Smith"
128
+ end
129
+ end
130
+
131
+ describe ".project_hooks" do
132
+ before do
133
+ stub_get("/projects/1/hooks", "project_hooks")
134
+ @hooks = Gitlab.project_hooks(1)
135
+ end
136
+
137
+ it "should get the correct resource" do
138
+ a_get("/projects/1/hooks").should have_been_made
139
+ end
140
+
141
+ it "should return an array of hooks" do
142
+ @hooks.should be_an Array
143
+ @hooks.first.url.should == "https://api.example.net/v1/webhooks/ci"
144
+ end
145
+ end
146
+
147
+ describe ".add_project_hook" do
148
+ before do
149
+ stub_post("/projects/1/hooks", "project_hook")
150
+ @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci")
151
+ end
152
+
153
+ it "should get the correct resource" do
154
+ body = {:url => "https://api.example.net/v1/webhooks/ci"}
155
+ a_post("/projects/1/hooks").with(:body => body).should have_been_made
156
+ end
157
+
158
+ it "should return information about an added hook" do
159
+ @hook.url.should == "https://api.example.net/v1/webhooks/ci"
160
+ end
161
+ end
162
+
163
+ describe ".delete_project_hook" do
164
+ before do
165
+ stub_delete("/projects/1/hooks/1", "project_hook")
166
+ @hook = Gitlab.delete_project_hook(1, 1)
167
+ end
168
+
169
+ it "should get the correct resource" do
170
+ a_delete("/projects/1/hooks/1").should have_been_made
171
+ end
172
+
173
+ it "should return information about a deleted hook" do
174
+ @hook.url.should == "https://api.example.net/v1/webhooks/ci"
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ it { should respond_to :repo_tags }
5
+ it { should respond_to :repo_branches }
6
+ it { should respond_to :repo_branch }
7
+ it { should respond_to :repo_commits }
8
+
9
+ describe ".tags" do
10
+ before do
11
+ stub_get("/projects/3/repository/tags", "project_tags")
12
+ @tags = Gitlab.tags(3)
13
+ end
14
+
15
+ it "should get the correct resource" do
16
+ a_get("/projects/3/repository/tags").should have_been_made
17
+ end
18
+
19
+ it "should return an array of repository tags" do
20
+ @tags.should be_an Array
21
+ @tags.first.name.should == "v2.8.2"
22
+ end
23
+ end
24
+
25
+ describe ".branches" do
26
+ before do
27
+ stub_get("/projects/3/repository/branches", "project_branches")
28
+ @branches = Gitlab.branches(3)
29
+ end
30
+
31
+ it "should get the correct resource" do
32
+ a_get("/projects/3/repository/branches").should have_been_made
33
+ end
34
+
35
+ it "should return an array of repository branches" do
36
+ @branches.should be_an Array
37
+ @branches.first.name.should == "api"
38
+ end
39
+ end
40
+
41
+ describe ".branch" do
42
+ before do
43
+ stub_get("/projects/3/repository/branches/api", "project_branch")
44
+ @branch = Gitlab.branch(3, "api")
45
+ end
46
+
47
+ it "should get the correct resource" do
48
+ a_get("/projects/3/repository/branches/api").should have_been_made
49
+ end
50
+
51
+ it "should return information about a repository branch" do
52
+ @branch.name.should == "api"
53
+ end
54
+ end
55
+
56
+ describe ".commits" do
57
+ before do
58
+ stub_get("/projects/3/repository/commits", "project_commits").
59
+ with(:query => {:ref_name => "api"})
60
+ @commits = Gitlab.commits(3, :ref_name => "api")
61
+ end
62
+
63
+ it "should get the correct resource" do
64
+ a_get("/projects/3/repository/commits").
65
+ with(:query => {:ref_name => "api"}).should have_been_made
66
+ end
67
+
68
+ it "should return an array of respository commits" do
69
+ @commits.should be_an Array
70
+ @commits.first.id.should == "f7dd067490fe57505f7226c3b54d3127d2f7fd46"
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".snippet" do
5
+ before do
6
+ stub_get("/projects/3/snippets/1", "snippet")
7
+ @snippet = Gitlab.snippet(3, 1)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ a_get("/projects/3/snippets/1").should have_been_made
12
+ end
13
+
14
+ it "should return information about a snippet" do
15
+ @snippet.file_name.should == "mailer_test.rb"
16
+ @snippet.author.name.should == "John Smith"
17
+ end
18
+ end
19
+
20
+ describe ".create_snippet" do
21
+ before do
22
+ stub_post("/projects/3/snippets", "snippet")
23
+ @snippet = Gitlab.create_snippet(3, {:title => 'API', :file_name => 'api.rb', :code => 'code'})
24
+ end
25
+
26
+ it "should get the correct resource" do
27
+ body = {:title => 'API', :file_name => 'api.rb', :code => 'code'}
28
+ a_post("/projects/3/snippets").with(:body => body).should have_been_made
29
+ end
30
+
31
+ it "should return information about a new snippet" do
32
+ @snippet.file_name.should == "mailer_test.rb"
33
+ @snippet.author.name.should == "John Smith"
34
+ end
35
+ end
36
+
37
+ describe ".edit_snippet" do
38
+ before do
39
+ stub_put("/projects/3/snippets/1", "snippet")
40
+ @snippet = Gitlab.edit_snippet(3, 1, :file_name => 'mailer_test.rb')
41
+ end
42
+
43
+ it "should get the correct resource" do
44
+ a_put("/projects/3/snippets/1").
45
+ with(:body => {:file_name => 'mailer_test.rb'}).should have_been_made
46
+ end
47
+
48
+ it "should return information about an edited snippet" do
49
+ @snippet.file_name.should == "mailer_test.rb"
50
+ @snippet.author.name.should == "John Smith"
51
+ end
52
+ end
53
+
54
+ describe ".delete_snippet" do
55
+ before do
56
+ stub_delete("/projects/3/snippets/1", "snippet")
57
+ @snippet = Gitlab.delete_snippet(3, 1)
58
+ end
59
+
60
+ it "should get the correct resource" do
61
+ a_delete("/projects/3/snippets/1").should have_been_made
62
+ end
63
+
64
+ it "should return information about a deleted snippet" do
65
+ @snippet.file_name.should == "mailer_test.rb"
66
+ @snippet.author.name.should == "John Smith"
67
+ end
68
+ end
69
+ end