gitlab 3.4.0 → 3.5.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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -2
  3. data/README.md +22 -0
  4. data/bin/console +10 -0
  5. data/bin/setup +6 -0
  6. data/{bin → exe}/gitlab +0 -0
  7. data/gitlab.gemspec +4 -1
  8. data/lib/gitlab.rb +1 -1
  9. data/lib/gitlab/cli.rb +20 -2
  10. data/lib/gitlab/cli_helpers.rb +74 -15
  11. data/lib/gitlab/client.rb +2 -0
  12. data/lib/gitlab/client/commits.rb +121 -0
  13. data/lib/gitlab/client/groups.rb +25 -2
  14. data/lib/gitlab/client/issues.rb +7 -0
  15. data/lib/gitlab/client/milestones.rb +6 -0
  16. data/lib/gitlab/client/namespaces.rb +19 -0
  17. data/lib/gitlab/client/notes.rb +12 -0
  18. data/lib/gitlab/client/projects.rb +30 -0
  19. data/lib/gitlab/client/repositories.rb +0 -75
  20. data/lib/gitlab/client/repository_files.rb +16 -0
  21. data/lib/gitlab/client/snippets.rb +15 -0
  22. data/lib/gitlab/client/users.rb +54 -5
  23. data/lib/gitlab/configuration.rb +14 -0
  24. data/lib/gitlab/error.rb +3 -0
  25. data/lib/gitlab/request.rb +13 -2
  26. data/lib/gitlab/shell.rb +1 -2
  27. data/lib/gitlab/version.rb +1 -1
  28. data/spec/fixtures/branch_delete.json +0 -0
  29. data/spec/fixtures/get_repository_file.json +1 -0
  30. data/spec/fixtures/group_create_with_description.json +1 -0
  31. data/spec/fixtures/group_search.json +2 -0
  32. data/spec/fixtures/namespaces.json +1 -0
  33. data/spec/fixtures/project_commit_status.json +42 -0
  34. data/spec/fixtures/project_edit.json +21 -0
  35. data/spec/fixtures/project_fork.json +50 -0
  36. data/spec/fixtures/project_forked_for_user.json +50 -0
  37. data/spec/fixtures/project_update_commit_status.json +20 -0
  38. data/spec/fixtures/snippet_content.json +3 -0
  39. data/spec/fixtures/user.json +1 -1
  40. data/spec/fixtures/user_block_unblock.json +1 -0
  41. data/spec/fixtures/users.json +1 -1
  42. data/spec/gitlab/cli_helpers_spec.rb +6 -6
  43. data/spec/gitlab/cli_spec.rb +16 -0
  44. data/spec/gitlab/client/commits_spec.rb +137 -0
  45. data/spec/gitlab/client/groups_spec.rb +51 -13
  46. data/spec/gitlab/client/namespaces_spec.rb +22 -0
  47. data/spec/gitlab/client/projects_spec.rb +51 -0
  48. data/spec/gitlab/client/repositories_spec.rb +0 -88
  49. data/spec/gitlab/client/repository_files_spec.rb +17 -0
  50. data/spec/gitlab/client/snippets_spec.rb +15 -0
  51. data/spec/gitlab/client/users_spec.rb +73 -0
  52. data/spec/gitlab/help_spec.rb +1 -1
  53. data/spec/gitlab/request_spec.rb +16 -3
  54. data/spec/gitlab/shell_spec.rb +2 -2
  55. metadata +51 -6
@@ -19,6 +19,10 @@ module Gitlab
19
19
  ObjectifiedHash.new body
20
20
  elsif body.is_a? Array
21
21
  body.collect! { |e| ObjectifiedHash.new(e) }
22
+ elsif body
23
+ true
24
+ elsif !body
25
+ false
22
26
  elsif body.nil?
23
27
  false
24
28
  else
@@ -69,6 +73,7 @@ module Gitlab
69
73
  when 404; raise Error::NotFound.new error_message(response)
70
74
  when 405; raise Error::MethodNotAllowed.new error_message(response)
71
75
  when 409; raise Error::Conflict.new error_message(response)
76
+ when 422; raise Error::Unprocessable.new error_message(response)
72
77
  when 500; raise Error::InternalServerError.new error_message(response)
73
78
  when 502; raise Error::BadGateway.new error_message(response)
74
79
  when 503; raise Error::ServiceUnavailable.new error_message(response)
