gitlab 3.0.0 → 3.1.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +1 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +28 -3
  6. data/bin/gitlab +7 -0
  7. data/gitlab.gemspec +3 -2
  8. data/lib/gitlab.rb +8 -0
  9. data/lib/gitlab/api.rb +1 -1
  10. data/lib/gitlab/cli.rb +57 -0
  11. data/lib/gitlab/cli_helpers.rb +141 -0
  12. data/lib/gitlab/client.rb +8 -6
  13. data/lib/gitlab/client/branches.rb +79 -0
  14. data/lib/gitlab/client/merge_requests.rb +15 -2
  15. data/lib/gitlab/client/projects.rb +25 -4
  16. data/lib/gitlab/client/repositories.rb +22 -23
  17. data/lib/gitlab/client/system_hooks.rb +58 -0
  18. data/lib/gitlab/client/users.rb +17 -0
  19. data/lib/gitlab/configuration.rb +3 -3
  20. data/lib/gitlab/objectified_hash.rb +8 -2
  21. data/lib/gitlab/request.rb +21 -5
  22. data/lib/gitlab/version.rb +1 -1
  23. data/spec/fixtures/branch.json +1 -0
  24. data/spec/fixtures/{project_branches.json → branches.json} +0 -0
  25. data/spec/fixtures/create_branch.json +1 -0
  26. data/spec/fixtures/merge_request_comments.json +1 -0
  27. data/spec/fixtures/project_commit.json +13 -0
  28. data/spec/fixtures/project_commit_diff.json +10 -0
  29. data/spec/fixtures/{project_branch.json → protect_branch.json} +1 -1
  30. data/spec/fixtures/system_hook.json +1 -0
  31. data/spec/fixtures/system_hook_test.json +1 -0
  32. data/spec/fixtures/system_hooks.json +1 -0
  33. data/spec/fixtures/unprotect_branch.json +1 -0
  34. data/spec/gitlab/cli_spec.rb +80 -0
  35. data/spec/gitlab/client/branches_spec.rb +103 -0
  36. data/spec/gitlab/client/groups_spec.rb +21 -21
  37. data/spec/gitlab/client/issues_spec.rb +26 -26
  38. data/spec/gitlab/client/merge_requests_spec.rb +45 -13
  39. data/spec/gitlab/client/milestones_spec.rb +11 -11
  40. data/spec/gitlab/client/notes_spec.rb +30 -30
  41. data/spec/gitlab/client/projects_spec.rb +93 -59
  42. data/spec/gitlab/client/repositories_spec.rb +28 -25
  43. data/spec/gitlab/client/snippets_spec.rb +16 -16
  44. data/spec/gitlab/client/system_hooks_spec.rb +69 -0
  45. data/spec/gitlab/client/users_spec.rb +60 -24
  46. data/spec/gitlab/objectified_hash_spec.rb +23 -0
  47. data/spec/gitlab/request_spec.rb +48 -0
  48. data/spec/gitlab_spec.rb +16 -7
  49. data/spec/spec_helper.rb +19 -8
  50. metadata +70 -22
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ it { should respond_to :repo_branches }
5
+ it { should respond_to :repo_branch }
6
+ it { should respond_to :repo_protect_branch }
7
+ it { should respond_to :repo_unprotect_branch }
8
+
9
+ describe ".branches" do
10
+ before do
11
+ stub_get("/projects/3/repository/branches", "branches")
12
+ @branches = Gitlab.branches(3)
13
+ end
14
+
15
+ it "should get the correct resource" do
16
+ expect(a_get("/projects/3/repository/branches")).to have_been_made
17
+ end
18
+
19
+ it "should return an array of repository branches" do
20
+ expect(@branches).to be_an Array
21
+ expect(@branches.first.name).to eq("api")
22
+ end
23
+ end
24
+
25
+ describe ".branch" do
26
+ before do
27
+ stub_get("/projects/3/repository/branches/api", "branch")
28
+ @branch = Gitlab.branch(3, "api")
29
+ end
30
+
31
+ it "should get the correct resource" do
32
+ expect(a_get("/projects/3/repository/branches/api")).to have_been_made
33
+ end
34
+
35
+ it "should return information about a repository branch" do
36
+ expect(@branch.name).to eq("api")
37
+ end
38
+ end
39
+
40
+ describe ".protect_branch" do
41
+ before do
42
+ stub_put("/projects/3/repository/branches/api/protect", "protect_branch")
43
+ @branch = Gitlab.protect_branch(3, "api")
44
+ end
45
+
46
+ it "should get the correct resource" do
47
+ expect(a_put("/projects/3/repository/branches/api/protect")).to have_been_made
48
+ end
49
+
50
+ it "should return information about a protected repository branch" do
51
+ expect(@branch.name).to eq("api")
52
+ expect(@branch.protected).to eq(true)
53
+ end
54
+ end
55
+
56
+ describe ".unprotect_branch" do
57
+ before do
58
+ stub_put("/projects/3/repository/branches/api/unprotect", "unprotect_branch")
59
+ @branch = Gitlab.unprotect_branch(3, "api")
60
+ end
61
+
62
+ it "should get the correct resource" do
63
+ expect(a_put("/projects/3/repository/branches/api/unprotect")).to have_been_made
64
+ end
65
+
66
+ it "should return information about an unprotected repository branch" do
67
+ expect(@branch.name).to eq("api")
68
+ expect(@branch.protected).to eq(false)
69
+ end
70
+ end
71
+
72
+ describe ".create_branch" do
73
+ context "with branch name" do
74
+ before do
75
+ stub_post("/projects/3/repository/branches", "create_branch")
76
+ @branch = Gitlab.create_branch(3, "api","master")
77
+ end
78
+
79
+ it "should get the correct resource" do
80
+ expect(a_post("/projects/3/repository/branches")).to have_been_made
81
+ end
82
+
83
+ it "should return information about a new repository branch" do
84
+ expect(@branch.name).to eq("api")
85
+ end
86
+ end
87
+ context "with commit hash" do
88
+ before do
89
+ stub_post("/projects/3/repository/branches", "create_branch")
90
+ @branch = Gitlab.create_branch(3, "api","949b1df930bedace1dbd755aaa4a82e8c451a616")
91
+ end
92
+
93
+ it "should get the correct resource" do
94
+ expect(a_post("/projects/3/repository/branches")).to have_been_made
95
+ end
96
+
97
+ it "should return information about a new repository branch" do
98
+ expect(@branch.name).to eq("api")
99
+ end
100
+ end
101
+ end
102
+
103
+ end
@@ -10,13 +10,13 @@ describe Gitlab::Client do
10
10
  end
