gitlab 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +195 -0
  3. data/README.md +12 -0
  4. data/lib/gitlab.rb +5 -0
  5. data/lib/gitlab/cli.rb +6 -0
  6. data/lib/gitlab/cli_helpers.rb +40 -3
  7. data/lib/gitlab/client.rb +1 -0
  8. data/lib/gitlab/client/labels.rb +55 -0
  9. data/lib/gitlab/client/merge_requests.rb +20 -2
  10. data/lib/gitlab/client/projects.rb +18 -9
  11. data/lib/gitlab/client/repositories.rb +84 -4
  12. data/lib/gitlab/configuration.rb +1 -1
  13. data/lib/gitlab/help.rb +2 -2
  14. data/lib/gitlab/objectified_hash.rb +4 -0
  15. data/lib/gitlab/request.rb +18 -6
  16. data/lib/gitlab/shell.rb +42 -4
  17. data/lib/gitlab/shell_history.rb +61 -0
  18. data/lib/gitlab/version.rb +1 -1
  19. data/spec/fixtures/compare_merge_request_diff.json +31 -0
  20. data/spec/fixtures/label.json +1 -0
  21. data/spec/fixtures/labels.json +1 -0
  22. data/spec/fixtures/{comment_merge_request.json → merge_request_comment.json} +0 -0
  23. data/spec/fixtures/project_commit_comment.json +1 -0
  24. data/spec/fixtures/project_commit_comments.json +1 -0
  25. data/spec/fixtures/project_tag_annotated.json +1 -0
  26. data/spec/fixtures/project_tag_lightweight.json +1 -0
  27. data/spec/fixtures/raw_file.json +2 -0
  28. data/spec/fixtures/shell_history.json +2 -0
  29. data/spec/fixtures/tree.json +1 -0
  30. data/spec/gitlab/client/branches_spec.rb +12 -31
  31. data/spec/gitlab/client/labels_spec.rb +68 -0
  32. data/spec/gitlab/client/merge_requests_spec.rb +39 -17
  33. data/spec/gitlab/client/projects_spec.rb +1 -1
  34. data/spec/gitlab/client/repositories_spec.rb +110 -5
  35. data/spec/gitlab/client/system_hooks_spec.rb +3 -3
  36. data/spec/gitlab/objectified_hash_spec.rb +19 -1
  37. data/spec/gitlab/request_spec.rb +4 -3
  38. data/spec/gitlab/shell_history_spec.rb +53 -0
  39. data/spec/gitlab_spec.rb +21 -1
  40. metadata +32 -21
  41. data/spec/fixtures/create_branch.json +0 -1
  42. data/spec/fixtures/create_merge_request.json +0 -1
  43. data/spec/fixtures/project_delete_key.json +0 -8
  44. data/spec/fixtures/protect_branch.json +0 -1
  45. data/spec/fixtures/system_hook_test.json +0 -1
  46. data/spec/fixtures/tag.json +0 -1
  47. data/spec/fixtures/unprotect_branch.json +0 -1
  48. data/spec/fixtures/update_merge_request.json +0 -1
@@ -19,14 +19,15 @@ class Gitlab::Client
19
19
  # Creates a new project repository tag.
20
20
  #
21
21
  # @example
22
- # Gitlab.create_tag(42,'new_tag','master'))
22
+ # Gitlab.create_tag(42,'new_tag','master')
23
23
  #
24
24
  # @param [Integer] project The ID of a project.
25
25
  # @param [String] tag_name The name of the new tag.
26
26
  # @param [String] ref The ref (commit sha, branch name, or another tag) the tag will point to.
27
+ # @param [String] message Optional message for tag, creates annotated tag if specified.
27
28
  # @return [Gitlab::ObjectifiedHash]
28
- def create_tag(project, tag_name, ref)
29
- post("/projects/#{project}/repository/tags", body: {tag_name: tag_name, ref: ref})
29
+ def create_tag(project, tag_name, ref, message='')
30
+ post("/projects/#{project}/repository/tags", body: {tag_name: tag_name, ref: ref, message: message})
30
31
  end
31
32
  alias_method :repo_create_tag, :create_tag
32
33
 
@@ -71,8 +72,87 @@ class Gitlab::Client
71
72
  # @param [String] sha The name of a repository branch or tag or if not given the default branch.