@@ -109,17 +114,23 @@ module Gitlab
109
114
  end
110
115
 
111
116
  def error_message(response)
117
+ parsed_response = response.parsed_response
118
+ message = parsed_response.message || parsed_response.error
119
+
112
120
  "Server responded with code #{response.code}, message: " \
113
- "#{handle_error(response.parsed_response.message)}. " \
121
+ "#{handle_error(message)}. " \
114
122
  "Request URI: #{response.request.base_uri}#{response.request.path}"
115
123
  end
116
124
 
117
125
  # Handle error response message in case of nested hashes
118
126
  def handle_error(message)
119
- if message.is_a? Gitlab::ObjectifiedHash
127
+ case message
128
+ when Gitlab::ObjectifiedHash
120
129
  message.to_h.sort.map do |key, val|
121
130
  "'#{key}' #{(val.is_a?(Hash) ? val.sort.map { |k,v| "(#{k}: #{v.join(' ')})"} : val).join(' ')}"
122
131
  end.join(', ')
132
+ when Array
133
+ message.join(' ')
123
134
  else
124
135
  message
125
136
  end
@@ -19,8 +19,7 @@ class Gitlab::Shell
19
19
  begin
20
20
  parse_input buffer
21
21
 
22
- yaml_load_arguments! @arguments
23
- @arguments.map! { |arg| symbolize_keys arg }
22
+ @arguments.map! { |arg| symbolize_keys(yaml_load(arg)) }
24
23
 
25
24
  case buffer
26
25
  when nil, ''
@@ -1,3 +1,3 @@
1
1
  module Gitlab
2
- VERSION = "3.4.0"
2
+ VERSION = "3.5.0"
3
3
  end
File without changes
@@ -0,0 +1 @@
1
+ {"file_name":"README.md", "file_path":"README.md", "size":"19", "encoding":"base64", "content":"VGhpcyBpcyBhICpSRUFETUUqIQ==\n", "ref":"master", "blob_id":"0eba9dff767611060181e0423a1de2941d27efc8", "commit_id":"eb38397cb6ae669219e6bc18ad19981fff18ea29"}
@@ -0,0 +1 @@
1
+ {"id":3,"name":"Gitlab-Group","path":"gitlab-group","owner_id":1,"description":"gitlab group description"}
@@ -0,0 +1,2 @@
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": 1, "path": "john", "kind": "user"}]
@@ -0,0 +1,42 @@
1
+ [
2
+ {
3
+ "id": 496,
4
+ "sha": "7d938cb8ac15788d71f4b67c035515a160ea76d8",
5
+ "ref": "decreased-spec",
6
+ "status": "failed",
7
+ "name": "test",
8
+ "target_url": null,
9
+ "description": null,
10
+ "created_at": "2015-10-23T23:35:48.693+02:00",
11
+ "started_at": null,
12
+ "finished_at": "2015-10-23T23:35:48.716+02:00",
13
+ "author": {
14
+ "name": "Dominik Sander",
15
+ "username": "dsander",
16
+ "id": 1,
17
+ "state": "active",
18
+ "avatar_url": "https://secure.gravatar.com/avatar/xxxxx?s=40&d=identicon",
19
+ "web_url": "https://github.com/u/dsander"
20
+ }
21
+ },
22
+ {
23
+ "id": 493,
24
+ "sha": "7d938cb8ac15788d71f4b67c035515a160ea76d8",
25
+ "ref": "decreased-spec",
26
+ "status": "success",
27
+ "name": "specs",
28
+ "target_url": "https://github.com/dsander/omniauth/builds/493",
29
+ "description": null,
30
+ "created_at": "2015-10-23T21:39:19.384+02:00",
31
+ "started_at": "2015-10-23T21:39:21.900+02:00",
32
+ "finished_at": "2015-10-23T21:39:35.215+02:00",
33
+ "author": {
34
+ "name": "Dominik Sander",
35
+ "username": "dsander",
36
+ "id": 1,
37
+ "state": "active",
38
+ "avatar_url": "https://secure.gravatar.com/avatar/xxxxx?s=40&d=identicon",
39
+ "web_url": "https://github.com/u/dsander"
40
+ }
41
+ }
42
+ ]
@@ -0,0 +1,21 @@
1
+ {
2
+ "id":3,
3
+ "code":"gitlab",
4
+ "name":"Gitlab-edit",
5
+ "description":null,
6
+ "path":"gitlab",
7
+ "default_branch":null,
8
+ "owner":{
9
+ "id":1,
10
+ "email":"john@example.com",
11
+ "name":"John Smith",
12
+ "blocked":false,
13
+ "created_at":"2012-09-17T09:41:56Z"
14
+ },
15
+ "public":false,
16
+ "issues_enabled":true,
17
+ "merge_requests_enabled":true,
18
+ "wall_enabled":true,
19
+ "wiki_enabled":true,
20
+ "created_at":"2012-09-17T09:41:58Z"
21
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "id":20,
3
+ "description":"desc",
4
+ "default_branch":"master",
5
+ "tag_list":[
6
+
7
+ ],
8
+ "public":false,
9
+ "archived":false,
10
+ "visibility_level":10,
11
+ "ssh_url_to_repo":"git@git.gitlab.com:root/gitlab.git",
12
+ "http_url_to_repo":"http://git.gitlab.com/root/gitlab.git",
13
+ "web_url":"http://git.gitlab.com/root/gitlab",
14
+ "owner":{
15
+ "name":"Administrator",
16
+ "username":"root",
17
+ "id":1,
18
+ "state":"active",
19
+ "avatar_url":"http://git.gitlab.com/uploads/user/avatar/1/12586377.jpeg"
20
+ },
21
+ "name":"gitlab",
22
+ "name_with_namespace":"Administrator / gitlab",
23
+ "path":"gitlab",
24
+ "path_with_namespace":"root/gitlab",
25
+ "issues_enabled":true,
26
+ "merge_requests_enabled":true,
27
+ "wiki_enabled":true,
28
+ "snippets_enabled":false,
29
+ "created_at":"2015-06-08T01:29:17.190Z",
30
+ "last_activity_at":"2015-06-08T01:29:17.190Z",
31
+ "creator_id":1,
32
+ "namespace":{
33
+ "id":1,
34
+ "name":"root",
35
+ "path":"root",
36
+ "owner_id":1,
37
+ "created_at":"2015-05-28T19:23:40.445Z",
38
+ "updated_at":"2015-05-28T19:23:40.445Z",
39
+ "description":"",
40
+ "avatar":null
41
+ },
42
+ "forked_from_project":{
43
+ "id":3,
44
+ "name":"Gitlab",
45
+ "name_with_namespace":"Root / gitlab",
46
+ "path":"gitlab",
47
+ "path_with_namespace":"root/gitlab"
48
+ },
49
+ "avatar_url":null
50
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "id":20,
3
+ "description":"desc",
4
+ "default_branch":"master",
5
+ "tag_list":[
6
+
7
+ ],
8
+ "public":false,
9
+ "archived":false,
10
+ "visibility_level":10,
11
+ "ssh_url_to_repo":"git@git.gitlab.com:root/gitlab.git",
12
+ "http_url_to_repo":"http://git.gitlab.com/root/gitlab.git",
13
+ "web_url":"http://git.gitlab.com/root/gitlab",
14
+ "owner":{
15
+ "name":"Jack Smith",
16
+ "username":"jack.smith",
17
+ "id":2,
18
+ "state":"active",
19
+ "avatar_url":"http://git.gitlab.com/uploads/user/avatar/1/12586377.jpeg"
20
+ },
21
+ "name":"gitlab",
22
+ "name_with_namespace":"Jack Smith / gitlab",
23
+ "path":"gitlab",
24
+ "path_with_namespace":"jack.smith/gitlab",
25
+ "issues_enabled":true,
26
+ "merge_requests_enabled":true,
27
+ "wiki_enabled":true,
28
+ "snippets_enabled":false,
29
+ "created_at":"2015-06-08T01:29:17.190Z",
30
+ "last_activity_at":"2015-06-08T01:29:17.190Z",
31
+ "creator_id":1,
32
+ "namespace":{
33
+ "id":1,
34
+ "name":"jack.smith",
35
+ "path":"jack.smith",
36
+ "owner_id":2,
37
+ "created_at":"2015-05-28T19:23:40.445Z",
38
+ "updated_at":"2015-05-28T19:23:40.445Z",
39
+ "description":"",
40
+ "avatar":null
41
+ },
42
+ "forked_from_project":{
43
+ "id":3,
44
+ "name":"Gitlab",
45
+ "name_with_namespace":"Root / gitlab",
46
+ "path":"gitlab",
47
+ "path_with_namespace":"root/gitlab"
48
+ },
49
+ "avatar_url":null
50
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "id": 498,
3
+ "sha": "7d938cb8ac15788d71f4b67c035515a160ea76d8",
4
+ "ref": "decreased-spec",
5
+ "status": "failed",
6
+ "name": "test",
7
+ "target_url": null,
8
+ "description": null,
9
+ "created_at": "2015-10-23T23:56:49.499+02:00",
10
+ "started_at": null,
11
+ "finished_at": "2015-10-23T23:56:49.534+02:00",
12
+ "author": {
13
+ "name": "Dominik Sander",
14
+ "username": "dsander",
15
+ "id": 1,
16
+ "state": "active",
17
+ "avatar_url": "https://secure.gravatar.com/avatar/xxx?s=40&d=identicon",
18
+ "web_url": "https://github.com/u/dsander"
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts "Cool snippet!"
@@ -1 +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"}
1
+ {"id":1,"email":"john@example.com","name":"John Smith","username":"john.smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"}
@@ -1 +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"}]
1
+ [{"id":1,"email":"john@example.com","name":"John Smith","username":"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","username":"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","username":"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","username":"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","username":"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","username":"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","username":"alana.hahn","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"}]
@@ -38,19 +38,19 @@ describe Gitlab::CLI::Helpers do
38
38
  end
39
39
  end
40
40
 
41
- describe ".yaml_load_arguments!" do
42
- context "when arguments are YAML" do
41
+ describe ".yaml_load" do
42
+ context "when argument is a YAML string" do
43
43
  it "should return Ruby objects" do
44
- arguments = ["{foo: bar, sna: fu}"]
45
- Gitlab::CLI::Helpers.yaml_load_arguments! arguments
46
- expect(arguments).to eq([{'foo' => 'bar', 'sna' => 'fu'}])
44
+ argument = "{foo: bar, sna: fu}"
45
+ output = Gitlab::CLI::Helpers.yaml_load argument
46
+ expect(output).to eq({'foo' => 'bar', 'sna' => 'fu'})
47
47
  end
48
48
  end
49
49
 
50
50
  context "when input is NOT valid YAML" do
51
51
  it "should raise" do
52
52
  ruby_array = [1, 2, 3, 4]
53
- expect { Gitlab::CLI::Helpers.yaml_load_arguments! ruby_array}.to raise_exception
53
+ expect { Gitlab::CLI::Helpers.yaml_load ruby_array}.to raise_error TypeError
54
54
  end
55
55
  end
56
56
  end
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'json'
2
3
 
3
4
  describe Gitlab::CLI do
4
5
  describe ".run" do
@@ -59,6 +60,21 @@ describe Gitlab::CLI do
59
60
  end
60
61
  end
61
62
 
63
+
64
+ context "when command with json output" do
65
+ before do
66
+ stub_get("/user", "user")
67
+ args = ['user', '--json']
68
+ @output = capture_output { Gitlab::CLI.start(args) }
69
+ end
70
+
71
+ it "should render output as json" do
72
+ expect(JSON.parse(@output)['result']).to eq(JSON.parse(File.read(File.dirname(__FILE__) + '/../fixtures/user.json')))
73
+ expect(JSON.parse(@output)['cmd']).to eq('Gitlab.user')
74
+ end
75
+ end
76
+
77
+
62
78
  context "when command with required fields" do
63
79
  before do
64
80
  stub_get("/user", "user")
@@ -0,0 +1,137 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ it { should respond_to :repo_commits }
5
+ it { should respond_to :repo_commit }
6
+ it { should respond_to :repo_commit_diff }
7
+ it { should respond_to :repo_commit_comments }
8
+ it { should respond_to :repo_create_commit_comment }
9
+ it { should respond_to :repo_commit_status }
10
+ it { should respond_to :repo_update_commit_status }
11
+
12
+ describe ".commits" do
13
+ before do
14
+ stub_get("/projects/3/repository/commits", "project_commits").
15
+ with(:query => {:ref_name => "api"})
16
+ @commits = Gitlab.commits(3, :ref_name => "api")
17
+ end
18
+
19
+ it "should get the correct resource" do
20
+ expect(a_get("/projects/3/repository/commits").
21
+ with(:query => {:ref_name => "api"})).to have_been_made
22
+ end
23
+
24
+ it "should return an array of repository commits" do
25
+ expect(@commits).to be_an Array
26
+ expect(@commits.first.id).to eq("f7dd067490fe57505f7226c3b54d3127d2f7fd46")
27
+ end
28
+ end
29
+
30
+ describe ".commit" do
31
+ before do
32
+ stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6", "project_commit")
33
+ @commit = Gitlab.commit(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
34
+ end
35
+
36
+ it "should get the correct resource" do
37
+ expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6"))
38
+ .to have_been_made
39
+ end
40
+
41
+ it "should return a repository commit" do
42
+ expect(@commit.id).to eq("6104942438c14ec7bd21c6cd5bd995272b3faff6")
43
+ end
44
+ end
45
+
46
+ describe ".commit_diff" do
47
+ before do
48
+ stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff", "project_commit_diff")
49
+ @diff = Gitlab.commit_diff(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
50
+ end
51
+
52
+ it "should get the correct resource" do
53
+ expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff"))
54
+ .to have_been_made
55
+ end
56
+
57
+ it "should return a diff of a commit" do
58
+ expect(@diff.new_path).to eq("doc/update/5.4-to-6.0.md")
59
+ end
60
+ end
61
+
62
+ describe ".commit_comments" do
63
+ before do
64
+ stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments", "project_commit_comments")
65
+ @commit_comments = Gitlab.commit_comments(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
66
+ end
67
+
68
+ it "should get the correct resource" do
69
+ expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments"))
70
+ .to have_been_made
71
+ end
72
+
73
+ it "should return commit's comments" do
74
+ expect(@commit_comments).to be_an Array
75
+ expect(@commit_comments.length).to eq(2)
76
+ expect(@commit_comments[0].note).to eq("this is the 1st comment on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6")
77
+ expect(@commit_comments[0].author.id).to eq(11)
78
+ expect(@commit_comments[1].note).to eq("another discussion point on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6")
79
+ expect(@commit_comments[1].author.id).to eq(12)
80
+ end
81
+ end
82
+
83
+ describe ".create_commit_comment" do
84
+ before do
85
+ stub_post("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments", "project_commit_comment")
86
+ @merge_request = Gitlab.create_commit_comment(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'Nice code!')
87
+ end
88
+
89
+ it "should return information about the newly created comment" do
90
+ expect(@merge_request.note).to eq('Nice code!')
91
+ expect(@merge_request.author.id).to eq(1)
92
+ end
93
+ end
94
+
95
+ describe ".commit_status" do
96
+ before do
97
+ stub_get("/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses", 'project_commit_status').
98
+ with(query: { all: 'true' })
99
+ @statuses = Gitlab.commit_status(6, '7d938cb8ac15788d71f4b67c035515a160ea76d8', all: true)
100
+ end
101
+
102
+ it "should get the correct resource" do
103
+ expect(a_get("/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses").
104
+ with(query: {all: true}))
105
+ end
106
+
107
+ it "should get statuses of a commit" do
108
+ expect(@statuses).to be_kind_of Array
109
+ expect(@statuses.first.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
110
+ expect(@statuses.first.ref).to eq('decreased-spec')
111
+ expect(@statuses.first.status).to eq('failed')
112
+ expect(@statuses.last.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
113
+ expect(@statuses.last.status).to eq('success')
114
+ end
115
+ end
116
+
117
+ describe ".update_commit_status" do
118
+ before do
119
+ stub_post("/projects/6/statuses/7d938cb8ac15788d71f4b67c035515a160ea76d8", 'project_update_commit_status').
120
+ with(query: {name: 'test', ref: 'decreased-spec', state: 'failed'})
121
+ @status = Gitlab.update_commit_status(6, '7d938cb8ac15788d71f4b67c035515a160ea76d8', 'failed', name: 'test', ref: 'decreased-spec')
122
+ end
123
+
124
+ it "should get the correct resource" do
125
+ expect(a_post('/projects/6/statuses/7d938cb8ac15788d71f4b67c035515a160ea76d8').
126
+ with(query: {name: 'test', ref: 'decreased-spec', state: 'failed'}))
127
+ end
128
+
129
+ it "should information about the newly created status" do
130
+ expect(@status).to be_kind_of Gitlab::ObjectifiedHash
131
+ expect(@status.id).to eq(498)
132
+ expect(@status.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8')
133
+ expect(@status.status).to eq('failed')
134
+ expect(@status.ref).to eq('decreased-spec')
135
+ end
136
+ end
137
+ end