11
11
 
12
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
13
+ expect(a_get("/groups")).to have_been_made
14
+ expect(a_get("/groups/3")).to have_been_made
15
15
  end
16
16
 
17
17
  it "should return an array of Groups" do
18
- @groups.should be_an Array
19
- @groups.first.path.should == "threegroup"
18
+ expect(@groups).to be_an Array
19
+ expect(@groups.first.path).to eq("threegroup")
20
20
  end
21
21
  end
22
22
 
@@ -27,13 +27,13 @@ describe Gitlab::Client do
27
27
  end
28
28
 
29
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
30
+ expect(a_post("/groups").
31
+ with(:body => {:path => 'gitlab-path', :name => 'GitLab-Group'})).to have_been_made
32
32
  end
33
33
 
34
34
  it "should return information about a created group" do
35
- @group.name.should == "Gitlab-Group"
36
- @group.path.should == "gitlab-group"
35
+ expect(@group.name).to eq("Gitlab-Group")
36
+ expect(@group.path).to eq("gitlab-group")
37
37
  end
38
38
  end
39
39
 
@@ -49,13 +49,13 @@ describe Gitlab::Client do
49
49
  end
50
50
 
51
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
52
+ expect(a_post("/groups/#{@group.id}/projects/#{@project.id}").with(:body => {:id => @group.id.to_s, :project_id => @project.id.to_s})).to have_been_made
53
53
  end
54
54
 
55
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
56
+ expect(@group_transfer.name).to eq(@group.name)
57
+ expect(@group_transfer.path).to eq(@group.path)
58
+ expect(@group_transfer.id).to eq(@group.id)
59
59
  end
60
60
  end
61
61
 
@@ -66,13 +66,13 @@ describe Gitlab::Client do
66
66
  end