72
73
  # @return [Gitlab::ObjectifiedHash]
73
74
  def commit_diff(project, sha)
74
- get("/projects/#{project}/repository/commits/#{sha}/diff")
75
+ get("/projects/#{project}/repository/commits/#{sha}/diff")
75
76
  end
76
77
  alias_method :repo_commit_diff, :commit_diff
78
+
79
+ # Get the contents of a file
80
+ #
81
+ # @example
82
+ # Gitlab.file_contents(42, 'Gemfile')
83
+ # Gitlab.repo_file_contents(3, 'Gemfile', 'ed899a2f4b50b4370feeea94676502b42383c746')
84
+ #
85
+ # @param [Integer] project The ID of a project.
86
+ # @param [String] filepath The relative path of the file in the repository
87
+ # @param [String] ref The name of a repository branch or tag or if not given the default branch.
88
+ # @return [String]
89
+ def file_contents(project, filepath, ref = 'master')
90
+ get "/projects/#{project}/repository/blobs/#{ref}?filepath=#{filepath}",
91
+ format: nil,
92
+ headers: { Accept: 'text/plain' },
93
+ parser: ::Gitlab::Request::Parser
94
+ end
95
+ alias_method :repo_file_contents, :file_contents
96
+
97
+ # Gets a list of comments for a commit.
98
+ #
99
+ # @example
100
+ # Gitlab.commit_comments(5, c9f9662a9b1116c838b523ed64c6abdb4aae4b8b)
101
+ #
102
+ # @param [Integer] project The ID of a project.
103
+ # @param [String] sha The commit hash or name of a repository branch or tag.
104
+ # @option options [Integer] :page The page number.
105
+ # @option options [Integer] :per_page The number of results per page.
106
+ # @return [Array<Gitlab::ObjectifiedHash>]
107
+ def commit_comments(project, commit, options={})
108
+ get("/projects/#{project}/repository/commits/#{commit}/comments", :query => options)
109
+ end
110
+ alias_method :repo_commit_comments, :commit_comments
111
+
112
+ # Creates a new comment for a commit.
113
+ #
114
+ # @param [Integer] project The ID of a project.
115
+ # @param [String] sha The commit hash or name of a repository branch or tag.
116
+ # @param [String] note The text of a comment.
117
+ # @param [Hash] options A customizable set of options.
118
+ # @option options [String] :path The file path.
119
+ # @option options [Integer] :line The line number.
120
+ # @option options [String] :line_type The line type (new or old).
121
+ # @return [Gitlab::ObjectifiedHash] Information about created comment.
122
+ def create_commit_comment(project, commit, note, options={})
123
+ post("/projects/#{project}/repository/commits/#{commit}/comments", :body => options.merge(:note => note))
124
+ end
125
+ alias_method :repo_create_commit_comment, :create_commit_comment
126
+
127
+ # Get file tree project (root level).
128
+ #
129
+ # @example
130
+ # Gitlab.tree(42)
131
+ # Gitlab.tree(42, path: "Gemfile")
132
+ #
133
+ # @param [Integer] project The ID of a project.
134
+ # @param [Hash] options A customizable set of options.
135
+ # @option options [String] :path The path inside repository.
136
+ # @option options [String] :ref_name The name of a repository branch or tag.
137
+ # @return [Gitlab::ObjectifiedHash]
138
+ def tree(project, options={})
139
+ get("/projects/#{project}/repository/tree", query: options)
140
+ end
141
+ alias_method :repo_tree, :tree
142
+
143
+ # Compares branches, tags or commits.
144
+ #
145
+ # @example
146
+ # Gitlab.compare(42, 'master', 'feature/branch')
147
+ # Gitlab.repo_compare(42, 'master', 'feature/branch')
148
+ #
149
+ # @param [Integer] project The ID of a project.
150
+ # @param [String] from The commit SHA or branch name of from branch.
151
+ # @param [String] to The commit SHA or branch name of to branch.
152
+ # @return [Gitlab::ObjectifiedHash]
153
+ def compare(project, from, to)
154
+ get("/projects/#{project}/repository/compare", :query => {:from => from, :to => to})
155
+ end
156
+ alias_method :repo_compare, :compare
77
157
  end
78
158
  end
@@ -2,7 +2,7 @@ module Gitlab
2
2
  # Defines constants and methods related to configuration.
3
3
  module Configuration
4
4
  # An array of valid keys in the options hash when configuring a Gitlab::API.
5
- VALID_OPTIONS_KEYS = [:endpoint, :private_token, :user_agent, :sudo].freeze
5
+ VALID_OPTIONS_KEYS = [:endpoint, :private_token, :user_agent, :sudo, :httparty].freeze
6
6
 
7
7
  # The user agent that will be sent to the API endpoint if none is set.
8
8
  DEFAULT_USER_AGENT = "Gitlab Ruby Gem #{Gitlab::VERSION}".freeze
@@ -20,10 +20,10 @@ module Gitlab::Help
20
20
  ri_output = `#{ri_cmd} -T #{namespace} 2>&1`.chomp
21
21
 
22
22
  if $? == 0
23
- ri_output.gsub!(/#{cmd}\((.*)\)/, cmd+' \1')
23
+ ri_output.gsub!(/#{cmd}\((.*?)\)/m, cmd+' \1')
24
24
  ri_output.gsub!(/Gitlab\./, 'gitlab> ')
25
25
  ri_output.gsub!(/Gitlab\..+$/, '')
26
- ri_output.gsub!(/\,/, '')
26
+ ri_output.gsub!(/\,[\s]*/, ' ')
27
27
  help = ri_output
28
28
  else
29
29
  help = "Ri docs not found for #{namespace}, please install the docs to use 'help'"
@@ -20,5 +20,9 @@ module Gitlab
20
20
  def method_missing(key)
21
21
  @data.key?(key.to_s) ? @data[key.to_s] : nil
22
22
  end
23
+
24
+ def respond_to?(method_name, include_private = false)
25
+ @hash.keys.map(&:to_sym).include?(method_name.to_sym) || super
26
+ end
23
27
  end
24
28
  end
@@ -9,7 +9,7 @@ module Gitlab
9
9
  headers 'Accept' => 'application/json'
10
10
  parser Proc.new { |body, _| parse(body) }
11
11
 
12
- attr_accessor :private_token
12
+ attr_accessor :private_token, :endpoint
13
13
 
14
14
  # Converts the response body to an ObjectifiedHash.
15
15
  def self.parse(body)
@@ -34,23 +34,27 @@ module Gitlab
34
34
  end
35
35
 
36
36
  def get(path, options={})
37
+ set_httparty_config(options)
37
38
  set_private_token_header(options)
38
- validate self.class.get(path, options)
39
+ validate self.class.get(@endpoint + path, options)
39
40
  end
40
41
 
41
42
  def post(path, options={})
43
+ set_httparty_config(options)
42
44
  set_private_token_header(options, path)
43
- validate self.class.post(path, options)
45
+ validate self.class.post(@endpoint + path, options)
44
46
  end
45
47
 
46
48
  def put(path, options={})
49
+ set_httparty_config(options)
47
50
  set_private_token_header(options)
48
- validate self.class.put(path, options)
51
+ validate self.class.put(@endpoint + path, options)
49
52
  end
50
53
 
51
54
  def delete(path, options={})
55
+ set_httparty_config(options)
52
56
  set_private_token_header(options)
53
- validate self.class.delete(path, options)
57
+ validate self.class.delete(@endpoint + path, options)
54
58
  end
55
59
 
56
60
  # Checks the response code for common errors.
@@ -76,8 +80,8 @@ module Gitlab
76
80
  def set_request_defaults(endpoint, private_token, sudo=nil)
77
81
  raise Error::MissingCredentials.new("Please set an endpoint to API") unless endpoint
78
82
  @private_token = private_token
83
+ @endpoint = endpoint
79
84
 
80
- self.class.base_uri endpoint
81
85
  self.class.default_params :sudo => sudo
82
86
  self.class.default_params.delete(:sudo) if sudo.nil?
83
87
  end
@@ -93,6 +97,14 @@ module Gitlab
93
97
  end
94
98
  end
95
99
 
100
+ # Set HTTParty configuration
101
+ # @see https://github.com/jnunemaker/httparty
102
+ def set_httparty_config(options)
103
+ if self.httparty
104
+ options.merge!(self.httparty)
105
+ end
106
+ end
107
+
96
108
  def error_message(response)
97
109
  "Server responded with code #{response.code}, message: #{response.parsed_response.message}. " \
98
110
  "Request URI: #{response.request.base_uri}#{response.request.path}"
@@ -1,12 +1,16 @@
1
1
  require 'gitlab'
2
2
  require 'gitlab/help'
3
3
  require 'gitlab/cli_helpers'
4
+ require 'gitlab/shell_history'
4
5
  require 'readline'
6
+ require 'shellwords'
5
7
 
6
8
  class Gitlab::Shell
7
9
  extend Gitlab::CLI::Helpers
8
10
 
11
+ # Start gitlab shell and run infinite loop waiting for user input
9
12
  def self.start
13
+ history.load
10
14
  actions = Gitlab.actions
11
15
 
12
16
  comp = proc { |s| actions.map(&:to_s).grep(/^#{Regexp.escape(s)}/) }
@@ -16,9 +20,21 @@ class Gitlab::Shell
16
20
 
17
21
  client = Gitlab::Client.new(endpoint: '')
18
22
 
19
- while buf = Readline.readline("gitlab> ", true)
23
+ while buf = Readline.readline('gitlab> ')
24
+ trap('INT') { quit_shell } # capture ctrl-c
25
+
20
26
  next if buf.nil? || buf.empty?
21
- buf = buf.split.map(&:chomp)
27
+ quit_shell if buf == 'exit'
28
+
29
+ history << buf
30
+
31
+ begin
32
+ buf = Shellwords.shellwords(buf)
33
+ rescue ArgumentError => e
34
+ puts e.message
35
+ next
36
+ end
37
+
22
38
  cmd = buf.shift
23
39
  args = buf.count > 0 ? buf : []
24
40
 
@@ -32,18 +48,40 @@ class Gitlab::Shell
32
48
  }
33
49
  end
34
50
 
35
- args[0].nil? ? Gitlab::Help.get_help(methods) : Gitlab::Help.get_help(methods, args[0])
51
+ args[0].nil? ? Gitlab::Help.get_help(methods) :
52
+ Gitlab::Help.get_help(methods, args[0])
36
53
  next
37
54
  end
38
55
 
56
+ syntax_errors = false
57
+
58
+ begin
59
+ yaml_load_and_symbolize_hash!(args)
60
+ rescue
61
+ syntax_errors = true
62
+ end
63
+
64
+ # errors have been displayed, return to the prompt
65
+ next if syntax_errors
66
+
39
67
  data = if actions.include?(cmd.to_sym)
40
68
  confirm_command(cmd)
41
69
  gitlab_helper(cmd, args)
42
70
  else
43
- "'#{cmd}' is not a valid command. See the 'help' for a list of valid commands."
71
+ "'#{cmd}' is not a valid command. " +
72
+ "See the 'help' for a list of valid commands."
44
73
  end
45
74
 
46
75
  output_table(cmd, args, data)
47
76
  end
48
77
  end
78
+
79
+ def self.quit_shell
80
+ history.save
81
+ exit
82
+ end
83
+
84
+ def self.history
85
+ @history ||= History.new
86
+ end
49
87
  end
@@ -0,0 +1,61 @@
1
+ class Gitlab::Shell
2
+ class History
3
+ DEFAULT_HISTFILESIZE = 200
4
+ DEFAULT_FILE_PATH = File.join(Dir.home, '.gitlab_shell_history')
5
+
6
+ def initialize(options = {})
7
+ @file_path = options[:file_path] || DEFAULT_FILE_PATH
8
+ Readline::HISTORY.clear
9
+ end
10
+
11
+ def load
12
+ read_from_file { |line| Readline::HISTORY << line.chomp }
13
+ end
14
+
15
+ def save
16
+ lines.each { |line| history_file.puts line if history_file }
17
+ end
18
+
19
+ def push(line)
20
+ Readline::HISTORY << line
21
+ end
22
+ alias_method :<<, :push
23
+
24
+ def lines
25
+ Readline::HISTORY.to_a.last(max_lines)
26
+ end
27
+
28
+ private
29
+
30
+ def history_file
31
+ if defined?(@history_file)
32
+ @history_file
33
+ else
34
+ @history_file = File.open(history_file_path, 'w', 0600).tap do |file|
35
+ file.sync = true
36
+ end
37
+ end
38
+ rescue Errno::EACCES
39
+ warn 'History not saved; unable to open your history file for writing.'
40
+ @history_file = false
41
+ end
42
+
43
+ def history_file_path
44
+ File.expand_path(@file_path)
45
+ end
46
+
47
+ def read_from_file
48
+ path = history_file_path
49
+
50
+ if File.exist?(path)
51
+ File.foreach(path) { |line| yield(line) }
52
+ end
53
+ rescue => error
54
+ warn "History file not loaded: #{error.message}"
55
+ end
56
+
57
+ def max_lines
58
+ (ENV['GITLAB_HISTFILESIZE']|| DEFAULT_HISTFILESIZE).to_i
59
+ end
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  module Gitlab
2
- VERSION = "3.2.0"
2
+ VERSION = "3.3.0"
3
3
  end
@@ -0,0 +1,31 @@
1
+
2
+ {
3
+ "commit": {
4
+ "id": "12d65c8dd2b2676fa3ac47d955accc085a37a9c1",
5
+ "short_id": "12d65c8dd2b",
6
+ "title": "JS fix",
7
+ "author_name": "Dmitriy Zaporozhets",
8
+ "author_email": "dmitriy.zaporozhets@gmail.com",
9
+ "created_at": "2014-02-27T10:27:00+02:00"
10
+ },
11
+ "commits": [{
12
+ "id": "12d65c8dd2b2676fa3ac47d955accc085a37a9c1",
13
+ "short_id": "12d65c8dd2b",
14
+ "title": "JS fix",
15
+ "author_name": "Dmitriy Zaporozhets",
16
+ "author_email": "dmitriy.zaporozhets@gmail.com",
17
+ "created_at": "2014-02-27T10:27:00+02:00"
18
+ }],
19
+ "diffs": [{
20
+ "old_path": "files/js/application.js",
21
+ "new_path": "files/js/application.js",
22
+ "a_mode": null,
23
+ "b_mode": "100644",
24
+ "diff": "--- a/files/js/application.js\n+++ b/files/js/application.js\n@@ -24,8 +24,10 @@\n //= require g.raphael-min\n //= require g.bar-min\n //= require branch-graph\n-//= require highlightjs.min\n-//= require ace/ace\n //= require_tree .\n //= require d3\n //= require underscore\n+\n+function fix() { \n+ alert(\"Fixed\")\n+}",
25
+ "new_file": false,
26
+ "renamed_file": false,
27
+ "deleted_file": false
28
+ }],
29
+ "compare_timeout": false,
30
+ "compare_same_ref": false
31
+ }
@@ -0,0 +1 @@
1
+ {"name": "Backlog", "color": "#DD10AA"}
@@ -0,0 +1 @@
1
+ [{"name": "Backlog", "color": "#DD10AA"},{"name": "Documentation", "color": "#1E80DD"}]
@@ -0,0 +1 @@
1
+ {"note":"Nice code!","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
+ [{"note":"this is the 1st comment on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6","author":{"id":11,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}},{"note":"another discussion point on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6","author":{"id":12,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}}]
@@ -0,0 +1 @@
1
+ {"name": "v1.1.0","message": "Release 1.1.0","commit": {"id": "2695effb5807a22ff3d138d593fd856244e155e7","parents": [],"message": "Initial commit","authored_date": "2012-05-28T04:42:42-07:00","author_name": "John Smith","author email": "john@example.com","committer_name": "Jack Smith","committed_date": "2012-05-28T04:42:42-07:00","committer_email": "jack@example.com"}}
@@ -0,0 +1 @@
1
+ {"name": "v1.0.0","message": null,"commit": {"id": "2695effb5807a22ff3d138d593fd856244e155e7","parents": [],"message": "Initial commit","authored_date": "2012-05-28T04:42:42-07:00","author_name": "John Smith","author email": "john@example.com","committer_name": "Jack Smith","committed_date": "2012-05-28T04:42:42-07:00","committer_email": "jack@example.com"}}
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rails', '4.1.2'
@@ -0,0 +1,2 @@
1
+ party on, dudes
2
+ be excellent to each other
@@ -0,0 +1 @@
1
+ [{"id":"a2cc3b0ffc1c7d06fab5642eb99ea387b57f22f8","name":"app","type":"tree","mode":"040000"},{"id":"63164bdfbc11b69f1032fbe35da0f1e9c18af2fd","name":"bin","type":"tree","mode":"040000"},{"id":"2cf682191722f20f00a371d7da58f6a35701c11d","name":"config","type":"tree","mode":"040000"},{"id":"2e76c8c1bbc46bcc762788a432d802d65a534a28","name":"db","type":"tree","mode":"040000"},{"id":"767cfc8360b50c50bb5bdde288b96a84e3efa66e","name":"doc","type":"tree","mode":"040000"},{"id":"3fa0d1024f5e372bf9e43d1dac47bd1e95ab0858","name":"lib","type":"tree","mode":"040000"},{"id":"4e79d0ac6225844602a1b9273b26d8996f777bf2","name":"log","type":"tree","mode":"040000"},{"id":"7cb7f593c6914d20fa6cc4ab5a7c34337a50e97c","name":"public","type":"tree","mode":"040000"},{"id":"d97169eef778f3cd1d4d94cbe3415b3166d15c71","name":"spec","type":"tree","mode":"040000"},{"id":"97c97da29fa97e2158cfdcdcb042af9da0bc3de4","name":"vendor","type":"tree","mode":"040000"},{"id":"d316760e4746059c117007507594a1d75b47df38","name":".gitignore","type":"blob","mode":"100644"},{"id":"f2e7cd477536f18d8e939faf452930b59a27063d","name":".travis.yml","type":"blob","mode":"100644"},{"id":"d5c68bda5f0fe703a80906f66cfe537ca807a5a6","name":"Capfile","type":"blob","mode":"100644"},{"id":"8f46eac03c6cd7ce03cda7ec3d78afdc6971e4c0","name":"Gemfile","type":"blob","mode":"100644"},{"id":"5e260573173b51eaa073661d7914fb0e935ee27f","name":"Gemfile.lock","type":"blob","mode":"100644"},{"id":"e57032f682b69f14243c09d66a0892a03b4c6045","name":"Procfile","type":"blob","mode":"100644"},{"id":"905e96da839dad683dfcf4e202bf1e030390b964","name":"README.md","type":"blob","mode":"100644"},{"id":"24a16769fd94926350a59f7b1cbd78e9e2674c57","name":"Rakefile","type":"blob","mode":"100644"},{"id":"b384d6d57c6a775a9b6bc35d79ad7f03e673a233","name":"config.ru","type":"blob","mode":"100644"}]
@@ -39,7 +39,7 @@ describe Gitlab::Client do
39
39
 
40
40
  describe ".protect_branch" do
41
41
  before do
42
- stub_put("/projects/3/repository/branches/api/protect", "protect_branch")
42
+ stub_put("/projects/3/repository/branches/api/protect", "branch")
43
43
  @branch = Gitlab.protect_branch(3, "api")
44
44
  end
45
45
 
@@ -49,13 +49,12 @@ describe Gitlab::Client do
49
49
 
50
50
  it "should return information about a protected repository branch" do
51
51
  expect(@branch.name).to eq("api")
52
- expect(@branch.protected).to eq(true)
53
52
  end
54
53
  end
55
54
 
56
55
  describe ".unprotect_branch" do
57
56
  before do
58
- stub_put("/projects/3/repository/branches/api/unprotect", "unprotect_branch")
57
+ stub_put("/projects/3/repository/branches/api/unprotect", "branch")
59
58
  @branch = Gitlab.unprotect_branch(3, "api")
60
59
  end
61
60
 
@@ -65,39 +64,21 @@ describe Gitlab::Client do
65
64
 
66
65
  it "should return information about an unprotected repository branch" do
67
66
  expect(@branch.name).to eq("api")
68
- expect(@branch.protected).to eq(false)
69
67
  end
70
68
  end
71
69
 
72
70
  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
71
+ before do
72
+ stub_post("/projects/3/repository/branches", "branch")
73
+ @branch = Gitlab.create_branch(3, "api", "master")
86
74
  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
75
+
76
+ it "should get the correct resource" do
77
+ expect(a_post("/projects/3/repository/branches")).to have_been_made
100
78
  end
101
- end
102
79
 
80
+ it "should return information about a new repository branch" do
81
+ expect(@branch.name).to eq("api")
82
+ end
83
+ end
103
84
  end