67
67
 
68
68
  it "should get the correct resource" do
69
- a_get("/groups/3/members").should have_been_made
69
+ expect(a_get("/groups/3/members")).to have_been_made
70
70
  end
71
71
 
72
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"
73
+ expect(@members).to be_an Array
74
+ expect(@members.size).to eq(2)
75
+ expect(@members[1].name).to eq("John Smith")
76
76
  end
77
77
  end
78
78
 
@@ -83,12 +83,12 @@ describe Gitlab::Client do
83
83
  end
84
84
 
85
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
86
+ expect(a_post("/groups/3/members").
87
+ with(:body => {:user_id => '1', :access_level => '40'})).to have_been_made
88
88
  end
89
89
 
90
90
  it "should return information about an added member" do
91
- @member.name.should == "John Smith"
91
+ expect(@member.name).to eq("John Smith")
92
92
  end
93
93
  end
94
94
 
@@ -99,11 +99,11 @@ describe Gitlab::Client do
99
99
  end
100
100
 
101
101
  it "should get the correct resource" do
102
- a_delete("/groups/3/members/1").should have_been_made
102
+ expect(a_delete("/groups/3/members/1")).to have_been_made
103
103
  end
104
104
 
105
105
  it "should return information about the group the member was removed from" do
106
- @group.group_id.should == 3
106
+ expect(@group.group_id).to eq(3)
107
107
  end
108
108
  end
109
109
 
@@ -9,12 +9,12 @@ describe Gitlab::Client do
9
9
  end
10
10
 
11
11
  it "should get the correct resource" do
12
- a_get("/projects/3/issues").should have_been_made
12
+ expect(a_get("/projects/3/issues")).to have_been_made
13
13
  end
14
14
 
15
15
  it "should return an array of project's issues" do
16
- @issues.should be_an Array
17
- @issues.first.project_id.should == 3
16
+ expect(@issues).to be_an Array
17
+ expect(@issues.first.project_id).to eq(3)
18
18
  end
19
19
  end
20
20
 
@@ -25,13 +25,13 @@ describe Gitlab::Client do
25
25
  end
26
26
 
27
27
  it "should get the correct resource" do
28
- a_get("/issues").should have_been_made
28
+ expect(a_get("/issues")).to have_been_made
29
29
  end
30
30
 
31
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"
32
+ expect(@issues).to be_an Array
33
+ expect(@issues.first.closed).to be_false
34
+ expect(@issues.first.author.name).to eq("John Smith")
35
35
  end
36
36
  end
37
37
  end
@@ -43,12 +43,12 @@ describe Gitlab::Client do
43
43
  end
44
44
 
45
45
  it "should get the correct resource" do
46
- a_get("/projects/3/issues/33").should have_been_made
46
+ expect(a_get("/projects/3/issues/33")).to have_been_made
47
47
  end
48
48
 
49
49
  it "should return information about an issue" do
50
- @issue.project_id.should == 3
51
- @issue.assignee.name.should == "Jack Smith"
50
+ expect(@issue.project_id).to eq(3)
51
+ expect(@issue.assignee.name).to eq("Jack Smith")
52
52
  end
53
53
  end
54
54
 
@@ -59,13 +59,13 @@ describe Gitlab::Client do
59
59
  end
60
60
 
61
61
  it "should get the correct resource" do
62
- a_post("/projects/3/issues").
63
- with(:body => {:title => 'title'}).should have_been_made
62
+ expect(a_post("/projects/3/issues").
63
+ with(:body => {:title => 'title'})).to have_been_made
64
64
  end
65
65
 
66
66
  it "should return information about a created issue" do
67
- @issue.project_id.should == 3
68
- @issue.assignee.name.should == "Jack Smith"
67
+ expect(@issue.project_id).to eq(3)
68
+ expect(@issue.assignee.name).to eq("Jack Smith")
69
69
  end
70
70
  end
71
71
 
@@ -76,13 +76,13 @@ describe Gitlab::Client do
76
76
  end
77
77
 
78
78
  it "should get the correct resource" do
79
- a_put("/projects/3/issues/33").
80
- with(:body => {:title => 'title'}).should have_been_made
79
+ expect(a_put("/projects/3/issues/33").
80
+ with(:body => {:title => 'title'})).to have_been_made
81
81
  end
82
82
 
83
83
  it "should return information about an edited issue" do
84
- @issue.project_id.should == 3
85
- @issue.assignee.name.should == "Jack Smith"
84
+ expect(@issue.project_id).to eq(3)
85
+ expect(@issue.assignee.name).to eq("Jack Smith")
86
86
  end
87
87
  end
88
88
 
@@ -93,13 +93,13 @@ describe Gitlab::Client do
93
93
  end
94
94
 
95
95
  it "should get the correct resource" do
96
- a_put("/projects/3/issues/33").
97
- with(:body => {:state_event => 'close'}).should have_been_made
96
+ expect(a_put("/projects/3/issues/33").
97
+ with(:body => {:state_event => 'close'})).to have_been_made
98
98
  end
99
99
 
100
100
  it "should return information about an closed issue" do
101
- @issue.project_id.should == 3
102
- @issue.assignee.name.should == "Jack Smith"
101
+ expect(@issue.project_id).to eq(3)
102
+ expect(@issue.assignee.name).to eq("Jack Smith")
103
103
  end
104
104
  end
105
105
 
@@ -110,13 +110,13 @@ describe Gitlab::Client do
110
110
  end
111
111
 
112
112
  it "should get the correct resource" do
113
- a_put("/projects/3/issues/33").
114
- with(:body => {:state_event => 'reopen'}).should have_been_made
113
+ expect(a_put("/projects/3/issues/33").
114
+ with(:body => {:state_event => 'reopen'})).to have_been_made
115
115
  end
116
116
 
117
117
  it "should return information about an reopened issue" do
118
- @issue.project_id.should == 3
119
- @issue.assignee.name.should == "Jack Smith"
118
+ expect(@issue.project_id).to eq(3)
119
+ expect(@issue.assignee.name).to eq("Jack Smith")
120
120
  end
121
121
  end
122
122
  end
@@ -8,12 +8,12 @@ describe Gitlab::Client do
8
8
  end
9
9
 
10
10
  it "should get the correct resource" do
11
- a_get("/projects/3/merge_requests").should have_been_made
11
+ expect(a_get("/projects/3/merge_requests")).to have_been_made
12
12
  end
13
13
 
14
14
  it "should return an array of project's merge requests" do
15
- @merge_requests.should be_an Array
16
- @merge_requests.first.project_id.should == 3
15
+ expect(@merge_requests).to be_an Array
16
+ expect(@merge_requests.first.project_id).to eq(3)
17
17
  end
18
18
  end
19
19
 
@@ -24,12 +24,12 @@ describe Gitlab::Client do
24
24
  end
25
25
 
26
26
  it "should get the correct resource" do
27
- a_get("/projects/3/merge_request/1").should have_been_made
27
+ expect(a_get("/projects/3/merge_request/1")).to have_been_made
28
28
  end
29
29
 
30
30
  it "should return information about a merge request" do
31
- @merge_request.project_id.should == 3
32
- @merge_request.assignee.name.should == "Jack Smith"
31
+ expect(@merge_request.project_id).to eq(3)
32
+ expect(@merge_request.assignee.name).to eq("Jack Smith")
33
33
  end
34
34
  end
35
35
 
@@ -55,9 +55,9 @@ describe Gitlab::Client do
55
55
  :source_branch => 'api',
56
56
  :target_branch => 'master'
57
57
  )
58
- @merge_request.project_id.should == 3
59
- @merge_request.assignee.name.should == "Jack Smith"
60
- @merge_request.title.should == 'New feature'
58
+ expect(@merge_request.project_id).to eq(3)
59
+ expect(@merge_request.assignee.name).to eq("Jack Smith")
60
+ expect(@merge_request.title).to eq('New feature')
61
61
  end
62
62
  end
63
63
 
@@ -72,9 +72,41 @@ describe Gitlab::Client do
72
72
  end
73
73
 
74
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'
75
+ expect(@merge_request.project_id).to eq(3)
76
+ expect(@merge_request.assignee.name).to eq("Jack Smith")
77
+ expect(@merge_request.title).to eq('A different new feature')
78
+ end
79
+ end
80
+
81
+ describe ".merge_request_comments" do
82
+ before do
83
+ stub_get("/projects/3/merge_request/2/comments", "merge_request_comments")
84
+ @merge_request = Gitlab.merge_request_comments(3, 2)
85
+ end
86
+
87
+ it "should return merge request's comments" do
88
+ expect(@merge_request).to be_an Array
89
+ expect(@merge_request.length).to eq(2)
90
+ expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request")
91
+ expect(@merge_request[0].author.id).to eq(11)
92
+ expect(@merge_request[1].note).to eq("another discussion point on the 2merge request")
93
+ expect(@merge_request[1].author.id).to eq(12)
94
+ end
95
+ end
96
+
97
+ describe ".merge_request_comments" do
98
+ before do
99
+ stub_get("/projects/3/merge_request/2/comments", "merge_request_comments")
100
+ @merge_request = Gitlab.merge_request_comments(3, 2)
101
+ end
102
+
103
+ it "should return merge request's comments" do
104
+ expect(@merge_request).to be_an Array
105
+ expect(@merge_request.length).to eq(2)
106
+ expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request")
107
+ expect(@merge_request[0].author.id).to eq(11)
108
+ expect(@merge_request[1].note).to eq("another discussion point on the 2merge request")
109
+ expect(@merge_request[1].author.id).to eq(12)
78
110
  end
79
111
  end
80
112
 
@@ -85,7 +117,7 @@ describe Gitlab::Client do
85
117
 
86
118
  it "should return information about a merge request" do
87
119
  @merge_request = Gitlab.create_merge_request_comment(3, 2, 'Cool Merge Request!')
88
- @merge_request.note.should == 'Cool Merge Request!'
120
+ expect(@merge_request.note).to eq('Cool Merge Request!')
89
121
  @merge_request.author.id == 1
90
122
  end
91
123
  end
@@ -8,12 +8,12 @@ describe Gitlab::Client do
8
8
  end
9
9
 
10
10
  it "should get the correct resource" do
11
- a_get("/projects/3/milestones").should have_been_made
11
+ expect(a_get("/projects/3/milestones")).to have_been_made
12
12
  end
13
13
 
14
14
  it "should return an array of project's milestones" do
15
- @milestones.should be_an Array
16
- @milestones.first.project_id.should == 3
15
+ expect(@milestones).to be_an Array
16
+ expect(@milestones.first.project_id).to eq(3)
17
17
  end
18
18
  end
19
19
 
@@ -24,11 +24,11 @@ describe Gitlab::Client do
24
24
  end
25
25
 
26
26
  it "should get the correct resource" do
27
- a_get("/projects/3/milestones/1").should have_been_made
27
+ expect(a_get("/projects/3/milestones/1")).to have_been_made
28
28
  end
29
29
 
30
30
  it "should return information about a milestone" do
31
- @milestone.project_id.should == 3
31
+ expect(@milestone.project_id).to eq(3)
32
32
  end
33
33
  end
34
34
 
@@ -39,12 +39,12 @@ describe Gitlab::Client do
39
39
  end
40
40
 
41
41
  it "should get the correct resource" do
42
- a_post("/projects/3/milestones").
43
- with(:body => {:title => 'title'}).should have_been_made
42
+ expect(a_post("/projects/3/milestones").
43
+ with(:body => {:title => 'title'})).to have_been_made
44
44
  end
45
45
 
46
46
  it "should return information about a created milestone" do
47
- @milestone.project_id.should == 3
47
+ expect(@milestone.project_id).to eq(3)
48
48
  end
49
49
  end
50
50
 
@@ -55,12 +55,12 @@ describe Gitlab::Client do
55
55
  end
56
56
 
57
57
  it "should get the correct resource" do
58
- a_put("/projects/3/milestones/33").
59
- with(:body => {:title => 'title'}).should have_been_made
58
+ expect(a_put("/projects/3/milestones/33").
59
+ with(:body => {:title => 'title'})).to have_been_made
60
60
  end
61
61
 
62
62
  it "should return information about an edited milestone" do
63
- @milestone.project_id.should == 3
63
+ expect(@milestone.project_id).to eq(3)
64
64
  end
65
65
  end
66
66
  end