New upstream version 4.8.0
Utkarsh Gupta
5 years ago
0 | # Number of days of inactivity before an issue becomes stale | |
1 | daysUntilStale: 90 | |
2 | # Number of days of inactivity before a stale issue is closed | |
3 | daysUntilClose: 10 | |
4 | # Issues with these labels will never be considered stale | |
5 | exemptLabels: | |
6 | - pinned | |
7 | - security | |
8 | - contribution welcome | |
9 | # Label to use when marking an issue as stale | |
10 | staleLabel: stale | |
11 | # Comment to post when marking an issue as stale. Set to `false` to disable | |
12 | markComment: > | |
13 | This issue has been automatically marked as stale because it has not had | |
14 | recent activity. It will be closed if no further activity occurs. Thank you | |
15 | for your contributions. | |
16 | # Comment to post when closing a stale issue. Set to `false` to disable | |
17 | closeComment: false |
0 | Layout/SpaceAroundEqualsInParameterDefault: | |
1 | Enabled: false | |
0 | --- | |
1 | inherit_from: .rubocop_todo.yml | |
2 | 2 | |
3 | Style/Alias: | |
4 | Enabled: false | |
5 | ||
6 | Style/PercentLiteralDelimiters: | |
7 | Enabled: false | |
8 | ||
9 | Layout/DotPosition: | |
10 | Enabled: false | |
3 | AllCops: | |
4 | TargetRubyVersion: 2.3 | |
11 | 5 | |
12 | 6 | Metrics/LineLength: |
13 | Max: 100 | |
7 | Max: 125 | |
14 | 8 | Exclude: |
15 | 9 | - 'lib/gitlab/client/*' |
16 | - 'spec/**/*' | |
17 | ||
18 | Style/ClassAndModuleChildren: | |
19 | Exclude: | |
20 | - 'lib/gitlab/client/*' | |
21 | ||
22 | Layout/SpaceInsideHashLiteralBraces: | |
23 | Exclude: | |
24 | - 'lib/gitlab/client/*' | |
25 | ||
26 | Style/StringLiterals: | |
27 | Exclude: | |
28 | 10 | - 'spec/**/*' |
29 | 11 | |
30 | 12 | Metrics/BlockLength: |
31 | 13 | Exclude: |
32 | 14 | - 'spec/**/*' |
15 | ||
16 | Style/Documentation: | |
17 | Enabled: false | |
18 | ||
19 | Style/ClassAndModuleChildren: | |
20 | Exclude: | |
21 | - 'lib/gitlab/*' | |
22 | - 'lib/gitlab/client/*' | |
23 | ||
24 | Style/FrozenStringLiteralComment: | |
25 | Exclude: | |
26 | - 'spec/gitlab/file_response_spec.rb' | |
27 | - 'spec/gitlab/help_spec.rb' | |
28 | ||
29 | Style/SpecialGlobalVars: | |
30 | Exclude: | |
31 | - 'gitlab.gemspec' |
0 | # This configuration was generated by | |
1 | # `rubocop --auto-gen-config` | |
2 | # on 2018-10-10 10:25:27 +0400 using RuboCop version 0.59.2. | |
3 | # The point is for the user to remove these configuration records | |
4 | # one by one as the offenses are removed from the code base. | |
5 | # Note that changes in the inspected code, or installation of new | |
6 | # versions of RuboCop, may require this file to be generated again. | |
7 | ||
8 | # Offense count: 1 | |
9 | Lint/UriEscapeUnescape: | |
10 | Exclude: | |
11 | - 'lib/gitlab/client.rb' | |
12 | ||
13 | # Offense count: 5 | |
14 | Metrics/AbcSize: | |
15 | Max: 34 | |
16 | ||
17 | # Offense count: 4 | |
18 | Metrics/CyclomaticComplexity: | |
19 | Max: 14 | |
20 | ||
21 | # Offense count: 10 | |
22 | # Configuration parameters: CountComments, ExcludedMethods. | |
23 | Metrics/MethodLength: | |
24 | Max: 34 | |
25 | ||
26 | # Offense count: 2 | |
27 | # Configuration parameters: CountComments. | |
28 | Metrics/ModuleLength: | |
29 | Max: 165 | |
30 | ||
31 | # Offense count: 2 | |
32 | # Configuration parameters: CountKeywordArgs. | |
33 | Metrics/ParameterLists: | |
34 | Max: 6 | |
35 | ||
36 | # Offense count: 1 | |
37 | Metrics/PerceivedComplexity: | |
38 | Max: 10 | |
39 | ||
40 | # Offense count: 1 | |
41 | # Cop supports --auto-correct. | |
42 | # Configuration parameters: AutoCorrect. | |
43 | Security/JSONLoad: | |
44 | Exclude: | |
45 | - 'lib/gitlab/request.rb' |
0 | --- | |
0 | 1 | language: ruby |
1 | 2 | rvm: |
2 | 3 | - 2.3 |
3 | 4 | - 2.4 |
4 | 5 | - 2.5 |
5 | before_install: gem update bundler | |
6 | - 2.6 | |
6 | 7 | |
7 | matrix: | |
8 | jobs: | |
8 | 9 | include: |
9 | - rvm: 2.4 | |
10 | env: "TRAVIS_CI_RUBOCOP=true" | |
11 | allow_failures: | |
12 | - env: "TRAVIS_CI_RUBOCOP=true" | |
10 | - stage: lint | |
11 | rvm: 2.3 | |
12 | script: bundle exec rake rubocop |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | source 'https://rubygems.org' |
1 | 3 | |
2 | 4 | # Specify your gem's dependencies in gitlab.gemspec |
0 | Copyright (c) 2012-2015 Nihad Abbasov <mail@narkoz.me> | |
0 | Copyright (c) 2012-2019 Nihad Abbasov <nihad@42na.in> | |
1 | 1 | All rights reserved. |
2 | 2 | |
3 | 3 | Redistribution and use in source and binary forms, with or without |
0 | 0 | # Gitlab |
1 | 1 | |
2 | 2 | [![Build Status](https://img.shields.io/travis/NARKOZ/gitlab.svg)](https://travis-ci.org/NARKOZ/gitlab) |
3 | [![Code Climate](https://img.shields.io/codeclimate/maintainability/NARKOZ/gitlab.svg)](https://codeclimate.com/github/NARKOZ/gitlab) | |
4 | [![Inline docs](http://inch-ci.org/github/NARKOZ/gitlab.svg)](https://inch-ci.org/github/NARKOZ/gitlab) | |
3 | [![Maintainability](https://api.codeclimate.com/v1/badges/2e310b334b1b5db4a7e1/maintainability)](https://codeclimate.com/github/NARKOZ/gitlab) | |
4 | [![Inline docs](https://inch-ci.org/github/NARKOZ/gitlab.svg)](https://inch-ci.org/github/NARKOZ/gitlab) | |
5 | 5 | [![Gem version](https://img.shields.io/gem/v/gitlab.svg)](https://rubygems.org/gems/gitlab) |
6 | 6 | [![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/NARKOZ/gitlab/blob/master/LICENSE.txt) |
7 | 7 | |
8 | [website](http://narkoz.github.io/gitlab) | | |
9 | [documentation](http://rubydoc.info/gems/gitlab/frames) | | |
8 | [website](https://narkoz.github.io/gitlab) | | |
9 | [documentation](https://rubydoc.info/gems/gitlab/frames) | | |
10 | 10 | [gitlab-live](https://github.com/NARKOZ/gitlab-live) |
11 | 11 | |
12 | 12 | Gitlab is a Ruby wrapper and CLI for the [GitLab API](https://docs.gitlab.com/ce/api/README.html). |
13 | As of version `4.0.0` this gem only supports Ruby 2.0+ and Gitlab API v4. | |
13 | As of version `4.0.0` this gem only supports Ruby 2.0+ and GitLab API v4. | |
14 | 14 | |
15 | 15 | ## Installation |
16 | 16 | |
53 | 53 | |
54 | 54 | ```ruby |
55 | 55 | # set an API endpoint |
56 | Gitlab.endpoint = 'http://example.net/api/v4' | |
57 | # => "http://example.net/api/v4" | |
56 | Gitlab.endpoint = 'https://example.net/api/v4' | |
57 | # => "https://example.net/api/v4" | |
58 | 58 | |
59 | 59 | # set a user private token |
60 | 60 | Gitlab.private_token = 'qEsq1pt6HJPaNciie3MG' |
62 | 62 | |
63 | 63 | # configure a proxy server |
64 | 64 | Gitlab.http_proxy('proxyhost', 8888) |
65 | # proxy server w/ basic auth | |
65 | # proxy server with basic auth | |
66 | 66 | Gitlab.http_proxy('proxyhost', 8888, 'proxyuser', 'strongpasswordhere') |
67 | # set timeout for responses | |
68 | ENV['GITLAB_API_HTTPARTY_OPTIONS'] = '{read_timeout: 60}' | |
67 | 69 | |
68 | 70 | # list projects |
69 | 71 | Gitlab.projects(per_page: 5) |
107 | 109 | projects.auto_paginate |
108 | 110 | ``` |
109 | 111 | |
110 | For more information, refer to [documentation](http://rubydoc.info/gems/gitlab/frames). | |
112 | For more information, refer to [documentation](https://rubydoc.info/gems/gitlab/frames). | |
111 | 113 | |
112 | 114 | ## CLI |
113 | 115 | |
114 | It is possible to use this gem as a command line interface to gitlab. In order to make that work you need to set a few environment variables: | |
116 | It is possible to use this gem as a command line interface to GitLab. In order to make that work you need to set a few environment variables: | |
115 | 117 | ```sh |
116 | 118 | export GITLAB_API_ENDPOINT=https://gitlab.yourcompany.com/api/v4 |
117 | 119 | export GITLAB_API_PRIVATE_TOKEN=<your private token from /profile/account> |
123 | 125 | |
124 | 126 | Usage: |
125 | 127 | |
126 | When you want to know which CLI commands are supported, take a look at the client [commands implemented in this gem](http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client). Any of those methods can be called as a command by passing the parameters of the commands as parameters of the CLI. | |
128 | When you want to know which CLI commands are supported, take a look at the client [commands implemented in this gem](https://www.rubydoc.info/gems/gitlab/4.5.0/Gitlab/Client). Any of those methods can be called as a command by passing the parameters of the commands as parameters of the CLI. | |
127 | 129 | |
128 | 130 | Usage examples: |
129 | 131 | |
130 | 132 | ```sh |
131 | 133 | # list users |
132 | # see: http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client/Users#users-instance_method | |
134 | # see: https://www.rubydoc.info/gems/gitlab/4.5.0/Gitlab/Client/Users#users-instance_method | |
133 | 135 | gitlab users |
134 | 136 | |
135 | 137 | # get current user |
136 | # see: http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client/Users#user-instance_method | |
138 | # see: https://www.rubydoc.info/gems/gitlab/4.5.0/Gitlab/Client/Users#user-instance_method | |
137 | 139 | gitlab user |
138 | 140 | |
139 | 141 | # get a user |
140 | # see: http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client/Users#user-instance_method | |
142 | # see: https://www.rubydoc.info/gems/gitlab/4.5.0/Gitlab/Client/Users#user-instance_method | |
141 | 143 | gitlab user 2 |
142 | 144 | |
143 | 145 | # filter output |
149 | 151 | gitlab user 2 --json |
150 | 152 | |
151 | 153 | # passing options hash to a command (use YAML) |
152 | # see: http://www.rubydoc.info/gems/gitlab/3.4.0/Gitlab/Client/MergeRequests#create_merge_request-instance_method | |
154 | # see: https://www.rubydoc.info/gems/gitlab/4.5.0/Gitlab/Client/MergeRequests#create_merge_request-instance_method | |
153 | 155 | gitlab create_merge_request 4 "New merge request" "{source_branch: 'new_branch', target_branch: 'master', assignee_id: 42}" |
154 | 156 | |
155 | 157 | ``` |
176 | 178 | ``` |
177 | 179 | |
178 | 180 | Web version is available at https://gitlab-live.herokuapp.com |
179 | For more information, refer to [website](http://narkoz.github.io/gitlab). | |
181 | For more information, refer to [website](https://narkoz.github.io/gitlab). | |
180 | 182 | |
181 | 183 | ## Development |
182 | 184 | |
183 | ### With a dockerized Gitlab instance | |
184 | ||
185 | ```shell | |
186 | docker-compose up -d gitlab # Will start the gitlab instance in the background (approx. 3 minutes) | |
187 | ``` | |
188 | ||
189 | After a while, your Gitlab instance will be accessible on http://localhost:3000. | |
185 | ### With a dockerized GitLab instance | |
186 | ||
187 | ```shell | |
188 | docker-compose up -d gitlab # Will start the GitLab instance in the background (approx. 3 minutes) | |
189 | ``` | |
190 | ||
191 | After a while, your GitLab instance will be accessible on http://localhost:3000. | |
190 | 192 | |
191 | 193 | Once you have set your new root password, you can login with the root user. |
192 | 194 | |
205 | 207 | => [#<Gitlab::ObjectifiedHash:47231290771040 {hash: {"id"=>1, "name"=>"Administrator", "username"=>"root", ...] |
206 | 208 | ``` |
207 | 209 | |
208 | To launch the specs, | |
210 | To launch the specs: | |
209 | 211 | |
210 | 212 | ```shell |
211 | 213 | docker-compose run app rake spec |
212 | 214 | ``` |
213 | 215 | |
214 | #### Want to use Gitlab Enterprise? | |
216 | #### Want to use GitLab Enterprise? | |
215 | 217 | |
216 | 218 | Just change the image from `gitlab/gitlab-ce:latest` to `gitlab/gitlab-ee:latest` in the `docker-compose.yml` file. |
217 | 219 | |
218 | ### With an external Gitlab instance | |
220 | ### With an external GitLab instance | |
219 | 221 | |
220 | 222 | First, set the variables to the correct values in the `docker.env` file. |
221 | 223 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'bundler/gem_tasks' |
1 | 3 | |
2 | 4 | require 'rspec/core/rake_task' |
9 | 11 | task.options = ['-D', '--parallel'] |
10 | 12 | end |
11 | 13 | |
12 | if ENV['TRAVIS_CI_RUBOCOP'] | |
13 | task default: :rubocop | |
14 | else | |
15 | task default: :spec | |
16 | end | |
14 | task default: :spec |
0 | 0 | #!/usr/bin/env ruby |
1 | # frozen_string_literal: true | |
1 | 2 | |
2 | 3 | # ENV['GITLAB_API_ENDPOINT'] = '' |
3 | 4 | # ENV['GITLAB_API_PRIVATE_TOKEN'] = '' |
0 | 0 | #!/usr/bin/env ruby |
1 | # frozen_string_literal: true | |
1 | 2 | |
2 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) | |
3 | $LOAD_PATH.unshift File.expand_path('../lib', __dir__) | |
4 | ||
5 | # Exit cleanly from an early interrupt | |
6 | Signal.trap('INT') { exit 1 } | |
3 | 7 | |
4 | 8 | require 'gitlab/cli' |
5 | 9 |
0 | lib = File.expand_path('../lib', __FILE__) | |
0 | # frozen_string_literal: true | |
1 | ||
2 | lib = File.expand_path('lib', __dir__) | |
1 | 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) |
2 | 4 | require 'gitlab/version' |
3 | 5 | |
10 | 12 | gem.summary = 'A Ruby wrapper and CLI for the GitLab API' |
11 | 13 | gem.homepage = 'https://github.com/narkoz/gitlab' |
12 | 14 | |
13 | gem.files = `git ls-files`.split($/). | |
14 | reject { |f| f[/^spec/] } - | |
15 | %w[Dockerfile docker-compose.yml docker.env .travis.yml .rubocop.yml .dockerignore] | |
15 | gem.files = `git ls-files`.split($/) | |
16 | .grep_v(/^spec/) - | |
17 | %w[Dockerfile docker-compose.yml docker.env .travis.yml | |
18 | .rubocop.yml .dockerignore] | |
16 | 19 | gem.bindir = 'exe' |
17 | 20 | gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) } |
18 | 21 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) |
19 | 22 | gem.require_paths = ['lib'] |
20 | 23 | gem.license = 'BSD' |
21 | 24 | |
22 | gem.required_ruby_version = '>= 2.0.0' | |
25 | gem.required_ruby_version = '>= 2.3' | |
23 | 26 | |
24 | 27 | gem.add_runtime_dependency 'httparty', '>= 0.14.0' |
25 | 28 | gem.add_runtime_dependency 'terminal-table', '>= 1.5.1' |
27 | 30 | gem.add_development_dependency 'pry' |
28 | 31 | gem.add_development_dependency 'rake' |
29 | 32 | gem.add_development_dependency 'rspec' |
33 | gem.add_development_dependency 'rubocop' | |
30 | 34 | gem.add_development_dependency 'webmock' |
31 | gem.add_development_dependency 'rubocop' | |
32 | 35 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | module Gitlab |
1 | 3 | # @private |
2 | 4 | class API < Request |
3 | 5 | # @private |
4 | 6 | attr_accessor(*Configuration::VALID_OPTIONS_KEYS) |
5 | 7 | # @private |
6 | alias_method :auth_token=, :private_token= | |
8 | alias auth_token= private_token= | |
7 | 9 | |
8 | 10 | # Creates a new API. |
9 | 11 | # @raise [Error:MissingCredentials] |
10 | def initialize(options={}) | |
12 | def initialize(options = {}) | |
11 | 13 | options = Gitlab.options.merge(options) |
12 | 14 | (Configuration::VALID_OPTIONS_KEYS + [:auth_token]).each do |key| |
13 | 15 | send("#{key}=", options[key]) if options[key] |
14 | 16 | end |
15 | request_defaults(@sudo) | |
17 | request_defaults(sudo) | |
16 | 18 | self.class.headers 'User-Agent' => user_agent |
17 | 19 | end |
18 | 20 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'gitlab' |
1 | 3 | require 'terminal-table/import' |
2 | 4 | require_relative 'cli_helpers' |
16 | 18 | # |
17 | 19 | # @param [Array] args The command and it's optional arguments. |
18 | 20 | def self.start(args) |
19 | command = args.shift.strip rescue 'help' | |
21 | command = begin | |
22 | args.shift.strip | |
23 | rescue StandardError | |
24 | 'help' | |
25 | end | |
20 | 26 | run(command, args) |
21 | 27 | end |
22 | 28 | |
29 | 35 | # @param [String] cmd The name of a command. |
30 | 36 | # @param [Array] args The optional arguments for a command. |
31 | 37 | # @return [nil] |
32 | def self.run(cmd, args=[]) | |
38 | def self.run(cmd, args = []) | |
33 | 39 | case cmd |
34 | 40 | when 'help' |
35 | 41 | puts help(args.shift) { |out| out.gsub!(/Gitlab\./, 'gitlab ') } |
36 | 42 | when 'info' |
37 | endpoint = Gitlab.endpoint ? Gitlab.endpoint : 'not set' | |
38 | private_token = Gitlab.private_token ? Gitlab.private_token : 'not set' | |
43 | endpoint = Gitlab.endpoint || 'not set' | |
44 | private_token = Gitlab.private_token || 'not set' | |
39 | 45 | puts "Gitlab endpoint is #{endpoint}" |
40 | 46 | puts "Gitlab private token is #{private_token}" |
41 | 47 | puts "Ruby Version is #{RUBY_VERSION}" |
59 | 65 | |
60 | 66 | begin |
61 | 67 | command_args.map! { |arg| symbolize_keys(yaml_load(arg)) } |
62 | rescue => e | |
68 | rescue StandardError => e | |
63 | 69 | puts e.message |
64 | 70 | exit 1 |
65 | 71 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'yaml' |
1 | 3 | require 'json' |
2 | 4 | require 'base64' |
4 | 6 | class Gitlab::CLI |
5 | 7 | # Defines methods related to CLI output and formatting. |
6 | 8 | module Helpers |
7 | extend self | |
9 | module_function | |
8 | 10 | |
9 | 11 | # Returns actions available to CLI & Shell |
10 | 12 | # |
70 | 72 | |
71 | 73 | puts 'Are you sure? (y/n)' |
72 | 74 | |
73 | if %w(y yes).include?($stdin.gets.to_s.strip.downcase) | |
75 | if %w[y yes].include?($stdin.gets.to_s.strip.downcase) | |
74 | 76 | puts 'Proceeding..' |
75 | 77 | else |
76 | 78 | puts 'Command aborted.' |
81 | 83 | # Gets defined help for a specific command/action. |
82 | 84 | # |
83 | 85 | # @return [String] |
84 | def help(cmd=nil, &block) | |
86 | def help(cmd = nil, &block) | |
85 | 87 | if cmd.nil? || Gitlab::Help.help_map.key?(cmd) |
86 | 88 | Gitlab::Help.actions_table(cmd) |
87 | 89 | else |
89 | 91 | end |
90 | 92 | end |
91 | 93 | |
92 | # Outputs a nicely formatted table or error msg. | |
94 | # Outputs a nicely formatted table or error message. | |
93 | 95 | def output_table(cmd, args, data) |
94 | 96 | case data |
95 | 97 | when Gitlab::ObjectifiedHash, Gitlab::FileResponse |
96 | 98 | puts record_table([data], cmd, args) |
97 | 99 | when Gitlab::PaginatedResponse |
98 | 100 | puts record_table(data, cmd, args) |
99 | else # probably just an error msg | |
101 | else # probably just an error message | |
100 | 102 | puts data |
101 | 103 | end |
102 | 104 | end |
158 | 160 | # @param [Array] args Options passed to the API call |
159 | 161 | # @param [bool] single_value If set to true, a single result should be returned |
160 | 162 | # @return [Hash] Result hash |
161 | def record_hash(data, cmd, args, single_value=false) | |
163 | def record_hash(data, cmd, args, single_value = false) | |
162 | 164 | if data.empty? |
163 | 165 | result = nil |
164 | 166 | else |
168 | 170 | row = {} |
169 | 171 | |
170 | 172 | keys.each do |key| |
171 | case hash[key] | |
172 | when Hash | |
173 | row[key] = 'Hash' | |
174 | when StringIO | |
175 | row[key] = Base64.encode64(hash[key].read) | |
176 | when nil | |
177 | row[key] = nil | |
178 | else | |
179 | row[key] = hash[key] | |
180 | end | |
173 | row[key] = case hash[key] | |
174 | when Hash | |
175 | 'Hash' | |
176 | when StringIO | |
177 | Base64.encode64(hash[key].read) | |
178 | when nil | |
179 | nil | |
180 | else | |
181 | hash[key] | |
182 | end | |
181 | 183 | end |
182 | 184 | |
183 | 185 | result.push row |
184 | 186 | end |
185 | result = result[0] if single_value && result.count > 0 | |
187 | result = result[0] if single_value && result.count.positive? | |
186 | 188 | end |
187 | 189 | |
188 | 190 | { |
201 | 203 | end |
202 | 204 | |
203 | 205 | # Helper function to call Gitlab commands with args. |
204 | def gitlab_helper(cmd, args=[]) | |
206 | def gitlab_helper(cmd, args = []) | |
205 | 207 | begin |
206 | 208 | data = args.any? ? Gitlab.send(cmd, *args) : Gitlab.send(cmd) |
207 | rescue => e | |
209 | rescue StandardError => e | |
208 | 210 | puts e.message |
209 | 211 | yield if block_given? |
210 | 212 | end |
216 | 218 | # @return [Hash] |
217 | 219 | def symbolize_keys(hash) |
218 | 220 | if hash.is_a?(Hash) |
219 | hash = hash.each_with_object({}) do |(key, value), newhash| | |
221 | hash = hash.each_with_object({}) do |(key, value), new_hash| | |
220 | 222 | begin |
221 | newhash[key.to_sym] = symbolize_keys(value) | |
223 | new_hash[key.to_sym] = symbolize_keys(value) | |
222 | 224 | rescue NoMethodError |
223 | 225 | raise "Error: cannot convert hash key to symbol: #{key}" |
224 | 226 | end |
228 | 230 | hash |
229 | 231 | end |
230 | 232 | |
233 | # Check if arg is a color in 6-digit hex notation with leading '#' sign | |
234 | def hex_color?(arg) | |
235 | pattern = /\A#\h{6}\Z/ | |
236 | ||
237 | pattern.match(arg) | |
238 | end | |
239 | ||
231 | 240 | # YAML::load on a single argument |
232 | 241 | def yaml_load(arg) |
233 | YAML.safe_load(arg) | |
242 | hex_color?(arg) ? arg : YAML.safe_load(arg) | |
234 | 243 | rescue Psych::SyntaxError |
235 | 244 | raise "Error: Argument is not valid YAML syntax: #{arg}" |
236 | 245 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to Award Emojis. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/access_requests.html |
11 | 13 | def project_access_requests(project) |
12 | 14 | get("/projects/#{url_encode project}/access_requests") |
13 | 15 | end |
16 | ||
14 | 17 | # Gets a list of access requests for a group viewable by the authenticated user. |
15 | 18 | # |
16 | 19 | # @example |
21 | 24 | def group_access_requests(group) |
22 | 25 | get("/groups/#{url_encode group}/access_requests") |
23 | 26 | end |
27 | ||
24 | 28 | # Requests access for the authenticated user to a project. |
25 | 29 | # |
26 | 30 | # @example |
31 | 35 | def request_project_access(project) |
32 | 36 | post("/projects/#{url_encode project}/access_requests") |
33 | 37 | end |
38 | ||
34 | 39 | # Requests access for the authenticated user to a group. |
35 | 40 | # |
36 | 41 | # @example |
41 | 46 | def request_group_access(group) |
42 | 47 | post("/groups/#{url_encode group}/access_requests") |
43 | 48 | end |
49 | ||
44 | 50 | # Approves a project access request for the given user. |
45 | 51 | # |
46 | 52 | # @example |
54 | 60 | def approve_project_access_request(project, user_id, options = {}) |
55 | 61 | put("/projects/#{url_encode project}/access_requests/#{user_id}/approve", body: options) |
56 | 62 | end |
63 | ||
57 | 64 | # Approves a group access request for the given user. |
58 | 65 | # |
59 | 66 | # @example |
67 | 74 | def approve_group_access_request(group, user_id, options = {}) |
68 | 75 | put("/groups/#{url_encode group}/access_requests/#{user_id}/approve", body: options) |
69 | 76 | end |
77 | ||
70 | 78 | # Denies a project access request for the given user. |
71 | 79 | # |
72 | 80 | # @example |
78 | 86 | def deny_project_access_request(project, user_id) |
79 | 87 | delete("/projects/#{url_encode project}/access_requests/#{user_id}") |
80 | 88 | end |
89 | ||
81 | 90 | # Denies a group access request for the given user. |
82 | 91 | # |
83 | 92 | # @example |
90 | 99 | delete("/groups/#{url_encode group}/access_requests/#{user_id}") |
91 | 100 | end |
92 | 101 | end |
93 | end⏎ | |
102 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to Award Emojis. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/award_emoji.html |
78 | 80 | # @param [String] emoji_name The name of the emoji, without colons. |
79 | 81 | # @return [Gitlab::ObjectifiedHash] |
80 | 82 | def create_award_emoji(project, awardable_id, awardable_type, emoji_name) |
81 | post("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/award_emoji", body: {name: emoji_name}) | |
83 | post("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/award_emoji", body: { name: emoji_name }) | |
82 | 84 | end |
83 | 85 | |
84 | 86 | # Awards a new emoji to a note on an awardable(issue, merge request or snippet) |
95 | 97 | # @param [String] emoji_name The name of the emoji, without colons. |
96 | 98 | # @return [Gitlab::ObjectifiedHash] |
97 | 99 | def create_note_award_emoji(project, awardable_id, awardable_type, note_id, emoji_name) |
98 | post("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/notes/#{note_id}/award_emoji", body: {name: emoji_name}) | |
100 | post("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/notes/#{note_id}/award_emoji", body: { name: emoji_name }) | |
99 | 101 | end |
100 | 102 | |
101 | 103 | # Deletes a single award emoji from an awardable(issue, merge request or snippet) |
131 | 133 | delete("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/notes/#{note_id}/award_emoji/#{award_id}") |
132 | 134 | end |
133 | 135 | end |
134 | end⏎ | |
136 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to issue boards. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/boards.html |
12 | 14 | # @option options [Integer] :page The page number. |
13 | 15 | # @option options [Integer] :per_page The number of results per page. |
14 | 16 | # @return [Array<Gitlab::ObjectifiedHash>] |
15 | def boards(project, options={}) | |
17 | def boards(project, options = {}) | |
16 | 18 | get("/projects/#{url_encode project}/boards", query: options) |
17 | 19 | end |
18 | 20 | |
27 | 29 | def board_lists(project, id) |
28 | 30 | get("/projects/#{url_encode project}/boards/#{id}/lists") |
29 | 31 | end |
32 | ||
30 | 33 | # |
31 | 34 | # Gets a single board list |
32 | 35 | # |
52 | 55 | # @param [Integer] label_id The ID of a label. |
53 | 56 | # @return [Gitlab::ObjectifiedHash] Information about created list. |
54 | 57 | def create_board_list(project, board_id, label_id) |
55 | post("/projects/#{url_encode project}/boards/#{board_id}/lists", body: {label_id: label_id}) | |
58 | post("/projects/#{url_encode project}/boards/#{board_id}/lists", body: { label_id: label_id }) | |
56 | 59 | end |
57 | 60 | |
58 | 61 | # Updates a board list. |
66 | 69 | # @param [Integer] id The ID of a list. |
67 | 70 | # @return [Gitlab::ObjectifiedHash] Information about updated board list. |
68 | 71 | def edit_board_list(project, board_id, id, position) |
69 | put("/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}", body: {position: position}) | |
72 | put("/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}", body: { position: position }) | |
70 | 73 | end |
71 | 74 | |
72 | 75 | # Deletes a board list. |
84 | 87 | end |
85 | 88 | end |
86 | 89 | end |
87 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to repositories. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/branches.html |
11 | 13 | # @option options [Integer] :page The page number. |
12 | 14 | # @option options [Integer] :per_page The number of results per page. |
13 | 15 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | def branches(project, options={}) | |
16 | def branches(project, options = {}) | |
15 | 17 | get("/projects/#{url_encode project}/repository/branches", query: options) |
16 | 18 | end |
17 | alias_method :repo_branches, :branches | |
19 | alias repo_branches branches | |
18 | 20 | |
19 | 21 | # Gets information about a repository branch. |
20 | 22 | # |
28 | 30 | def branch(project, branch) |
29 | 31 | get("/projects/#{url_encode project}/repository/branches/#{url_encode branch}") |
30 | 32 | end |
31 | alias_method :repo_branch, :branch | |
33 | alias repo_branch branch | |
32 | 34 | |
33 | 35 | # Protects a repository branch. |
34 | 36 | # |
46 | 48 | # @option options [Boolean] :developers_can_merge True to allow developers to merge into the branch (default = false) |
47 | 49 | # @return [Gitlab::ObjectifiedHash] Details about the branch |
48 | 50 | def protect_branch(project, branch, options = {}) |
49 | post("/projects/#{url_encode project}/protected_branches", body: {name: branch}.merge(options)) | |
51 | post("/projects/#{url_encode project}/protected_branches", body: { name: branch }.merge(options)) | |
50 | 52 | end |
51 | alias_method :repo_protect_branch, :protect_branch | |
53 | alias repo_protect_branch protect_branch | |
52 | 54 | |
53 | 55 | # Unprotects a repository branch. |
54 | 56 | # |
62 | 64 | def unprotect_branch(project, branch) |
63 | 65 | delete("/projects/#{url_encode project}/protected_branches/#{url_encode branch}") |
64 | 66 | end |
65 | alias_method :repo_unprotect_branch, :unprotect_branch | |
67 | alias repo_unprotect_branch unprotect_branch | |
66 | 68 | |
67 | 69 | # Creates a repository branch. Requires Gitlab >= 6.8.x |
68 | 70 | # |
77 | 79 | def create_branch(project, branch, ref) |
78 | 80 | post("/projects/#{url_encode project}/repository/branches", query: { branch: branch, ref: ref }) |
79 | 81 | end |
80 | alias_method :repo_create_branch, :create_branch | |
82 | alias repo_create_branch create_branch | |
81 | 83 | |
82 | 84 | # Deletes a repository branch. Requires Gitlab >= 6.8.x |
83 | 85 | # |
90 | 92 | def delete_branch(project, branch) |
91 | 93 | delete("/projects/#{url_encode project}/repository/branches/#{url_encode branch}") |
92 | 94 | end |
93 | alias_method :repo_delete_branch, :delete_branch | |
95 | alias repo_delete_branch delete_branch | |
96 | ||
97 | # Delete all branches that are merged into the project default branch. Protected branches will not be deleted as part of this operation. | |
98 | # | |
99 | # @example | |
100 | # Gitlab.delete_merged_branches(3) | |
101 | # | |
102 | # @param [Integer, String] project The ID or name of a project. | |
103 | # @return [nil] This API call returns an empty response body. | |
104 | def delete_merged_branches(project) | |
105 | delete("/projects/#{url_encode project}/repository/merged_branches") | |
106 | end | |
107 | alias repo_delete_merged_branches delete_merged_branches | |
108 | ||
109 | # Gets a list of protected branches from a project. | |
110 | # | |
111 | # @example | |
112 | # Gitlab.protected_branches(42) | |
113 | # | |
114 | # @param [Integer, String] project The ID or name of a project. | |
115 | # @return [Array<Gitlab::ObjectifiedHash>] | |
116 | def protected_branches(project) | |
117 | get("/projects/#{url_encode project}/protected_branches") | |
118 | end | |
119 | alias repo_protected_branches protected_branches | |
120 | ||
121 | # Gets a single protected branch or wildcard protected branch | |
122 | # | |
123 | # @example | |
124 | # Gitlab.protected_branch(3, 'api') | |
125 | # | |
126 | # @param [Integer, String] project The ID or name of a project. | |
127 | # @param [String] name The name of the branch or wildcard | |
128 | # @return [Gitlab::ObjectifiedHash] | |
129 | def protected_branch(project, branch) | |
130 | get("/projects/#{url_encode project}/protected_branches/#{url_encode branch}") | |
131 | end | |
132 | alias repo_protected_branch protected_branch | |
94 | 133 | end |
95 | 134 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | class Gitlab::Client | |
3 | # Defines methods related to broadcast messages (only accessible to administrators). | |
4 | # @see https://docs.gitlab.com/ce/api/broadcast_messages.html | |
5 | module BroadcastMessages | |
6 | # Get all broadcast messages | |
7 | # | |
8 | # @example | |
9 | # Gitlab.broadcast_messages | |
10 | # | |
11 | # @return [Array<Gitlab::ObjectifiedHash>] | |
12 | def broadcast_messages | |
13 | get('/broadcast_messages') | |
14 | end | |
15 | ||
16 | # Get a specific broadcast message | |
17 | # | |
18 | # @example | |
19 | # Gitlab.broadcast_message(3) | |
20 | # | |
21 | # @param [Integer] id The ID of broadcast message | |
22 | # @return [Gitlab::ObjectifiedHash] | |
23 | def broadcast_message(id) | |
24 | get("/broadcast_messages/#{id}") | |
25 | end | |
26 | ||
27 | # Create a broadcast message. | |
28 | # | |
29 | # @example | |
30 | # Gitlab.create_broadcast_message('Mayday') | |
31 | # Gitlab.create_broadcast_message('Mayday', {starts_at: Time.zone.now, ends_at: Time.zone.now + 30.minutes, color: '#cecece', font: '#FFFFFF'}) | |
32 | # | |
33 | # @param [String] message Message to display | |
34 | # @param [Hash] options A customizable set of options. | |
35 | # @option options [DateTime] :starts_at(optional) Starting time (defaults to current time) | |
36 | # @option options [DateTime] :ends_at(optional) Ending time (defaults to one hour from current time) | |
37 | # @option options [String] :color(optional) Background color hex code | |
38 | # @option options [String] :font(optional) Foreground color hex code | |
39 | # @return [Gitlab::ObjectifiedHash] Information about created broadcast message. | |
40 | def create_broadcast_message(message, options = {}) | |
41 | body = { message: message }.merge(options) | |
42 | post('/broadcast_messages', body: body) | |
43 | end | |
44 | ||
45 | # Update a broadcast message | |
46 | # | |
47 | # @example | |
48 | # Gitlab.edit_broadcast_message(6, { message: 'No Mayday' }) | |
49 | # Gitlab.edit_broadcast_message(6, { font: '#FEFEFE' }) | |
50 | # | |
51 | # @param [Integer] id The ID of a broadcast message | |
52 | # @param [Hash] options A customizable set of options. | |
53 | # @option options [String] :message(optional) Message to display | |
54 | # @option options [DateTime] :starts_at(optional) Starting time (defaults to current time) | |
55 | # @option options [DateTime] :ends_at(optional) Ending time (defaults to one hour from current time) | |
56 | # @option options [String] :color(optional) Background color hex code | |
57 | # @option options [String] :font(optional) Foreground color hex code | |
58 | # @return [Gitlab::ObjectifiedHash] Information about updated broadcast message. | |
59 | def edit_broadcast_message(id, options = {}) | |
60 | put("/broadcast_messages/#{id}", body: options) | |
61 | end | |
62 | ||
63 | # Delete a broadcast message. | |
64 | # | |
65 | # @example | |
66 | # Gitlab.delete_broadcast_message(3) | |
67 | # | |
68 | # @param [Integer] id The ID of a broadcast message. | |
69 | # @return [nil] This API call returns an empty response body. | |
70 | def delete_broadcast_message(id) | |
71 | delete("/broadcast_messages/#{id}") | |
72 | end | |
73 | end | |
74 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to builds. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/build_variables.html |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to builds. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/builds.html |
13 | 15 | # @option options [Integer] :per_page The number of results per page. |
14 | 16 | # @param [Integer, String] project The ID or name of a project. |
15 | 17 | # @return [Array<Gitlab::ObjectifiedHash>] |
16 | def builds(project, options={}) | |
18 | def builds(project, options = {}) | |
17 | 19 | get("/projects/#{url_encode project}/builds", query: options) |
18 | 20 | end |
19 | 21 | |
39 | 41 | # @return [Gitlab::FileResponse] |
40 | 42 | def build_artifacts(project, id) |
41 | 43 | get("/projects/#{url_encode project}/builds/#{id}/artifacts", |
42 | format: nil, | |
43 | headers: { Accept: 'application/octet-stream' }, | |
44 | parser: proc { |body, _| | |
45 | if body.encoding == Encoding::ASCII_8BIT # binary response | |
46 | ::Gitlab::FileResponse.new StringIO.new(body, 'rb+') | |
47 | else # error with json response | |
48 | ::Gitlab::Request.parse(body) | |
49 | end | |
50 | }) | |
44 | format: nil, | |
45 | headers: { Accept: 'application/octet-stream' }, | |
46 | parser: proc { |body, _| | |
47 | if body.encoding == Encoding::ASCII_8BIT # binary response | |
48 | ::Gitlab::FileResponse.new StringIO.new(body, 'rb+') | |
49 | else # error with json response | |
50 | ::Gitlab::Request.parse(body) | |
51 | end | |
52 | }) | |
51 | 53 | end |
52 | 54 | |
53 | 55 | # Gets a list of builds for specific commit in a project. |
62 | 64 | # @option options [Integer] :page The page number. |
63 | 65 | # @option options [Integer] :per_page The number of results per page. |
64 | 66 | # @return [Array<Gitlab::ObjectifiedHash>] The list of builds. |
65 | def commit_builds(project, sha, options={}) | |
67 | def commit_builds(project, sha, options = {}) | |
66 | 68 | get("/projects/#{url_encode project}/repository/commits/#{sha}/builds", query: options) |
67 | 69 | end |
68 | 70 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to repository commits. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/commits.html |
13 | 15 | # @option options [Integer] :page The page number. |
14 | 16 | # @option options [Integer] :per_page The number of results per page. |
15 | 17 | # @return [Array<Gitlab::ObjectifiedHash>] |
16 | def commits(project, options={}) | |
18 | def commits(project, options = {}) | |
17 | 19 | get("/projects/#{url_encode project}/repository/commits", query: options) |
18 | 20 | end |
19 | alias_method :repo_commits, :commits | |
21 | alias repo_commits commits | |
20 | 22 | |
21 | 23 | # Gets a specific commit identified by the commit hash or name of a branch or tag. |
22 | 24 | # |
30 | 32 | def commit(project, sha) |
31 | 33 | get("/projects/#{url_encode project}/repository/commits/#{sha}") |
32 | 34 | end |
33 | alias_method :repo_commit, :commit | |
35 | alias repo_commit commit | |
36 | ||
37 | # Cherry picks a commit to a given branch. | |
38 | # | |
39 | # @example | |
40 | # Gitlab.cherry_pick_commit(42, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'master') | |
41 | # | |
42 | # @param [Integer, String] project The ID or name of a project. | |
43 | # @param [String] sha The commit hash or name of a repository branch or tag | |
44 | # @param [String] branch The name of the branch | |
45 | # @return [Gitlab::ObjectifiedHash] | |
46 | def cherry_pick_commit(project, sha, branch) | |
47 | post("/projects/#{url_encode project}/repository/commits/#{sha}/cherry_pick", body: { branch: branch }) | |
48 | end | |
34 | 49 | |
35 | 50 | # Get the diff of a commit in a project. |
36 | 51 | # |
44 | 59 | def commit_diff(project, sha) |
45 | 60 | get("/projects/#{url_encode project}/repository/commits/#{sha}/diff") |
46 | 61 | end |
47 | alias_method :repo_commit_diff, :commit_diff | |
62 | alias repo_commit_diff commit_diff | |
48 | 63 | |
49 | 64 | # Gets a list of comments for a commit. |
50 | 65 | # |
56 | 71 | # @option options [Integer] :page The page number. |
57 | 72 | # @option options [Integer] :per_page The number of results per page. |
58 | 73 | # @return [Array<Gitlab::ObjectifiedHash>] |
59 | def commit_comments(project, commit, options={}) | |
74 | def commit_comments(project, commit, options = {}) | |
60 | 75 | get("/projects/#{url_encode project}/repository/commits/#{commit}/comments", query: options) |
61 | 76 | end |
62 | alias_method :repo_commit_comments, :commit_comments | |
77 | alias repo_commit_comments commit_comments | |
63 | 78 | |
64 | 79 | # Creates a new comment for a commit. |
65 | 80 | # |
74 | 89 | # @option options [Integer] :line The line number. |
75 | 90 | # @option options [String] :line_type The line type (new or old). |
76 | 91 | # @return [Gitlab::ObjectifiedHash] Information about created comment. |
77 | def create_commit_comment(project, commit, note, options={}) | |
92 | def create_commit_comment(project, commit, note, options = {}) | |
78 | 93 | post("/projects/#{url_encode project}/repository/commits/#{commit}/comments", body: options.merge(note: note)) |
79 | 94 | end |
80 | alias_method :repo_create_commit_comment, :create_commit_comment | |
95 | alias repo_create_commit_comment create_commit_comment | |
81 | 96 | |
82 | 97 | # Get the status of a commit |
83 | 98 | # |
93 | 108 | # @option options [String] :stage Filter by stage |
94 | 109 | # @option options [String] :name Filter by status name, eg. jenkins |
95 | 110 | # @option options [Boolean] :all The flag to return all statuses, not only latest ones |
96 | def commit_status(project, sha, options={}) | |
111 | def commit_status(project, sha, options = {}) | |
97 | 112 | get("/projects/#{url_encode project}/repository/commits/#{sha}/statuses", query: options) |
98 | 113 | end |
99 | alias_method :repo_commit_status, :commit_status | |
114 | alias repo_commit_status commit_status | |
100 | 115 | |
101 | 116 | # Adds or updates a status of a commit. |
102 | 117 | # |
112 | 127 | # @option options [String] :ref The ref (branch or tag) to which the status refers |
113 | 128 | # @option options [String] :name Filter by status name, eg. jenkins |
114 | 129 | # @option options [String] :target_url The target URL to associate with this status |
115 | def update_commit_status(project, sha, state, options={}) | |
130 | def update_commit_status(project, sha, state, options = {}) | |
116 | 131 | post("/projects/#{url_encode project}/statuses/#{sha}", query: options.merge(state: state)) |
117 | 132 | end |
118 | alias_method :repo_update_commit_status, :update_commit_status | |
133 | alias repo_update_commit_status update_commit_status | |
119 | 134 | |
120 | 135 | # Creates a single commit with one or more changes |
121 | 136 | # |
133 | 148 | # @option options [String] :author_email the email address of the author |
134 | 149 | # @option options [String] :author_name the name of the author |
135 | 150 | # @return [Gitlab::ObjectifiedHash] hash of commit related data |
136 | def create_commit(project, branch, message, actions, options={}) | |
151 | def create_commit(project, branch, message, actions, options = {}) | |
137 | 152 | payload = { |
138 | branch: branch, | |
139 | commit_message: message, | |
140 | actions: actions, | |
153 | branch: branch, | |
154 | commit_message: message, | |
155 | actions: actions | |
141 | 156 | }.merge(options) |
142 | 157 | post("/projects/#{url_encode project}/repository/commits", body: payload) |
143 | 158 | end |
155 | 170 | # @option options [Integer] :page The page number. |
156 | 171 | # @option options [Integer] :per_page The number of results per page. |
157 | 172 | # @return [Array<Gitlab::ObjectifiedHash>] |
158 | def commit_merge_requests(project, commit, options={}) | |
173 | def commit_merge_requests(project, commit, options = {}) | |
159 | 174 | get("/projects/#{url_encode project}/repository/commits/#{commit}/merge_requests", query: options) |
160 | 175 | end |
161 | alias_method :repo_commit_merge_requests, :commit_merge_requests | |
176 | alias repo_commit_merge_requests commit_merge_requests | |
162 | 177 | end |
163 | 178 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to deployments. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/deployments.html |
12 | 14 | # @option options [Integer] :page The page number. |
13 | 15 | # @option options [Integer] :per_page The number of results per page. |
14 | 16 | # @return [Array<Gitlab::ObjectifiedHash>] |
15 | def deployments(project, options={}) | |
17 | def deployments(project, options = {}) | |
16 | 18 | get("/projects/#{url_encode project}/deployments", query: options) |
17 | 19 | end |
18 | 20 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to environments. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/environments.html |
12 | 14 | # @option options [Integer] :page The page number. |
13 | 15 | # @option options [Integer] :per_page The number of results per page. |
14 | 16 | # @return [Array<Gitlab::ObjectifiedHash>] |
15 | def environments(project, options={}) | |
17 | def environments(project, options = {}) | |
16 | 18 | get("/projects/#{url_encode project}/environments", query: options) |
17 | 19 | end |
18 | 20 | |
39 | 41 | # @option options [String] :external_url Optional URL for viewing the deployed project in this environment |
40 | 42 | # @return [Gitlab::ObjectifiedHash] The updated environment. |
41 | 43 | def create_environment(project, env_name, options = {}) |
42 | body = {name: env_name}.merge(options) | |
44 | body = { name: env_name }.merge(options) | |
43 | 45 | post("/projects/#{url_encode project}/environments", body: body) |
44 | 46 | end |
45 | 47 | |
55 | 57 | # @option options [String] env_name Name for the environment |
56 | 58 | # @option options [String] external_url Optional URL for viewing the deployed project in this environment |
57 | 59 | # @return [Gitlab::ObjectifiedHash] The updated environment. |
58 | def edit_environment(project, id, options={}) | |
60 | def edit_environment(project, id, options = {}) | |
59 | 61 | put("/projects/#{url_encode project}/environments/#{id}", body: options) |
60 | 62 | end |
61 | 63 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to events. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/events.html |
14 | 16 | # @option options [String] :after Only events created after YYYY-MM-DD |
15 | 17 | # @option options [String] :sort Sort by created_at either 'asc' or 'desc' |
16 | 18 | # @return [Array<Gitlab::ObjectifiedHash>] |
17 | def events(options={}) | |
19 | def events(options = {}) | |
18 | 20 | get('/events', query: options) |
19 | 21 | end |
20 | 22 | |
32 | 34 | # @option options [String] :after Only events created after YYYY-MM-DD |
33 | 35 | # @option options [String] :sort Sort by created_at either 'asc' or 'desc' |
34 | 36 | # @return [Array<Gitlab::ObjectifiedHash>] |
35 | def user_events(user, options={}) | |
37 | def user_events(user, options = {}) | |
36 | 38 | get("/users/#{url_encode user}/events", query: options) |
37 | 39 | end |
38 | 40 | |
50 | 52 | # @option options [String] :after Only events created after YYYY-MM-DD |
51 | 53 | # @option options [String] :sort Sort by created_at either 'asc' or 'desc' |
52 | 54 | # @return [Array<Gitlab::ObjectifiedHash>] |
53 | def project_events(project, options={}) | |
54 | get("/#{url_encode project}/events", query: options) | |
55 | def project_events(project, options = {}) | |
56 | get("/projects/#{url_encode project}/events", query: options) | |
55 | 57 | end |
56 | 58 | end |
57 | 59 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to group milestones. |
2 | 4 | # @see https://docs.gitlab.com/ee/api/group_milestones.html |
11 | 13 | # @option options [Integer] :page The page number. |
12 | 14 | # @option options [Integer] :per_page The number of results per page. |
13 | 15 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | def group_milestones(id, options={}) | |
16 | def group_milestones(id, options = {}) | |
15 | 17 | get("/groups/#{url_encode id}/milestones", query: options) |
16 | 18 | end |
17 | 19 | |
38 | 40 | # @option options [String] :description The description of a milestone. |
39 | 41 | # @option options [String] :due_date The due date of a milestone. |
40 | 42 | # @return [Gitlab::ObjectifiedHash] Information about created milestone. |
41 | def create_group_milestone(id, title, options={}) | |
43 | def create_group_milestone(id, title, options = {}) | |
42 | 44 | body = { title: title }.merge(options) |
43 | 45 | post("/groups/#{url_encode id}/milestones", body: body) |
44 | 46 | end |
56 | 58 | # @option options [String] :due_date The due date of a milestone. |
57 | 59 | # @option options [String] :state_event The state of a milestone ('close' or 'activate'). |
58 | 60 | # @return [Gitlab::ObjectifiedHash] Information about updated milestone. |
59 | def edit_group_milestone(id, milestone_id, options={}) | |
61 | def edit_group_milestone(id, milestone_id, options = {}) | |
60 | 62 | put("/groups/#{url_encode id}/milestones/#{milestone_id}", body: options) |
61 | 63 | end |
62 | 64 | |
70 | 72 | # @option options [Integer] :page The page number. |
71 | 73 | # @option options [Integer] :per_page The number of results per page. |
72 | 74 | # @return [Array<Gitlab::ObjectifiedHash>] |
73 | def group_milestone_issues(id, milestone_id, options={}) | |
75 | def group_milestone_issues(id, milestone_id, options = {}) | |
74 | 76 | get("/groups/#{url_encode id}/milestones/#{milestone_id}/issues", query: options) |
75 | 77 | end |
76 | 78 | |
84 | 86 | # @option options [Integer] :page The page number. |
85 | 87 | # @option options [Integer] :per_page The number of results per page. |
86 | 88 | # @return [Array<Gitlab::ObjectifiedHash>] |
87 | def group_milestone_merge_requests(id, milestone_id, options={}) | |
89 | def group_milestone_merge_requests(id, milestone_id, options = {}) | |
88 | 90 | get("/groups/#{url_encode id}/milestones/#{milestone_id}/merge_requests", query: options) |
89 | 91 | end |
90 | 92 | end |
91 | 93 | end |
92 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to groups. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/groups.html |
11 | 13 | # @option options [Integer] :page The page number. |
12 | 14 | # @option options [Integer] :per_page The number of results per page. |
13 | 15 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | def groups(options={}) | |
15 | get("/groups", query: options) | |
16 | def groups(options = {}) | |
17 | get('/groups', query: options) | |
16 | 18 | end |
17 | 19 | |
18 | 20 | # Gets a single group. |
35 | 37 | # @param [String] name The name of a group. |
36 | 38 | # @param [String] path The path of a group. |
37 | 39 | # @return [Gitlab::ObjectifiedHash] Information about created group. |
38 | def create_group(name, path, options={}) | |
40 | def create_group(name, path, options = {}) | |
39 | 41 | body = { name: name, path: path }.merge(options) |
40 | post("/groups", body: body) | |
42 | post('/groups', body: body) | |
41 | 43 | end |
42 | 44 | |
43 | 45 | # Delete's a group. |
61 | 63 | # @option options [Integer] :page The page number. |
62 | 64 | # @option options [Integer] :per_page The number of results per page. |
63 | 65 | # @return [Array<Gitlab::ObjectifiedHash>] |
64 | def group_members(id, options={}) | |
66 | def group_members(id, options = {}) | |
65 | 67 | get("/groups/#{url_encode id}/members", query: options) |
66 | 68 | end |
67 | 69 | |
137 | 139 | # @option options [String] :per_page Number of projects to return per page |
138 | 140 | # @option options [String] :page The page to retrieve |
139 | 141 | # @return [Array<Gitlab::ObjectifiedHash>] |
140 | def group_search(search, options={}) | |
142 | def group_search(search, options = {}) | |
141 | 143 | options[:search] = search |
142 | get("/groups", query: options) | |
144 | get('/groups', query: options) | |
143 | 145 | end |
144 | 146 | |
145 | 147 | # Get a list of projects under a group |
148 | 150 | # |
149 | 151 | # @param [Integer] id The ID of a group |
150 | 152 | # @return [Array<Gitlab::ObjectifiedHash>] List of projects under a group |
151 | def group_projects(id, options={}) | |
153 | def group_projects(id, options = {}) | |
152 | 154 | get("/groups/#{url_encode id}/projects", query: options) |
153 | 155 | end |
154 | 156 | |
166 | 168 | # @option options [String] :statistics Include group statistics (admins only). |
167 | 169 | # @option options [String] :owned Limit to groups owned by the current user. |
168 | 170 | # @return [Array<Gitlab::ObjectifiedHash>] List of subgroups under a group |
169 | def group_subgroups(id, options={}) | |
171 | def group_subgroups(id, options = {}) | |
170 | 172 | get("/groups/#{url_encode id}/subgroups", query: options) |
171 | 173 | end |
172 | 174 | |
185 | 187 | # @option options [String] :lfs_enabled Enable/disable Large File Storage (LFS) for the projects in this groupr. |
186 | 188 | # @option options [String] :request_access_enabled Allow users to request member access. |
187 | 189 | # @return [Gitlab::ObjectifiedHash] Information about the edited group. |
188 | def edit_group(id, options={}) | |
190 | def edit_group(id, options = {}) | |
189 | 191 | put("/groups/#{url_encode id}", body: options) |
190 | 192 | end |
191 | 193 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to issues. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/issues.html |
14 | 16 | # @option options [Integer] :page The page number. |
15 | 17 | # @option options [Integer] :per_page The number of results per page. |
16 | 18 | # @return [Array<Gitlab::ObjectifiedHash>] |
17 | def issues(project=nil, options={}) | |
19 | def issues(project = nil, options = {}) | |
18 | 20 | if project.to_s.empty? && project.to_i.zero? |
19 | get("/issues", query: options) | |
21 | get('/issues', query: options) | |
20 | 22 | else |
21 | 23 | get("/projects/#{url_encode project}/issues", query: options) |
22 | 24 | end |
48 | 50 | # @option options [Integer] :milestone_id The ID of a milestone to assign issue. |
49 | 51 | # @option options [String] :labels Comma-separated label names for an issue. |
50 | 52 | # @return [Gitlab::ObjectifiedHash] Information about created issue. |
51 | def create_issue(project, title, options={}) | |
53 | def create_issue(project, title, options = {}) | |
52 | 54 | body = { title: title }.merge(options) |
53 | 55 | post("/projects/#{url_encode project}/issues", body: body) |
54 | 56 | end |
68 | 70 | # @option options [String] :labels Comma-separated label names for an issue. |
69 | 71 | # @option options [String] :state_event The state event of an issue ('close' or 'reopen'). |
70 | 72 | # @return [Gitlab::ObjectifiedHash] Information about updated issue. |
71 | def edit_issue(project, id, options={}) | |
73 | def edit_issue(project, id, options = {}) | |
72 | 74 | put("/projects/#{url_encode project}/issues/#{id}", body: options) |
73 | 75 | end |
74 | 76 | |
142 | 144 | # @param [Integer] id The ID of an issue. |
143 | 145 | # @option options [String] :to_project_id The ID of the new project. |
144 | 146 | # @return [Gitlab::ObjectifiedHash] Information about moved issue. |
145 | def move_issue(project, id, options={}) | |
147 | def move_issue(project, id, options = {}) | |
146 | 148 | post("/projects/#{url_encode project}/issues/#{id}/move", body: options) |
147 | 149 | end |
148 | ||
150 | ||
149 | 151 | # Sets an estimated time of work for an issue. |
150 | 152 | # |
151 | 153 | # @example |
157 | 159 | def estimate_time_of_issue(project, id, duration) |
158 | 160 | post("/projects/#{url_encode project}/issues/#{id}/time_estimate", body: { duration: url_encode(duration) }) |
159 | 161 | end |
160 | ||
161 | # Resets the estimated time for an issue to 0 seconds. | |
162 | ||
163 | # Resets the estimated time for an issue to 0 seconds. | |
162 | 164 | # |
163 | 165 | # @example |
164 | 166 | # Gitlab.reset_time_estimate_of_issue(3, 42) |
168 | 170 | def reset_time_estimate_of_issue(project, id) |
169 | 171 | post("/projects/#{url_encode project}/issues/#{id}/reset_time_estimate") |
170 | 172 | end |
171 | ||
173 | ||
172 | 174 | # Adds spent time for an issue |
173 | 175 | # |
174 | 176 | # @example |
180 | 182 | def add_time_spent_on_issue(project, id, duration) |
181 | 183 | post("/projects/#{url_encode project}/issues/#{id}/add_spent_time", body: { duration: url_encode(duration) }) |
182 | 184 | end |
183 | ||
185 | ||
184 | 186 | # Resets the total spent time for this issue to 0 seconds. |
185 | 187 | # |
186 | 188 | # @example |
191 | 193 | def reset_time_spent_on_issue(project, id) |
192 | 194 | post("/projects/#{url_encode project}/issues/#{id}/reset_spent_time") |
193 | 195 | end |
194 | ||
196 | ||
195 | 197 | # Get time tracking stats for an issue |
196 | 198 | # |
197 | 199 | # @example |
202 | 204 | def time_stats_for_issue(project, id) |
203 | 205 | get("/projects/#{url_encode project}/issues/#{id}/time_stats") |
204 | 206 | end |
205 | ||
207 | ||
208 | # Get participants on issue | |
209 | # | |
210 | # @example | |
211 | # @gitlab.participants_on_issue(3, 42) | |
212 | # | |
213 | # @param [Integer, String] project The ID or name of a project. | |
214 | # @param [Integer] id The ID of an issue. | |
215 | def participants_on_issue(project, id) | |
216 | get("/projects/#{url_encode project}/issues/#{id}/participants") | |
217 | end | |
218 | ||
219 | # List merge requests that will close issue on merge | |
220 | # | |
221 | # @example | |
222 | # Gitlab.merge_requests_closing_issue_on_merge(3, 42) | |
223 | # | |
224 | # @param [Integer, String] project The ID or name of a project. | |
225 | # @param [Integer] id The ID of an issue. | |
226 | def merge_requests_closing_issue_on_merge(project, id) | |
227 | get("/projects/#{url_encode project}/issues/#{id}/closed_by") | |
228 | end | |
206 | 229 | end |
207 | 230 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to projects. |
2 | 4 | # @see https://docs.gitlab.com/ee/api/jobs.html |
6 | 8 | # @example |
7 | 9 | # Gitlab.jobs(1) |
8 | 10 | # Gitlab.jobs("project") |
11 | # Gitlab.jobs("project", {scope: ["manual", "success"], per_page: 100 }) | |
9 | 12 | # |
10 | 13 | # @param [Integer, String] id The ID or name of a project. |
11 | 14 | # @param [Hash] options A customizable set of options. |
12 | 15 | # @option options [Array] :scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided. |
16 | # @option options [Integer] :page The page number. | |
17 | # @option options [Integer] :per_page The number of results per page. | |
13 | 18 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | 19 | def jobs(project_id, options = {}) |
15 | 20 | get("/projects/#{url_encode project_id}/jobs", query: options) |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to keys. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/keys.html |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to labels. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/labels.html |
8 | 10 | # |
9 | 11 | # @param [Integer, String] project The ID or name of a project. |
10 | 12 | # @return [Array<Gitlab::ObjectifiedHash>] |
11 | def labels(project, options={}) | |
13 | def labels(project, options = {}) | |
12 | 14 | get("/projects/#{url_encode project}/labels", query: options) |
13 | 15 | end |
14 | 16 | |
42 | 44 | # @option options [String] :description The description of the label. |
43 | 45 | # @option options [String] :priority The priority of the label. Must be greater or equal than zero or null to remove the priority. |
44 | 46 | # @return [Gitlab::ObjectifiedHash] Information about updated label. |
45 | def edit_label(project, name, options={}) | |
47 | def edit_label(project, name, options = {}) | |
46 | 48 | put("/projects/#{url_encode project}/labels", body: options.merge(name: name)) |
47 | 49 | end |
48 | 50 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to MR Approvals. |
2 | 4 | # @see https://docs.gitlab.com/ee/api/merge_request_approvals.html |
106 | 108 | post("/projects/#{url_encode project}/merge_requests/#{merge_request}/unapprove") |
107 | 109 | end |
108 | 110 | end |
109 | end⏎ | |
111 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to merge requests. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/merge_requests.html |
24 | 26 | # @option options [Integer] :page The page number. |
25 | 27 | # @option options [Integer] :per_page The number of results per page. |
26 | 28 | # @return [Array<Gitlab::ObjectifiedHash>] |
27 | def merge_requests(project, options={}) | |
29 | def merge_requests(project, options = {}) | |
28 | 30 | get("/projects/#{url_encode project}/merge_requests", query: options) |
29 | 31 | end |
30 | 32 | |
38 | 40 | # @return <Gitlab::ObjectifiedHash] |
39 | 41 | def merge_request(project, id) |
40 | 42 | get("/projects/#{url_encode project}/merge_requests/#{id}") |
43 | end | |
44 | ||
45 | # Gets a list of merge request pipelines. | |
46 | # | |
47 | # @example | |
48 | # Gitlab.merge_request_pipelines(5, 36) | |
49 | # | |
50 | # @param [Integer, String] project The ID or name of a project. | |
51 | # @param [Integer] id The ID of a merge request. | |
52 | # @return [Array<Gitlab::ObjectifiedHash>] | |
53 | def merge_request_pipelines(project, id) | |
54 | get("/projects/#{url_encode project}/merge_requests/#{id}/pipelines") | |
41 | 55 | end |
42 | 56 | |
43 | 57 | # Creates a merge request. |
57 | 71 | # @option options [Integer] :target_project_id (optional) The target project ID. |
58 | 72 | # @option options [String] :labels (optional) Labels as a comma-separated list. |
59 | 73 | # @return [Gitlab::ObjectifiedHash] Information about created merge request. |
60 | def create_merge_request(project, title, options={}) | |
74 | def create_merge_request(project, title, options = {}) | |
61 | 75 | body = { title: title }.merge(options) |
62 | 76 | post("/projects/#{url_encode project}/merge_requests", body: body) |
63 | 77 | end |
76 | 90 | # @option options [Integer] :assignee_id The ID of a user to assign merge request. |
77 | 91 | # @option options [String] :state_event New state (close|reopen|merge). |
78 | 92 | # @return [Gitlab::ObjectifiedHash] Information about updated merge request. |
79 | def update_merge_request(project, id, options={}) | |
93 | def update_merge_request(project, id, options = {}) | |
80 | 94 | put("/projects/#{url_encode project}/merge_requests/#{id}", body: options) |
81 | 95 | end |
82 | 96 | |
90 | 104 | # @param [Hash] options A customizable set of options. |
91 | 105 | # @option options [String] :merge_commit_message Custom merge commit message |
92 | 106 | # @return [Gitlab::ObjectifiedHash] Information about updated merge request. |
93 | def accept_merge_request(project, id, options={}) | |
107 | def accept_merge_request(project, id, options = {}) | |
94 | 108 | put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options) |
95 | 109 | end |
96 | 110 | |
204 | 218 | # * :x (Integer) X coordinate (for 'image' diff notes) |
205 | 219 | # * :y (Integer) Y coordinate (for 'image' diff notes) |
206 | 220 | # @return [Gitlab::ObjectifiedHash] The created merge request discussion. |
207 | def create_merge_request_discussion(project, merge_request_id, options={}) | |
221 | def create_merge_request_discussion(project, merge_request_id, options = {}) | |
208 | 222 | post("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions", body: options) |
209 | 223 | end |
210 | 224 | |
270 | 284 | def delete_merge_request_discussion_note(project, merge_request_id, discussion_id, note_id) |
271 | 285 | delete("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/discussions/#{discussion_id}/notes/#{note_id}") |
272 | 286 | end |
287 | ||
288 | # Gets a list of merge request diff versions | |
289 | # | |
290 | # @example | |
291 | # Gitlab.merge_request_versions(5, 1) | |
292 | # Gitlab.merge_request_versions('gitlab', 1) | |
293 | # @param [Integer, String] project The ID or name of a project. | |
294 | # @param [Integer] id The ID of a merge request. | |
295 | # @return [Gitlab::ObjectifiedHash] A list of the merge request versions. | |
296 | def merge_request_diff_versions(project, merge_request_id) | |
297 | get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions") | |
298 | end | |
299 | ||
300 | # Gets the diff a single merge request diff version\ | |
301 | # | |
302 | # @example | |
303 | # Gitlab.merge_request_diff_version(5, 1, 1) | |
304 | # Gitlab.merge_request_diff_version('gitlab', 1, 1) | |
305 | # @param [Integer, String] project The ID or name of a project. | |
306 | # @param [Integer] id The ID of a merge request. | |
307 | # @param [Integer] id The ID of a merge request diff version. | |
308 | # @return [Gitlab::ObjectifiedHash] Record of the specific diff | |
309 | def merge_request_diff_version(project, merge_request_id, version_id) | |
310 | get("/projects/#{url_encode project}/merge_requests/#{merge_request_id}/versions/#{version_id}") | |
311 | end | |
273 | 312 | end |
274 | 313 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to milestones. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/milestones.html |
11 | 13 | # @option options [Integer] :page The page number. |
12 | 14 | # @option options [Integer] :per_page The number of results per page. |
13 | 15 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | def milestones(project, options={}) | |
16 | def milestones(project, options = {}) | |
15 | 17 | get("/projects/#{url_encode project}/milestones", query: options) |
16 | 18 | end |
17 | 19 | |
37 | 39 | # @option options [Integer] :page The page number. |
38 | 40 | # @option options [Integer] :per_page The number of results per page. |
39 | 41 | # @return [Array<Gitlab::ObjectifiedHash>] |
40 | def milestone_issues(project, milestone, options={}) | |
42 | def milestone_issues(project, milestone, options = {}) | |
41 | 43 | get("/projects/#{url_encode project}/milestones/#{milestone}/issues", query: options) |
42 | 44 | end |
43 | 45 | |
51 | 53 | # @option options [Integer] :page The page number. |
52 | 54 | # @option options [Integer] :per_page The number of results per page. |
53 | 55 | # @return [Array<Gitlab::ObjectifiedHash>] |
54 | def milestone_merge_requests(project, milestone, options={}) | |
56 | def milestone_merge_requests(project, milestone, options = {}) | |
55 | 57 | get("/projects/#{url_encode project}/milestones/#{milestone}/merge_requests", query: options) |
56 | 58 | end |
57 | 59 | |
66 | 68 | # @option options [String] :description The description of a milestone. |
67 | 69 | # @option options [String] :due_date The due date of a milestone. |
68 | 70 | # @return [Gitlab::ObjectifiedHash] Information about created milestone. |
69 | def create_milestone(project, title, options={}) | |
71 | def create_milestone(project, title, options = {}) | |
70 | 72 | body = { title: title }.merge(options) |
71 | 73 | post("/projects/#{url_encode project}/milestones", body: body) |
72 | 74 | end |
84 | 86 | # @option options [String] :due_date The due date of a milestone. |
85 | 87 | # @option options [String] :state_event The state of a milestone ('close' or 'activate'). |
86 | 88 | # @return [Gitlab::ObjectifiedHash] Information about updated milestone. |
87 | def edit_milestone(project, id, options={}) | |
89 | def edit_milestone(project, id, options = {}) | |
88 | 90 | put("/projects/#{url_encode project}/milestones/#{id}", body: options) |
91 | end | |
92 | ||
93 | # Delete a project milestone. | |
94 | # | |
95 | # @example | |
96 | # Gitlab.delete_milestone(5, 2) | |
97 | # | |
98 | # @param [Integer, String] project The ID or name of a project. | |
99 | # @param [Integer] id The ID of a milestone. | |
100 | # @return [nil] This API call returns an empty response body. | |
101 | def delete_milestone(project, id) | |
102 | delete("/projects/#{url_encode project}/milestones/#{id}") | |
89 | 103 | end |
90 | 104 | end |
91 | 105 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to namespaces |
2 | 4 | # @see https://docs.gitlab.com/ce/api/namespaces.html |
12 | 14 | # @options options [Integer] :per_page The number of results per page. |
13 | 15 | # @options opttion [String] :search The string to search for. |
14 | 16 | # @return [Array<Gitlab::ObjectifiedHash>] |
15 | def namespaces(options={}) | |
16 | get("/namespaces", query: options) | |
17 | def namespaces(options = {}) | |
18 | get('/namespaces', query: options) | |
17 | 19 | end |
18 | 20 | end |
19 | 21 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to notes. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/notes.html |
10 | 12 | # @option options [Integer] :page The page number. |
11 | 13 | # @option options [Integer] :per_page The number of results per page. |
12 | 14 | # @return [Array<Gitlab::ObjectifiedHash>] |
13 | def notes(project, options={}) | |
15 | def notes(project, options = {}) | |
14 | 16 | get("/projects/#{url_encode project}/notes", query: options) |
15 | 17 | end |
16 | 18 | |
24 | 26 | # @option options [Integer] :page The page number. |
25 | 27 | # @option options [Integer] :per_page The number of results per page. |
26 | 28 | # @return [Array<Gitlab::ObjectifiedHash>] |
27 | def issue_notes(project, issue, options={}) | |
29 | def issue_notes(project, issue, options = {}) | |
28 | 30 | get("/projects/#{url_encode project}/issues/#{issue}/notes", query: options) |
29 | 31 | end |
30 | 32 | |
38 | 40 | # @option options [Integer] :page The page number. |
39 | 41 | # @option options [Integer] :per_page The number of results per page. |
40 | 42 | # @return [Array<Gitlab::ObjectifiedHash>] |
41 | def snippet_notes(project, snippet, options={}) | |
43 | def snippet_notes(project, snippet, options = {}) | |
42 | 44 | get("/projects/#{url_encode project}/snippets/#{snippet}/notes", query: options) |
43 | 45 | end |
44 | 46 | |
52 | 54 | # @option options [Integer] :page The page number. |
53 | 55 | # @option options [Integer] :per_page The number of results per page. |
54 | 56 | # @return [Array<Gitlab::ObjectifiedHash>] |
55 | def merge_request_notes(project, merge_request, options={}) | |
57 | def merge_request_notes(project, merge_request, options = {}) | |
56 | 58 | get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options) |
57 | 59 | end |
58 | alias_method :merge_request_comments, :merge_request_notes | |
60 | alias merge_request_comments merge_request_notes | |
59 | 61 | |
60 | 62 | # Gets a single wall note. |
61 | 63 | # |
157 | 159 | def create_merge_request_note(project, merge_request, body) |
158 | 160 | post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body }) |
159 | 161 | end |
160 | alias_method :create_merge_request_comment, :create_merge_request_note | |
162 | alias create_merge_request_comment create_merge_request_note | |
161 | 163 | |
162 | 164 | # Deletes a wall note. |
163 | 165 | # |
209 | 211 | def delete_merge_request_note(project, merge_request, id) |
210 | 212 | delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}") |
211 | 213 | end |
212 | alias_method :delete_merge_request_comment, :delete_merge_request_note | |
214 | alias delete_merge_request_comment delete_merge_request_note | |
213 | 215 | |
214 | 216 | # Modifies a wall note. |
215 | 217 | # |
265 | 267 | def edit_merge_request_note(project, merge_request, id, body) |
266 | 268 | put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: note_content(body)) |
267 | 269 | end |
268 | alias_method :edit_merge_request_comment, :edit_merge_request_note | |
270 | alias edit_merge_request_comment edit_merge_request_note | |
269 | 271 | |
270 | 272 | private |
271 | 273 | |
273 | 275 | # in the 'else'. |
274 | 276 | def note_content(body) |
275 | 277 | if body.is_a?(Hash) |
276 | STDERR.puts "Passing the note body as a Hash is deprecated. You should just pass the String." | |
278 | STDERR.puts 'Passing the note body as a Hash is deprecated. You should just pass the String.' | |
277 | 279 | body |
278 | 280 | else |
279 | 281 | { body: body } |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to pipeline schedules. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/pipeline_schedules.html |
11 | 13 | # @param [Hash] options A customizable set of options. |
12 | 14 | # @options options [String] :scope The scope of pipeline schedules, one of a 'active' or 'inactive'. |
13 | 15 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | def pipeline_schedules(project, options={}) | |
16 | def pipeline_schedules(project, options = {}) | |
15 | 17 | get("/projects/#{url_encode project}/pipeline_schedules", query: options) |
16 | 18 | end |
17 | 19 | |
40 | 42 | # @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC'). |
41 | 43 | # @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true). |
42 | 44 | # @return [Array<Gitlab::ObjectifiedHash>] |
43 | def create_pipeline_schedule(project, options={}) | |
45 | def create_pipeline_schedule(project, options = {}) | |
44 | 46 | post("/projects/#{url_encode project}/pipeline_schedules", query: options) |
45 | 47 | end |
46 | 48 | |
58 | 60 | # @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC'). |
59 | 61 | # @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true). |
60 | 62 | # @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule. |
61 | def edit_pipeline_schedule(project, pipeline_schedule_id, options={}) | |
63 | def edit_pipeline_schedule(project, pipeline_schedule_id, options = {}) | |
62 | 64 | put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", query: options) |
63 | 65 | end |
64 | 66 | |
97 | 99 | # @option options [String] :key The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed. |
98 | 100 | # @option options [String] :value The value of a variable |
99 | 101 | # @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable. |
100 | def create_pipeline_schedule_variable(project, pipeline_schedule_id, options={}) | |
102 | def create_pipeline_schedule_variable(project, pipeline_schedule_id, options = {}) | |
101 | 103 | post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", query: options) |
102 | 104 | end |
103 | 105 | |
112 | 114 | # @param [Hash] options A customizable set of options. |
113 | 115 | # @option options [String] :value The value of a variable. |
114 | 116 | # @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable. |
115 | def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options={}) | |
117 | def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options = {}) | |
116 | 118 | put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", query: options) |
117 | 119 | end |
118 | 120 | |
125 | 127 | # @param [Integer] The pipeline schedule ID. |
126 | 128 | # @param [String] The key of a variable. |
127 | 129 | # @return [Array<Gitlab::ObjectifiedHash>] The deleted pipeline schedule variable. |
128 | def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, options={}) | |
130 | def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, _options = {}) | |
129 | 131 | delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}") |
130 | 132 | end |
131 | 133 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to pipelines. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/pipeline_triggers.html |
34 | 36 | # @param [String] description The trigger name |
35 | 37 | # @return [Gitlab::ObjectifiedHash] The created trigger. |
36 | 38 | def create_trigger(project, description) |
37 | post("/projects/#{url_encode project}/triggers", body: {description: description}) | |
39 | post("/projects/#{url_encode project}/triggers", body: { description: description }) | |
38 | 40 | end |
39 | 41 | |
40 | 42 | # Update a project trigger |
47 | 49 | # @param [Hash] options A customizable set of options. |
48 | 50 | # @option options [String] :description The trigger name. |
49 | 51 | # @return [Gitlab::ObjectifiedHash] The updated trigger. |
50 | def update_trigger(project, trigger_id, options={}) | |
52 | def update_trigger(project, trigger_id, options = {}) | |
51 | 53 | put("/projects/#{url_encode project}/triggers/#{trigger_id}", body: options) |
52 | 54 | end |
53 | 55 | |
74 | 76 | def remove_trigger(project, trigger_id) |
75 | 77 | delete("/projects/#{url_encode project}/triggers/#{trigger_id}") |
76 | 78 | end |
77 | alias_method :delete_trigger, :remove_trigger | |
79 | alias delete_trigger remove_trigger | |
78 | 80 | |
79 | 81 | # Run the given project pipeline trigger. |
80 | 82 | # |
89 | 91 | # @param [String] ref Branch or tag name to build. |
90 | 92 | # @param [Hash] variables A set of build variables to use for the build. (optional) |
91 | 93 | # @return [Gitlab::ObjectifiedHash] The trigger. |
92 | def run_trigger(project, token, ref, variables={}) | |
94 | def run_trigger(project, token, ref, variables = {}) | |
93 | 95 | post("/projects/#{url_encode project}/trigger/pipeline", unauthenticated: true, body: { |
94 | token: token, | |
95 | ref: ref, | |
96 | variables: variables | |
97 | }) | |
96 | token: token, | |
97 | ref: ref, | |
98 | variables: variables | |
99 | }) | |
98 | 100 | end |
99 | 101 | end |
100 | 102 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to pipelines. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/pipelines.html |
12 | 14 | # @option options [Integer] :page The page number. |
13 | 15 | # @option options [Integer] :per_page The number of results per page. |
14 | 16 | # @return [Array<Gitlab::ObjectifiedHash>] |
15 | def pipelines(project, options={}) | |
17 | def pipelines(project, options = {}) | |
16 | 18 | get("/projects/#{url_encode project}/pipelines", query: options) |
17 | 19 | end |
18 | 20 | |
35 | 37 | # |
36 | 38 | # @param [Integer, String] project The ID or name of a project. |
37 | 39 | # @param [String] ref Reference to commit. |
40 | # @param [Hash] variables Variables passed to pipelines | |
38 | 41 | # @return [Gitlab::ObjectifiedHash] The pipelines changes. |
39 | def create_pipeline(project, ref) | |
40 | post("/projects/#{url_encode project}/pipeline?ref=#{ref}") | |
42 | def create_pipeline(project, ref, variables = {}) | |
43 | body = {} | |
44 | ||
45 | # This mapping is necessary, cause the API expects an array with objects (with `key` and `value` keys) | |
46 | # See: https://docs.gitlab.com/ee/api/pipelines.html#create-a-new-pipeline | |
47 | body[:variables] = variables.map { |(key, value)| { key: key, value: value } } if variables.any? | |
48 | ||
49 | post( | |
50 | "/projects/#{url_encode project}/pipeline", | |
51 | query: { ref: ref }, | |
52 | body: body | |
53 | ) | |
41 | 54 | end |
42 | 55 | |
43 | 56 | # Cancels a pipeline. |
0 | # frozen_string_literal: true | |
1 | ||
2 | class Gitlab::Client | |
3 | # Defines methods related to project badges. | |
4 | # @see https://docs.gitlab.com/ee/api/project_badges.html | |
5 | module ProjectBadges | |
6 | # Gets a list of a projects badges and its group badges. | |
7 | # | |
8 | # @example | |
9 | # Gitlab.project_badges(5) | |
10 | # | |
11 | # @param [Integer, String] project The ID or name of a project. | |
12 | # @return [Array<Gitlab::ObjectifiedHash>] List of all badges of a project | |
13 | def project_badges(project) | |
14 | get("/projects/#{url_encode project}/badges") | |
15 | end | |
16 | ||
17 | # Gets a badge of a project. | |
18 | # | |
19 | # @example | |
20 | # Gitlab.project_badge(5, 42) | |
21 | # | |
22 | # @param [Integer, String] project The ID or name of a project. | |
23 | # @param [Integer] badge_id The badge ID. | |
24 | # @return [Gitlab::ObjectifiedHash] Information about the requested badge | |
25 | def project_badge(project, badge_id) | |
26 | get("/projects/#{url_encode project}/badges/#{badge_id}") | |
27 | end | |
28 | ||
29 | # Adds a badge to a project. | |
30 | # | |
31 | # @example | |
32 | # Gitlab.add_project_badge(5, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' }) | |
33 | # | |
34 | # @param [Integer, String] project The ID or name of a project. | |
35 | # @param [Hash] options A customizable set of options. | |
36 | # @option options [String] :link_url(required) URL of the badge link | |
37 | # @option options [String] :image_url(required) URL of the badge image | |
38 | # @return [Gitlab::ObjectifiedHash] Information about the added project badge. | |
39 | def add_project_badge(project, options = {}) | |
40 | post("/projects/#{url_encode project}/badges", body: options) | |
41 | end | |
42 | ||
43 | # Updates a badge of a project.. | |
44 | # | |
45 | # @example | |
46 | # Gitlab.edit_project_badge(5, 1, { link_url: 'https://abc.com/gitlab/gitlab-ce/commits/master', image_url: 'https://shields.io/my/badge1' }) | |
47 | # | |
48 | # @param [Integer, String] project The ID or name of a project. | |
49 | # @param [Integer] badge_id The badge ID. | |
50 | # @param [Hash] options A customizable set of options. | |
51 | # @option options [String] :link_url(optional) URL of the badge link | |
52 | # @option options [String] :image_url(optional) URL of the badge image | |
53 | # @return [Gitlab::ObjectifiedHash] Information about the updated project badge. | |
54 | def edit_project_badge(project, badge_id, options = {}) | |
55 | put("/projects/#{url_encode project}/badges/#{badge_id}", body: options) | |
56 | end | |
57 | ||
58 | # Removes a badge from a project. Only projects badges will be removed by using this endpoint. | |
59 | # | |
60 | # @example | |
61 | # Gitlab.remove_project_badge(5, 42) | |
62 | # | |
63 | # @param [Integer, String] project The ID or name of a project. | |
64 | # @param [Integer] badge_id The badge ID. | |
65 | # @return [nil] This API call returns an empty response body. | |
66 | def remove_project_badge(project, badge_id) | |
67 | delete("/projects/#{url_encode project}/badges/#{badge_id}") | |
68 | end | |
69 | ||
70 | # Preview a badge from a project. | |
71 | # | |
72 | # @example | |
73 | # Gitlab.preview_project_badge(3, 'https://abc.com/gitlab/gitlab-ce/commits/master', 'https://shields.io/my/badge1') | |
74 | # | |
75 | # @param [Integer, String] project The ID or name of a project. | |
76 | # @param [String] :link_url URL of the badge link | |
77 | # @param [String] :image_url URL of the badge image | |
78 | # @return [Gitlab::ObjectifiedHash] Returns how the link_url and image_url final URLs would be after resolving the placeholder interpolation. | |
79 | def preview_project_badge(project, link_url, image_url) | |
80 | query = { link_url: link_url, image_url: image_url } | |
81 | get("/projects/#{url_encode project}/badges/render", query: query) | |
82 | end | |
83 | end | |
84 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to projects. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/projects.html |
12 | 14 | # (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#list-all-projects Gitlab docs} for all valid options) |
13 | 15 | # |
14 | 16 | # @return [Array<Gitlab::ObjectifiedHash>] |
15 | def projects(options={}) | |
16 | get("/projects", query: options) | |
17 | def projects(options = {}) | |
18 | get('/projects', query: options) | |
17 | 19 | end |
18 | 20 | |
19 | 21 | # Search for projects by name. |
29 | 31 | # @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields |
30 | 32 | # @option options [String] :sort Return requests sorted in asc or desc order |
31 | 33 | # @return [Array<Gitlab::ObjectifiedHash>] |
32 | def project_search(query, options={}) | |
33 | get("/projects", query: options.merge(search:query)) | |
34 | end | |
35 | alias_method :search_projects, :project_search | |
34 | def project_search(query, options = {}) | |
35 | get('/projects', query: options.merge(search: query)) | |
36 | end | |
37 | alias search_projects project_search | |
36 | 38 | |
37 | 39 | # Gets information about a project. |
38 | 40 | # |
67 | 69 | # @option options [Boolean] :public The setting for making a project public (0 = false, 1 = true). |
68 | 70 | # @option options [Integer] :user_id The user/owner id of a project. |
69 | 71 | # @return [Gitlab::ObjectifiedHash] Information about created project. |
70 | def create_project(name, options={}) | |
71 | url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : "/projects" | |
72 | def create_project(name, options = {}) | |
73 | url = options[:user_id] ? "/projects/user/#{options[:user_id]}" : '/projects' | |
72 | 74 | post(url, body: { name: name }.merge(options)) |
73 | 75 | end |
74 | 76 | |
95 | 97 | # @option options [Integer] :page The page number. |
96 | 98 | # @option options [Integer] :per_page The number of results per page. |
97 | 99 | # @return [Array<Gitlab::ObjectifiedHash>] |
98 | def team_members(project, options={}) | |
100 | def team_members(project, options = {}) | |
99 | 101 | get("/projects/#{url_encode project}/members", query: options) |
100 | 102 | end |
101 | 103 | |
115 | 117 | # |
116 | 118 | # @example |
117 | 119 | # Gitlab.add_team_member('gitlab', 2, 40) |
120 | # Gitlab.add_team_member('gitlab', 2, 40, { expires_at: "2018-12-31"}) | |
118 | 121 | # |
119 | 122 | # @param [Integer, String] project The ID or path of a project. |
120 | 123 | # @param [Integer] id The ID of a user. |
121 | 124 | # @param [Integer] access_level The access level to project. |
122 | 125 | # @param [Hash] options A customizable set of options. |
126 | # @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY. | |
123 | 127 | # @return [Gitlab::ObjectifiedHash] Information about added team member. |
124 | def add_team_member(project, id, access_level) | |
125 | post("/projects/#{url_encode project}/members", body: { user_id: id, access_level: access_level }) | |
128 | def add_team_member(project, id, access_level, options = {}) | |
129 | body = { user_id: id, access_level: access_level }.merge(options) | |
130 | post("/projects/#{url_encode project}/members", body: body) | |
126 | 131 | end |
127 | 132 | |
128 | 133 | # Updates a team member's project access level. |
129 | 134 | # |
130 | 135 | # @example |
131 | 136 | # Gitlab.edit_team_member('gitlab', 3, 20) |
137 | # Gitlab.edit_team_member('gitlab', 3, 20, { expires_at: "2018-12-31"}) | |
132 | 138 | # |
133 | 139 | # @param [Integer, String] project The ID or path of a project. |
134 | 140 | # @param [Integer] id The ID of a user. |
135 | 141 | # @param [Integer] access_level The access level to project. |
136 | 142 | # @param [Hash] options A customizable set of options. |
143 | # @option options [String] :expires_at A date string in the format YEAR-MONTH-DAY. | |
137 | 144 | # @return [Array<Gitlab::ObjectifiedHash>] Information about updated team member. |
138 | def edit_team_member(project, id, access_level) | |
139 | put("/projects/#{url_encode project}/members/#{id}", body: { access_level: access_level }) | |
145 | def edit_team_member(project, id, access_level, options = {}) | |
146 | body = { access_level: access_level }.merge(options) | |
147 | put("/projects/#{url_encode project}/members/#{id}", body: body) | |
140 | 148 | end |
141 | 149 | |
142 | 150 | # Removes a user from project team. |
163 | 171 | # @option options [Integer] :page The page number. |
164 | 172 | # @option options [Integer] :per_page The number of results per page. |
165 | 173 | # @return [Array<Gitlab::ObjectifiedHash>] |
166 | def project_hooks(project, options={}) | |
174 | def project_hooks(project, options = {}) | |
167 | 175 | get("/projects/#{url_encode project}/hooks", query: options) |
168 | 176 | end |
169 | 177 | |
193 | 201 | # @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true) |
194 | 202 | # @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true) |
195 | 203 | # @return [Gitlab::ObjectifiedHash] Information about added hook. |
196 | def add_project_hook(project, url, options={}) | |
204 | def add_project_hook(project, url, options = {}) | |
197 | 205 | body = { url: url }.merge(options) |
198 | 206 | post("/projects/#{url_encode project}/hooks", body: body) |
199 | 207 | end |
212 | 220 | # @param option [Boolean] :merge_requests_events Trigger hook on merge_requests events (0 = false, 1 = true) |
213 | 221 | # @param option [Boolean] :tag_push_events Trigger hook on push_tag events (0 = false, 1 = true) |
214 | 222 | # @return [Gitlab::ObjectifiedHash] Information about updated hook. |
215 | def edit_project_hook(project, id, url, options={}) | |
223 | def edit_project_hook(project, id, url, options = {}) | |
216 | 224 | body = { url: url }.merge(options) |
217 | 225 | put("/projects/#{url_encode project}/hooks/#{id}", body: body) |
218 | 226 | end |
252 | 260 | # @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true) |
253 | 261 | # @param option [String] :commit_message_regex Commit message regex |
254 | 262 | # @return [Gitlab::ObjectifiedHash] Information about added push rule. |
255 | def add_push_rule(id, options={}) | |
263 | def add_push_rule(id, options = {}) | |
256 | 264 | post("/projects/#{url_encode id}/push_rule", body: options) |
257 | 265 | end |
258 | 266 | |
267 | 275 | # @param option [Boolean] :deny_delete_tag Do not allow users to remove git tags with git push (0 = false, 1 = true) |
268 | 276 | # @param option [String] :commit_message_regex Commit message regex |
269 | 277 | # @return [Gitlab::ObjectifiedHash] Information about updated push rule. |
270 | def edit_push_rule(id, options={}) | |
278 | def edit_push_rule(id, options = {}) | |
271 | 279 | put("/projects/#{url_encode id}/push_rule", body: options) |
272 | 280 | end |
273 | 281 | |
317 | 325 | # @option options [Integer] :page The page number. |
318 | 326 | # @option options [Integer] :per_page The number of results per page. |
319 | 327 | # @return [Array<Gitlab::ObjectifiedHash>] |
320 | def deploy_keys(project, options={}) | |
328 | def deploy_keys(project, options = {}) | |
321 | 329 | get("/projects/#{url_encode project}/deploy_keys", query: options) |
322 | 330 | end |
323 | 331 | |
393 | 401 | # @param [Hash] options A customizable set of options. |
394 | 402 | # @option options [String] :sudo The username the project will be forked for |
395 | 403 | # @return [Gitlab::ObjectifiedHash] Information about the forked project. |
396 | def create_fork(id, options={}) | |
404 | def create_fork(id, options = {}) | |
397 | 405 | post("/projects/#{url_encode id}/fork", body: options) |
398 | 406 | end |
399 | 407 | |
411 | 419 | # @option options [String] :order_by Return requests ordered by id, name, created_at or last_activity_at fields |
412 | 420 | # @option options [String] :sort Return requests sorted in asc or desc order |
413 | 421 | # @return [Array<Gitlab::ObjectifiedHash>] |
414 | def project_forks(id, options={}) | |
422 | def project_forks(id, options = {}) | |
415 | 423 | get("/projects/#{url_encode id}/forks", query: options) |
416 | 424 | end |
417 | 425 | |
430 | 438 | # (Any provided options will be passed to Gitlab. See {https://docs.gitlab.com/ce/api/projects.html#edit-project Gitlab docs} for all valid options) |
431 | 439 | # |
432 | 440 | # @return [Gitlab::ObjectifiedHash] Information about the edited project. |
433 | def edit_project(id, options={}) | |
441 | def edit_project(id, options = {}) | |
434 | 442 | put("/projects/#{url_encode id}", body: options) |
435 | 443 | end |
436 | 444 | |
458 | 466 | delete("/projects/#{url_encode project}/share/#{id}") |
459 | 467 | end |
460 | 468 | |
469 | # Transfer a project to a new namespace. | |
470 | # | |
471 | # @example | |
472 | # Gitlab.transfer_project(42, 'yolo') | |
473 | # | |
474 | # @param [Integer, String] project The ID or path of a project | |
475 | # @param [Integer, String] namespace The ID or path of the namespace to transfer to project to | |
476 | # @return [Gitlab::ObjectifiedHash] Information about transfered project. | |
477 | def transfer_project(project, namespace) | |
478 | put("/projects/#{url_encode project}/transfer", body: { namespace: namespace }) | |
479 | end | |
480 | ||
461 | 481 | # Stars a project. |
462 | 482 | # @see https://docs.gitlab.com/ce/api/projects.html#star-a-project |
463 | 483 | # |
499 | 519 | # @option options [String] :order_by Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields. |
500 | 520 | # @option options [String] :sort Return projects sorted in asc or desc order. |
501 | 521 | # @return [Array<Gitlab::ObjectifiedHash>] |
502 | def user_projects(user_id, options={}) | |
522 | def user_projects(user_id, options = {}) | |
503 | 523 | get("/users/#{url_encode user_id}/projects", query: options) |
524 | end | |
525 | ||
526 | # Uploads a file to the specified project to be used in an issue or | |
527 | # merge request description, or a comment. | |
528 | # @see https://docs.gitlab.com/ee/api/projects.html#upload-a-file | |
529 | # | |
530 | # @example | |
531 | # Gitlab.upload_file(1, File.open(File::NULL, 'r')) | |
532 | # File.open('myfile') { |file| Gitlab.upload_file(1, file) } | |
533 | # | |
534 | # @param [Integer, String] id The ID or path of a project. | |
535 | # @param [File] The file you are interested to upload. | |
536 | # @return [Gitlab::ObjectifiedHash] | |
537 | def upload_file(id, file) | |
538 | post("/projects/#{url_encode id}/uploads", body: { file: file }) | |
539 | end | |
540 | ||
541 | # Get all project templates of a particular type | |
542 | # @see https://docs.gitlab.com/ce/api/project_templates.html | |
543 | # | |
544 | # @example | |
545 | # Gitlab.project_templates(1, 'dockerfiles') | |
546 | # Gitlab.project_templates(1, 'licenses') | |
547 | # | |
548 | # @param [Integer, String] id The ID or URL-encoded path of the project. | |
549 | # @param [String] type The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template | |
550 | # @return [Array<Gitlab::ObjectifiedHash>] | |
551 | def project_templates(project, type) | |
552 | get("/projects/#{url_encode project}/templates/#{type}") | |
553 | end | |
554 | ||
555 | # Get one project template of a particular type | |
556 | # @see https://docs.gitlab.com/ce/api/project_templates.html | |
557 | # | |
558 | # @example | |
559 | # Gitlab.project_template(1, 'dockerfiles', 'dockey') | |
560 | # Gitlab.project_template(1, 'licenses', 'gpl', { project: 'some project', fullname: 'Holder Holding' }) | |
561 | # | |
562 | # @param [Integer, String] project The ID or URL-encoded path of the project. | |
563 | # @param [String] type The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template | |
564 | # @param [String] key The key of the template, as obtained from the collection endpoint | |
565 | # @param [Hash] options A customizable set of options. | |
566 | # @option options [String] project(optional) The project name to use when expanding placeholders in the template. Only affects licenses | |
567 | # @option options [String] fullname(optional) The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses | |
568 | # @return [Gitlab::ObjectifiedHash] | |
569 | def project_template(project, type, key, options = {}) | |
570 | get("/projects/#{url_encode project}/templates/#{type}/#{key}", query: options) | |
504 | 571 | end |
505 | 572 | end |
506 | 573 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | class Gitlab::Client | |
3 | # Defines methods related to Protected Tags. | |
4 | # @see https://docs.gitlab.com/ce/api/protected_tags.html | |
5 | module ProtectedTags | |
6 | # Gets a list of protected tags from a project | |
7 | # | |
8 | # @example | |
9 | # Gitlab.protected_tags(1) | |
10 | # | |
11 | # @param [Integer, String] project(required) The ID or name of a project. | |
12 | # @option options [Integer] :page The page number. | |
13 | # @option options [Integer] :per_page The number of results per page. | |
14 | # @return [Array<Gitlab::ObjectifiedHash>] List of all protected tags requested | |
15 | def protected_tags(project, options = {}) | |
16 | get("/projects/#{url_encode project}/protected_tags", query: options) | |
17 | end | |
18 | ||
19 | # Gets a single protected tag or wildcard protected tag. | |
20 | # | |
21 | # @example | |
22 | # Gitlab.protected_tag(1, 'release-1-0') | |
23 | # | |
24 | # @param [Integer, String] project(required) The ID or name of a project. | |
25 | # @param [String] name(required) The name of the tag or wildcard | |
26 | # @return <Gitlab::ObjectifiedHash] Information about the requested protected tag | |
27 | def protected_tag(project, name) | |
28 | get("/projects/#{url_encode project}/protected_tags/#{name}") | |
29 | end | |
30 | ||
31 | # Protects a single repository tag or several project repository tags using a wildcard protected tag. | |
32 | # | |
33 | # @example | |
34 | # Gitlab.protect_repository_tag(1, 'release-1-0') | |
35 | # Gitlab.protect_repository_tag(1, 'release-1-0', create_access_level: 30) | |
36 | # | |
37 | # @param [Integer, String] project(required) The ID or name of a project. | |
38 | # @param [String] name(required) The name of the tag or wildcard | |
39 | # @option options [Integer] :create_access_level Access levels allowed to create (defaults: 40, maintainer access level) | |
40 | # @return <Gitlab::ObjectifiedHash] Information about the protected repository tag | |
41 | def protect_repository_tag(project, name, options = {}) | |
42 | body = { name: name }.merge(options) | |
43 | post("/projects/#{url_encode project}/protected_tags", body: body) | |
44 | end | |
45 | ||
46 | # Unprotects the given protected tag or wildcard protected tag. | |
47 | # | |
48 | # @example | |
49 | # Gitlab.unprotect_repository_tag(1, 'release-1-0') | |
50 | # | |
51 | # @param [Integer, String] project(required) The ID or name of a project. | |
52 | # @param [String] name(required) The name of the tag or wildcard | |
53 | # @return [nil] This API call returns an empty response body. | |
54 | def unprotect_repository_tag(project, name) | |
55 | delete("/projects/#{url_encode project}/protected_tags/#{name}") | |
56 | end | |
57 | end | |
58 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to repositories. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/repositories.html |
12 | 14 | # @option options [String] :path The path inside repository. |
13 | 15 | # @option options [String] :ref_name The name of a repository branch or tag. |
14 | 16 | # @return [Gitlab::ObjectifiedHash] |
15 | def tree(project, options={}) | |
17 | def tree(project, options = {}) | |
16 | 18 | get("/projects/#{url_encode project}/repository/tree", query: options) |
17 | 19 | end |
18 | alias_method :repo_tree, :tree | |
20 | alias repo_tree tree | |
19 | 21 | |
20 | 22 | # Get project repository archive |
21 | 23 | # |
53 | 55 | def compare(project, from, to) |
54 | 56 | get("/projects/#{url_encode project}/repository/compare", query: { from: from, to: to }) |
55 | 57 | end |
56 | alias_method :repo_compare, :compare | |
58 | alias repo_compare compare | |
59 | ||
60 | # Get the common ancestor for 2 refs (commit SHAs, branch names or tags). | |
61 | # | |
62 | # @example | |
63 | # Gitlab.merge_base(42, ['master', 'feature/branch']) | |
64 | # Gitlab.merge_base(42, ['master', 'feature/branch']) | |
65 | # | |
66 | # @param [Integer, String] project The ID or URL-encoded path of the project. | |
67 | # @param [Array] refs Array containing 2 commit SHAs, branch names, or tags. | |
68 | # @return [Gitlab::ObjectifiedHash] | |
69 | def merge_base(project, refs) | |
70 | get("/projects/#{url_encode project}/repository/merge_base", query: { refs: refs }) | |
71 | end | |
57 | 72 | end |
58 | 73 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'base64' |
1 | 3 | |
2 | 4 | class Gitlab::Client |
13 | 15 | # @param [String] filepath The relative path of the file in the repository |
14 | 16 | # @param [String] ref The name of a repository branch or tag or if not given the default branch. |
15 | 17 | # @return [String] |
16 | def file_contents(project, filepath, ref='master') | |
18 | def file_contents(project, filepath, ref = 'master') | |
17 | 19 | get "/projects/#{url_encode project}/repository/files/#{url_encode filepath}/raw", |
18 | query: { ref: ref}, | |
20 | query: { ref: ref }, | |
19 | 21 | format: nil, |
20 | 22 | headers: { Accept: 'text/plain' }, |
21 | 23 | parser: ::Gitlab::Request::Parser |
22 | 24 | end |
23 | alias_method :repo_file_contents, :file_contents | |
25 | alias repo_file_contents file_contents | |
24 | 26 | |
25 | 27 | # Gets a repository file. |
26 | 28 | # |
0 | # frozen_string_literal: true | |
1 | ||
2 | class Gitlab::Client | |
3 | # Defines methods related to repository submodules. | |
4 | # @see https://docs.gitlab.com/ce/api/repository_submodules.html | |
5 | module RepositorySubmodules | |
6 | # Edits an existing repository submodule. | |
7 | # | |
8 | # @example | |
9 | # Gitlab.edit_file(42, "submodule", { | |
10 | # branch: "branch", | |
11 | # commit_sha: "3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88", | |
12 | # commit_message: "commit message" | |
13 | # }) | |
14 | # | |
15 | # @param [Integer, String] project The ID or name of a project. | |
16 | # @param [String] submodule full path of submodule to update. | |
17 | # @param [Hash] options A customizable set of options. | |
18 | # @param options [String] :branch the name of the branch to commit changes to. | |
19 | # @param options [String] :commit_sha commit SHA to update the submodule to. | |
20 | # @param options [String] :commit_message commit message text. | |
21 | # @return [Gitlab::ObjectifiedHash] | |
22 | def edit_submodule(project, submodule, options = {}) | |
23 | put("/projects/#{url_encode project}/repository/submodules/#{url_encode submodule}", body: options) | |
24 | end | |
25 | end | |
26 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to runners. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/runners.html |
3 | 5 | module Runners |
4 | ||
5 | 6 | # Get a list of specific runners available to the user. |
6 | 7 | # @see https://docs.gitlab.com/ce/api/runners.html#list-owned-runners |
7 | 8 | # |
14 | 15 | # @option options [String] :scope The scope of specific runners to show, one of: active, paused, online; showing all runners if none provided |
15 | 16 | # @return [Array<Gitlab::ObjectifiedHash>] |
16 | 17 | def runners(options = {}) |
17 | get("/runners", query: options) | |
18 | get('/runners', query: options) | |
18 | 19 | end |
19 | 20 | |
20 | 21 | # Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges. |
27 | 28 | # @option options [String] :scope The scope of runners to show, one of: specific, shared, active, paused, online; showing all runners if none provided |
28 | 29 | # @return [Array<Gitlab::ObjectifiedHash>] |
29 | 30 | def all_runners(options = {}) |
30 | get("/runners/all", query: options) | |
31 | get('/runners/all', query: options) | |
31 | 32 | end |
32 | 33 | |
33 | 34 | # Get details of a runner.. |
55 | 56 | # @option options [String] :active The state of a runner; can be set to true or false. |
56 | 57 | # @option options [String] :tag_list The list of tags for a runner; put array of tags, that should be finally assigned to a runner |
57 | 58 | # @return <Gitlab::ObjectifiedHash> |
58 | def update_runner(id, options={}) | |
59 | def update_runner(id, options = {}) | |
59 | 60 | put("/runners/#{id}", query: options) |
60 | 61 | end |
61 | 62 | |
120 | 121 | def project_disable_runner(id, runner_id) |
121 | 122 | delete("/projects/#{url_encode id}/runners/#{runner_id}") |
122 | 123 | end |
123 | ||
124 | 124 | end |
125 | 125 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Third party services connected to a project. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/services.html |
42 | 44 | end |
43 | 45 | |
44 | 46 | private |
47 | ||
45 | 48 | def correct_service_name(service) |
46 | service.to_s.gsub('_', '-') | |
49 | service.to_s.tr('_', '-') | |
47 | 50 | end |
48 | 51 | end |
49 | 52 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to sidekiq metrics. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/sidekiq_metrics.html |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to snippets. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/project_snippets.html |
11 | 13 | # @option options [Integer] :page The page number. |
12 | 14 | # @option options [Integer] :per_page The number of results per page. |
13 | 15 | # @return [Gitlab::ObjectifiedHash] |
14 | def snippets(project, options={}) | |
16 | def snippets(project, options = {}) | |
15 | 17 | get("/projects/#{url_encode project}/snippets", query: options) |
16 | 18 | end |
17 | 19 | |
40 | 42 | # @option options [String] :lifetime (optional) The expiration date of a snippet. |
41 | 43 | # @option options [String] :visibility (required) The visibility of a snippet |
42 | 44 | # @return [Gitlab::ObjectifiedHash] Information about created snippet. |
43 | def create_snippet(project, options={}) | |
45 | def create_snippet(project, options = {}) | |
44 | 46 | post("/projects/#{url_encode project}/snippets", body: options) |
45 | 47 | end |
46 | 48 | |
58 | 60 | # @option options [String] :lifetime The expiration date of a snippet. |
59 | 61 | # @option options [String] :visibility (optional) The visibility of a snippet |
60 | 62 | # @return [Gitlab::ObjectifiedHash] Information about updated snippet. |
61 | def edit_snippet(project, id, options={}) | |
63 | def edit_snippet(project, id, options = {}) | |
62 | 64 | put("/projects/#{url_encode project}/snippets/#{id}", body: options) |
63 | 65 | end |
64 | 66 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to system hooks. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/system_hooks.html |
11 | 13 | # @option options [Integer] :page The page number. |
12 | 14 | # @option options [Integer] :per_page The number of results per page. |
13 | 15 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | def hooks(options={}) | |
15 | get("/hooks", query: options) | |
16 | def hooks(options = {}) | |
17 | get('/hooks', query: options) | |
16 | 18 | end |
17 | alias_method :system_hooks, :hooks | |
19 | alias system_hooks hooks | |
18 | 20 | |
19 | 21 | # Adds a new system hook. |
20 | 22 | # |
28 | 30 | # @option options [boolean] :enable_ssl_verification `false` will cause Gitlab to ignore invalid/unsigned certificate errors (default is `true`) |
29 | 31 | # @return [Gitlab::ObjectifiedHash] |
30 | 32 | def add_hook(url, options = {}) |
31 | post("/hooks", body: options.merge(url: url)) | |
33 | post('/hooks', body: options.merge(url: url)) | |
32 | 34 | end |
33 | alias_method :add_system_hook, :add_hook | |
35 | alias add_system_hook add_hook | |
34 | 36 | |
35 | 37 | # Tests a system hook. |
36 | 38 | # |
43 | 45 | def hook(id) |
44 | 46 | get("/hooks/#{id}") |
45 | 47 | end |
46 | alias_method :system_hook, :hook | |
48 | alias system_hook hook | |
47 | 49 | |
48 | 50 | # Deletes a new system hook. |
49 | 51 | # |
56 | 58 | def delete_hook(id) |
57 | 59 | delete("/hooks/#{id}") |
58 | 60 | end |
59 | alias_method :delete_system_hook, :delete_hook | |
61 | alias delete_system_hook delete_hook | |
60 | 62 | end |
61 | 63 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to tags. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/tags.html |
11 | 13 | # @option options [Integer] :page The page number. |
12 | 14 | # @option options [Integer] :per_page The number of results per page. |
13 | 15 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | def tags(project, options={}) | |
16 | def tags(project, options = {}) | |
15 | 17 | get("/projects/#{url_encode project}/repository/tags", query: options) |
16 | 18 | end |
17 | alias_method :repo_tags, :tags | |
19 | alias repo_tags tags | |
18 | 20 | |
19 | 21 | # Creates a new project repository tag. |
20 | 22 | # |
28 | 30 | # @param [String] message Optional message for tag, creates annotated tag if specified. |
29 | 31 | # @param [String] description Optional release notes for tag. |
30 | 32 | # @return [Gitlab::ObjectifiedHash] |
31 | def create_tag(project, tag_name, ref, message='', description=nil) | |
33 | def create_tag(project, tag_name, ref, message = '', description = nil) | |
32 | 34 | post("/projects/#{url_encode project}/repository/tags", body: { tag_name: tag_name, ref: ref, message: message, release_description: description }) |
33 | 35 | end |
34 | alias_method :repo_create_tag, :create_tag | |
36 | alias repo_create_tag create_tag | |
35 | 37 | |
36 | 38 | # Gets information about a repository tag. |
37 | 39 | # |
45 | 47 | def tag(project, tag) |
46 | 48 | get("/projects/#{url_encode project}/repository/tags/#{url_encode tag}") |
47 | 49 | end |
48 | alias_method :repo_tag, :tag | |
50 | alias repo_tag tag | |
49 | 51 | |
50 | 52 | # Deletes a repository tag. Requires Gitlab >= 6.8.x |
51 | 53 | # |
59 | 61 | def delete_tag(project, tag) |
60 | 62 | delete("/projects/#{url_encode project}/repository/tags/#{url_encode tag}") |
61 | 63 | end |
62 | alias_method :repo_delete_tag, :delete_tag | |
64 | alias repo_delete_tag delete_tag | |
63 | 65 | |
64 | 66 | # Adds release notes to an existing repository tag. Requires Gitlab >= 8.2.0 |
65 | 67 | # |
74 | 76 | def create_release(project, tag, description) |
75 | 77 | post("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description }) |
76 | 78 | end |
77 | alias_method :repo_create_release, :create_release | |
79 | alias repo_create_release create_release | |
78 | 80 | |
79 | 81 | # Updates the release notes of a given release. Requires Gitlab >= 8.2.0 |
80 | 82 | # |
89 | 91 | def update_release(project, tag, description) |
90 | 92 | put("/projects/#{url_encode project}/repository/tags/#{url_encode tag}/release", body: { description: description }) |
91 | 93 | end |
92 | alias_method :repo_update_release, :update_release | |
93 | ||
94 | alias repo_update_release update_release | |
94 | 95 | end |
95 | 96 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | class Gitlab::Client | |
3 | # Defines methods related to templates. | |
4 | # @see https://docs.gitlab.com/ce/api/templates/dockerfiles.html | |
5 | # @see https://docs.gitlab.com/ce/api/templates/gitignores.html | |
6 | # @see https://docs.gitlab.com/ce/api/templates/gitlab_ci_ymls.html | |
7 | # @see https://docs.gitlab.com/ce/api/templates/licenses.html | |
8 | module Templates | |
9 | # Get all Dockerfile templates. | |
10 | # | |
11 | # @example | |
12 | # Gitlab.dockerfile_templates | |
13 | # | |
14 | # @return [Array<Gitlab::ObjectifiedHash>] | |
15 | def dockerfile_templates | |
16 | get('/templates/dockerfiles') | |
17 | end | |
18 | ||
19 | # Get a single Dockerfile template. | |
20 | # | |
21 | # @example | |
22 | # Gitlab.dockerfile_template('Binary') | |
23 | # | |
24 | # @param [String] key The key of the Dockerfile template | |
25 | # @return [Gitlab::ObjectifiedHash] | |
26 | def dockerfile_template(key) | |
27 | get("/templates/dockerfiles/#{key}") | |
28 | end | |
29 | ||
30 | # Get all gitignore templates. | |
31 | # | |
32 | # @example | |
33 | # Gitlab.gitignore_templates | |
34 | # | |
35 | # @return [Array<Gitlab::ObjectifiedHash>] | |
36 | def gitignore_templates | |
37 | get('/templates/gitignores') | |
38 | end | |
39 | ||
40 | # Get a single gitignore template. | |
41 | # | |
42 | # @example | |
43 | # Gitlab.gitignore_template('Ruby') | |
44 | # | |
45 | # @param [String] key The key of the gitignore template | |
46 | # @return [Gitlab::ObjectifiedHash] | |
47 | def gitignore_template(key) | |
48 | get("/templates/gitignores/#{key}") | |
49 | end | |
50 | ||
51 | # Get all `gitlab_ci.yml` templates. | |
52 | # | |
53 | # @example | |
54 | # Gitlab.gitlab_ci_yml_templates | |
55 | # | |
56 | # @return [Array<Gitlab::ObjectifiedHash>] | |
57 | def gitlab_ci_yml_templates | |
58 | get('/templates/gitlab_ci_ymls') | |
59 | end | |
60 | ||
61 | # Get a single `gitlab_ci.yml` template. | |
62 | # | |
63 | # @example | |
64 | # Gitlab.gitlab_ci_yml_template('Ruby') | |
65 | # | |
66 | # @param [String] key The key of the gitlab_ci_yml template | |
67 | # @return [Gitlab::ObjectifiedHash] | |
68 | def gitlab_ci_yml_template(key) | |
69 | get("/templates/gitlab_ci_ymls/#{key}") | |
70 | end | |
71 | ||
72 | # Get all license templates. | |
73 | # | |
74 | # @example | |
75 | # Gitlab.license_templates | |
76 | # Gitlab.license_templates(popular: true) | |
77 | # | |
78 | # @param [Hash] options A customizable set of options. | |
79 | # @option options [Boolean] popular(optional) If passed, returns only popular licenses. | |
80 | # @return [Array<Gitlab::ObjectifiedHash>] | |
81 | def license_templates(options = {}) | |
82 | get('/templates/licenses', query: options) | |
83 | end | |
84 | ||
85 | # Get a single license template. You can pass parameters to replace the license placeholder. | |
86 | # | |
87 | # @example | |
88 | # Gitlab.license_template('Ruby') | |
89 | # | |
90 | # @param [String] key The key of the license template | |
91 | # @param [Hash] options A customizable set of options. | |
92 | # @option options [String] project(optional) The copyrighted project name. | |
93 | # @option options [String] fullname(optional) The full-name of the copyright holder | |
94 | # @return [Gitlab::ObjectifiedHash] | |
95 | def license_template(key, options = {}) | |
96 | get("/templates/licenses/#{key}", query: options) | |
97 | end | |
98 | end | |
99 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to todos |
2 | # @see https://docs.gitlab.com/ce/api/todos.html | |
4 | # @see https://docs.gitlab.com/ce/api/todos.html | |
3 | 5 | module Todos |
4 | 6 | # Gets a list of todos. |
5 | 7 | # |
15 | 17 | # @option options [Integer] :state The state of the todo. Can be either `pending` or `done` |
16 | 18 | # @option options [Integer] :type The type of a todo. Can be either `Issue` or `MergeRequest` |
17 | 19 | # @return [Array<Gitlab::ObjectifiedHash>] |
18 | def todos(options={}) | |
19 | get("/todos", query: options) | |
20 | def todos(options = {}) | |
21 | get('/todos', query: options) | |
20 | 22 | end |
21 | 23 | |
22 | 24 | # Marks a single pending todo for the current user as done. |
37 | 39 | # |
38 | 40 | # @return [void] This API call returns an empty response body. |
39 | 41 | def mark_all_todos_as_done |
40 | post("/todos/mark_as_done") | |
42 | post('/todos/mark_as_done') | |
41 | 43 | end |
42 | 44 | end |
43 | end⏎ | |
45 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Client |
1 | 3 | # Defines methods related to users. |
2 | 4 | # @see https://docs.gitlab.com/ce/api/users.html |
11 | 13 | # @option options [Integer] :page The page number. |
12 | 14 | # @option options [Integer] :per_page The number of results per page. |
13 | 15 | # @return [Array<Gitlab::ObjectifiedHash>] |
14 | def users(options={}) | |
15 | get("/users", query: options) | |
16 | def users(options = {}) | |
17 | get('/users', query: options) | |
16 | 18 | end |
17 | 19 | |
18 | 20 | # Gets information about a user. |
24 | 26 | # |
25 | 27 | # @param [Integer] id The ID of a user. |
26 | 28 | # @return [Gitlab::ObjectifiedHash] |
27 | def user(id=nil) | |
28 | id.to_i.zero? ? get("/user") : get("/users/#{id}") | |
29 | def user(id = nil) | |
30 | id.to_i.zero? ? get('/user') : get("/users/#{id}") | |
29 | 31 | end |
30 | 32 | |
31 | 33 | # Creates a new user. |
47 | 49 | # @option options [Integer] :projects_limit The limit of projects for a user. |
48 | 50 | # @return [Gitlab::ObjectifiedHash] Information about created user. |
49 | 51 | def create_user(*args) |
50 | options = Hash === args.last ? args.pop : {} | |
52 | options = args.last.is_a?(Hash) ? args.pop : {} | |
51 | 53 | body = if args[2] |
52 | 54 | { email: args[0], password: args[1], username: args[2] } |
53 | 55 | else |
72 | 74 | # @option options [String] :twitter The twitter of a user. |
73 | 75 | # @option options [Integer] :projects_limit The limit of projects for a user. |
74 | 76 | # @return [Gitlab::ObjectifiedHash] Information about created user. |
75 | def edit_user(user_id, options={}) | |
77 | def edit_user(user_id, options = {}) | |
76 | 78 | put("/users/#{user_id}", body: options) |
77 | 79 | end |
78 | 80 | |
119 | 121 | # @return [Gitlab::ObjectifiedHash] |
120 | 122 | # @note This method doesn't require private_token to be set. |
121 | 123 | def session(email, password) |
122 | post("/session", body: { email: email, password: password }, unauthenticated: true) | |
124 | post('/session', body: { email: email, password: password }, unauthenticated: true) | |
123 | 125 | end |
124 | 126 | |
125 | 127 | # Gets a list of user's SSH keys. |
133 | 135 | # @option options [Integer] :per_page The number of results per page. |
134 | 136 | # @option options [Integer] :user_id The ID of the user to retrieve the keys for. |
135 | 137 | # @return [Array<Gitlab::ObjectifiedHash>] |
136 | def ssh_keys(options={}) | |
138 | def ssh_keys(options = {}) | |
137 | 139 | user_id = options.delete :user_id |
138 | 140 | if user_id.to_i.zero? |
139 | get("/user/keys", query: options) | |
141 | get('/user/keys', query: options) | |
140 | 142 | else |
141 | 143 | get("/users/#{user_id}/keys", query: options) |
142 | 144 | end |
160 | 162 | # |
161 | 163 | # @param [String] title The title of an SSH key. |
162 | 164 | # @param [String] key The SSH key body. |
165 | # @param [Hash] options A customizable set of options. | |
166 | # @option options [Integer] :user_id id of the user to associate the key with | |
163 | 167 | # @return [Gitlab::ObjectifiedHash] Information about created SSH key. |
164 | def create_ssh_key(title, key) | |
165 | post("/user/keys", body: { title: title, key: key }) | |
168 | def create_ssh_key(title, key, options = {}) | |
169 | user_id = options.delete :user_id | |
170 | if user_id.to_i.zero? | |
171 | post('/user/keys', body: { title: title, key: key }) | |
172 | else | |
173 | post("/users/#{user_id}/keys", body: { title: title, key: key }) | |
174 | end | |
166 | 175 | end |
167 | 176 | |
168 | 177 | # Deletes an SSH key. |
171 | 180 | # Gitlab.delete_ssh_key(1) |
172 | 181 | # |
173 | 182 | # @param [Integer] id The ID of a user's SSH key. |
183 | # @param [Hash] options A customizable set of options. | |
184 | # @option options [Integer] :user_id id of the user to associate the key with | |
174 | 185 | # @return [Gitlab::ObjectifiedHash] Information about deleted SSH key. |
175 | def delete_ssh_key(id) | |
176 | delete("/user/keys/#{id}") | |
186 | def delete_ssh_key(id, options = {}) | |
187 | user_id = options.delete :user_id | |
188 | if user_id.to_i.zero? | |
189 | delete("/user/keys/#{id}") | |
190 | else | |
191 | delete("/users/#{user_id}/keys/#{id}") | |
192 | end | |
177 | 193 | end |
178 | 194 | |
179 | 195 | # Gets user emails. |
185 | 201 | # |
186 | 202 | # @param [Integer] user_id The ID of a user. |
187 | 203 | # @return [Gitlab::ObjectifiedHash] |
188 | def emails(user_id=nil) | |
189 | url = user_id.to_i.zero? ? "/user/emails" : "/users/#{user_id}/emails" | |
204 | def emails(user_id = nil) | |
205 | url = user_id.to_i.zero? ? '/user/emails' : "/users/#{user_id}/emails" | |
190 | 206 | get(url) |
191 | 207 | end |
192 | 208 | |
211 | 227 | # @param [String] email Email address |
212 | 228 | # @param [Integer] user_id The ID of a user. |
213 | 229 | # @return [Gitlab::ObjectifiedHash] |
214 | def add_email(email, user_id=nil) | |
215 | url = user_id.to_i.zero? ? "/user/emails" : "/users/#{user_id}/emails" | |
216 | post(url, body: {email: email}) | |
230 | def add_email(email, user_id = nil) | |
231 | url = user_id.to_i.zero? ? '/user/emails' : "/users/#{user_id}/emails" | |
232 | post(url, body: { email: email }) | |
217 | 233 | end |
218 | 234 | |
219 | 235 | # Delete email |
226 | 242 | # @param [Integer] id Email address ID |
227 | 243 | # @param [Integer] user_id The ID of a user. |
228 | 244 | # @return [Boolean] |
229 | def delete_email(id, user_id=nil) | |
245 | def delete_email(id, user_id = nil) | |
230 | 246 | url = user_id.to_i.zero? ? "/user/emails/#{id}" : "/users/#{user_id}/emails/#{id}" |
231 | 247 | delete(url) |
232 | 248 | end |
241 | 257 | # @option options [String] :per_page Number of user to return per page |
242 | 258 | # @option options [String] :page The page to retrieve |
243 | 259 | # @return [Array<Gitlab::ObjectifiedHash>] |
244 | def user_search(search, options={}) | |
260 | def user_search(search, options = {}) | |
245 | 261 | options[:search] = search |
246 | get("/users", query: options) | |
262 | get('/users', query: options) | |
247 | 263 | end |
248 | 264 | end |
249 | 265 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | class Gitlab::Client | |
3 | # Defines methods related to version | |
4 | # @see https://docs.gitlab.com/ce/api/version.html | |
5 | module Versions | |
6 | # Returns server version. | |
7 | # @see https://docs.gitlab.com/ce/api/version.html | |
8 | # | |
9 | # @example | |
10 | # Gitlab.version | |
11 | # | |
12 | # @return [Array<Gitlab::ObjectifiedHash>] | |
13 | def version | |
14 | get('/version') | |
15 | end | |
16 | end | |
17 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | class Gitlab::Client | |
3 | # Defines methods related to wikis. | |
4 | # @see https://docs.gitlab.com/ce/api/wikis.html | |
5 | module Wikis | |
6 | # Get all wiki pages for a given project. | |
7 | # | |
8 | # @example | |
9 | # Gitlab.wikis(3) | |
10 | # Gitlab.wikis(3, {with_content: 'Some wiki content'}) | |
11 | # | |
12 | # @param [Integer, String] project The ID or name of a project. | |
13 | # @param [Hash] options A customizable set of options. | |
14 | # @option options [String] with_content(optional) Include pages content | |
15 | # @return [Array<Gitlab::ObjectifiedHash>] | |
16 | def wikis(project, options = {}) | |
17 | get("/projects/#{url_encode project}/wikis", query: options) | |
18 | end | |
19 | ||
20 | # Get a wiki page for a given project. | |
21 | # | |
22 | # @example | |
23 | # Gitlab.wiki(3, 'home') | |
24 | # | |
25 | # @param [Integer, String] project The ID or name of a project. | |
26 | # @param [String] slug The slug (a unique string) of the wiki page | |
27 | # @return [Gitlab::ObjectifiedHash] | |
28 | def wiki(project, slug) | |
29 | get("/projects/#{url_encode project}/wikis/#{slug}") | |
30 | end | |
31 | ||
32 | # Creates a new wiki page for the given repository with the given title, slug, and content. | |
33 | # | |
34 | # @example | |
35 | # Gitlab.create_wiki(3, 'Some Title', 'Some Content') | |
36 | # Gitlab.create_wiki(3, 'Some Title', 'Some Content', { format: 'rdoc' }) | |
37 | # | |
38 | # @param [Integer, String] project The ID or name of a project. | |
39 | # @param [String] content The content of the wiki page. | |
40 | # @param [String] title The title of the wiki page. | |
41 | # @param [Hash] options A customizable set of options. | |
42 | # @option options [String] format (optional) The format of the wiki page. Available formats are: markdown (default), rdoc, and asciidoc. | |
43 | # @return [Gitlab::ObjectifiedHash] Information about created wiki page. | |
44 | def create_wiki(project, title, content, options = {}) | |
45 | body = { content: content, title: title }.merge(options) | |
46 | post("/projects/#{url_encode project}/wikis", body: body) | |
47 | end | |
48 | ||
49 | # Updates an existing wiki page. At least one parameter is required to update the wiki page. | |
50 | # | |
51 | # @example | |
52 | # Gitlab.update_wiki(6, 'home', { title: 'New title' }) | |
53 | # Gitlab.update_wiki(6, 'home', { title: 'New title', content: 'New Message', format: 'rdoc' }) | |
54 | # | |
55 | # @param [Integer, String] project The ID or name of a project. | |
56 | # @param [String] slug The slug (a unique string) of the wiki page. | |
57 | # @param [Hash] options A customizable set of options. | |
58 | # @option options [String] content The content of the wiki page. | |
59 | # @option options [String] title The title of the wiki page. | |
60 | # @option options [String] format (optional) The format of the wiki page. Available formats are: markdown (default), rdoc, and asciidoc. | |
61 | # @return [Gitlab::ObjectifiedHash] Information about updated wiki page. | |
62 | def update_wiki(project, slug, options = {}) | |
63 | put("/projects/#{url_encode project}/wikis/#{slug}", body: options) | |
64 | end | |
65 | ||
66 | # Deletes a wiki page with a given slug. | |
67 | # | |
68 | # @example | |
69 | # Gitlab.delete_wiki(42, 'foo') | |
70 | # | |
71 | # @param [Integer, String] project The ID or name of a project. | |
72 | # @param [String] slug The slug (a unique string) of the wiki page. | |
73 | # @return [Gitlab::ObjectifiedHash] An empty objectified hash | |
74 | def delete_wiki(project, slug) | |
75 | delete("/projects/#{url_encode project}/wikis/#{slug}") | |
76 | end | |
77 | end | |
78 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | module Gitlab |
1 | 3 | # Wrapper for the Gitlab REST API. |
2 | 4 | class Client < API |
3 | Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f } | |
5 | Dir[File.expand_path('client/*.rb', __dir__)].each { |f| require f } | |
4 | 6 | |
5 | 7 | # Please keep in alphabetical order |
6 | 8 | include AccessRequests |
7 | 9 | include AwardEmojis |
8 | 10 | include Boards |
9 | 11 | include Branches |
12 | include BroadcastMessages | |
10 | 13 | include BuildVariables |
11 | 14 | include Builds |
12 | 15 | include Commits |
27 | 30 | include PipelineSchedules |
28 | 31 | include PipelineTriggers |
29 | 32 | include Pipelines |
33 | include ProjectBadges | |
30 | 34 | include Projects |
35 | include ProtectedTags | |
31 | 36 | include Repositories |
32 | 37 | include RepositoryFiles |
38 | include RepositorySubmodules | |
33 | 39 | include Runners |
34 | 40 | include Services |
35 | 41 | include Sidekiq |
36 | 42 | include Snippets |
37 | 43 | include SystemHooks |
38 | 44 | include Tags |
45 | include Templates | |
39 | 46 | include Todos |
40 | 47 | include Users |
48 | include Versions | |
49 | include Wikis | |
41 | 50 | |
42 | 51 | # Text representation of the client, masking private token. |
43 | 52 | # |
44 | 53 | # @return [String] |
45 | 54 | def inspect |
46 | 55 | inspected = super |
47 | ||
48 | if @private_token | |
49 | inspected = inspected.sub! @private_token, only_show_last_four_chars(@private_token) | |
50 | end | |
51 | ||
56 | inspected.sub! @private_token, only_show_last_four_chars(@private_token) if @private_token | |
52 | 57 | inspected |
53 | 58 | end |
54 | 59 | |
55 | def url_encode(s) | |
56 | URI.encode(s.to_s, /\W/) | |
60 | def url_encode(url) | |
61 | URI.encode(url.to_s, /\W/) | |
57 | 62 | end |
58 | 63 | |
59 | 64 | private |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'gitlab/cli_helpers' |
1 | 3 | module Gitlab |
2 | 4 | # Defines constants and methods related to configuration. |
3 | 5 | module Configuration |
4 | 6 | # An array of valid keys in the options hash when configuring a Gitlab::API. |
5 | VALID_OPTIONS_KEYS = %i(endpoint private_token user_agent sudo httparty).freeze | |
7 | VALID_OPTIONS_KEYS = %i[endpoint private_token user_agent sudo httparty].freeze | |
6 | 8 | |
7 | 9 | # The user agent that will be sent to the API endpoint if none is set. |
8 | DEFAULT_USER_AGENT = "Gitlab Ruby Gem #{Gitlab::VERSION}".freeze | |
10 | DEFAULT_USER_AGENT = "Gitlab Ruby Gem #{Gitlab::VERSION}" | |
9 | 11 | |
10 | 12 | # @private |
11 | 13 | attr_accessor(*VALID_OPTIONS_KEYS) |
12 | 14 | # @private |
13 | alias_method :auth_token=, :private_token= | |
15 | alias auth_token= private_token= | |
14 | 16 | |
15 | 17 | # Sets all configuration options to their default values |
16 | 18 | # when this module is extended. |
43 | 45 | |
44 | 46 | # Allows HTTParty config to be specified in ENV using YAML hash. |
45 | 47 | def get_httparty_config(options) |
46 | return options if options.nil? | |
48 | return if options.nil? | |
47 | 49 | |
48 | 50 | httparty = Gitlab::CLI::Helpers.yaml_load(options) |
51 | raise ArgumentError, 'HTTParty config should be a Hash.' unless httparty.is_a? Hash | |
49 | 52 | |
50 | raise ArgumentError, 'HTTParty config should be a Hash.' unless httparty.is_a? Hash | |
51 | 53 | Gitlab::CLI::Helpers.symbolize_keys httparty |
52 | 54 | end |
53 | 55 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | module Gitlab |
1 | 3 | module Error |
2 | 4 | # Custom error class for rescuing from all Gitlab errors. |
10 | 12 | |
11 | 13 | # Custom error class for rescuing from HTTP response errors. |
12 | 14 | class ResponseError < Error |
13 | POSSIBLE_MESSAGE_KEYS = %i(message error_description error) | |
15 | POSSIBLE_MESSAGE_KEYS = %i[message error_description error].freeze | |
14 | 16 | |
15 | 17 | def initialize(response) |
16 | 18 | @response = response |
56 | 58 | case message |
57 | 59 | when Gitlab::ObjectifiedHash |
58 | 60 | message.to_h.sort.map do |key, val| |
59 | "'#{key}' #{(val.is_a?(Hash) ? val.sort.map { |k, v| "(#{k}: #{v.join(' ')})" } : val).join(' ')}" | |
61 | "'#{key}' #{(val.is_a?(Hash) ? val.sort.map { |k, v| "(#{k}: #{v.join(' ')})" } : [val].flatten).join(' ')}" | |
60 | 62 | end.join(', ') |
61 | 63 | when Array |
62 | 64 | message.join(' ') |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | module Gitlab |
1 | 3 | # Wrapper class of file response. |
2 | 4 | class FileResponse |
3 | HEADER_CONTENT_DISPOSITION = 'Content-Disposition'.freeze | |
5 | HEADER_CONTENT_DISPOSITION = 'Content-Disposition' | |
4 | 6 | |
5 | 7 | attr_reader :filename |
6 | 8 | |
17 | 19 | def to_hash |
18 | 20 | { filename: @filename, data: @file } |
19 | 21 | end |
20 | alias_method :to_h, :to_hash | |
22 | alias to_h to_hash | |
21 | 23 | |
22 | 24 | # @return [String] Formatted string with the class name, object id and filename. |
23 | 25 | def inspect |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'gitlab' |
1 | 3 | require 'gitlab/cli_helpers' |
2 | 4 | |
31 | 33 | # @return [String] |
32 | 34 | def ri_cmd |
33 | 35 | which_ri = `which ri`.chomp |
34 | if which_ri.empty? | |
35 | raise "'ri' tool not found in $PATH. Please install it to use the help." | |
36 | end | |
36 | raise "'ri' tool not found in $PATH. Please install it to use the help." if which_ri.empty? | |
37 | 37 | |
38 | 38 | which_ri |
39 | 39 | end |
46 | 46 | def help_map |
47 | 47 | @help_map ||= begin |
48 | 48 | actions.each_with_object({}) do |action, hsh| |
49 | key = client.method(action). | |
50 | owner.to_s.gsub(/Gitlab::(?:Client::)?/, '') | |
49 | key = client.method(action) | |
50 | .owner.to_s.gsub(/Gitlab::(?:Client::)?/, '') | |
51 | 51 | hsh[key] ||= [] |
52 | 52 | hsh[key] << action.to_s |
53 | 53 | end |
57 | 57 | # Table with available commands. |
58 | 58 | # |
59 | 59 | # @return [Terminal::Table] |
60 | def actions_table(topic=nil) | |
60 | def actions_table(topic = nil) | |
61 | 61 | rows = topic ? help_map[topic] : help_map.keys |
62 | 62 | table do |t| |
63 | 63 | t.title = topic || 'Help Topics' |
72 | 72 | |
73 | 73 | # Returns full namespace of a command (e.g. Gitlab::Client::Branches.cmd) |
74 | 74 | def namespace(cmd) |
75 | method_owners.select { |method| method[:name] == cmd }. | |
76 | map { |method| method[:owner] + '.' + method[:name] }. | |
77 | shift | |
75 | method_owners.select { |method| method[:name] == cmd } | |
76 | .map { |method| method[:owner] + '.' + method[:name] } | |
77 | .shift | |
78 | 78 | end |
79 | 79 | |
80 | 80 | # Massage output from 'ri'. |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | module Gitlab |
1 | 3 | # Converts hashes to the objects. |
2 | 4 | class ObjectifiedHash |
3 | 5 | # Creates a new ObjectifiedHash object. |
4 | 6 | def initialize(hash) |
5 | 7 | @hash = hash |
6 | @data = hash.inject({}) do |data, (key, value)| | |
8 | @data = hash.each_with_object({}) do |(key, value), data| | |
7 | 9 | value = ObjectifiedHash.new(value) if value.is_a? Hash |
8 | 10 | data[key.to_s] = value |
9 | data | |
10 | 11 | end |
11 | 12 | end |
12 | 13 | |
14 | 15 | def to_hash |
15 | 16 | @hash |
16 | 17 | end |
17 | alias_method :to_h, :to_hash | |
18 | alias to_h to_hash | |
18 | 19 | |
19 | 20 | # @return [String] Formatted string with the class name, object id and original hash. |
20 | 21 | def inspect |
23 | 24 | |
24 | 25 | # Delegate to ObjectifiedHash. |
25 | 26 | def method_missing(key) |
26 | @data.key?(key.to_s) ? @data[key.to_s] : nil | |
27 | @data.key?(key.to_s) ? @data[key.to_s] : super | |
27 | 28 | end |
28 | 29 | |
29 | 30 | def respond_to_missing?(method_name, include_private = false) |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | module Gitlab |
1 | 3 | # Parses link header. |
2 | 4 | # |
3 | 5 | # @private |
4 | 6 | class PageLinks |
5 | HEADER_LINK = 'Link'.freeze | |
6 | DELIM_LINKS = ','.freeze | |
7 | LINK_REGEX = /<([^>]+)>; rel=\"([^\"]+)\"/ | |
8 | METAS = %w(last next first prev).freeze | |
7 | HEADER_LINK = 'Link' | |
8 | DELIM_LINKS = ',' | |
9 | LINK_REGEX = /<([^>]+)>; rel=\"([^\"]+)\"/.freeze | |
10 | METAS = %w[last next first prev].freeze | |
9 | 11 | |
10 | 12 | attr_accessor(*METAS) |
11 | 13 | |
12 | 14 | def initialize(headers) |
13 | 15 | link_header = headers[HEADER_LINK] |
14 | 16 | |
15 | if link_header && link_header =~ /(next|first|last|prev)/ | |
16 | extract_links(link_header) | |
17 | end | |
17 | extract_links(link_header) if link_header && link_header =~ /(next|first|last|prev)/ | |
18 | 18 | end |
19 | 19 | |
20 | 20 | private |
22 | 22 | def extract_links(header) |
23 | 23 | header.split(DELIM_LINKS).each do |link| |
24 | 24 | LINK_REGEX.match(link.strip) do |match| |
25 | url, meta = match[1], match[2] | |
25 | url = match[1] | |
26 | meta = match[2] | |
26 | 27 | next if !url || !meta || METAS.index(meta).nil? |
28 | ||
27 | 29 | send("#{meta}=", url) |
28 | 30 | end |
29 | 31 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | module Gitlab |
1 | 3 | # Wrapper class of paginated response. |
2 | 4 | class PaginatedResponse |
53 | 55 | response |
54 | 56 | end |
55 | 57 | |
56 | def has_last_page? | |
58 | def last_page? | |
57 | 59 | !(@links.nil? || @links.last.nil?) |
58 | 60 | end |
61 | alias has_last_page? last_page? | |
59 | 62 | |
60 | 63 | def last_page |
61 | 64 | return nil if @client.nil? || !has_last_page? |
65 | ||
62 | 66 | path = @links.last.sub(/#{@client.endpoint}/, '') |
63 | 67 | @client.get(path) |
64 | 68 | end |
65 | 69 | |
66 | def has_first_page? | |
70 | def first_page? | |
67 | 71 | !(@links.nil? || @links.first.nil?) |
68 | 72 | end |
73 | alias has_first_page? first_page? | |
69 | 74 | |
70 | 75 | def first_page |
71 | 76 | return nil if @client.nil? || !has_first_page? |
77 | ||
72 | 78 | path = @links.first.sub(/#{@client.endpoint}/, '') |
73 | 79 | @client.get(path) |
74 | 80 | end |
75 | 81 | |
76 | def has_next_page? | |
82 | def next_page? | |
77 | 83 | !(@links.nil? || @links.next.nil?) |
78 | 84 | end |
85 | alias has_next_page? next_page? | |
79 | 86 | |
80 | 87 | def next_page |
81 | 88 | return nil if @client.nil? || !has_next_page? |
89 | ||
82 | 90 | path = @links.next.sub(/#{@client.endpoint}/, '') |
83 | 91 | @client.get(path) |
84 | 92 | end |
85 | 93 | |
86 | def has_prev_page? | |
94 | def prev_page? | |
87 | 95 | !(@links.nil? || @links.prev.nil?) |
88 | 96 | end |
97 | alias has_prev_page? prev_page? | |
89 | 98 | |
90 | 99 | def prev_page |
91 | 100 | return nil if @client.nil? || !has_prev_page? |
101 | ||
92 | 102 | path = @links.prev.sub(/#{@client.endpoint}/, '') |
93 | 103 | @client.get(path) |
94 | 104 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'httparty' |
1 | 3 | require 'json' |
2 | 4 | |
6 | 8 | include HTTParty |
7 | 9 | format :json |
8 | 10 | headers 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded' |
9 | parser proc { |body, _| parse(body) } | |
11 | parser(proc { |body, _| parse(body) }) | |
10 | 12 | |
11 | 13 | attr_accessor :private_token, :endpoint |
12 | 14 | |
31 | 33 | |
32 | 34 | # Decodes a JSON response into Ruby object. |
33 | 35 | def self.decode(response) |
34 | return response ? JSON.load(response) : {} | |
36 | response ? JSON.load(response) : {} | |
35 | 37 | rescue JSON::ParserError |
36 | 38 | raise Error::Parsing, 'The response is not a valid JSON' |
37 | 39 | end |
38 | 40 | |
39 | %w(get post put delete).each do |method| | |
40 | define_method method do |path, options={}| | |
41 | %w[get post put delete].each do |method| | |
42 | define_method method do |path, options = {}| | |
41 | 43 | httparty_config(options) |
42 | 44 | authorization_header(options) |
43 | 45 | validate self.class.send(method, @endpoint + path, options) |
70 | 72 | |
71 | 73 | # Sets a base_uri and default_params for requests. |
72 | 74 | # @raise [Error::MissingCredentials] if endpoint not set. |
73 | def request_defaults(sudo=nil) | |
75 | def request_defaults(sudo = nil) | |
74 | 76 | self.class.default_params sudo: sudo |
75 | 77 | raise Error::MissingCredentials, 'Please set an endpoint to API' unless @endpoint |
78 | ||
76 | 79 | self.class.default_params.delete(:sudo) if sudo.nil? |
77 | 80 | end |
78 | 81 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'gitlab' |
1 | 3 | require 'gitlab/help' |
2 | 4 | require 'gitlab/cli_helpers' |
14 | 16 | trap('INT') { quit_shell } # capture ctrl-c |
15 | 17 | setup |
16 | 18 | |
17 | while buffer = Readline.readline('gitlab> ') | |
19 | while (buffer = Readline.readline('gitlab> ')) | |
18 | 20 | begin |
19 | 21 | parse_input buffer |
20 | 22 | |
33 | 35 | data = execute command, arguments |
34 | 36 | output_table command, arguments, data |
35 | 37 | end |
36 | rescue => e | |
38 | rescue StandardError => e | |
37 | 39 | puts e.message |
38 | 40 | end |
39 | 41 | end |
45 | 47 | buf = Shellwords.shellwords(buffer) |
46 | 48 | |
47 | 49 | @command = buf.shift |
48 | @arguments = buf.count > 0 ? buf : [] | |
50 | @arguments = buf.count.positive? ? buf : [] | |
49 | 51 | end |
50 | 52 | |
51 | 53 | def setup |
61 | 63 | end |
62 | 64 | |
63 | 65 | # Execute a given command with arguements |
64 | def execute(cmd=command, args=arguments) | |
66 | def execute(cmd = command, args = arguments) | |
65 | 67 | raise "Unknown command: #{cmd}. See the 'help' for a list of valid commands." unless actions.include?(cmd.to_sym) |
66 | 68 | |
67 | 69 | confirm_command(cmd) |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | class Gitlab::Shell |
1 | 3 | class History |
2 | 4 | DEFAULT_HISTFILESIZE = 200 |
3 | 5 | DEFAULT_FILE_PATH = File.join(Dir.home, '.gitlab_shell_history') |
4 | 6 | |
5 | def initialize(options={}) | |
7 | def initialize(options = {}) | |
6 | 8 | @file_path = options[:file_path] || DEFAULT_FILE_PATH |
7 | 9 | Readline::HISTORY.clear |
8 | 10 | end |
12 | 14 | end |
13 | 15 | |
14 | 16 | def save |
15 | lines.each { |line| history_file.puts line if history_file } | |
17 | lines.each { |line| history_file&.puts line } | |
16 | 18 | end |
17 | 19 | |
18 | 20 | def push(line) |
19 | 21 | Readline::HISTORY << line |
20 | 22 | end |
21 | alias_method :<<, :push | |
23 | alias << push | |
22 | 24 | |
23 | 25 | def lines |
24 | 26 | Readline::HISTORY.to_a.last(max_lines) |
30 | 32 | if defined?(@history_file) |
31 | 33 | @history_file |
32 | 34 | else |
33 | @history_file = File.open(history_file_path, 'w', 0600).tap do |file| | |
35 | @history_file = File.open(history_file_path, 'w', 0o600).tap do |file| | |
34 | 36 | file.sync = true |
35 | 37 | end |
36 | 38 | end |
47 | 49 | path = history_file_path |
48 | 50 | |
49 | 51 | File.foreach(path) { |line| yield(line) } if File.exist?(path) |
50 | rescue => error | |
52 | rescue StandardError => error | |
51 | 53 | warn "History file not loaded: #{error.message}" |
52 | 54 | end |
53 | 55 |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | module Gitlab |
1 | VERSION = '4.5.0'.freeze | |
3 | VERSION = '4.8.0' | |
2 | 4 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'gitlab/version' |
1 | 3 | require 'gitlab/objectified_hash' |
2 | 4 | require 'gitlab/configuration' |
14 | 16 | # Alias for Gitlab::Client.new |
15 | 17 | # |
16 | 18 | # @return [Gitlab::Client] |
17 | def self.client(options={}) | |
19 | def self.client(options = {}) | |
18 | 20 | Gitlab::Client.new(options) |
19 | 21 | end |
20 | 22 | |
21 | 23 | # Delegate to Gitlab::Client |
22 | 24 | def self.method_missing(method, *args, &block) |
23 | 25 | return super unless client.respond_to?(method) |
26 | ||
24 | 27 | client.send(method, *args, &block) |
25 | 28 | end |
26 | 29 | |
27 | 30 | # Delegate to Gitlab::Client |
28 | def self.respond_to_missing?(method_name, include_private=false) | |
31 | def self.respond_to_missing?(method_name, include_private = false) | |
29 | 32 | client.respond_to?(method_name) || super |
30 | 33 | end |
31 | 34 | |
32 | 35 | # Delegate to HTTParty.http_proxy |
33 | def self.http_proxy(address=nil, port=nil, username=nil, password=nil) | |
36 | def self.http_proxy(address = nil, port = nil, username = nil, password = nil) | |
34 | 37 | Gitlab::Request.http_proxy(address, port, username, password) |
35 | 38 | end |
36 | 39 |
0 | { | |
1 | "message":"Deploy in progress", | |
2 | "starts_at":"2016-08-24T23:21:16.078Z", | |
3 | "ends_at":"2016-08-26T23:21:16.080Z", | |
4 | "color":"#cecece", | |
5 | "font":"#FFFFFF", | |
6 | "id":1, | |
7 | "active":false | |
8 | } |
0 | [ | |
1 | { | |
2 | "message":"Example broadcast message", | |
3 | "starts_at":"2016-08-24T23:21:16.078Z", | |
4 | "ends_at":"2016-08-26T23:21:16.080Z", | |
5 | "color":"#E75E40", | |
6 | "font":"#FFFFFF", | |
7 | "id":1, | |
8 | "active": false | |
9 | } | |
10 | ] |
0 | { | |
1 | "name": "Binary", | |
2 | "content": "# This file is a template, and might need editing before it works on your project.\n# This Dockerfile installs a compiled binary into a bare system.\n# You must either commit your compiled binary into source control (not recommended)\n# or build the binary first as part of a CI/CD pipeline.\n\nFROM buildpack-deps:jessie\n\nWORKDIR /usr/local/bin\n\n# Change `app` to whatever your binary is called\nAdd app .\nCMD [\"./app\"]\n" | |
3 | } | |
4 |
0 | [ | |
1 | { | |
2 | "key": "Binary", | |
3 | "name": "Binary" | |
4 | }, | |
5 | { | |
6 | "key": "Binary-alpine", | |
7 | "name": "Binary-alpine" | |
8 | }, | |
9 | { | |
10 | "key": "Binary-scratch", | |
11 | "name": "Binary-scratch" | |
12 | }, | |
13 | { | |
14 | "key": "Golang", | |
15 | "name": "Golang" | |
16 | }, | |
17 | { | |
18 | "key": "Golang-alpine", | |
19 | "name": "Golang-alpine" | |
20 | }, | |
21 | { | |
22 | "key": "Golang-scratch", | |
23 | "name": "Golang-scratch" | |
24 | }, | |
25 | { | |
26 | "key": "HTTPd", | |
27 | "name": "HTTPd" | |
28 | }, | |
29 | { | |
30 | "key": "Node", | |
31 | "name": "Node" | |
32 | }, | |
33 | { | |
34 | "key": "Node-alpine", | |
35 | "name": "Node-alpine" | |
36 | }, | |
37 | { | |
38 | "key": "OpenJDK", | |
39 | "name": "OpenJDK" | |
40 | }, | |
41 | { | |
42 | "key": "OpenJDK-alpine", | |
43 | "name": "OpenJDK-alpine" | |
44 | }, | |
45 | { | |
46 | "key": "PHP", | |
47 | "name": "PHP" | |
48 | }, | |
49 | { | |
50 | "key": "Python", | |
51 | "name": "Python" | |
52 | }, | |
53 | { | |
54 | "key": "Python-alpine", | |
55 | "name": "Python-alpine" | |
56 | }, | |
57 | { | |
58 | "key": "Python2", | |
59 | "name": "Python2" | |
60 | }, | |
61 | { | |
62 | "key": "Ruby", | |
63 | "name": "Ruby" | |
64 | }, | |
65 | { | |
66 | "key": "Ruby-alpine", | |
67 | "name": "Ruby-alpine" | |
68 | } | |
69 | ] |
0 | { | |
1 | "name": "Ruby", | |
2 | "content": "*.gem\n*.rbc\n/.config\n/coverage/\n/InstalledFiles\n/pkg/\n/spec/reports/\n/spec/examples.txt\n/test/tmp/\n/test/version_tmp/\n/tmp/\n\n# Used by dotenv library to load environment variables.\n# .env\n\n## Specific to RubyMotion:\n.dat*\n.repl_history\nbuild/\n*.bridgesupport\nbuild-iPhoneOS/\nbuild-iPhoneSimulator/\n\n## Specific to RubyMotion (use of CocoaPods):\n#\n# We recommend against adding the Pods directory to your .gitignore. However\n# you should judge for yourself, the pros and cons are mentioned at:\n# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control\n#\n# vendor/Pods/\n\n## Documentation cache and generated files:\n/.yardoc/\n/_yardoc/\n/doc/\n/rdoc/\n\n## Environment normalization:\n/.bundle/\n/vendor/bundle\n/lib/bundler/man/\n\n# for a library or gem, you might want to ignore these files since the code is\n# intended to run in multiple environments; otherwise, check them in:\n# Gemfile.lock\n# .ruby-version\n# .ruby-gemset\n\n# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:\n.rvmrc\n" | |
3 | } |
0 | [ | |
1 | { | |
2 | "key": "Actionscript", | |
3 | "name": "Actionscript" | |
4 | }, | |
5 | { | |
6 | "key": "Ada", | |
7 | "name": "Ada" | |
8 | }, | |
9 | { | |
10 | "key": "Agda", | |
11 | "name": "Agda" | |
12 | }, | |
13 | { | |
14 | "key": "Android", | |
15 | "name": "Android" | |
16 | }, | |
17 | { | |
18 | "key": "AppEngine", | |
19 | "name": "AppEngine" | |
20 | }, | |
21 | { | |
22 | "key": "AppceleratorTitanium", | |
23 | "name": "AppceleratorTitanium" | |
24 | }, | |
25 | { | |
26 | "key": "ArchLinuxPackages", | |
27 | "name": "ArchLinuxPackages" | |
28 | }, | |
29 | { | |
30 | "key": "Autotools", | |
31 | "name": "Autotools" | |
32 | }, | |
33 | { | |
34 | "key": "C", | |
35 | "name": "C" | |
36 | }, | |
37 | { | |
38 | "key": "C++", | |
39 | "name": "C++" | |
40 | }, | |
41 | { | |
42 | "key": "CFWheels", | |
43 | "name": "CFWheels" | |
44 | }, | |
45 | { | |
46 | "key": "CMake", | |
47 | "name": "CMake" | |
48 | }, | |
49 | { | |
50 | "key": "CUDA", | |
51 | "name": "CUDA" | |
52 | }, | |
53 | { | |
54 | "key": "CakePHP", | |
55 | "name": "CakePHP" | |
56 | }, | |
57 | { | |
58 | "key": "ChefCookbook", | |
59 | "name": "ChefCookbook" | |
60 | }, | |
61 | { | |
62 | "key": "Clojure", | |
63 | "name": "Clojure" | |
64 | }, | |
65 | { | |
66 | "key": "CodeIgniter", | |
67 | "name": "CodeIgniter" | |
68 | }, | |
69 | { | |
70 | "key": "CommonLisp", | |
71 | "name": "CommonLisp" | |
72 | }, | |
73 | { | |
74 | "key": "Composer", | |
75 | "name": "Composer" | |
76 | }, | |
77 | { | |
78 | "key": "Concrete5", | |
79 | "name": "Concrete5" | |
80 | } | |
81 | ] |
0 | { | |
1 | "name": "Ruby", | |
2 | "content": "# This file is a template, and might need editing before it works on your project.\n# Official language image. Look for the different tagged releases at:\n# https://hub.docker.com/r/library/ruby/tags/\nimage: \"ruby:2.3\"\n\n# Pick zero or more services to be used on all builds.\n# Only needed when using a docker container to run your tests in.\n# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service\nservices:\n - mysql:latest\n - redis:latest\n - postgres:latest\n\nvariables:\n POSTGRES_DB: database_name\n\n# Cache gems in between builds\ncache:\n paths:\n - vendor/ruby\n\n# This is a basic example for a gem or script which doesn't use\n# services such as redis or postgres\nbefore_script:\n - ruby -v # Print out ruby version for debugging\n # Uncomment next line if your rails app needs a JS runtime:\n # - apt-get update -q && apt-get install nodejs -yqq\n - gem install bundler --no-ri --no-rdoc # Bundler is not installed with the image\n - bundle install -j $(nproc) --path vendor # Install dependencies into ./vendor/ruby\n\n# Optional - Delete if not using `rubocop`\nrubocop:\n script:\n - rubocop\n\nrspec:\n script:\n - rspec spec\n\nrails:\n variables:\n DATABASE_URL: \"postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB\"\n script:\n - bundle exec rake db:migrate\n - bundle exec rake db:seed\n - bundle exec rake test\n" | |
3 | } |
0 | [ | |
1 | { | |
2 | "key": "Android", | |
3 | "name": "Android" | |
4 | }, | |
5 | { | |
6 | "key": "Auto-DevOps", | |
7 | "name": "Auto-DevOps" | |
8 | }, | |
9 | { | |
10 | "key": "Bash", | |
11 | "name": "Bash" | |
12 | }, | |
13 | { | |
14 | "key": "C++", | |
15 | "name": "C++" | |
16 | }, | |
17 | { | |
18 | "key": "Chef", | |
19 | "name": "Chef" | |
20 | }, | |
21 | { | |
22 | "key": "Clojure", | |
23 | "name": "Clojure" | |
24 | }, | |
25 | { | |
26 | "key": "Crystal", | |
27 | "name": "Crystal" | |
28 | }, | |
29 | { | |
30 | "key": "Django", | |
31 | "name": "Django" | |
32 | }, | |
33 | { | |
34 | "key": "Docker", | |
35 | "name": "Docker" | |
36 | }, | |
37 | { | |
38 | "key": "Elixir", | |
39 | "name": "Elixir" | |
40 | }, | |
41 | { | |
42 | "key": "Go", | |
43 | "name": "Go" | |
44 | }, | |
45 | { | |
46 | "key": "Gradle", | |
47 | "name": "Gradle" | |
48 | }, | |
49 | { | |
50 | "key": "Grails", | |
51 | "name": "Grails" | |
52 | }, | |
53 | { | |
54 | "key": "Julia", | |
55 | "name": "Julia" | |
56 | }, | |
57 | { | |
58 | "key": "LaTeX", | |
59 | "name": "LaTeX" | |
60 | }, | |
61 | { | |
62 | "key": "Laravel", | |
63 | "name": "Laravel" | |
64 | }, | |
65 | { | |
66 | "key": "Maven", | |
67 | "name": "Maven" | |
68 | }, | |
69 | { | |
70 | "key": "Mono", | |
71 | "name": "Mono" | |
72 | }, | |
73 | { | |
74 | "key": "Nodejs", | |
75 | "name": "Nodejs" | |
76 | }, | |
77 | { | |
78 | "key": "OpenShift", | |
79 | "name": "OpenShift" | |
80 | } | |
81 | ] |
0 | { | |
1 | "key": "mit", | |
2 | "name": "MIT License", | |
3 | "nickname": null, | |
4 | "popular": true, | |
5 | "html_url": "http://choosealicense.com/licenses/mit/", | |
6 | "source_url": "https://opensource.org/licenses/MIT", | |
7 | "description": "A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.", | |
8 | "conditions": [ | |
9 | "include-copyright" | |
10 | ], | |
11 | "permissions": [ | |
12 | "commercial-use", | |
13 | "modifications", | |
14 | "distribution", | |
15 | "private-use" | |
16 | ], | |
17 | "limitations": [ | |
18 | "liability", | |
19 | "warranty" | |
20 | ], | |
21 | "content": "MIT License\n\nCopyright (c) 2018 [fullname]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" | |
22 | }⏎ |
0 | { | |
1 | "key": "mit", | |
2 | "name": "MIT License", | |
3 | "nickname": null, | |
4 | "featured": true, | |
5 | "html_url": "http://choosealicense.com/licenses/mit/", | |
6 | "source_url": "http://opensource.org/licenses/MIT", | |
7 | "description": "A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty.", | |
8 | "conditions": [ | |
9 | "include-copyright" | |
10 | ], | |
11 | "permissions": [ | |
12 | "commercial-use", | |
13 | "modifications", | |
14 | "distribution", | |
15 | "private-use" | |
16 | ], | |
17 | "limitations": [ | |
18 | "no-liability" | |
19 | ], | |
20 | "content": "The MIT License (MIT)\n\nCopyright (c) 2016 John Doe\n [...]" | |
21 | } |
0 | [ | |
1 | { | |
2 | "key": "apache-2.0", | |
3 | "name": "Apache License 2.0", | |
4 | "nickname": null, | |
5 | "featured": true, | |
6 | "html_url": "http://choosealicense.com/licenses/apache-2.0/", | |
7 | "source_url": "http://www.apache.org/licenses/LICENSE-2.0.html", | |
8 | "description": "A permissive license that also provides an express grant of patent rights from contributors to users.", | |
9 | "conditions": [ | |
10 | "include-copyright", | |
11 | "document-changes" | |
12 | ], | |
13 | "permissions": [ | |
14 | "commercial-use", | |
15 | "modifications", | |
16 | "distribution", | |
17 | "patent-use", | |
18 | "private-use" | |
19 | ], | |
20 | "limitations": [ | |
21 | "trademark-use", | |
22 | "no-liability" | |
23 | ], | |
24 | "content": " Apache License\n Version 2.0, January 2004\n [...]" | |
25 | }, | |
26 | { | |
27 | "key": "gpl-3.0", | |
28 | "name": "GNU General Public License v3.0", | |
29 | "nickname": "GNU GPLv3", | |
30 | "featured": true, | |
31 | "html_url": "http://choosealicense.com/licenses/gpl-3.0/", | |
32 | "source_url": "http://www.gnu.org/licenses/gpl-3.0.txt", | |
33 | "description": "The GNU GPL is the most widely used free software license and has a strong copyleft requirement. When distributing derived works, the source code of the work must be made available under the same license.", | |
34 | "conditions": [ | |
35 | "include-copyright", | |
36 | "document-changes", | |
37 | "disclose-source", | |
38 | "same-license" | |
39 | ], | |
40 | "permissions": [ | |
41 | "commercial-use", | |
42 | "modifications", | |
43 | "distribution", | |
44 | "patent-use", | |
45 | "private-use" | |
46 | ], | |
47 | "limitations": [ | |
48 | "no-liability" | |
49 | ], | |
50 | "content": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n [...]" | |
51 | }, | |
52 | { | |
53 | "key": "mit", | |
54 | "name": "MIT License", | |
55 | "nickname": null, | |
56 | "featured": true, | |
57 | "html_url": "http://choosealicense.com/licenses/mit/", | |
58 | "source_url": "http://opensource.org/licenses/MIT", | |
59 | "description": "A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty.", | |
60 | "conditions": [ | |
61 | "include-copyright" | |
62 | ], | |
63 | "permissions": [ | |
64 | "commercial-use", | |
65 | "modifications", | |
66 | "distribution", | |
67 | "private-use" | |
68 | ], | |
69 | "limitations": [ | |
70 | "no-liability" | |
71 | ], | |
72 | "content": "The MIT License (MIT)\n\nCopyright (c) [year] [fullname]\n [...]" | |
73 | } | |
74 | ] |
0 | { | |
1 | "id": "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863", | |
2 | "short_id": "1a0b36b3", | |
3 | "title": "Initial commit", | |
4 | "created_at": "2014-02-27T08:03:18.000Z", | |
5 | "parent_ids": [], | |
6 | "message": "Initial commit\n", | |
7 | "author_name": "Dmitriy Zaporozhets", | |
8 | "author_email": "dmitriy.zaporozhets@gmail.com", | |
9 | "authored_date": "2014-02-27T08:03:18.000Z", | |
10 | "committer_name": "Dmitriy Zaporozhets", | |
11 | "committer_email": "dmitriy.zaporozhets@gmail.com", | |
12 | "committed_date": "2014-02-27T08:03:18.000Z" | |
13 | } |
0 | { | |
1 | "id": 110, | |
2 | "head_commit_sha": "33e2ee8579fda5bc36accc9c6fbd0b4fefda9e30", | |
3 | "base_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", | |
4 | "start_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", | |
5 | "created_at": "2016-07-26T14:44:48.926Z", | |
6 | "merge_request_id": 105, | |
7 | "state": "collected", | |
8 | "real_size": "1", | |
9 | "commits": [{ | |
10 | "id": "33e2ee8579fda5bc36accc9c6fbd0b4fefda9e30", | |
11 | "short_id": "33e2ee85", | |
12 | "title": "Change year to 2018", | |
13 | "author_name": "Administrator", | |
14 | "author_email": "admin@example.com", | |
15 | "created_at": "2016-07-26T17:44:29.000+03:00", | |
16 | "message": "Change year to 2018" | |
17 | }, { | |
18 | "id": "aa24655de48b36335556ac8a3cd8bb521f977cbd", | |
19 | "short_id": "aa24655d", | |
20 | "title": "Update LICENSE", | |
21 | "author_name": "Administrator", | |
22 | "author_email": "admin@example.com", | |
23 | "created_at": "2016-07-25T17:21:53.000+03:00", | |
24 | "message": "Update LICENSE" | |
25 | }, { | |
26 | "id": "3eed087b29835c48015768f839d76e5ea8f07a24", | |
27 | "short_id": "3eed087b", | |
28 | "title": "Add license", | |
29 | "author_name": "Administrator", | |
30 | "author_email": "admin@example.com", | |
31 | "created_at": "2016-07-25T17:21:20.000+03:00", | |
32 | "message": "Add license" | |
33 | }], | |
34 | "diffs": [{ | |
35 | "old_path": "LICENSE", | |
36 | "new_path": "LICENSE", | |
37 | "a_mode": "0", | |
38 | "b_mode": "100644", | |
39 | "diff": "--- /dev/null\n+++ b/LICENSE\n@@ -0,0 +1,21 @@\n+The MIT License (MIT)\n+\n+Copyright (c) 2018 Administrator\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n", | |
40 | "new_file": true, | |
41 | "renamed_file": false, | |
42 | "deleted_file": false | |
43 | }] | |
44 | } |
0 | [{ | |
1 | "id": 110, | |
2 | "head_commit_sha": "33e2ee8579fda5bc36accc9c6fbd0b4fefda9e30", | |
3 | "base_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", | |
4 | "start_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", | |
5 | "created_at": "2016-07-26T14:44:48.926Z", | |
6 | "merge_request_id": 105, | |
7 | "state": "collected", | |
8 | "real_size": "1" | |
9 | }, { | |
10 | "id": 108, | |
11 | "head_commit_sha": "3eed087b29835c48015768f839d76e5ea8f07a24", | |
12 | "base_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", | |
13 | "start_commit_sha": "eeb57dffe83deb686a60a71c16c32f71046868fd", | |
14 | "created_at": "2016-07-25T14:21:33.028Z", | |
15 | "merge_request_id": 105, | |
16 | "state": "collected", | |
17 | "real_size": "1" | |
18 | }] |
0 | [{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":2,"email":"john2@example.com","name":"John Smith 2","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith 2","blocked":false,"created_at":"2012-10-19T05:56:14Z"}},{"id":2,"target_branch":"master","source_branch":"api","project_id":2,"title":"New feature 2","closed":false,"merged":false,"author":{"id":2,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":4,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}] |
0 | [ | |
1 | { | |
2 | "id": 1, | |
3 | "name": "John Doe1", | |
4 | "username": "user1", | |
5 | "state": "active", | |
6 | "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon", | |
7 | "web_url": "http://localhost/user1" | |
8 | }, | |
9 | { | |
10 | "id": 5, | |
11 | "name": "John Doe5", | |
12 | "username": "user5", | |
13 | "state": "active", | |
14 | "avatar_url": "http://www.gravatar.com/avatar/4aea8cf834ed91844a2da4ff7ae6b491?s=80&d=identicon", | |
15 | "web_url": "http://localhost/user5" | |
16 | } | |
17 | ] |
0 | { | |
1 | "link_url": "http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}", | |
2 | "image_url": "https://shields.io/my/badge", | |
3 | "rendered_link_url": "http://example.com/ci_status.svg?project=example-org/example-project&ref=master", | |
4 | "rendered_image_url": "https://shields.io/my/badge" | |
5 | } |
0 | { | |
1 | "id": 1, | |
2 | "link_url": "http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}", | |
3 | "image_url": "https://shields.io/my/badge", | |
4 | "rendered_link_url": "http://example.com/ci_status.svg?project=example-org/example-project&ref=master", | |
5 | "rendered_image_url": "https://shields.io/my/badge", | |
6 | "kind": "project" | |
7 | } |
0 | [ | |
1 | { | |
2 | "id": 1, | |
3 | "link_url": "http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}", | |
4 | "image_url": "https://shields.io/my/badge", | |
5 | "rendered_link_url": "http://example.com/ci_status.svg?project=example-org/example-project&ref=master", | |
6 | "rendered_image_url": "https://shields.io/my/badge", | |
7 | "kind": "project" | |
8 | }, | |
9 | { | |
10 | "id": 2, | |
11 | "link_url": "http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}", | |
12 | "image_url": "https://shields.io/my/badge", | |
13 | "rendered_link_url": "http://example.com/ci_status.svg?project=example-org/example-project&ref=master", | |
14 | "rendered_image_url": "https://shields.io/my/badge", | |
15 | "kind": "group" | |
16 | } | |
17 | ] |
0 | [ | |
1 | { | |
2 | "key": "epl-1.0", | |
3 | "name": "Eclipse Public License 1.0" | |
4 | }, | |
5 | { | |
6 | "key": "lgpl-3.0", | |
7 | "name": "GNU Lesser General Public License v3.0" | |
8 | }, | |
9 | { | |
10 | "key": "unlicense", | |
11 | "name": "The Unlicense" | |
12 | }, | |
13 | { | |
14 | "key": "agpl-3.0", | |
15 | "name": "GNU Affero General Public License v3.0" | |
16 | }, | |
17 | { | |
18 | "key": "gpl-3.0", | |
19 | "name": "GNU General Public License v3.0" | |
20 | }, | |
21 | { | |
22 | "key": "bsd-3-clause", | |
23 | "name": "BSD 3-clause \"New\" or \"Revised\" License" | |
24 | }, | |
25 | { | |
26 | "key": "lgpl-2.1", | |
27 | "name": "GNU Lesser General Public License v2.1" | |
28 | }, | |
29 | { | |
30 | "key": "mit", | |
31 | "name": "MIT License" | |
32 | }, | |
33 | { | |
34 | "key": "apache-2.0", | |
35 | "name": "Apache License 2.0" | |
36 | }, | |
37 | { | |
38 | "key": "bsd-2-clause", | |
39 | "name": "BSD 2-clause \"Simplified\" License" | |
40 | }, | |
41 | { | |
42 | "key": "mpl-2.0", | |
43 | "name": "Mozilla Public License 2.0" | |
44 | }, | |
45 | { | |
46 | "key": "gpl-2.0", | |
47 | "name": "GNU General Public License v2.0" | |
48 | } | |
49 | ] |
0 | { | |
1 | "name": "master", | |
2 | "push_access_levels": [ | |
3 | { | |
4 | "access_level": 40, | |
5 | "access_level_description": "Maintainers" | |
6 | } | |
7 | ], | |
8 | "merge_access_levels": [ | |
9 | { | |
10 | "access_level": 40, | |
11 | "access_level_description": "Maintainers" | |
12 | } | |
13 | ] | |
14 | } |
0 | [ | |
1 | { | |
2 | "name": "master", | |
3 | "push_access_levels": [ | |
4 | { | |
5 | "access_level": 40, | |
6 | "access_level_description": "Maintainers" | |
7 | } | |
8 | ], | |
9 | "merge_access_levels": [ | |
10 | { | |
11 | "access_level": 40, | |
12 | "access_level_description": "Maintainers" | |
13 | } | |
14 | ] | |
15 | } | |
16 | ] |
0 | { | |
1 | "name": "release-1-0", | |
2 | "create_access_levels": [ | |
3 | { | |
4 | "access_level": 40, | |
5 | "access_level_description": "Maintainers" | |
6 | } | |
7 | ] | |
8 | } |
0 | [ | |
1 | { | |
2 | "name": "release-1-0", | |
3 | "create_access_levels": [ | |
4 | { | |
5 | "access_level": 40, | |
6 | "access_level_description": "Maintainers" | |
7 | } | |
8 | ] | |
9 | } | |
10 | ] |
0 | { | |
1 | "id": "ed899a2f4b50b4370feeea94676502b42383c746", | |
2 | "short_id": "ed899a2f4b5", | |
3 | "title": "Updated submodule example_submodule with oid 3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88", | |
4 | "author_name": "Dmitriy Zaporozhets", | |
5 | "author_email": "dzaporozhets@sphereconsultinginc.com", | |
6 | "committer_name": "Dmitriy Zaporozhets", | |
7 | "committer_email": "dzaporozhets@sphereconsultinginc.com", | |
8 | "created_at": "2018-09-20T09:26:24.000-07:00", | |
9 | "message": "Updated submodule example_submodule with oid 3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88", | |
10 | "parent_ids": [ | |
11 | "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" | |
12 | ], | |
13 | "committed_date": "2018-09-20T09:26:24.000-07:00", | |
14 | "authored_date": "2018-09-20T09:26:24.000-07:00", | |
15 | "status": null | |
16 | } |
0 | {"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z","access_level":40}⏎ | |
0 | { | |
1 | "id": 1, | |
2 | "username": "john_smith", | |
3 | "name": "John Smith", | |
4 | "state": "active", | |
5 | "avatar_url": "https://www.gravatar.com/avatar/c2525a7f58ae3776070e44c106c48e15?s=80&d=identicon", | |
6 | "web_url": "http://192.168.1.8:3000/root", | |
7 | "expires_at": "2018-12-31T00:00:00Z", | |
8 | "access_level": 40 | |
9 | }⏎ |
0 | { | |
1 | "id": 1, | |
2 | "description": null, | |
3 | "name": "test", | |
4 | "name_with_namespace": "Yolo / test", | |
5 | "path": "test", | |
6 | "path_with_namespace": "yolo/test", | |
7 | "created_at": "2018-10-26T21:14:12.851Z", | |
8 | "default_branch": "master", | |
9 | "tag_list": [], | |
10 | "ssh_url_to_repo": "git@gitlab.com:yolo/test.git", | |
11 | "http_url_to_repo": "https://gitlab.com/yolo/test.git", | |
12 | "web_url": "https://gitlab.com/yolo/test", | |
13 | "readme_url": null, | |
14 | "avatar_url": null, | |
15 | "star_count": 0, | |
16 | "forks_count": 0, | |
17 | "last_activity_at": "2018-10-26T21:14:12.851Z", | |
18 | "namespace": { | |
19 | "id": 2, | |
20 | "name": "Yolo", | |
21 | "path": "yolo", | |
22 | "kind": "group", | |
23 | "full_path": "yolo", | |
24 | "parent_id": null | |
25 | }, | |
26 | "_links": { | |
27 | "self": "https://gitlab.com/api/v4/projects/1", | |
28 | "issues": "https://gitlab.com/api/v4/projects/1/issues", | |
29 | "merge_requests": "https://gitlab.com/api/v4/projects/1/merge_requests", | |
30 | "repo_branches": "https://gitlab.com/api/v4/projects/1/repository/branches", | |
31 | "labels": "https://gitlab.com/api/v4/projects/1/labels", | |
32 | "events": "https://gitlab.com/api/v4/projects/1/events", | |
33 | "members": "https://gitlab.com/api/v4/projects/1/members" | |
34 | }, | |
35 | "archived": false, | |
36 | "visibility": "private", | |
37 | "resolve_outdated_diff_discussions": false, | |
38 | "container_registry_enabled": true, | |
39 | "issues_enabled": true, | |
40 | "merge_requests_enabled": true, | |
41 | "wiki_enabled": true, | |
42 | "jobs_enabled": true, | |
43 | "snippets_enabled": true, | |
44 | "shared_runners_enabled": true, | |
45 | "lfs_enabled": true, | |
46 | "creator_id": 42, | |
47 | "import_status": "none", | |
48 | "open_issues_count": 0, | |
49 | "public_jobs": true, | |
50 | "ci_config_path": null, | |
51 | "shared_with_groups": [], | |
52 | "only_allow_merge_if_pipeline_succeeds": false, | |
53 | "request_access_enabled": false, | |
54 | "only_allow_merge_if_all_discussions_are_resolved": false, | |
55 | "printing_merge_request_link_enabled": true, | |
56 | "merge_method": "merge", | |
57 | "mirror": false | |
58 | } |
0 | { | |
1 | "alt": "null", | |
2 | "url": "/uploads/f22e67e35e1bcb339058212c54bb8772/null", | |
3 | "markdown": "[null](/uploads/f22e67e35e1bcb339058212c54bb8772/null)" | |
4 | } |
0 | { | |
1 | "file_name" : "dk.png", | |
2 | "file_path" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png", | |
3 | "branch" : "master", | |
4 | "link" : { | |
5 | "url" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png", | |
6 | "markdown" : "![dk](uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png)" | |
7 | } | |
8 | } |
0 | [ | |
1 | { | |
2 | "content" : "Here is an instruction how to deploy this project.", | |
3 | "format" : "markdown", | |
4 | "slug" : "deploy", | |
5 | "title" : "deploy" | |
6 | }, | |
7 | { | |
8 | "content" : "Our development process is described here.", | |
9 | "format" : "markdown", | |
10 | "slug" : "development", | |
11 | "title" : "development" | |
12 | },{ | |
13 | "content" : "* [Deploy](deploy)\n* [Development](development)", | |
14 | "format" : "markdown", | |
15 | "slug" : "home", | |
16 | "title" : "home" | |
17 | } | |
18 | ] |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::API do |
3 | 5 | let(:default_headers) { subject.class.default_options[:headers] } |
4 | 6 | |
5 | describe ".default_options[:headers]" do | |
7 | describe '.default_options[:headers]' do | |
6 | 8 | it "has 'User-Agent'" do |
7 | 9 | expect(default_headers).to include('User-Agent' => Gitlab::Configuration::DEFAULT_USER_AGENT) |
8 | 10 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::CLI::Helpers do |
3 | describe ".method_owners" do | |
4 | let(:methods) { Gitlab::CLI::Helpers.method_owners } | |
5 | describe '.method_owners' do | |
6 | let(:methods) { described_class.method_owners } | |
5 | 7 | |
6 | it "returns Array of Hashes containing method names and owners" do | |
8 | it 'returns Array of Hashes containing method names and owners' do | |
7 | 9 | expect(methods).to be_a Array |
8 | 10 | expect(methods.all? { |m| m.is_a? Hash }).to be true |
9 | expect(methods.all? { |m| m.keys.sort == %i(name owner) }).to be true | |
11 | expect(methods.all? { |m| m.keys.sort == %i[name owner] }).to be true | |
10 | 12 | end |
11 | 13 | end |
12 | 14 | |
13 | describe ".valid_command?" do | |
14 | it "returns true when command is valid" do | |
15 | expect(Gitlab::CLI::Helpers.valid_command?('merge_requests')).to be_truthy | |
15 | describe '.valid_command?' do | |
16 | it 'returns true when command is valid' do | |
17 | expect(described_class).to be_valid_command('merge_requests') | |
16 | 18 | end |
17 | it "returns false when command is NOT valid" do | |
18 | expect(Gitlab::CLI::Helpers.valid_command?('mmmmmerge_requests')).to be_falsy | |
19 | it 'returns false when command is NOT valid' do | |
20 | expect(described_class).not_to be_valid_command('mmmmmerge_requests') | |
19 | 21 | end |
20 | 22 | end |
21 | 23 | |
22 | describe ".symbolize_keys" do | |
23 | context "when input is a Hash" do | |
24 | it "returns a Hash with symbols for keys" do | |
24 | describe '.symbolize_keys' do | |
25 | context 'when input is a Hash' do | |
26 | it 'returns a Hash with symbols for keys' do | |
25 | 27 | hash = { 'key1' => 'val1', 'key2' => 'val2' } |
26 | symbolized_hash = Gitlab::CLI::Helpers.symbolize_keys(hash) | |
28 | symbolized_hash = described_class.symbolize_keys(hash) | |
27 | 29 | expect(symbolized_hash).to eq(key1: 'val1', key2: 'val2') |
28 | 30 | end |
29 | 31 | end |
30 | context "when input is NOT a Hash" do | |
31 | it "returns input untouched" do | |
32 | ||
33 | context 'when input is NOT a Hash' do | |
34 | it 'returns input untouched' do | |
32 | 35 | array = [1, 2, 3] |
33 | new_array = Gitlab::CLI::Helpers.symbolize_keys(array) | |
36 | new_array = described_class.symbolize_keys(array) | |
34 | 37 | expect(new_array).to eq([1, 2, 3]) |
35 | 38 | end |
36 | 39 | end |
37 | 40 | end |
38 | 41 | |
39 | describe ".yaml_load" do | |
40 | context "when argument is a YAML string" do | |
41 | it "returns Ruby objects" do | |
42 | argument = "{foo: bar, sna: fu}" | |
43 | output = Gitlab::CLI::Helpers.yaml_load argument | |
42 | describe '.yaml_load' do | |
43 | context 'when argument is a YAML string' do | |
44 | it 'returns Ruby objects' do | |
45 | argument = '{foo: bar, sna: fu}' | |
46 | output = described_class.yaml_load argument | |
44 | 47 | expect(output).to eq('foo' => 'bar', 'sna' => 'fu') |
45 | 48 | end |
46 | 49 | end |
47 | 50 | |
48 | context "when input is NOT valid YAML" do | |
49 | it "raises a TypeError" do | |
51 | context 'when input is NOT valid YAML' do | |
52 | it 'raises a TypeError' do | |
50 | 53 | ruby_array = [1, 2, 3, 4] |
51 | expect { Gitlab::CLI::Helpers.yaml_load ruby_array }.to raise_error TypeError | |
54 | expect { described_class.yaml_load ruby_array }.to raise_error TypeError | |
52 | 55 | end |
53 | 56 | end |
54 | 57 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | require 'json' |
2 | 4 | |
3 | 5 | describe Gitlab::CLI do |
4 | describe ".run" do | |
5 | context "when command is version" do | |
6 | it "shows gem version" do | |
7 | output = capture_output { Gitlab::CLI.run('-v') } | |
6 | describe '.run' do | |
7 | context 'when command is version' do | |
8 | it 'shows gem version' do | |
9 | output = capture_output { described_class.run('-v') } | |
8 | 10 | expect(output).to eq("Gitlab Ruby Gem #{Gitlab::VERSION}\n") |
9 | 11 | end |
10 | 12 | end |
11 | 13 | |
12 | context "when command is info" do | |
13 | it "shows environment info" do | |
14 | output = capture_output { Gitlab::CLI.run('info') } | |
15 | expect(output).to include("Gitlab endpoint is") | |
16 | expect(output).to include("Gitlab private token is") | |
17 | expect(output).to include("Ruby Version is") | |
18 | expect(output).to include("Gitlab Ruby Gem") | |
14 | context 'when command is info' do | |
15 | it 'shows environment info' do | |
16 | output = capture_output { described_class.run('info') } | |
17 | expect(output).to include('Gitlab endpoint is') | |
18 | expect(output).to include('Gitlab private token is') | |
19 | expect(output).to include('Ruby Version is') | |
20 | expect(output).to include('Gitlab Ruby Gem') | |
19 | 21 | end |
20 | 22 | end |
21 | 23 | |
22 | context "when command is help" do | |
23 | it "shows available actions" do | |
24 | output = capture_output { Gitlab::CLI.run('help') } | |
24 | context 'when command is help' do | |
25 | it 'shows available actions' do | |
26 | output = capture_output { described_class.run('help') } | |
25 | 27 | expect(output).to include('Help Topics') |
26 | 28 | expect(output).to include('MergeRequests') |
27 | 29 | end |
28 | 30 | end |
29 | 31 | |
30 | context "when command is user" do | |
32 | context 'when command is user' do | |
31 | 33 | before do |
32 | stub_get("/user", "user") | |
33 | @output = capture_output { Gitlab::CLI.run('user') } | |
34 | stub_get('/user', 'user') | |
35 | @output = capture_output { described_class.run('user') } | |
34 | 36 | end |
35 | 37 | |
36 | it "shows executed command" do | |
38 | it 'shows executed command' do | |
37 | 39 | expect(@output).to include('Gitlab.user') |
38 | 40 | end |
39 | 41 | |
40 | it "shows user data" do | |
42 | it 'shows user data' do | |
41 | 43 | expect(@output).to include('name') |
42 | 44 | expect(@output).to include('John Smith') |
43 | 45 | end |
44 | 46 | end |
45 | 47 | |
46 | context "when command is users" do | |
48 | context 'when command is users' do | |
47 | 49 | before do |
48 | stub_get("/users", "users") | |
49 | @output = capture_output { Gitlab::CLI.run('users') } | |
50 | stub_get('/users', 'users') | |
51 | @output = capture_output { described_class.run('users') } | |
50 | 52 | end |
51 | 53 | |
52 | it "shows executed command" do | |
54 | it 'shows executed command' do | |
53 | 55 | expect(@output).to include('Gitlab.users') |
54 | 56 | end |
55 | 57 | |
56 | it "shows users data" do | |
58 | it 'shows users data' do | |
57 | 59 | expect(@output).to include('name') |
58 | 60 | expect(@output).to include('John Smith') |
59 | 61 | expect(@output).to include('Jack Smith') |
60 | 62 | end |
61 | 63 | end |
64 | ||
65 | context 'when command is create_label' do | |
66 | before do | |
67 | stub_post('/projects/Project/labels', 'label') | |
68 | args = ['Project', 'Backlog', '#DD10AA'] | |
69 | @output = capture_output { described_class.run('create_label', args) } | |
70 | end | |
71 | ||
72 | it 'shows executed command' do | |
73 | expect(@output).to include('Gitlab.create_label Project, Backlog, #DD10AA') | |
74 | end | |
75 | end | |
62 | 76 | end |
63 | 77 | |
64 | describe ".start" do | |
65 | context "when command with excluded fields" do | |
78 | describe '.start' do | |
79 | context 'when command with excluded fields' do | |
66 | 80 | before do |
67 | stub_get("/user", "user") | |
81 | stub_get('/user', 'user') | |
68 | 82 | args = ['user', '--except=id,email,name'] |
69 | @output = capture_output { Gitlab::CLI.start(args) } | |
83 | @output = capture_output { described_class.start(args) } | |
70 | 84 | end |
71 | 85 | |
72 | it "shows user data with excluded fields" do | |
73 | expect(@output).to_not include('John Smith') | |
86 | it 'shows user data with excluded fields' do | |
87 | expect(@output).not_to include('John Smith') | |
74 | 88 | expect(@output).to include('bio') |
75 | 89 | expect(@output).to include('created_at') |
76 | 90 | end |
77 | 91 | end |
78 | 92 | |
79 | context "when command with json output" do | |
93 | context 'when command with json output' do | |
80 | 94 | before do |
81 | stub_get("/user", "user") | |
95 | stub_get('/user', 'user') | |
82 | 96 | args = ['user', '--json'] |
83 | @output = capture_output { Gitlab::CLI.start(args) } | |
97 | @output = capture_output { described_class.start(args) } | |
84 | 98 | end |
85 | 99 | |
86 | it "renders output as json" do | |
100 | it 'renders output as json' do | |
87 | 101 | expect(JSON.parse(@output)['result']).to eq(JSON.parse(File.read(File.dirname(__FILE__) + '/../fixtures/user.json'))) |
88 | 102 | expect(JSON.parse(@output)['cmd']).to eq('Gitlab.user') |
89 | 103 | end |
90 | 104 | end |
91 | 105 | |
92 | context "when command with required fields" do | |
106 | context 'when command with required fields' do | |
93 | 107 | before do |
94 | stub_get("/user", "user") | |
108 | stub_get('/user', 'user') | |
95 | 109 | args = ['user', '--only=id,email,name'] |
96 | @output = capture_output { Gitlab::CLI.start(args) } | |
110 | @output = capture_output { described_class.start(args) } | |
97 | 111 | end |
98 | 112 | |
99 | it "shows user data with required fields" do | |
113 | it 'shows user data with required fields' do | |
100 | 114 | expect(@output).to include('id') |
101 | 115 | expect(@output).to include('name') |
102 | 116 | expect(@output).to include('email') |
103 | 117 | expect(@output).to include('John Smith') |
104 | expect(@output).to_not include('bio') | |
105 | expect(@output).to_not include('created_at') | |
118 | expect(@output).not_to include('bio') | |
119 | expect(@output).not_to include('created_at') | |
106 | 120 | end |
107 | 121 | end |
108 | 122 | |
109 | context "fetch project with namespace/repo" do | |
110 | it "encodes delimiter" do | |
111 | stub_get("/projects/gitlab-org%2Fgitlab-ce", "project") | |
123 | context 'fetch project with namespace/repo' do | |
124 | it 'encodes delimiter' do | |
125 | stub_get('/projects/gitlab-org%2Fgitlab-ce', 'project') | |
112 | 126 | args = ['project', 'gitlab-org/gitlab-ce'] |
113 | @output = capture_output { Gitlab::CLI.start(args) } | |
127 | @output = capture_output { described_class.start(args) } | |
114 | 128 | expect(@output).to include('id') |
115 | 129 | end |
116 | 130 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | 5 | describe '.project_access_requests' do |
4 | 6 | before do |
5 | stub_get("/projects/1/access_requests", "access_requests") | |
7 | stub_get('/projects/1/access_requests', 'access_requests') | |
6 | 8 | @access_requests = Gitlab.project_access_requests(1) |
7 | 9 | end |
8 | 10 | |
9 | 11 | it 'gets the correct resources' do |
10 | expect(a_get("/projects/1/access_requests")).to have_been_made | |
12 | expect(a_get('/projects/1/access_requests')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it 'returns a paginated response of project access requests' do |
17 | 19 | |
18 | 20 | describe '.group_access_requests' do |
19 | 21 | before do |
20 | stub_get("/groups/1/access_requests", "access_requests") | |
22 | stub_get('/groups/1/access_requests', 'access_requests') | |
21 | 23 | @access_requests = Gitlab.group_access_requests(1) |
22 | 24 | end |
23 | 25 | |
24 | 26 | it 'gets the correct resources' do |
25 | expect(a_get("/groups/1/access_requests")).to have_been_made | |
27 | expect(a_get('/groups/1/access_requests')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | 30 | it 'returns a paginated response of group access requests' do |
32 | 34 | |
33 | 35 | describe '.request_project_access' do |
34 | 36 | before do |
35 | stub_post("/projects/1/access_requests", "access_request") | |
37 | stub_post('/projects/1/access_requests', 'access_request') | |
36 | 38 | @access_request = Gitlab.request_project_access(1) |
37 | 39 | end |
38 | 40 | |
39 | 41 | it 'gets the correct resource' do |
40 | expect(a_post("/projects/1/access_requests")).to have_been_made | |
42 | expect(a_post('/projects/1/access_requests')).to have_been_made | |
41 | 43 | end |
42 | 44 | end |
43 | 45 | |
44 | 46 | describe '.request_group_access' do |
45 | 47 | before do |
46 | stub_post("/groups/1/access_requests", "access_request") | |
48 | stub_post('/groups/1/access_requests', 'access_request') | |
47 | 49 | @access_request = Gitlab.request_group_access(1) |
48 | 50 | end |
49 | 51 | |
50 | 52 | it 'gets the correct resource' do |
51 | expect(a_post("/groups/1/access_requests")).to have_been_made | |
53 | expect(a_post('/groups/1/access_requests')).to have_been_made | |
52 | 54 | end |
53 | 55 | end |
54 | 56 | |
55 | 57 | describe '.approve_project_access_request' do |
56 | 58 | context 'When no access level is given' do |
57 | 59 | before do |
58 | stub_put("/projects/1/access_requests/1/approve", "default_approved_access_request") | |
60 | stub_put('/projects/1/access_requests/1/approve', 'default_approved_access_request') | |
59 | 61 | @access_request = Gitlab.approve_project_access_request(1, 1) |
60 | 62 | end |
61 | 63 | |
62 | 64 | it 'gets the correct resource' do |
63 | expect(a_put("/projects/1/access_requests/1/approve")).to have_been_made | |
65 | expect(a_put('/projects/1/access_requests/1/approve')).to have_been_made | |
64 | 66 | end |
65 | 67 | |
66 | it "returns information about the project access request" do | |
68 | it 'returns information about the project access request' do | |
67 | 69 | expect(@access_request.access_level).to eq(30) |
68 | 70 | end |
69 | 71 | end |
72 | ||
70 | 73 | context 'When access level is given' do |
71 | 74 | before do |
72 | stub_put("/projects/1/access_requests/1/approve", "approved_access_request").with(body: {access_level: '20'}) | |
73 | @access_request = Gitlab.approve_project_access_request(1, 1, {access_level: '20'}) | |
75 | stub_put('/projects/1/access_requests/1/approve', 'approved_access_request').with(body: { access_level: '20' }) | |
76 | @access_request = Gitlab.approve_project_access_request(1, 1, access_level: '20') | |
74 | 77 | end |
75 | 78 | |
76 | 79 | it 'gets the correct resource' do |
77 | expect(a_put("/projects/1/access_requests/1/approve"). | |
78 | with(body: { access_level: "20" })).to have_been_made | |
80 | expect(a_put('/projects/1/access_requests/1/approve') | |
81 | .with(body: { access_level: '20' })).to have_been_made | |
79 | 82 | end |
80 | 83 | |
81 | it "returns information about the project access request" do | |
84 | it 'returns information about the project access request' do | |
82 | 85 | expect(@access_request.access_level).to eq(20) |
83 | 86 | end |
84 | 87 | end |
87 | 90 | describe '.approve_group_access_request' do |
88 | 91 | context 'When no access level is given' do |
89 | 92 | before do |
90 | stub_put("/groups/1/access_requests/1/approve", "default_approved_access_request") | |
93 | stub_put('/groups/1/access_requests/1/approve', 'default_approved_access_request') | |
91 | 94 | @access_request = Gitlab.approve_group_access_request(1, 1) |
92 | 95 | end |
93 | 96 | |
94 | 97 | it 'gets the correct resource' do |
95 | expect(a_put("/groups/1/access_requests/1/approve")).to have_been_made | |
98 | expect(a_put('/groups/1/access_requests/1/approve')).to have_been_made | |
96 | 99 | end |
97 | 100 | |
98 | it "returns information about the group access request" do | |
101 | it 'returns information about the group access request' do | |
99 | 102 | expect(@access_request.access_level).to eq(30) |
100 | 103 | end |
101 | 104 | end |
105 | ||
102 | 106 | context 'When access level is given' do |
103 | 107 | before do |
104 | stub_put("/groups/1/access_requests/1/approve", "approved_access_request").with(body: {access_level: '20'}) | |
105 | @access_request = Gitlab.approve_group_access_request(1, 1, {access_level: '20'}) | |
108 | stub_put('/groups/1/access_requests/1/approve', 'approved_access_request').with(body: { access_level: '20' }) | |
109 | @access_request = Gitlab.approve_group_access_request(1, 1, access_level: '20') | |
106 | 110 | end |
107 | 111 | |
108 | 112 | it 'gets the correct resource' do |
109 | expect(a_put("/groups/1/access_requests/1/approve"). | |
110 | with(body: { access_level: "20" })).to have_been_made | |
113 | expect(a_put('/groups/1/access_requests/1/approve') | |
114 | .with(body: { access_level: '20' })).to have_been_made | |
111 | 115 | end |
112 | 116 | |
113 | it "returns information about the group access request" do | |
117 | it 'returns information about the group access request' do | |
114 | 118 | expect(@access_request.access_level).to eq(20) |
115 | 119 | end |
116 | 120 | end |
118 | 122 | |
119 | 123 | describe '.deny_project_access_request' do |
120 | 124 | before do |
121 | stub_delete("/projects/1/access_requests/1", "access_request") | |
125 | stub_delete('/projects/1/access_requests/1', 'access_request') | |
122 | 126 | @access_request = Gitlab.deny_project_access_request(1, 1) |
123 | 127 | end |
124 | 128 | |
125 | 129 | it 'gets the correct resource' do |
126 | expect(a_delete("/projects/1/access_requests/1")).to have_been_made | |
130 | expect(a_delete('/projects/1/access_requests/1')).to have_been_made | |
127 | 131 | end |
128 | 132 | end |
129 | 133 | |
130 | 134 | describe '.deny_group_access_request' do |
131 | 135 | before do |
132 | stub_delete("/groups/1/access_requests/1", "access_request") | |
136 | stub_delete('/groups/1/access_requests/1', 'access_request') | |
133 | 137 | @access_request = Gitlab.deny_group_access_request(1, 1) |
134 | 138 | end |
135 | 139 | |
136 | 140 | it 'gets the correct resource' do |
137 | expect(a_delete("/groups/1/access_requests/1")).to have_been_made | |
141 | expect(a_delete('/groups/1/access_requests/1')).to have_been_made | |
138 | 142 | end |
139 | 143 | end |
140 | end⏎ | |
144 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | 5 | describe '.award_emojis' do |
4 | 6 | context 'when issue award emojis' do |
5 | 7 | before do |
6 | stub_get("/projects/1/issues/80/award_emoji", "issue_award_emojis") | |
8 | stub_get('/projects/1/issues/80/award_emoji', 'issue_award_emojis') | |
7 | 9 | @emojis = Gitlab.award_emojis(1, 80, 'issue') |
8 | 10 | end |
9 | 11 | |
10 | it "gets the correct resources" do | |
11 | expect(a_get("/projects/1/issues/80/award_emoji")).to have_been_made | |
12 | end | |
13 | ||
14 | it "returns a paginated response of issue award emojis" do | |
12 | it 'gets the correct resources' do | |
13 | expect(a_get('/projects/1/issues/80/award_emoji')).to have_been_made | |
14 | end | |
15 | ||
16 | it 'returns a paginated response of issue award emojis' do | |
15 | 17 | expect(@emojis).to be_a Gitlab::PaginatedResponse |
16 | 18 | expect(@emojis.first.awardable_id).to eq(80) |
17 | expect(@emojis.first.awardable_type).to eq("Issue") | |
19 | expect(@emojis.first.awardable_type).to eq('Issue') | |
18 | 20 | end |
19 | 21 | end |
20 | 22 | |
21 | 23 | context 'when merge request award emojis' do |
22 | 24 | before do |
23 | stub_get("/projects/1/merge_requests/80/award_emoji", "merge_request_award_emojis") | |
25 | stub_get('/projects/1/merge_requests/80/award_emoji', 'merge_request_award_emojis') | |
24 | 26 | @emojis = Gitlab.award_emojis(1, 80, 'merge_request') |
25 | 27 | end |
26 | 28 | |
27 | it "gets the correct resources" do | |
28 | expect(a_get("/projects/1/merge_requests/80/award_emoji")).to have_been_made | |
29 | end | |
30 | ||
31 | it "returns a paginated response of merge request award emojis" do | |
29 | it 'gets the correct resources' do | |
30 | expect(a_get('/projects/1/merge_requests/80/award_emoji')).to have_been_made | |
31 | end | |
32 | ||
33 | it 'returns a paginated response of merge request award emojis' do | |
32 | 34 | expect(@emojis).to be_a Gitlab::PaginatedResponse |
33 | 35 | expect(@emojis.first.awardable_id).to eq(80) |
34 | expect(@emojis.first.awardable_type).to eq("MergeRequest") | |
36 | expect(@emojis.first.awardable_type).to eq('MergeRequest') | |
35 | 37 | end |
36 | 38 | end |
37 | 39 | |
38 | 40 | context 'when snippet award emojis' do |
39 | 41 | before do |
40 | stub_get("/projects/1/snippets/80/award_emoji", "snippet_award_emojis") | |
42 | stub_get('/projects/1/snippets/80/award_emoji', 'snippet_award_emojis') | |
41 | 43 | @emojis = Gitlab.award_emojis(1, 80, 'snippet') |
42 | 44 | end |
43 | 45 | |
44 | it "gets the correct resources" do | |
45 | expect(a_get("/projects/1/snippets/80/award_emoji")).to have_been_made | |
46 | end | |
47 | ||
48 | it "returns a paginated response of snippet award emojis" do | |
46 | it 'gets the correct resources' do | |
47 | expect(a_get('/projects/1/snippets/80/award_emoji')).to have_been_made | |
48 | end | |
49 | ||
50 | it 'returns a paginated response of snippet award emojis' do | |
49 | 51 | expect(@emojis).to be_a Gitlab::PaginatedResponse |
50 | 52 | expect(@emojis.first.awardable_id).to eq(80) |
51 | expect(@emojis.first.awardable_type).to eq("Snippet") | |
53 | expect(@emojis.first.awardable_type).to eq('Snippet') | |
52 | 54 | end |
53 | 55 | end |
54 | 56 | end |
56 | 58 | describe '.note_award_emojis' do |
57 | 59 | context 'when issue note award emojis' do |
58 | 60 | before do |
59 | stub_get("/projects/1/issues/80/notes/1/award_emoji", "note_award_emojis") | |
61 | stub_get('/projects/1/issues/80/notes/1/award_emoji', 'note_award_emojis') | |
60 | 62 | @note_emojis = Gitlab.note_award_emojis(1, 80, 'issue', 1) |
61 | 63 | end |
62 | 64 | |
63 | it "gets the correct resources" do | |
64 | expect(a_get("/projects/1/issues/80/notes/1/award_emoji")).to have_been_made | |
65 | end | |
66 | ||
67 | it "returns a paginated response of issue note award emojis" do | |
65 | it 'gets the correct resources' do | |
66 | expect(a_get('/projects/1/issues/80/notes/1/award_emoji')).to have_been_made | |
67 | end | |
68 | ||
69 | it 'returns a paginated response of issue note award emojis' do | |
68 | 70 | expect(@note_emojis).to be_a Gitlab::PaginatedResponse |
69 | 71 | expect(@note_emojis.first.awardable_id).to eq(1) |
70 | expect(@note_emojis.first.awardable_type).to eq("Note") | |
72 | expect(@note_emojis.first.awardable_type).to eq('Note') | |
71 | 73 | end |
72 | 74 | end |
73 | 75 | |
74 | 76 | context 'when merge request note award emojis' do |
75 | 77 | before do |
76 | stub_get("/projects/1/merge_requests/80/notes/1/award_emoji", "note_award_emojis") | |
78 | stub_get('/projects/1/merge_requests/80/notes/1/award_emoji', 'note_award_emojis') | |
77 | 79 | @note_emojis = Gitlab.note_award_emojis(1, 80, 'merge_request', 1) |
78 | 80 | end |
79 | 81 | |
80 | it "gets the correct resources" do | |
81 | expect(a_get("/projects/1/merge_requests/80/notes/1/award_emoji")).to have_been_made | |
82 | end | |
83 | ||
84 | it "returns a paginated response of merge request note award emojis" do | |
82 | it 'gets the correct resources' do | |
83 | expect(a_get('/projects/1/merge_requests/80/notes/1/award_emoji')).to have_been_made | |
84 | end | |
85 | ||
86 | it 'returns a paginated response of merge request note award emojis' do | |
85 | 87 | expect(@note_emojis).to be_a Gitlab::PaginatedResponse |
86 | 88 | expect(@note_emojis.first.awardable_id).to eq(1) |
87 | expect(@note_emojis.first.awardable_type).to eq("Note") | |
89 | expect(@note_emojis.first.awardable_type).to eq('Note') | |
88 | 90 | end |
89 | 91 | end |
90 | 92 | |
91 | 93 | context 'when snippet note award emojis' do |
92 | 94 | before do |
93 | stub_get("/projects/1/snippets/80/notes/1/award_emoji", "note_award_emojis") | |
95 | stub_get('/projects/1/snippets/80/notes/1/award_emoji', 'note_award_emojis') | |
94 | 96 | @note_emojis = Gitlab.note_award_emojis(1, 80, 'snippet', 1) |
95 | 97 | end |
96 | 98 | |
97 | it "gets the correct resources" do | |
98 | expect(a_get("/projects/1/snippets/80/notes/1/award_emoji")).to have_been_made | |
99 | end | |
100 | ||
101 | it "returns a paginated response of snippet note award emojis" do | |
99 | it 'gets the correct resources' do | |
100 | expect(a_get('/projects/1/snippets/80/notes/1/award_emoji')).to have_been_made | |
101 | end | |
102 | ||
103 | it 'returns a paginated response of snippet note award emojis' do | |
102 | 104 | expect(@note_emojis).to be_a Gitlab::PaginatedResponse |
103 | 105 | expect(@note_emojis.first.awardable_id).to eq(1) |
104 | expect(@note_emojis.first.awardable_type).to eq("Note") | |
106 | expect(@note_emojis.first.awardable_type).to eq('Note') | |
105 | 107 | end |
106 | 108 | end |
107 | 109 | end |
109 | 111 | describe '.award_emoji' do |
110 | 112 | context 'when issue award emoji' do |
111 | 113 | before do |
112 | stub_get("/projects/1/issues/80/award_emoji/4", "issue_award_emoji") | |
114 | stub_get('/projects/1/issues/80/award_emoji/4', 'issue_award_emoji') | |
113 | 115 | @emoji = Gitlab.award_emoji(1, 80, 'issue', 4) |
114 | 116 | end |
115 | 117 | |
116 | it "gets the correct resource" do | |
117 | expect(a_get("/projects/1/issues/80/award_emoji/4")).to have_been_made | |
118 | end | |
119 | ||
120 | it "returns information about an issue award emoji" do | |
118 | it 'gets the correct resource' do | |
119 | expect(a_get('/projects/1/issues/80/award_emoji/4')).to have_been_made | |
120 | end | |
121 | ||
122 | it 'returns information about an issue award emoji' do | |
121 | 123 | expect(@emoji.id).to eq(4) |
122 | expect(@emoji.awardable_type).to eq("Issue") | |
124 | expect(@emoji.awardable_type).to eq('Issue') | |
123 | 125 | expect(@emoji.awardable_id).to eq(80) |
124 | 126 | end |
125 | 127 | end |
126 | 128 | |
127 | 129 | context 'when merge request award emoji' do |
128 | 130 | before do |
129 | stub_get("/projects/1/merge_requests/80/award_emoji/4", "merge_request_award_emoji") | |
131 | stub_get('/projects/1/merge_requests/80/award_emoji/4', 'merge_request_award_emoji') | |
130 | 132 | @emoji = Gitlab.award_emoji(1, 80, 'merge_request', 4) |
131 | 133 | end |
132 | 134 | |
133 | it "gets the correct resource" do | |
134 | expect(a_get("/projects/1/merge_requests/80/award_emoji/4")).to have_been_made | |
135 | end | |
136 | ||
137 | it "returns information about a merge request award emoji" do | |
135 | it 'gets the correct resource' do | |
136 | expect(a_get('/projects/1/merge_requests/80/award_emoji/4')).to have_been_made | |
137 | end | |
138 | ||
139 | it 'returns information about a merge request award emoji' do | |
138 | 140 | expect(@emoji.id).to eq(4) |
139 | expect(@emoji.awardable_type).to eq("MergeRequest") | |
141 | expect(@emoji.awardable_type).to eq('MergeRequest') | |
140 | 142 | expect(@emoji.awardable_id).to eq(80) |
141 | 143 | end |
142 | 144 | end |
143 | 145 | |
144 | 146 | context 'when snippet award emoji' do |
145 | 147 | before do |
146 | stub_get("/projects/1/snippets/80/award_emoji/4", "snippet_award_emoji") | |
148 | stub_get('/projects/1/snippets/80/award_emoji/4', 'snippet_award_emoji') | |
147 | 149 | @emoji = Gitlab.award_emoji(1, 80, 'snippet', 4) |
148 | 150 | end |
149 | 151 | |
150 | it "gets the correct resource" do | |
151 | expect(a_get("/projects/1/snippets/80/award_emoji/4")).to have_been_made | |
152 | end | |
153 | ||
154 | it "returns information about a snippet award emoji" do | |
152 | it 'gets the correct resource' do | |
153 | expect(a_get('/projects/1/snippets/80/award_emoji/4')).to have_been_made | |
154 | end | |
155 | ||
156 | it 'returns information about a snippet award emoji' do | |
155 | 157 | expect(@emoji.id).to eq(4) |
156 | expect(@emoji.awardable_type).to eq("Snippet") | |
158 | expect(@emoji.awardable_type).to eq('Snippet') | |
157 | 159 | expect(@emoji.awardable_id).to eq(80) |
158 | 160 | end |
159 | 161 | end |
162 | 164 | describe '.note_award_emoji' do |
163 | 165 | context 'when issue note award emoji' do |
164 | 166 | before do |
165 | stub_get("/projects/1/issues/80/notes/1/award_emoji/4", "note_award_emoji") | |
167 | stub_get('/projects/1/issues/80/notes/1/award_emoji/4', 'note_award_emoji') | |
166 | 168 | @note_emoji = Gitlab.note_award_emoji(1, 80, 'issue', 1, 4) |
167 | 169 | end |
168 | 170 | |
169 | it "gets the correct resource" do | |
170 | expect(a_get("/projects/1/issues/80/notes/1/award_emoji/4")).to have_been_made | |
171 | end | |
172 | ||
173 | it "returns information about an issue note award emoji" do | |
171 | it 'gets the correct resource' do | |
172 | expect(a_get('/projects/1/issues/80/notes/1/award_emoji/4')).to have_been_made | |
173 | end | |
174 | ||
175 | it 'returns information about an issue note award emoji' do | |
174 | 176 | expect(@note_emoji.id).to eq(4) |
175 | expect(@note_emoji.awardable_type).to eq("Note") | |
177 | expect(@note_emoji.awardable_type).to eq('Note') | |
176 | 178 | expect(@note_emoji.awardable_id).to eq(1) |
177 | 179 | end |
178 | 180 | end |
179 | 181 | |
180 | 182 | context 'when merge request note award emoji' do |
181 | 183 | before do |
182 | stub_get("/projects/1/merge_requests/80/notes/1/award_emoji/4", "note_award_emoji") | |
184 | stub_get('/projects/1/merge_requests/80/notes/1/award_emoji/4', 'note_award_emoji') | |
183 | 185 | @note_emoji = Gitlab.note_award_emoji(1, 80, 'merge_request', 1, 4) |
184 | 186 | end |
185 | 187 | |
186 | it "gets the correct resource" do | |
187 | expect(a_get("/projects/1/merge_requests/80/notes/1/award_emoji/4")).to have_been_made | |
188 | end | |
189 | ||
190 | it "returns information about a merge request note award emoji" do | |
188 | it 'gets the correct resource' do | |
189 | expect(a_get('/projects/1/merge_requests/80/notes/1/award_emoji/4')).to have_been_made | |
190 | end | |
191 | ||
192 | it 'returns information about a merge request note award emoji' do | |
191 | 193 | expect(@note_emoji.id).to eq(4) |
192 | expect(@note_emoji.awardable_type).to eq("Note") | |
194 | expect(@note_emoji.awardable_type).to eq('Note') | |
193 | 195 | expect(@note_emoji.awardable_id).to eq(1) |
194 | 196 | end |
195 | 197 | end |
196 | 198 | |
197 | 199 | context 'when snippet note award emoji' do |
198 | 200 | before do |
199 | stub_get("/projects/1/snippets/80/notes/1/award_emoji/4", "note_award_emoji") | |
201 | stub_get('/projects/1/snippets/80/notes/1/award_emoji/4', 'note_award_emoji') | |
200 | 202 | @note_emoji = Gitlab.note_award_emoji(1, 80, 'snippet', 1, 4) |
201 | 203 | end |
202 | 204 | |
203 | it "gets the correct resource" do | |
204 | expect(a_get("/projects/1/snippets/80/notes/1/award_emoji/4")).to have_been_made | |
205 | end | |
206 | ||
207 | it "returns information about a snippet note award emoji" do | |
205 | it 'gets the correct resource' do | |
206 | expect(a_get('/projects/1/snippets/80/notes/1/award_emoji/4')).to have_been_made | |
207 | end | |
208 | ||
209 | it 'returns information about a snippet note award emoji' do | |
208 | 210 | expect(@note_emoji.id).to eq(4) |
209 | expect(@note_emoji.awardable_type).to eq("Note") | |
211 | expect(@note_emoji.awardable_type).to eq('Note') | |
210 | 212 | expect(@note_emoji.awardable_id).to eq(1) |
211 | 213 | end |
212 | 214 | end |
215 | 217 | describe '.create_award_emoji' do |
216 | 218 | context 'when issue award emoji' do |
217 | 219 | before do |
218 | stub_post("/projects/1/issues/80/award_emoji", "issue_award_emoji") | |
219 | @emoji = Gitlab.create_award_emoji(1, 80, "issue", "blowfish") | |
220 | end | |
221 | ||
222 | it "gets the correct resource" do | |
223 | expect(a_post("/projects/1/issues/80/award_emoji"). | |
224 | with(body: { name: 'blowfish' })).to have_been_made | |
225 | end | |
226 | ||
227 | it "returns correct information about the created issue award emoji" do | |
220 | stub_post('/projects/1/issues/80/award_emoji', 'issue_award_emoji') | |
221 | @emoji = Gitlab.create_award_emoji(1, 80, 'issue', 'blowfish') | |
222 | end | |
223 | ||
224 | it 'gets the correct resource' do | |
225 | expect(a_post('/projects/1/issues/80/award_emoji') | |
226 | .with(body: { name: 'blowfish' })).to have_been_made | |
227 | end | |
228 | ||
229 | it 'returns correct information about the created issue award emoji' do | |
228 | 230 | expect(@emoji.name).to eq('blowfish') |
229 | 231 | expect(@emoji.awardable_type).to eq('Issue') |
230 | 232 | end |
232 | 234 | |
233 | 235 | context 'when merge request award emoji' do |
234 | 236 | before do |
235 | stub_post("/projects/1/merge_requests/80/award_emoji", "merge_request_award_emoji") | |
236 | @emoji = Gitlab.create_award_emoji(1, 80, "merge_request", "blowfish") | |
237 | end | |
238 | ||
239 | it "gets the correct resource" do | |
240 | expect(a_post("/projects/1/merge_requests/80/award_emoji"). | |
241 | with(body: { name: 'blowfish' })).to have_been_made | |
242 | end | |
243 | ||
244 | it "returns correct information about the created merge request award emoji" do | |
237 | stub_post('/projects/1/merge_requests/80/award_emoji', 'merge_request_award_emoji') | |
238 | @emoji = Gitlab.create_award_emoji(1, 80, 'merge_request', 'blowfish') | |
239 | end | |
240 | ||
241 | it 'gets the correct resource' do | |
242 | expect(a_post('/projects/1/merge_requests/80/award_emoji') | |
243 | .with(body: { name: 'blowfish' })).to have_been_made | |
244 | end | |
245 | ||
246 | it 'returns correct information about the created merge request award emoji' do | |
245 | 247 | expect(@emoji.name).to eq('blowfish') |
246 | 248 | expect(@emoji.awardable_type).to eq('MergeRequest') |
247 | 249 | end |
249 | 251 | |
250 | 252 | context 'when snippet award emoji' do |
251 | 253 | before do |
252 | stub_post("/projects/1/snippets/80/award_emoji", "snippet_award_emoji") | |
253 | @emoji = Gitlab.create_award_emoji(1, 80, "snippet", "blowfish") | |
254 | end | |
255 | ||
256 | it "gets the correct resource" do | |
257 | expect(a_post("/projects/1/snippets/80/award_emoji"). | |
258 | with(body: { name: 'blowfish' })).to have_been_made | |
259 | end | |
260 | ||
261 | it "returns correct information about the created snippet award emoji" do | |
254 | stub_post('/projects/1/snippets/80/award_emoji', 'snippet_award_emoji') | |
255 | @emoji = Gitlab.create_award_emoji(1, 80, 'snippet', 'blowfish') | |
256 | end | |
257 | ||
258 | it 'gets the correct resource' do | |
259 | expect(a_post('/projects/1/snippets/80/award_emoji') | |
260 | .with(body: { name: 'blowfish' })).to have_been_made | |
261 | end | |
262 | ||
263 | it 'returns correct information about the created snippet award emoji' do | |
262 | 264 | expect(@emoji.name).to eq('blowfish') |
263 | 265 | expect(@emoji.awardable_type).to eq('Snippet') |
264 | 266 | end |
268 | 270 | describe '.create_note_award_emoji' do |
269 | 271 | context 'when issue note award emoji' do |
270 | 272 | before do |
271 | stub_post("/projects/1/issues/80/notes/1/award_emoji", "note_award_emoji") | |
272 | @note_emoji = Gitlab.create_note_award_emoji(1, 80, "issue", 1, "mood_bubble_lightning") | |
273 | end | |
274 | ||
275 | it "gets the correct resource" do | |
276 | expect(a_post("/projects/1/issues/80/notes/1/award_emoji"). | |
277 | with(body: { name: 'mood_bubble_lightning' })).to have_been_made | |
278 | end | |
279 | ||
280 | it "returns correct information about the created issue note award emoji" do | |
273 | stub_post('/projects/1/issues/80/notes/1/award_emoji', 'note_award_emoji') | |
274 | @note_emoji = Gitlab.create_note_award_emoji(1, 80, 'issue', 1, 'mood_bubble_lightning') | |
275 | end | |
276 | ||
277 | it 'gets the correct resource' do | |
278 | expect(a_post('/projects/1/issues/80/notes/1/award_emoji') | |
279 | .with(body: { name: 'mood_bubble_lightning' })).to have_been_made | |
280 | end | |
281 | ||
282 | it 'returns correct information about the created issue note award emoji' do | |
281 | 283 | expect(@note_emoji.name).to eq('mood_bubble_lightning') |
282 | 284 | expect(@note_emoji.awardable_type).to eq('Note') |
283 | 285 | end |
285 | 287 | |
286 | 288 | context 'when merge request note award emoji' do |
287 | 289 | before do |
288 | stub_post("/projects/1/merge_requests/80/notes/1/award_emoji", "note_award_emoji") | |
289 | @note_emoji = Gitlab.create_note_award_emoji(1, 80, "merge_request", 1, "mood_bubble_lightning") | |
290 | end | |
291 | ||
292 | it "gets the correct resource" do | |
293 | expect(a_post("/projects/1/merge_requests/80/notes/1/award_emoji"). | |
294 | with(body: { name: 'mood_bubble_lightning' })).to have_been_made | |
295 | end | |
296 | ||
297 | it "returns correct information about the created merge request note award emoji" do | |
290 | stub_post('/projects/1/merge_requests/80/notes/1/award_emoji', 'note_award_emoji') | |
291 | @note_emoji = Gitlab.create_note_award_emoji(1, 80, 'merge_request', 1, 'mood_bubble_lightning') | |
292 | end | |
293 | ||
294 | it 'gets the correct resource' do | |
295 | expect(a_post('/projects/1/merge_requests/80/notes/1/award_emoji') | |
296 | .with(body: { name: 'mood_bubble_lightning' })).to have_been_made | |
297 | end | |
298 | ||
299 | it 'returns correct information about the created merge request note award emoji' do | |
298 | 300 | expect(@note_emoji.name).to eq('mood_bubble_lightning') |
299 | 301 | expect(@note_emoji.awardable_type).to eq('Note') |
300 | 302 | end |
302 | 304 | |
303 | 305 | context 'when snippet note award emoji' do |
304 | 306 | before do |
305 | stub_post("/projects/1/snippets/80/notes/1/award_emoji", "note_award_emoji") | |
306 | @note_emoji = Gitlab.create_note_award_emoji(1, 80, "snippet", 1, "mood_bubble_lightning") | |
307 | end | |
308 | ||
309 | it "gets the correct resource" do | |
310 | expect(a_post("/projects/1/snippets/80/notes/1/award_emoji"). | |
311 | with(body: { name: 'mood_bubble_lightning' })).to have_been_made | |
312 | end | |
313 | ||
314 | it "returns correct information about the created snippet note award emoji" do | |
307 | stub_post('/projects/1/snippets/80/notes/1/award_emoji', 'note_award_emoji') | |
308 | @note_emoji = Gitlab.create_note_award_emoji(1, 80, 'snippet', 1, 'mood_bubble_lightning') | |
309 | end | |
310 | ||
311 | it 'gets the correct resource' do | |
312 | expect(a_post('/projects/1/snippets/80/notes/1/award_emoji') | |
313 | .with(body: { name: 'mood_bubble_lightning' })).to have_been_made | |
314 | end | |
315 | ||
316 | it 'returns correct information about the created snippet note award emoji' do | |
315 | 317 | expect(@note_emoji.name).to eq('mood_bubble_lightning') |
316 | 318 | expect(@note_emoji.awardable_type).to eq('Note') |
317 | 319 | end |
321 | 323 | describe '.delete_award_emoji' do |
322 | 324 | context 'when issue award emoji' do |
323 | 325 | before do |
324 | stub_delete("/projects/1/issues/80/award_emoji/4", "issue_award_emoji") | |
325 | @emoji = Gitlab.delete_award_emoji(1, 80, "issue", 4) | |
326 | end | |
327 | ||
328 | it "gets the correct resource" do | |
329 | expect(a_delete("/projects/1/issues/80/award_emoji/4")).to have_been_made | |
326 | stub_delete('/projects/1/issues/80/award_emoji/4', 'issue_award_emoji') | |
327 | @emoji = Gitlab.delete_award_emoji(1, 80, 'issue', 4) | |
328 | end | |
329 | ||
330 | it 'gets the correct resource' do | |
331 | expect(a_delete('/projects/1/issues/80/award_emoji/4')).to have_been_made | |
330 | 332 | end |
331 | 333 | end |
332 | 334 | |
333 | 335 | context 'when merge request award emoji' do |
334 | 336 | before do |
335 | stub_delete("/projects/1/merge_requests/80/award_emoji/4", "merge_request_award_emoji") | |
336 | @emoji = Gitlab.delete_award_emoji(1, 80, "merge_request", 4) | |
337 | end | |
338 | ||
339 | it "gets the correct resource" do | |
340 | expect(a_delete("/projects/1/merge_requests/80/award_emoji/4")).to have_been_made | |
337 | stub_delete('/projects/1/merge_requests/80/award_emoji/4', 'merge_request_award_emoji') | |
338 | @emoji = Gitlab.delete_award_emoji(1, 80, 'merge_request', 4) | |
339 | end | |
340 | ||
341 | it 'gets the correct resource' do | |
342 | expect(a_delete('/projects/1/merge_requests/80/award_emoji/4')).to have_been_made | |
341 | 343 | end |
342 | 344 | end |
343 | 345 | |
344 | 346 | context 'when snippet award emoji' do |
345 | 347 | before do |
346 | stub_delete("/projects/1/snippets/80/award_emoji/4", "snippet_award_emoji") | |
347 | @emoji = Gitlab.delete_award_emoji(1, 80, "snippet", 4) | |
348 | end | |
349 | ||
350 | it "gets the correct resource" do | |
351 | expect(a_delete("/projects/1/snippets/80/award_emoji/4")).to have_been_made | |
348 | stub_delete('/projects/1/snippets/80/award_emoji/4', 'snippet_award_emoji') | |
349 | @emoji = Gitlab.delete_award_emoji(1, 80, 'snippet', 4) | |
350 | end | |
351 | ||
352 | it 'gets the correct resource' do | |
353 | expect(a_delete('/projects/1/snippets/80/award_emoji/4')).to have_been_made | |
352 | 354 | end |
353 | 355 | end |
354 | 356 | end |
356 | 358 | describe '.delete_note_award_emoji' do |
357 | 359 | context 'when issue note award emoji' do |
358 | 360 | before do |
359 | stub_delete("/projects/1/issues/80/notes/1/award_emoji/4", "note_award_emoji") | |
360 | @note_emoji = Gitlab.delete_note_award_emoji(1, 80, "issue", 1, 4) | |
361 | end | |
362 | ||
363 | it "gets the correct resource" do | |
364 | expect(a_delete("/projects/1/issues/80/notes/1/award_emoji/4")).to have_been_made | |
361 | stub_delete('/projects/1/issues/80/notes/1/award_emoji/4', 'note_award_emoji') | |
362 | @note_emoji = Gitlab.delete_note_award_emoji(1, 80, 'issue', 1, 4) | |
363 | end | |
364 | ||
365 | it 'gets the correct resource' do | |
366 | expect(a_delete('/projects/1/issues/80/notes/1/award_emoji/4')).to have_been_made | |
365 | 367 | end |
366 | 368 | end |
367 | 369 | |
368 | 370 | context 'when merge request note award emoji' do |
369 | 371 | before do |
370 | stub_delete("/projects/1/merge_requests/80/notes/1/award_emoji/4", "note_award_emoji") | |
371 | @note_emoji = Gitlab.delete_note_award_emoji(1, 80, "merge_request", 1, 4) | |
372 | end | |
373 | ||
374 | it "gets the correct resource" do | |
375 | expect(a_delete("/projects/1/merge_requests/80/notes/1/award_emoji/4")).to have_been_made | |
372 | stub_delete('/projects/1/merge_requests/80/notes/1/award_emoji/4', 'note_award_emoji') | |
373 | @note_emoji = Gitlab.delete_note_award_emoji(1, 80, 'merge_request', 1, 4) | |
374 | end | |
375 | ||
376 | it 'gets the correct resource' do | |
377 | expect(a_delete('/projects/1/merge_requests/80/notes/1/award_emoji/4')).to have_been_made | |
376 | 378 | end |
377 | 379 | end |
378 | 380 | |
379 | 381 | context 'when snippet note award emoji' do |
380 | 382 | before do |
381 | stub_delete("/projects/1/snippets/80/notes/1/award_emoji/4", "note_award_emoji") | |
382 | @note_emoji = Gitlab.delete_note_award_emoji(1, 80, "snippet", 1, 4) | |
383 | end | |
384 | ||
385 | it "gets the correct resource" do | |
386 | expect(a_delete("/projects/1/snippets/80/notes/1/award_emoji/4")).to have_been_made | |
383 | stub_delete('/projects/1/snippets/80/notes/1/award_emoji/4', 'note_award_emoji') | |
384 | @note_emoji = Gitlab.delete_note_award_emoji(1, 80, 'snippet', 1, 4) | |
385 | end | |
386 | ||
387 | it 'gets the correct resource' do | |
388 | expect(a_delete('/projects/1/snippets/80/notes/1/award_emoji/4')).to have_been_made | |
387 | 389 | end |
388 | 390 | end |
389 | 391 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".boards" do | |
5 | describe '.boards' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/boards", "boards") | |
7 | stub_get('/projects/3/boards', 'boards') | |
6 | 8 | @boards = Gitlab.boards(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/boards")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/boards')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of project's boards" do |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".board_lists" do | |
20 | describe '.board_lists' do | |
19 | 21 | before do |
20 | stub_get("/projects/3/boards/1/lists", "board_lists") | |
22 | stub_get('/projects/3/boards/1/lists', 'board_lists') | |
21 | 23 | @board_lists = Gitlab.board_lists(3, 1) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/projects/3/boards/1/lists")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/3/boards/1/lists')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | 30 | it "returns a paginated response of board's lists" do |
31 | 33 | end |
32 | 34 | end |
33 | 35 | |
34 | describe ".board_list" do | |
36 | describe '.board_list' do | |
35 | 37 | before do |
36 | stub_get("/projects/3/boards/1/lists/1", "board_list") | |
38 | stub_get('/projects/3/boards/1/lists/1', 'board_list') | |
37 | 39 | @board_list = Gitlab.board_list(3, 1, 1) |
38 | 40 | end |
39 | 41 | |
40 | it "gets the correct resource" do | |
41 | expect(a_get("/projects/3/boards/1/lists/1")).to have_been_made | |
42 | it 'gets the correct resource' do | |
43 | expect(a_get('/projects/3/boards/1/lists/1')).to have_been_made | |
42 | 44 | end |
43 | 45 | |
44 | it "returns information about the list" do | |
46 | it 'returns information about the list' do | |
45 | 47 | expect(@board_list.id).to eq(1) |
46 | 48 | end |
47 | 49 | end |
48 | 50 | |
49 | describe ".create_board_list" do | |
51 | describe '.create_board_list' do | |
50 | 52 | before do |
51 | stub_post("/projects/3/boards/1/lists", "board_list") | |
53 | stub_post('/projects/3/boards/1/lists', 'board_list') | |
52 | 54 | @board_list = Gitlab.create_board_list(3, 1, 4) |
53 | 55 | end |
54 | 56 | |
55 | it "gets the correct resource" do | |
56 | expect(a_post("/projects/3/boards/1/lists")).to have_been_made | |
57 | it 'gets the correct resource' do | |
58 | expect(a_post('/projects/3/boards/1/lists')).to have_been_made | |
57 | 59 | end |
58 | 60 | |
59 | it "returns information about a created board" do | |
61 | it 'returns information about a created board' do | |
60 | 62 | expect(@board_list.position).to eq(1) |
61 | 63 | end |
62 | 64 | end |
63 | 65 | |
64 | describe ".edit_board_list" do | |
66 | describe '.edit_board_list' do | |
65 | 67 | before do |
66 | stub_put("/projects/3/boards/1/lists/1", "board_list") | |
68 | stub_put('/projects/3/boards/1/lists/1', 'board_list') | |
67 | 69 | @board_list = Gitlab.edit_board_list(3, 1, 1, 3) |
68 | 70 | end |
69 | 71 | |
70 | it "gets the correct resource" do | |
71 | expect(a_put("/projects/3/boards/1/lists/1")).to have_been_made | |
72 | it 'gets the correct resource' do | |
73 | expect(a_put('/projects/3/boards/1/lists/1')).to have_been_made | |
72 | 74 | end |
73 | 75 | |
74 | it "returns information about an edited board" do | |
76 | it 'returns information about an edited board' do | |
75 | 77 | expect(@board_list.id).to eq(1) |
76 | 78 | end |
77 | 79 | end |
78 | 80 | |
79 | describe ".delete_board_list" do | |
81 | describe '.delete_board_list' do | |
80 | 82 | before do |
81 | stub_delete("/projects/3/boards/1/lists/1", "board_list") | |
83 | stub_delete('/projects/3/boards/1/lists/1', 'board_list') | |
82 | 84 | @board_list = Gitlab.delete_board_list(3, 1, 1) |
83 | 85 | end |
84 | 86 | |
85 | it "gets the correct resource" do | |
86 | expect(a_delete("/projects/3/boards/1/lists/1")).to have_been_made | |
87 | it 'gets the correct resource' do | |
88 | expect(a_delete('/projects/3/boards/1/lists/1')).to have_been_made | |
87 | 89 | end |
88 | 90 | |
89 | it "returns information about the deleted board list" do | |
91 | it 'returns information about the deleted board list' do | |
90 | 92 | expect(@board_list.id).to eq(1) |
91 | 93 | end |
92 | 94 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
4 | 6 | it { is_expected.to respond_to :repo_branch } |
5 | 7 | it { is_expected.to respond_to :repo_protect_branch } |
6 | 8 | it { is_expected.to respond_to :repo_unprotect_branch } |
9 | it { is_expected.to respond_to :repo_create_branch } | |
10 | it { is_expected.to respond_to :repo_delete_branch } | |
11 | it { is_expected.to respond_to :repo_delete_merged_branches } | |
12 | it { is_expected.to respond_to :repo_protected_branches } | |
13 | it { is_expected.to respond_to :repo_protected_branch } | |
7 | 14 | |
8 | describe ".branches" do | |
15 | describe '.branches' do | |
9 | 16 | before do |
10 | stub_get("/projects/3/repository/branches", "branches") | |
17 | stub_get('/projects/3/repository/branches', 'branches') | |
11 | 18 | @branches = Gitlab.branches(3) |
12 | 19 | end |
13 | 20 | |
14 | it "gets the correct resource" do | |
15 | expect(a_get("/projects/3/repository/branches")).to have_been_made | |
21 | it 'gets the correct resource' do | |
22 | expect(a_get('/projects/3/repository/branches')).to have_been_made | |
16 | 23 | end |
17 | 24 | |
18 | it "returns a paginated response of repository branches" do | |
25 | it 'returns a paginated response of repository branches' do | |
19 | 26 | expect(@branches).to be_a Gitlab::PaginatedResponse |
20 | expect(@branches.first.name).to eq("api") | |
27 | expect(@branches.first.name).to eq('api') | |
21 | 28 | end |
22 | 29 | end |
23 | 30 | |
24 | describe ".branch" do | |
31 | describe '.branch' do | |
25 | 32 | before do |
26 | stub_get("/projects/3/repository/branches/api", "branch") | |
27 | @branch = Gitlab.branch(3, "api") | |
33 | stub_get('/projects/3/repository/branches/api', 'branch') | |
34 | @branch = Gitlab.branch(3, 'api') | |
28 | 35 | end |
29 | 36 | |
30 | it "gets the correct resource" do | |
31 | expect(a_get("/projects/3/repository/branches/api")).to have_been_made | |
37 | it 'gets the correct resource' do | |
38 | expect(a_get('/projects/3/repository/branches/api')).to have_been_made | |
32 | 39 | end |
33 | 40 | |
34 | it "returns information about a repository branch" do | |
35 | expect(@branch.name).to eq("api") | |
41 | it 'returns information about a repository branch' do | |
42 | expect(@branch.name).to eq('api') | |
36 | 43 | end |
37 | 44 | end |
38 | 45 | |
39 | describe ".protect_branch" do | |
46 | describe '.protect_branch' do | |
40 | 47 | before do |
41 | stub_post("/projects/3/protected_branches", "branch") | |
48 | stub_post('/projects/3/protected_branches', 'branch') | |
42 | 49 | end |
43 | 50 | |
44 | context "without options" do | |
51 | context 'without options' do | |
45 | 52 | before do |
46 | @branch = Gitlab.protect_branch(3, "api") | |
53 | @branch = Gitlab.protect_branch(3, 'api') | |
47 | 54 | end |
48 | 55 | |
49 | it "updates the correct resource" do | |
50 | expect(a_post("/projects/3/protected_branches")).to have_been_made | |
56 | it 'updates the correct resource' do | |
57 | expect(a_post('/projects/3/protected_branches')).to have_been_made | |
51 | 58 | end |
52 | 59 | |
53 | it "returns information about a protected repository branch" do | |
54 | expect(@branch.name).to eq("api") | |
60 | it 'returns information about a protected repository branch' do | |
61 | expect(@branch.name).to eq('api') | |
55 | 62 | end |
56 | 63 | end |
57 | 64 | |
58 | context "with options" do | |
65 | context 'with options' do | |
59 | 66 | before do |
60 | @branch = Gitlab.protect_branch(3, "api", developers_can_push: true) | |
67 | @branch = Gitlab.protect_branch(3, 'api', developers_can_push: true) | |
61 | 68 | end |
62 | 69 | |
63 | it "updates the correct resource with the correct options" do | |
70 | it 'updates the correct resource with the correct options' do | |
64 | 71 | expect( |
65 | a_post("/projects/3/protected_branches").with(body: { name: "api", developers_can_push: 'true' }) | |
72 | a_post('/projects/3/protected_branches').with(body: { name: 'api', developers_can_push: 'true' }) | |
66 | 73 | ).to have_been_made |
67 | 74 | end |
68 | 75 | end |
69 | 76 | end |
70 | 77 | |
71 | describe ".unprotect_branch" do | |
78 | describe '.unprotect_branch' do | |
72 | 79 | before do |
73 | stub_delete("/projects/3/protected_branches/api","branch") | |
74 | @branch = Gitlab.unprotect_branch(3, "api") | |
80 | stub_delete('/projects/3/protected_branches/api', 'branch') | |
81 | @branch = Gitlab.unprotect_branch(3, 'api') | |
75 | 82 | end |
76 | 83 | |
77 | it "gets the correct resource" do | |
78 | expect(a_delete("/projects/3/protected_branches/api")).to have_been_made | |
84 | it 'gets the correct resource' do | |
85 | expect(a_delete('/projects/3/protected_branches/api')).to have_been_made | |
79 | 86 | end |
80 | 87 | |
81 | it "returns information about an unprotected repository branch" do | |
82 | expect(@branch.name).to eq("api") | |
88 | it 'returns information about an unprotected repository branch' do | |
89 | expect(@branch.name).to eq('api') | |
83 | 90 | end |
84 | 91 | end |
85 | 92 | |
86 | describe ".create_branch" do | |
93 | describe '.create_branch' do | |
87 | 94 | before do |
88 | stub_post("/projects/3/repository/branches", "branch").with(query: { branch: 'api', ref: "master"}) | |
89 | @branch = Gitlab.create_branch(3, "api", "master") | |
95 | stub_post('/projects/3/repository/branches', 'branch').with(query: { branch: 'api', ref: 'master' }) | |
96 | @branch = Gitlab.create_branch(3, 'api', 'master') | |
90 | 97 | end |
91 | 98 | |
92 | it "gets the correct resource" do | |
99 | it 'gets the correct resource' do | |
93 | 100 | expect( |
94 | a_post("/projects/3/repository/branches").with(query: { branch: 'api', ref: "master"}) | |
101 | a_post('/projects/3/repository/branches').with(query: { branch: 'api', ref: 'master' }) | |
95 | 102 | ).to have_been_made |
96 | 103 | end |
97 | 104 | |
98 | it "returns information about a new repository branch" do | |
99 | expect(@branch.name).to eq("api") | |
105 | it 'returns information about a new repository branch' do | |
106 | expect(@branch.name).to eq('api') | |
100 | 107 | end |
101 | 108 | end |
102 | 109 | |
103 | describe ".delete_branch" do | |
110 | describe '.delete_branch' do | |
104 | 111 | before do |
105 | stub_delete("/projects/3/repository/branches/api", "branch_delete") | |
106 | @branch = Gitlab.delete_branch(3, "api") | |
112 | stub_delete('/projects/3/repository/branches/api', 'branch_delete') | |
113 | @branch = Gitlab.delete_branch(3, 'api') | |
107 | 114 | end |
108 | 115 | |
109 | it "gets the correct resource" do | |
110 | expect(a_delete("/projects/3/repository/branches/api")).to have_been_made | |
116 | it 'gets the correct resource' do | |
117 | expect(a_delete('/projects/3/repository/branches/api')).to have_been_made | |
111 | 118 | end |
112 | 119 | |
113 | it "returns information about the deleted repository branch" do | |
114 | expect(@branch.branch_name).to eq("api") | |
120 | it 'returns information about the deleted repository branch' do | |
121 | expect(@branch.branch_name).to eq('api') | |
122 | end | |
123 | end | |
124 | ||
125 | describe '.delete_merged_branches' do | |
126 | before do | |
127 | stub_delete('/projects/3/repository/merged_branches', 'empty') | |
128 | @branch = Gitlab.delete_merged_branches(3) | |
129 | end | |
130 | ||
131 | it 'gets the correct resource' do | |
132 | expect(a_delete('/projects/3/repository/merged_branches')).to have_been_made | |
133 | end | |
134 | end | |
135 | ||
136 | describe '.protected_branches' do | |
137 | before do | |
138 | stub_get('/projects/3/protected_branches', 'protected_branches') | |
139 | @branches = Gitlab.protected_branches(3) | |
140 | end | |
141 | ||
142 | it 'gets the correct resource' do | |
143 | expect(a_get('/projects/3/protected_branches')).to have_been_made | |
144 | end | |
145 | ||
146 | it 'returns information about the protected_branches' do | |
147 | expect(@branches).to be_a Gitlab::PaginatedResponse | |
148 | expect(@branches.first.merge_access_levels).to be_a Array | |
149 | expect(@branches.first.push_access_levels).to be_a Array | |
150 | end | |
151 | end | |
152 | ||
153 | describe '.protected_branch' do | |
154 | before do | |
155 | stub_get('/projects/3/protected_branches/master', 'protected_branch') | |
156 | @branch = Gitlab.protected_branch(3, 'master') | |
157 | end | |
158 | ||
159 | it 'gets the correct resource' do | |
160 | expect(a_get('/projects/3/protected_branches/master')).to have_been_made | |
161 | end | |
162 | ||
163 | it 'returns correct information about the protected_branch' do | |
164 | expect(@branch.name).to eq 'master' | |
165 | expect(@branch.merge_access_levels).to be_a Array | |
166 | expect(@branch.push_access_levels).to be_a Array | |
115 | 167 | end |
116 | 168 | end |
117 | 169 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe Gitlab::Client do | |
5 | describe '.broadcast_messages' do | |
6 | before do | |
7 | stub_get('/broadcast_messages', 'broadcast_messages') | |
8 | @broadcast_messages = Gitlab.broadcast_messages | |
9 | end | |
10 | ||
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/broadcast_messages')).to have_been_made | |
13 | end | |
14 | ||
15 | it 'returns a paginated response of broadcast messages' do | |
16 | expect(@broadcast_messages).to be_a Gitlab::PaginatedResponse | |
17 | end | |
18 | end | |
19 | ||
20 | describe '.broadcast_message' do | |
21 | before do | |
22 | stub_get('/broadcast_messages/1', 'broadcast_message') | |
23 | @broadcast_message = Gitlab.broadcast_message(1) | |
24 | end | |
25 | ||
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/broadcast_messages/1')).to have_been_made | |
28 | end | |
29 | ||
30 | it 'returns correct information about the broadcast message' do | |
31 | expect(@broadcast_message.id).to eq 1 | |
32 | end | |
33 | end | |
34 | ||
35 | describe '.create_broadcast_message' do | |
36 | before do | |
37 | stub_post('/broadcast_messages', 'broadcast_message') | |
38 | @broadcast_message = Gitlab.create_broadcast_message('Deploy in progress', color: '#cecece') | |
39 | end | |
40 | ||
41 | it 'gets the correct resource' do | |
42 | expect(a_post('/broadcast_messages') | |
43 | .with(body: { message: 'Deploy in progress', color: '#cecece' })).to have_been_made | |
44 | end | |
45 | ||
46 | it 'returns correct information about the broadcast message created' do | |
47 | expect(@broadcast_message.message).to eq 'Deploy in progress' | |
48 | expect(@broadcast_message.color).to eq '#cecece' | |
49 | end | |
50 | end | |
51 | ||
52 | describe '.edit_broadcast_message' do | |
53 | before do | |
54 | stub_put('/broadcast_messages/1', 'broadcast_message') | |
55 | @broadcast_message = Gitlab.edit_broadcast_message(1, font: '#FFFFFF') | |
56 | end | |
57 | ||
58 | it 'gets the correct resource' do | |
59 | expect(a_put('/broadcast_messages/1') | |
60 | .with(body: { font: '#FFFFFF' })).to have_been_made | |
61 | end | |
62 | ||
63 | it 'returns correct information about the edited broadcast message' do | |
64 | expect(@broadcast_message.font).to eq '#FFFFFF' | |
65 | end | |
66 | end | |
67 | ||
68 | describe '.delete_broadcast_message' do | |
69 | before do | |
70 | stub_delete('/broadcast_messages/1', 'empty') | |
71 | @broadcast_message = Gitlab.delete_broadcast_message(1) | |
72 | end | |
73 | ||
74 | it 'gets the correct resource' do | |
75 | expect(a_delete('/broadcast_messages/1')).to have_been_made | |
76 | end | |
77 | end | |
78 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".variables" do | |
5 | describe '.variables' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/variables", "variables") | |
7 | stub_get('/projects/3/variables', 'variables') | |
6 | 8 | @variables = Gitlab.variables(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/variables")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/variables')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns an array of project's variables" do |
14 | 16 | expect(@variables).to be_a Gitlab::PaginatedResponse |
15 | expect(@variables.first.key).to eq("TEST_VARIABLE_1") | |
16 | expect(@variables.first.value).to eq("TEST_1") | |
17 | expect(@variables.first.key).to eq('TEST_VARIABLE_1') | |
18 | expect(@variables.first.value).to eq('TEST_1') | |
17 | 19 | end |
18 | 20 | end |
19 | 21 | |
20 | describe ".variable" do | |
22 | describe '.variable' do | |
21 | 23 | before do |
22 | stub_get("/projects/3/variables/VARIABLE", "variable") | |
23 | @variable = Gitlab.variable(3, "VARIABLE") | |
24 | stub_get('/projects/3/variables/VARIABLE', 'variable') | |
25 | @variable = Gitlab.variable(3, 'VARIABLE') | |
24 | 26 | end |
25 | 27 | |
26 | it "gets the correct resource" do | |
27 | expect(a_get("/projects/3/variables/VARIABLE")).to have_been_made | |
28 | it 'gets the correct resource' do | |
29 | expect(a_get('/projects/3/variables/VARIABLE')).to have_been_made | |
28 | 30 | end |
29 | 31 | |
30 | it "returns information about a variable" do | |
31 | expect(@variable.key).to eq("VARIABLE") | |
32 | expect(@variable.value).to eq("the value") | |
32 | it 'returns information about a variable' do | |
33 | expect(@variable.key).to eq('VARIABLE') | |
34 | expect(@variable.value).to eq('the value') | |
33 | 35 | end |
34 | 36 | end |
35 | 37 | |
36 | describe ".create_variable" do | |
38 | describe '.create_variable' do | |
37 | 39 | before do |
38 | stub_post("/projects/3/variables", "variable") | |
39 | @variable = Gitlab.create_variable(3, "NEW_VARIABLE", "new value") | |
40 | stub_post('/projects/3/variables', 'variable') | |
41 | @variable = Gitlab.create_variable(3, 'NEW_VARIABLE', 'new value') | |
40 | 42 | end |
41 | 43 | |
42 | it "gets the correct resource" do | |
43 | body = { key: "NEW_VARIABLE", value: "new value" } | |
44 | expect(a_post("/projects/3/variables").with(body: body)).to have_been_made | |
44 | it 'gets the correct resource' do | |
45 | body = { key: 'NEW_VARIABLE', value: 'new value' } | |
46 | expect(a_post('/projects/3/variables').with(body: body)).to have_been_made | |
45 | 47 | end |
46 | 48 | |
47 | it "returns information about a new variable" do | |
48 | expect(@variable.key).to eq("VARIABLE") | |
49 | expect(@variable.value).to eq("the value") | |
49 | it 'returns information about a new variable' do | |
50 | expect(@variable.key).to eq('VARIABLE') | |
51 | expect(@variable.value).to eq('the value') | |
50 | 52 | end |
51 | 53 | end |
52 | 54 | |
53 | describe ".update_variable" do | |
55 | describe '.update_variable' do | |
54 | 56 | before do |
55 | stub_put("/projects/3/variables/UPD_VARIABLE", "variable") | |
56 | @variable = Gitlab.update_variable(3, "UPD_VARIABLE", "updated value") | |
57 | stub_put('/projects/3/variables/UPD_VARIABLE', 'variable') | |
58 | @variable = Gitlab.update_variable(3, 'UPD_VARIABLE', 'updated value') | |
57 | 59 | end |
58 | 60 | |
59 | it "puts the correct resource" do | |
60 | body = { value: "updated value" } | |
61 | expect(a_put("/projects/3/variables/UPD_VARIABLE").with(body: body)).to have_been_made | |
61 | it 'puts the correct resource' do | |
62 | body = { value: 'updated value' } | |
63 | expect(a_put('/projects/3/variables/UPD_VARIABLE').with(body: body)).to have_been_made | |
62 | 64 | end |
63 | 65 | |
64 | it "returns information about an updated variable" do | |
65 | expect(@variable.key).to eq("VARIABLE") | |
66 | expect(@variable.value).to eq("the value") | |
66 | it 'returns information about an updated variable' do | |
67 | expect(@variable.key).to eq('VARIABLE') | |
68 | expect(@variable.value).to eq('the value') | |
67 | 69 | end |
68 | 70 | end |
69 | 71 | |
70 | describe ".remove_variable" do | |
72 | describe '.remove_variable' do | |
71 | 73 | before do |
72 | stub_delete("/projects/3/variables/DEL_VARIABLE", "variable") | |
73 | @variable = Gitlab.remove_variable(3, "DEL_VARIABLE") | |
74 | stub_delete('/projects/3/variables/DEL_VARIABLE', 'variable') | |
75 | @variable = Gitlab.remove_variable(3, 'DEL_VARIABLE') | |
74 | 76 | end |
75 | 77 | |
76 | it "gets the correct resource" do | |
77 | expect(a_delete("/projects/3/variables/DEL_VARIABLE")).to have_been_made | |
78 | it 'gets the correct resource' do | |
79 | expect(a_delete('/projects/3/variables/DEL_VARIABLE')).to have_been_made | |
78 | 80 | end |
79 | 81 | |
80 | it "returns information about a deleted variable" do | |
81 | expect(@variable.key).to eq("VARIABLE") | |
82 | expect(@variable.value).to eq("the value") | |
82 | it 'returns information about a deleted variable' do | |
83 | expect(@variable.key).to eq('VARIABLE') | |
84 | expect(@variable.value).to eq('the value') | |
83 | 85 | end |
84 | 86 | end |
85 | 87 | |
86 | describe ".group_variables" do | |
88 | describe '.group_variables' do | |
87 | 89 | before do |
88 | stub_get("/groups/3/variables", "variables") | |
90 | stub_get('/groups/3/variables', 'variables') | |
89 | 91 | @variables = Gitlab.group_variables(3) |
90 | 92 | end |
91 | 93 | |
92 | it "gets the correct resource" do | |
93 | expect(a_get("/groups/3/variables")).to have_been_made | |
94 | it 'gets the correct resource' do | |
95 | expect(a_get('/groups/3/variables')).to have_been_made | |
94 | 96 | end |
95 | 97 | |
96 | 98 | it "returns an array of group's variables" do |
97 | 99 | expect(@variables).to be_a Gitlab::PaginatedResponse |
98 | expect(@variables.first.key).to eq("TEST_VARIABLE_1") | |
99 | expect(@variables.first.value).to eq("TEST_1") | |
100 | expect(@variables.first.key).to eq('TEST_VARIABLE_1') | |
101 | expect(@variables.first.value).to eq('TEST_1') | |
100 | 102 | end |
101 | 103 | end |
102 | 104 | |
103 | describe ".group_variable" do | |
105 | describe '.group_variable' do | |
104 | 106 | before do |
105 | stub_get("/groups/3/variables/VARIABLE", "variable") | |
106 | @variable = Gitlab.group_variable(3, "VARIABLE") | |
107 | stub_get('/groups/3/variables/VARIABLE', 'variable') | |
108 | @variable = Gitlab.group_variable(3, 'VARIABLE') | |
107 | 109 | end |
108 | 110 | |
109 | it "gets the correct resource" do | |
110 | expect(a_get("/groups/3/variables/VARIABLE")).to have_been_made | |
111 | it 'gets the correct resource' do | |
112 | expect(a_get('/groups/3/variables/VARIABLE')).to have_been_made | |
111 | 113 | end |
112 | 114 | |
113 | it "returns information about a variable" do | |
114 | expect(@variable.key).to eq("VARIABLE") | |
115 | expect(@variable.value).to eq("the value") | |
115 | it 'returns information about a variable' do | |
116 | expect(@variable.key).to eq('VARIABLE') | |
117 | expect(@variable.value).to eq('the value') | |
116 | 118 | end |
117 | 119 | end |
118 | 120 | |
119 | describe ".create_group_variable" do | |
121 | describe '.create_group_variable' do | |
120 | 122 | before do |
121 | stub_post("/groups/3/variables", "variable") | |
122 | @variable = Gitlab.create_group_variable(3, "NEW_VARIABLE", "new value") | |
123 | stub_post('/groups/3/variables', 'variable') | |
124 | @variable = Gitlab.create_group_variable(3, 'NEW_VARIABLE', 'new value') | |
123 | 125 | end |
124 | 126 | |
125 | it "gets the correct resource" do | |
126 | body = { key: "NEW_VARIABLE", value: "new value" } | |
127 | expect(a_post("/groups/3/variables").with(body: body)).to have_been_made | |
127 | it 'gets the correct resource' do | |
128 | body = { key: 'NEW_VARIABLE', value: 'new value' } | |
129 | expect(a_post('/groups/3/variables').with(body: body)).to have_been_made | |
128 | 130 | end |
129 | 131 | |
130 | it "returns information about a new variable" do | |
131 | expect(@variable.key).to eq("VARIABLE") | |
132 | expect(@variable.value).to eq("the value") | |
132 | it 'returns information about a new variable' do | |
133 | expect(@variable.key).to eq('VARIABLE') | |
134 | expect(@variable.value).to eq('the value') | |
133 | 135 | end |
134 | 136 | end |
135 | 137 | |
136 | describe ".update_group_variable" do | |
138 | describe '.update_group_variable' do | |
137 | 139 | before do |
138 | stub_put("/groups/3/variables/UPD_VARIABLE", "variable") | |
139 | @variable = Gitlab.update_group_variable(3, "UPD_VARIABLE", "updated value") | |
140 | stub_put('/groups/3/variables/UPD_VARIABLE', 'variable') | |
141 | @variable = Gitlab.update_group_variable(3, 'UPD_VARIABLE', 'updated value') | |
140 | 142 | end |
141 | 143 | |
142 | it "puts the correct resource" do | |
143 | body = { value: "updated value" } | |
144 | expect(a_put("/groups/3/variables/UPD_VARIABLE").with(body: body)).to have_been_made | |
144 | it 'puts the correct resource' do | |
145 | body = { value: 'updated value' } | |
146 | expect(a_put('/groups/3/variables/UPD_VARIABLE').with(body: body)).to have_been_made | |
145 | 147 | end |
146 | 148 | |
147 | it "returns information about an updated variable" do | |
148 | expect(@variable.key).to eq("VARIABLE") | |
149 | expect(@variable.value).to eq("the value") | |
149 | it 'returns information about an updated variable' do | |
150 | expect(@variable.key).to eq('VARIABLE') | |
151 | expect(@variable.value).to eq('the value') | |
150 | 152 | end |
151 | 153 | end |
152 | 154 | |
153 | describe ".remove_group_variable" do | |
155 | describe '.remove_group_variable' do | |
154 | 156 | before do |
155 | stub_delete("/groups/3/variables/DEL_VARIABLE", "variable") | |
156 | @variable = Gitlab.remove_group_variable(3, "DEL_VARIABLE") | |
157 | stub_delete('/groups/3/variables/DEL_VARIABLE', 'variable') | |
158 | @variable = Gitlab.remove_group_variable(3, 'DEL_VARIABLE') | |
157 | 159 | end |
158 | 160 | |
159 | it "gets the correct resource" do | |
160 | expect(a_delete("/groups/3/variables/DEL_VARIABLE")).to have_been_made | |
161 | it 'gets the correct resource' do | |
162 | expect(a_delete('/groups/3/variables/DEL_VARIABLE')).to have_been_made | |
161 | 163 | end |
162 | 164 | |
163 | it "returns information about a deleted variable" do | |
164 | expect(@variable.key).to eq("VARIABLE") | |
165 | expect(@variable.value).to eq("the value") | |
165 | it 'returns information about a deleted variable' do | |
166 | expect(@variable.key).to eq('VARIABLE') | |
167 | expect(@variable.value).to eq('the value') | |
166 | 168 | end |
167 | 169 | end |
168 | 170 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".builds" do | |
5 | describe '.builds' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/builds", "builds") | |
7 | stub_get('/projects/3/builds', 'builds') | |
6 | 8 | @builds = Gitlab.builds(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/builds")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/builds')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of project's builds" do |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".build" do | |
20 | describe '.build' do | |
19 | 21 | before do |
20 | stub_get("/projects/3/builds/8", "build") | |
22 | stub_get('/projects/3/builds/8', 'build') | |
21 | 23 | @build = Gitlab.build(3, 8) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/projects/3/builds/8")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/3/builds/8')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | it "returns a single build" do | |
30 | it 'returns a single build' do | |
29 | 31 | expect(@build).to be_a Gitlab::ObjectifiedHash |
30 | 32 | end |
31 | 33 | |
32 | it "returns information about a build" do | |
34 | it 'returns information about a build' do | |
33 | 35 | expect(@build.id).to eq(8) |
34 | expect(@build.user.name).to eq("John Smith") | |
36 | expect(@build.user.name).to eq('John Smith') | |
35 | 37 | end |
36 | 38 | end |
37 | 39 | |
38 | describe ".build_artifacts" do | |
39 | context "when successful request" do | |
40 | describe '.build_artifacts' do | |
41 | context 'when successful request' do | |
40 | 42 | before do |
41 | 43 | fixture = load_fixture('build_artifacts') |
42 | 44 | fixture.set_encoding(Encoding::ASCII_8BIT) |
43 | stub_request(:get, "#{Gitlab.endpoint}/projects/3/builds/8/artifacts"). | |
44 | with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }). | |
45 | to_return(body: fixture.read, headers: { 'Content-Disposition' => "attachment; filename=artifacts.zip" }) | |
45 | stub_request(:get, "#{Gitlab.endpoint}/projects/3/builds/8/artifacts") | |
46 | .with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }) | |
47 | .to_return(body: fixture.read, headers: { 'Content-Disposition' => 'attachment; filename=artifacts.zip' }) | |
46 | 48 | @build_artifacts = Gitlab.build_artifacts(3, 8) |
47 | 49 | end |
48 | 50 | |
49 | it "gets the correct resource" do | |
50 | expect(a_get("/projects/3/builds/8/artifacts")).to have_been_made | |
51 | it 'gets the correct resource' do | |
52 | expect(a_get('/projects/3/builds/8/artifacts')).to have_been_made | |
51 | 53 | end |
52 | 54 | |
53 | it "returns a FileResponse" do | |
55 | it 'returns a FileResponse' do | |
54 | 56 | expect(@build_artifacts).to be_a Gitlab::FileResponse |
55 | 57 | end |
56 | 58 | |
57 | it "returns a file with filename" do | |
58 | expect(@build_artifacts.filename).to eq "artifacts.zip" | |
59 | it 'returns a file with filename' do | |
60 | expect(@build_artifacts.filename).to eq 'artifacts.zip' | |
59 | 61 | end |
60 | 62 | end |
61 | 63 | |
62 | context "when bad request" do | |
63 | it "throws an exception" do | |
64 | stub_get("/projects/3/builds/8/artifacts", "error_project_not_found", 404) | |
65 | expect{ Gitlab.build_artifacts(3, 8) }.to raise_error(Gitlab::Error::NotFound, "Server responded with code 404, message: 404 Project Not Found. Request URI: #{Gitlab.endpoint}/projects/3/builds/8/artifacts") | |
64 | context 'when bad request' do | |
65 | it 'throws an exception' do | |
66 | stub_get('/projects/3/builds/8/artifacts', 'error_project_not_found', 404) | |
67 | expect { Gitlab.build_artifacts(3, 8) }.to raise_error(Gitlab::Error::NotFound, "Server responded with code 404, message: 404 Project Not Found. Request URI: #{Gitlab.endpoint}/projects/3/builds/8/artifacts") | |
66 | 68 | end |
67 | 69 | end |
68 | 70 | end |
69 | 71 | |
70 | describe ".builds_commits" do | |
72 | describe '.builds_commits' do | |
71 | 73 | before do |
72 | stub_get("/projects/3/repository/commits/0ff3ae198f8601a285adcf5c0fff204ee6fba5fd/builds", "builds_commits") | |
73 | @builds_commits = Gitlab.commit_builds(3, "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd") | |
74 | stub_get('/projects/3/repository/commits/0ff3ae198f8601a285adcf5c0fff204ee6fba5fd/builds', 'builds_commits') | |
75 | @builds_commits = Gitlab.commit_builds(3, '0ff3ae198f8601a285adcf5c0fff204ee6fba5fd') | |
74 | 76 | end |
75 | 77 | |
76 | it "gets the correct resource" do | |
77 | expect(a_get("/projects/3/repository/commits/0ff3ae198f8601a285adcf5c0fff204ee6fba5fd/builds")).to have_been_made | |
78 | it 'gets the correct resource' do | |
79 | expect(a_get('/projects/3/repository/commits/0ff3ae198f8601a285adcf5c0fff204ee6fba5fd/builds')).to have_been_made | |
78 | 80 | end |
79 | 81 | |
80 | it "returns a paginated response of commit builds" do | |
82 | it 'returns a paginated response of commit builds' do | |
81 | 83 | expect(@builds_commits).to be_a Gitlab::PaginatedResponse |
82 | 84 | end |
83 | 85 | |
84 | it "returns information about the builds" do | |
86 | it 'returns information about the builds' do | |
85 | 87 | expect(@builds_commits.count).to eq(2) |
86 | 88 | end |
87 | 89 | end |
88 | 90 | |
89 | ||
90 | ||
91 | describe ".build_cancel" do | |
91 | describe '.build_cancel' do | |
92 | 92 | before do |
93 | stub_post("/projects/3/builds/8/cancel", "build_cancel") | |
93 | stub_post('/projects/3/builds/8/cancel', 'build_cancel') | |
94 | 94 | @build_cancel = Gitlab.build_cancel(3, 8) |
95 | 95 | end |
96 | 96 | |
97 | it "gets the correct resource" do | |
98 | expect(a_post("/projects/3/builds/8/cancel")).to have_been_made | |
97 | it 'gets the correct resource' do | |
98 | expect(a_post('/projects/3/builds/8/cancel')).to have_been_made | |
99 | 99 | end |
100 | 100 | |
101 | it "returns a single build" do | |
101 | it 'returns a single build' do | |
102 | 102 | expect(@build_cancel).to be_a Gitlab::ObjectifiedHash |
103 | 103 | end |
104 | 104 | |
105 | it "returns information about a build" do | |
106 | expect(@build_cancel.commit.author_name).to eq("John Smith") | |
105 | it 'returns information about a build' do | |
106 | expect(@build_cancel.commit.author_name).to eq('John Smith') | |
107 | 107 | end |
108 | 108 | end |
109 | 109 | |
110 | describe ".build_retry" do | |
110 | describe '.build_retry' do | |
111 | 111 | before do |
112 | stub_post("/projects/3/builds/69/retry", "build_retry") | |
112 | stub_post('/projects/3/builds/69/retry', 'build_retry') | |
113 | 113 | @build_retry = Gitlab.build_retry(3, 69) |
114 | 114 | end |
115 | 115 | |
116 | it "gets the correct resource" do | |
117 | expect(a_post("/projects/3/builds/69/retry")).to have_been_made | |
116 | it 'gets the correct resource' do | |
117 | expect(a_post('/projects/3/builds/69/retry')).to have_been_made | |
118 | 118 | end |
119 | 119 | |
120 | it "returns a single build" do | |
120 | it 'returns a single build' do | |
121 | 121 | expect(@build_retry).to be_a Gitlab::ObjectifiedHash |
122 | 122 | end |
123 | 123 | |
124 | it "returns information about a build" do | |
125 | expect(@build_retry.commit.author_name).to eq("John Smith") | |
124 | it 'returns information about a build' do | |
125 | expect(@build_retry.commit.author_name).to eq('John Smith') | |
126 | 126 | end |
127 | 127 | end |
128 | 128 | |
129 | describe ".build_erase" do | |
129 | describe '.build_erase' do | |
130 | 130 | before do |
131 | stub_post("/projects/3/builds/69/erase", "build_erase") | |
131 | stub_post('/projects/3/builds/69/erase', 'build_erase') | |
132 | 132 | @build_retry = Gitlab.build_erase(3, 69) |
133 | 133 | end |
134 | 134 | |
135 | it "gets the correct resource" do | |
136 | expect(a_post("/projects/3/builds/69/erase")).to have_been_made | |
135 | it 'gets the correct resource' do | |
136 | expect(a_post('/projects/3/builds/69/erase')).to have_been_made | |
137 | 137 | end |
138 | 138 | |
139 | it "returns a single build" do | |
139 | it 'returns a single build' do | |
140 | 140 | expect(@build_retry).to be_a Gitlab::ObjectifiedHash |
141 | 141 | end |
142 | 142 | |
143 | it "returns information about a build" do | |
144 | expect(@build_retry.commit.author_name).to eq("John Smith") | |
143 | it 'returns information about a build' do | |
144 | expect(@build_retry.commit.author_name).to eq('John Smith') | |
145 | 145 | end |
146 | 146 | end |
147 | 147 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
9 | 11 | it { is_expected.to respond_to :repo_update_commit_status } |
10 | 12 | it { is_expected.to respond_to :repo_commit_merge_requests } |
11 | 13 | |
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 "gets 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 "returns a paginated response of repository commits" do | |
14 | describe '.commits' do | |
15 | before do | |
16 | stub_get('/projects/3/repository/commits', 'project_commits') | |
17 | .with(query: { ref_name: 'api' }) | |
18 | @commits = Gitlab.commits(3, ref_name: 'api') | |
19 | end | |
20 | ||
21 | it 'gets the correct resource' do | |
22 | expect(a_get('/projects/3/repository/commits') | |
23 | .with(query: { ref_name: 'api' })).to have_been_made | |
24 | end | |
25 | ||
26 | it 'returns a paginated response of repository commits' do | |
25 | 27 | expect(@commits).to be_a Gitlab::PaginatedResponse |
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") | |
28 | expect(@commits.first.id).to eq('f7dd067490fe57505f7226c3b54d3127d2f7fd46') | |
29 | end | |
30 | end | |
31 | ||
32 | describe '.commit' do | |
33 | before do | |
34 | stub_get('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6', 'project_commit') | |
33 | 35 | @commit = Gitlab.commit(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6') |
34 | 36 | end |
35 | 37 | |
36 | it "gets the correct resource" do | |
37 | expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6")). | |
38 | to have_been_made | |
39 | end | |
40 | ||
41 | it "returns 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") | |
38 | it 'gets the correct resource' do | |
39 | expect(a_get('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6')) | |
40 | .to have_been_made | |
41 | end | |
42 | ||
43 | it 'returns a repository commit' do | |
44 | expect(@commit.id).to eq('6104942438c14ec7bd21c6cd5bd995272b3faff6') | |
45 | end | |
46 | end | |
47 | ||
48 | describe '.cherry_pick_commit' do | |
49 | before do | |
50 | stub_post('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/cherry_pick', 'project_commit').with(body: { branch: 'master' }) | |
51 | @cherry_pick_commit = Gitlab.cherry_pick_commit(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'master') | |
52 | end | |
53 | ||
54 | it 'gets the correct resource' do | |
55 | expect(a_post('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/cherry_pick') | |
56 | .with(body: { branch: 'master' })) | |
57 | .to have_been_made | |
58 | end | |
59 | ||
60 | it 'returns the correct response' do | |
61 | expect(@cherry_pick_commit).to be_a Gitlab::ObjectifiedHash | |
62 | expect(@cherry_pick_commit.id).to eq('6104942438c14ec7bd21c6cd5bd995272b3faff6') | |
63 | end | |
64 | end | |
65 | ||
66 | describe '.commit_diff' do | |
67 | before do | |
68 | stub_get('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff', 'project_commit_diff') | |
49 | 69 | @diff = Gitlab.commit_diff(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6') |
50 | 70 | end |
51 | 71 | |
52 | it "gets the correct resource" do | |
53 | expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff")). | |
54 | to have_been_made | |
55 | end | |
56 | ||
57 | it "returns 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") | |
72 | it 'gets the correct resource' do | |
73 | expect(a_get('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff')) | |
74 | .to have_been_made | |
75 | end | |
76 | ||
77 | it 'returns a diff of a commit' do | |
78 | expect(@diff.new_path).to eq('doc/update/5.4-to-6.0.md') | |
79 | end | |
80 | end | |
81 | ||
82 | describe '.commit_comments' do | |
83 | before do | |
84 | stub_get('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments', 'project_commit_comments') | |
65 | 85 | @commit_comments = Gitlab.commit_comments(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6') |
66 | 86 | end |
67 | 87 | |
68 | it "gets the correct resource" do | |
69 | expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments")). | |
70 | to have_been_made | |
88 | it 'gets the correct resource' do | |
89 | expect(a_get('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments')) | |
90 | .to have_been_made | |
71 | 91 | end |
72 | 92 | |
73 | 93 | it "returns commit's comments" do |
74 | 94 | expect(@commit_comments).to be_a Gitlab::PaginatedResponse |
75 | 95 | expect(@commit_comments.length).to eq(2) |
76 | expect(@commit_comments[0].note).to eq("this is the 1st comment on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6") | |
96 | expect(@commit_comments[0].note).to eq('this is the 1st comment on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6') | |
77 | 97 | expect(@commit_comments[0].author.id).to eq(11) |
78 | expect(@commit_comments[1].note).to eq("another discussion point on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6") | |
98 | expect(@commit_comments[1].note).to eq('another discussion point on commit 6104942438c14ec7bd21c6cd5bd995272b3faff6') | |
79 | 99 | expect(@commit_comments[1].author.id).to eq(12) |
80 | 100 | end |
81 | 101 | end |
82 | 102 | |
83 | describe ".create_commit_comment" do | |
84 | before do | |
85 | stub_post("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments", "project_commit_comment") | |
103 | describe '.create_commit_comment' do | |
104 | before do | |
105 | stub_post('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/comments', 'project_commit_comment') | |
86 | 106 | @merge_request = Gitlab.create_commit_comment(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6', 'Nice code!') |
87 | 107 | end |
88 | 108 | |
89 | it "returns information about the newly created comment" do | |
109 | it 'returns information about the newly created comment' do | |
90 | 110 | expect(@merge_request.note).to eq('Nice code!') |
91 | 111 | expect(@merge_request.author.id).to eq(1) |
92 | 112 | end |
93 | 113 | end |
94 | 114 | |
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' }) | |
115 | describe '.commit_status' do | |
116 | before do | |
117 | stub_get('/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses', 'project_commit_status') | |
118 | .with(query: { all: 'true' }) | |
99 | 119 | @statuses = Gitlab.commit_status(6, '7d938cb8ac15788d71f4b67c035515a160ea76d8', all: true) |
100 | 120 | end |
101 | 121 | |
102 | it "gets the correct resource" do | |
103 | expect(a_get("/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses"). | |
104 | with(query: { all: true })) | |
105 | end | |
106 | ||
107 | it "gets statuses of a commit" do | |
122 | it 'gets the correct resource' do | |
123 | expect(a_get('/projects/6/repository/commits/7d938cb8ac15788d71f4b67c035515a160ea76d8/statuses') | |
124 | .with(query: { all: true })) | |
125 | end | |
126 | ||
127 | it 'gets statuses of a commit' do | |
108 | 128 | expect(@statuses).to be_kind_of Gitlab::PaginatedResponse |
109 | 129 | expect(@statuses.first.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8') |
110 | 130 | expect(@statuses.first.ref).to eq('decreased-spec') |
114 | 134 | end |
115 | 135 | end |
116 | 136 | |
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' }) | |
137 | describe '.update_commit_status' do | |
138 | before do | |
139 | stub_post('/projects/6/statuses/7d938cb8ac15788d71f4b67c035515a160ea76d8', 'project_update_commit_status') | |
140 | .with(query: { name: 'test', ref: 'decreased-spec', state: 'failed' }) | |
121 | 141 | @status = Gitlab.update_commit_status(6, '7d938cb8ac15788d71f4b67c035515a160ea76d8', 'failed', name: 'test', ref: 'decreased-spec') |
122 | 142 | end |
123 | 143 | |
124 | it "gets 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 "returns information about the newly created status" do | |
144 | it 'gets the correct resource' do | |
145 | expect(a_post('/projects/6/statuses/7d938cb8ac15788d71f4b67c035515a160ea76d8') | |
146 | .with(query: { name: 'test', ref: 'decreased-spec', state: 'failed' })) | |
147 | end | |
148 | ||
149 | it 'returns information about the newly created status' do | |
130 | 150 | expect(@status).to be_kind_of Gitlab::ObjectifiedHash |
131 | 151 | expect(@status.id).to eq(498) |
132 | 152 | expect(@status.sha).to eq('7d938cb8ac15788d71f4b67c035515a160ea76d8') |
135 | 155 | end |
136 | 156 | end |
137 | 157 | |
138 | describe ".create_commit" do | |
158 | describe '.create_commit' do | |
139 | 159 | let(:actions) do |
140 | 160 | [ |
141 | 161 | { |
142 | action: "create", | |
143 | file_path: "foo/bar", | |
144 | content: "some content" | |
162 | action: 'create', | |
163 | file_path: 'foo/bar', | |
164 | content: 'some content' | |
145 | 165 | } |
146 | 166 | ] |
147 | 167 | end |
157 | 177 | end |
158 | 178 | |
159 | 179 | before do |
160 | stub_post("/projects/6/repository/commits", 'project_commit_create').with(body: query) | |
161 | @commit = Gitlab.create_commit(6, 'dev', 'refactors everything', actions, {author_email: 'joe@sample.org', author_name: 'Joe Sample'}) | |
162 | end | |
163 | ||
164 | it "returns id of a created commit" do | |
180 | stub_post('/projects/6/repository/commits', 'project_commit_create').with(body: query) | |
181 | @commit = Gitlab.create_commit(6, 'dev', 'refactors everything', actions, author_email: 'joe@sample.org', author_name: 'Joe Sample') | |
182 | end | |
183 | ||
184 | it 'returns id of a created commit' do | |
165 | 185 | expect(@commit.id).to eq('ed899a2f4b50b4370feeea94676502b42383c746') |
166 | 186 | end |
167 | 187 | end |
168 | 188 | |
169 | describe ".repo_commit_merge_requests" do | |
170 | before do | |
171 | stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/merge_requests", "project_commit_merge_requests") | |
189 | describe '.repo_commit_merge_requests' do | |
190 | before do | |
191 | stub_get('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/merge_requests', 'project_commit_merge_requests') | |
172 | 192 | @commit_merge_requests = Gitlab.commit_merge_requests(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6') |
173 | 193 | end |
174 | 194 | |
175 | it "gets the correct resource" do | |
176 | expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/merge_requests")). | |
177 | to have_been_made | |
195 | it 'gets the correct resource' do | |
196 | expect(a_get('/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/merge_requests')) | |
197 | .to have_been_made | |
178 | 198 | end |
179 | 199 | |
180 | 200 | it "returns commit's associated merge_requests" do |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".deployments" do | |
5 | describe '.deployments' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/deployments", "deployments") | |
7 | stub_get('/projects/3/deployments', 'deployments') | |
6 | 8 | @deployments = Gitlab.deployments(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/deployments")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/deployments')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of project's deployments" do |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".deployment" do | |
20 | describe '.deployment' do | |
19 | 21 | before do |
20 | stub_get("/projects/3/deployments/42", "deployment") | |
22 | stub_get('/projects/3/deployments/42', 'deployment') | |
21 | 23 | @deployment = Gitlab.deployment(3, 42) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/projects/3/deployments/42")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/3/deployments/42')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | it "returns a single deployment" do | |
30 | it 'returns a single deployment' do | |
29 | 31 | expect(@deployment).to be_a Gitlab::ObjectifiedHash |
30 | 32 | end |
31 | 33 | |
32 | it "returns information about an deployment" do | |
34 | it 'returns information about an deployment' do | |
33 | 35 | expect(@deployment.id).to eq(42) |
34 | expect(@deployment.deployable.commit.id).to eq("a91957a858320c0e17f3a0eca7cfacbff50ea29a") | |
36 | expect(@deployment.deployable.commit.id).to eq('a91957a858320c0e17f3a0eca7cfacbff50ea29a') | |
35 | 37 | end |
36 | 38 | end |
37 | 39 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".environments" do | |
5 | describe '.environments' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/environments", "environments") | |
7 | stub_get('/projects/3/environments', 'environments') | |
6 | 8 | @environments = Gitlab.environments(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/environments")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/environments')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of project's environments" do |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".environment" do | |
20 | describe '.environment' do | |
19 | 21 | before do |
20 | stub_get("/projects/3/environments/12", "environment") | |
22 | stub_get('/projects/3/environments/12', 'environment') | |
21 | 23 | @environment = Gitlab.environment(3, 12) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/projects/3/environments/12")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/3/environments/12')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | it "returns a single environment" do | |
30 | it 'returns a single environment' do | |
29 | 31 | expect(@environment).to be_a Gitlab::ObjectifiedHash |
30 | 32 | end |
31 | 33 | |
32 | it "returns information about an environment" do | |
34 | it 'returns information about an environment' do | |
33 | 35 | expect(@environment.id).to eq(12) |
34 | expect(@environment.name).to eq("staging") | |
36 | expect(@environment.name).to eq('staging') | |
35 | 37 | end |
36 | 38 | end |
37 | 39 | |
38 | describe ".create_environment" do | |
39 | context "without external_url" do | |
40 | describe '.create_environment' do | |
41 | context 'without external_url' do | |
40 | 42 | before do |
41 | stub_post("/projects/3/environments", "environment") | |
43 | stub_post('/projects/3/environments', 'environment') | |
42 | 44 | @environment = Gitlab.create_environment(3, 'staging') |
43 | 45 | end |
44 | 46 | |
45 | it "gets the correct resource" do | |
46 | expect(a_post("/projects/3/environments").with(body: { name: 'staging' })).to have_been_made | |
47 | it 'gets the correct resource' do | |
48 | expect(a_post('/projects/3/environments').with(body: { name: 'staging' })).to have_been_made | |
47 | 49 | end |
48 | 50 | |
49 | it "returns a single environment" do | |
51 | it 'returns a single environment' do | |
50 | 52 | expect(@environment).to be_a Gitlab::ObjectifiedHash |
51 | 53 | end |
52 | 54 | |
53 | it "returns information about an environment" do | |
54 | expect(@environment.name).to eq("staging") | |
55 | it 'returns information about an environment' do | |
56 | expect(@environment.name).to eq('staging') | |
55 | 57 | end |
56 | 58 | end |
57 | 59 | |
58 | context "with external_url" do | |
60 | context 'with external_url' do | |
59 | 61 | before do |
60 | stub_post("/projects/3/environments", "environment") | |
61 | @environment = Gitlab.create_environment(3, 'staging', external_url: "https://staging.example.gitlab.com") | |
62 | stub_post('/projects/3/environments', 'environment') | |
63 | @environment = Gitlab.create_environment(3, 'staging', external_url: 'https://staging.example.gitlab.com') | |
62 | 64 | end |
63 | 65 | |
64 | it "gets the correct resource" do | |
65 | expect(a_post("/projects/3/environments") | |
66 | .with(body: { name: 'staging', external_url: "https://staging.example.gitlab.com" })).to have_been_made | |
66 | it 'gets the correct resource' do | |
67 | expect(a_post('/projects/3/environments') | |
68 | .with(body: { name: 'staging', external_url: 'https://staging.example.gitlab.com' })).to have_been_made | |
67 | 69 | end |
68 | 70 | end |
69 | 71 | end |
70 | 72 | |
71 | describe ".edit_environment" do | |
73 | describe '.edit_environment' do | |
72 | 74 | before do |
73 | stub_put("/projects/3/environments/12", "environment") | |
74 | @environment = Gitlab.edit_environment(3, 12, { | |
75 | name: 'staging', | |
76 | external_url: "https://staging.example.gitlab.com" | |
77 | }) | |
75 | stub_put('/projects/3/environments/12', 'environment') | |
76 | @environment = Gitlab.edit_environment(3, 12, | |
77 | name: 'staging', | |
78 | external_url: 'https://staging.example.gitlab.com') | |
78 | 79 | end |
79 | 80 | |
80 | it "gets the correct resource" do | |
81 | expect(a_put("/projects/3/environments/12") | |
82 | .with(body: { name: 'staging', external_url: "https://staging.example.gitlab.com" })).to have_been_made | |
81 | it 'gets the correct resource' do | |
82 | expect(a_put('/projects/3/environments/12') | |
83 | .with(body: { name: 'staging', external_url: 'https://staging.example.gitlab.com' })).to have_been_made | |
83 | 84 | end |
84 | 85 | |
85 | it "returns a single environment" do | |
86 | it 'returns a single environment' do | |
86 | 87 | expect(@environment).to be_a Gitlab::ObjectifiedHash |
87 | 88 | end |
88 | 89 | |
89 | it "returns information about an environment" do | |
90 | expect(@environment.name).to eq("staging") | |
90 | it 'returns information about an environment' do | |
91 | expect(@environment.name).to eq('staging') | |
91 | 92 | end |
92 | 93 | end |
93 | 94 | |
94 | describe ".delete_environment" do | |
95 | describe '.delete_environment' do | |
95 | 96 | before do |
96 | stub_delete("/projects/3/environments/12", "environment") | |
97 | stub_delete('/projects/3/environments/12', 'environment') | |
97 | 98 | @environment = Gitlab.delete_environment(3, 12) |
98 | 99 | end |
99 | 100 | |
100 | it "gets the correct resource" do | |
101 | expect(a_delete("/projects/3/environments/12")).to have_been_made | |
101 | it 'gets the correct resource' do | |
102 | expect(a_delete('/projects/3/environments/12')).to have_been_made | |
102 | 103 | end |
103 | 104 | |
104 | it "returns a single pipeline" do | |
105 | it 'returns a single pipeline' do | |
105 | 106 | expect(@environment).to be_a Gitlab::ObjectifiedHash |
106 | 107 | end |
107 | 108 | |
108 | it "returns information about a pipeline" do | |
109 | expect(@environment.name).to eq("staging") | |
109 | it 'returns information about a pipeline' do | |
110 | expect(@environment.name).to eq('staging') | |
110 | 111 | end |
111 | 112 | end |
112 | 113 | |
113 | describe ".stop_environment" do | |
114 | describe '.stop_environment' do | |
114 | 115 | before do |
115 | stub_post("/projects/3/environments/12/stop", "environment") | |
116 | stub_post('/projects/3/environments/12/stop', 'environment') | |
116 | 117 | @environment = Gitlab.stop_environment(3, 12) |
117 | 118 | end |
118 | 119 | |
119 | it "gets the correct resource" do | |
120 | expect(a_post("/projects/3/environments/12/stop")).to have_been_made | |
120 | it 'gets the correct resource' do | |
121 | expect(a_post('/projects/3/environments/12/stop')).to have_been_made | |
121 | 122 | end |
122 | 123 | |
123 | it "returns a single pipeline" do | |
124 | it 'returns a single pipeline' do | |
124 | 125 | expect(@environment).to be_a Gitlab::ObjectifiedHash |
125 | 126 | end |
126 | 127 | |
127 | it "returns information about a pipeline" do | |
128 | expect(@environment.name).to eq("staging") | |
128 | it 'returns information about a pipeline' do | |
129 | expect(@environment.name).to eq('staging') | |
129 | 130 | end |
130 | 131 | end |
131 | 132 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".events" do | |
5 | describe '.events' do | |
4 | 6 | before do |
5 | stub_get("/events", "user_events") | |
6 | @events = Gitlab.events() | |
7 | stub_get('/events', 'user_events') | |
8 | @events = Gitlab.events | |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/events")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/events')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | it "it returns a response of user's events" do | |
15 | it "returns a response of user's events" do | |
14 | 16 | expect(@events).to be_a Gitlab::PaginatedResponse |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".user_events" do | |
20 | describe '.user_events' do | |
19 | 21 | before do |
20 | stub_get("/users/1/events", "user_events") | |
22 | stub_get('/users/1/events', 'user_events') | |
21 | 23 | @events = Gitlab.user_events(1) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/users/1/events")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/users/1/events')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | 30 | it "returns a response of user's contribution events" do |
32 | 34 | |
33 | 35 | describe '.project_events' do |
34 | 36 | before do |
35 | stub_get("/1/events", "project_events") | |
37 | stub_get('/projects/1/events', 'project_events') | |
36 | 38 | @events = Gitlab.project_events(1) |
37 | 39 | end |
38 | 40 | |
39 | it "gets the correct resource" do | |
40 | expect(a_get("/1/events")).to have_been_made | |
41 | it 'gets the correct resource' do | |
42 | expect(a_get('/projects/1/events')).to have_been_made | |
41 | 43 | end |
42 | 44 | |
43 | 45 | it "returns a response of project's visible events" do |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".group_milestones" do | |
5 | describe '.group_milestones' do | |
4 | 6 | before do |
5 | stub_get("/groups/3/milestones", "group_milestones") | |
7 | stub_get('/groups/3/milestones', 'group_milestones') | |
6 | 8 | @milestones = Gitlab.group_milestones(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/groups/3/milestones")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/groups/3/milestones')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of group's milestones" do |
16 | 18 | end |
17 | 19 | end |
18 | 20 | |
19 | describe ".group_milestone" do | |
21 | describe '.group_milestone' do | |
20 | 22 | before do |
21 | stub_get("/groups/3/milestones/1", "group_milestone") | |
23 | stub_get('/groups/3/milestones/1', 'group_milestone') | |
22 | 24 | @milestone = Gitlab.group_milestone(3, 1) |
23 | 25 | end |
24 | 26 | |
25 | it "gets the correct resource" do | |
26 | expect(a_get("/groups/3/milestones/1")).to have_been_made | |
27 | it 'gets the correct resource' do | |
28 | expect(a_get('/groups/3/milestones/1')).to have_been_made | |
27 | 29 | end |
28 | 30 | |
29 | it "returns information about a milestone" do | |
31 | it 'returns information about a milestone' do | |
30 | 32 | expect(@milestone.group_id).to eq(3) |
31 | 33 | end |
32 | 34 | end |
33 | 35 | |
34 | describe ".create_group_milestone" do | |
36 | describe '.create_group_milestone' do | |
35 | 37 | before do |
36 | stub_post("/groups/3/milestones", "group_milestone") | |
38 | stub_post('/groups/3/milestones', 'group_milestone') | |
37 | 39 | @milestone = Gitlab.create_group_milestone(3, 'title') |
38 | 40 | end |
39 | 41 | |
40 | it "gets the correct resource" do | |
41 | expect(a_post("/groups/3/milestones"). | |
42 | with(body: { title: 'title' })).to have_been_made | |
42 | it 'gets the correct resource' do | |
43 | expect(a_post('/groups/3/milestones') | |
44 | .with(body: { title: 'title' })).to have_been_made | |
43 | 45 | end |
44 | 46 | |
45 | it "returns information about a created milestone" do | |
47 | it 'returns information about a created milestone' do | |
46 | 48 | expect(@milestone.group_id).to eq(3) |
47 | 49 | end |
48 | 50 | end |
49 | 51 | |
50 | describe ".edit_group_milestone" do | |
52 | describe '.edit_group_milestone' do | |
51 | 53 | before do |
52 | stub_put("/groups/3/milestones/33", "group_milestone") | |
54 | stub_put('/groups/3/milestones/33', 'group_milestone') | |
53 | 55 | @milestone = Gitlab.edit_group_milestone(3, 33, title: 'title') |
54 | 56 | end |
55 | 57 | |
56 | it "gets the correct resource" do | |
57 | expect(a_put("/groups/3/milestones/33"). | |
58 | with(body: { title: 'title' })).to have_been_made | |
58 | it 'gets the correct resource' do | |
59 | expect(a_put('/groups/3/milestones/33') | |
60 | .with(body: { title: 'title' })).to have_been_made | |
59 | 61 | end |
60 | 62 | |
61 | it "returns information about an edited milestone" do | |
63 | it 'returns information about an edited milestone' do | |
62 | 64 | expect(@milestone.group_id).to eq(3) |
63 | 65 | end |
64 | 66 | end |
65 | 67 | |
66 | describe ".group_milestone_issues" do | |
68 | describe '.group_milestone_issues' do | |
67 | 69 | before do |
68 | stub_get("/groups/3/milestones/1/issues", "group_milestone_issues") | |
70 | stub_get('/groups/3/milestones/1/issues', 'group_milestone_issues') | |
69 | 71 | @milestone_issues = Gitlab.group_milestone_issues(3, 1) |
70 | 72 | end |
71 | 73 | |
72 | it "gets the correct resource" do | |
73 | expect(a_get("/groups/3/milestones/1/issues")).to have_been_made | |
74 | it 'gets the correct resource' do | |
75 | expect(a_get('/groups/3/milestones/1/issues')).to have_been_made | |
74 | 76 | end |
75 | 77 | |
76 | 78 | it "returns a paginated response of milestone's issues" do |
79 | 81 | end |
80 | 82 | end |
81 | 83 | |
82 | describe ".group_milestone_merge_requests" do | |
84 | describe '.group_milestone_merge_requests' do | |
83 | 85 | before do |
84 | stub_get("/groups/3/milestones/1/merge_requests", "group_milestone_merge_requests") | |
86 | stub_get('/groups/3/milestones/1/merge_requests', 'group_milestone_merge_requests') | |
85 | 87 | @milestone_merge_requests = Gitlab.group_milestone_merge_requests(3, 1) |
86 | 88 | end |
87 | 89 | |
88 | it "gets the correct resource" do | |
89 | expect(a_get("/groups/3/milestones/1/merge_requests")).to have_been_made | |
90 | it 'gets the correct resource' do | |
91 | expect(a_get('/groups/3/milestones/1/merge_requests')).to have_been_made | |
90 | 92 | end |
91 | 93 | |
92 | 94 | it "returns a paginated response of milestone's merge_requests" do |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".groups" do | |
4 | before do | |
5 | stub_get("/groups", "groups") | |
6 | stub_get("/groups/3", "group") | |
5 | describe '.groups' do | |
6 | before do | |
7 | stub_get('/groups', 'groups') | |
8 | stub_get('/groups/3', 'group') | |
7 | 9 | @group = Gitlab.group(3) |
8 | 10 | @groups = Gitlab.groups |
9 | 11 | end |
10 | 12 | |
11 | it "gets the correct resource" do | |
12 | expect(a_get("/groups")).to have_been_made | |
13 | expect(a_get("/groups/3")).to have_been_made | |
14 | end | |
15 | ||
16 | it "returns a paginated response of groups" do | |
13 | it 'gets the correct resource' do | |
14 | expect(a_get('/groups')).to have_been_made | |
15 | expect(a_get('/groups/3')).to have_been_made | |
16 | end | |
17 | ||
18 | it 'returns a paginated response of groups' do | |
17 | 19 | expect(@groups).to be_a Gitlab::PaginatedResponse |
18 | expect(@groups.first.path).to eq("threegroup") | |
19 | end | |
20 | end | |
21 | ||
22 | describe ".create_group" do | |
23 | context "without description" do | |
20 | expect(@groups.first.path).to eq('threegroup') | |
21 | end | |
22 | end | |
23 | ||
24 | describe '.create_group' do | |
25 | context 'without description' do | |
24 | 26 | before do |
25 | stub_post("/groups", "group_create") | |
27 | stub_post('/groups', 'group_create') | |
26 | 28 | @group = Gitlab.create_group('GitLab-Group', 'gitlab-path') |
27 | 29 | end |
28 | 30 | |
29 | it "gets the correct resource" do | |
30 | expect(a_post("/groups"). | |
31 | with(body: { path: 'gitlab-path', name: 'GitLab-Group' })).to have_been_made | |
32 | end | |
33 | ||
34 | it "returns information about a created group" do | |
35 | expect(@group.name).to eq("Gitlab-Group") | |
36 | expect(@group.path).to eq("gitlab-group") | |
37 | end | |
38 | end | |
39 | ||
40 | context "with description" do | |
31 | it 'gets the correct resource' do | |
32 | expect(a_post('/groups') | |
33 | .with(body: { path: 'gitlab-path', name: 'GitLab-Group' })).to have_been_made | |
34 | end | |
35 | ||
36 | it 'returns information about a created group' do | |
37 | expect(@group.name).to eq('Gitlab-Group') | |
38 | expect(@group.path).to eq('gitlab-group') | |
39 | end | |
40 | end | |
41 | ||
42 | context 'with description' do | |
41 | 43 | before do |
42 | stub_post("/groups", "group_create_with_description") | |
44 | stub_post('/groups', 'group_create_with_description') | |
43 | 45 | @group = Gitlab.create_group('GitLab-Group', 'gitlab-path', description: 'gitlab group description') |
44 | 46 | end |
45 | 47 | |
46 | it "gets the correct resource" do | |
47 | expect(a_post("/groups"). | |
48 | with(body: { path: 'gitlab-path', name: 'GitLab-Group', | |
49 | description: 'gitlab group description' })).to have_been_made | |
50 | end | |
51 | ||
52 | it "returns information about a created group" do | |
53 | expect(@group.name).to eq("Gitlab-Group") | |
54 | expect(@group.path).to eq("gitlab-group") | |
55 | expect(@group.description).to eq("gitlab group description") | |
56 | end | |
57 | end | |
58 | end | |
59 | ||
60 | describe ".delete_group" do | |
61 | before do | |
62 | stub_delete("/groups/42", "group_delete") | |
48 | it 'gets the correct resource' do | |
49 | expect(a_post('/groups') | |
50 | .with(body: { path: 'gitlab-path', name: 'GitLab-Group', | |
51 | description: 'gitlab group description' })).to have_been_made | |
52 | end | |
53 | ||
54 | it 'returns information about a created group' do | |
55 | expect(@group.name).to eq('Gitlab-Group') | |
56 | expect(@group.path).to eq('gitlab-group') | |
57 | expect(@group.description).to eq('gitlab group description') | |
58 | end | |
59 | end | |
60 | end | |
61 | ||
62 | describe '.delete_group' do | |
63 | before do | |
64 | stub_delete('/groups/42', 'group_delete') | |
63 | 65 | @group = Gitlab.delete_group(42) |
64 | 66 | end |
65 | 67 | |
66 | it "gets the correct resource" do | |
67 | expect(a_delete("/groups/42")).to have_been_made | |
68 | end | |
69 | ||
70 | it "returns information about a deleted group" do | |
71 | expect(@group.name).to eq("Gitlab-Group") | |
72 | expect(@group.path).to eq("gitlab-group") | |
73 | end | |
74 | end | |
75 | ||
76 | describe ".transfer_project_to_group" do | |
77 | before do | |
78 | stub_post("/projects", "project") | |
68 | it 'gets the correct resource' do | |
69 | expect(a_delete('/groups/42')).to have_been_made | |
70 | end | |
71 | ||
72 | it 'returns information about a deleted group' do | |
73 | expect(@group.name).to eq('Gitlab-Group') | |
74 | expect(@group.path).to eq('gitlab-group') | |
75 | end | |
76 | end | |
77 | ||
78 | describe '.transfer_project_to_group' do | |
79 | before do | |
80 | stub_post('/projects', 'project') | |
79 | 81 | @project = Gitlab.create_project('Gitlab') |
80 | stub_post("/groups", "group_create") | |
82 | stub_post('/groups', 'group_create') | |
81 | 83 | @group = Gitlab.create_group('GitLab-Group', 'gitlab-path') |
82 | 84 | |
83 | stub_post("/groups/#{@group.id}/projects/#{@project.id}", "group_create") | |
85 | stub_post("/groups/#{@group.id}/projects/#{@project.id}", 'group_create') | |
84 | 86 | @group_transfer = Gitlab.transfer_project_to_group(@group.id, @project.id) |
85 | 87 | end |
86 | 88 | |
87 | it "posts to the correct resource" do | |
89 | it 'posts to the correct resource' do | |
88 | 90 | 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 |
89 | 91 | end |
90 | 92 | |
91 | it "returns information about the group" do | |
93 | it 'returns information about the group' do | |
92 | 94 | expect(@group_transfer.name).to eq(@group.name) |
93 | 95 | expect(@group_transfer.path).to eq(@group.path) |
94 | 96 | expect(@group_transfer.id).to eq(@group.id) |
95 | 97 | end |
96 | 98 | end |
97 | 99 | |
98 | describe ".group_members" do | |
99 | before do | |
100 | stub_get("/groups/3/members", "group_members") | |
100 | describe '.group_members' do | |
101 | before do | |
102 | stub_get('/groups/3/members', 'group_members') | |
101 | 103 | @members = Gitlab.group_members(3) |
102 | 104 | end |
103 | 105 | |
104 | it "gets the correct resource" do | |
105 | expect(a_get("/groups/3/members")).to have_been_made | |
106 | it 'gets the correct resource' do | |
107 | expect(a_get('/groups/3/members')).to have_been_made | |
106 | 108 | end |
107 | 109 | |
108 | 110 | it "returns information about a group's members" do |
109 | 111 | expect(@members).to be_a Gitlab::PaginatedResponse |
110 | 112 | expect(@members.size).to eq(2) |
111 | expect(@members[1].name).to eq("John Smith") | |
112 | end | |
113 | end | |
114 | ||
115 | describe ".group_member" do | |
116 | before do | |
117 | stub_get("/groups/3/members/2", "group_member") | |
113 | expect(@members[1].name).to eq('John Smith') | |
114 | end | |
115 | end | |
116 | ||
117 | describe '.group_member' do | |
118 | before do | |
119 | stub_get('/groups/3/members/2', 'group_member') | |
118 | 120 | @member = Gitlab.group_member(3, 2) |
119 | 121 | end |
120 | 122 | |
121 | it "gets the correct resource" do | |
122 | expect(a_get("/groups/3/members/2")).to have_been_made | |
123 | end | |
124 | ||
125 | it "returns information about a group member" do | |
123 | it 'gets the correct resource' do | |
124 | expect(a_get('/groups/3/members/2')).to have_been_made | |
125 | end | |
126 | ||
127 | it 'returns information about a group member' do | |
126 | 128 | expect(@member).to be_a Gitlab::ObjectifiedHash |
127 | 129 | expect(@member.access_level).to eq(10) |
128 | expect(@member.name).to eq("John Smith") | |
129 | end | |
130 | end | |
131 | ||
132 | describe ".add_group_member" do | |
133 | before do | |
134 | stub_post("/groups/3/members", "group_member") | |
130 | expect(@member.name).to eq('John Smith') | |
131 | end | |
132 | end | |
133 | ||
134 | describe '.add_group_member' do | |
135 | before do | |
136 | stub_post('/groups/3/members', 'group_member') | |
135 | 137 | @member = Gitlab.add_group_member(3, 1, 40) |
136 | 138 | end |
137 | 139 | |
138 | it "gets the correct resource" do | |
139 | expect(a_post("/groups/3/members"). | |
140 | with(body: { user_id: '1', access_level: '40' })).to have_been_made | |
141 | end | |
142 | ||
143 | it "returns information about the added member" do | |
144 | expect(@member.name).to eq("John Smith") | |
145 | end | |
146 | end | |
147 | ||
148 | describe ".edit_group_member" do | |
149 | before do | |
150 | stub_put("/groups/3/members/1", "group_member_edit") | |
140 | it 'gets the correct resource' do | |
141 | expect(a_post('/groups/3/members') | |
142 | .with(body: { user_id: '1', access_level: '40' })).to have_been_made | |
143 | end | |
144 | ||
145 | it 'returns information about the added member' do | |
146 | expect(@member.name).to eq('John Smith') | |
147 | end | |
148 | end | |
149 | ||
150 | describe '.edit_group_member' do | |
151 | before do | |
152 | stub_put('/groups/3/members/1', 'group_member_edit') | |
151 | 153 | @member = Gitlab.edit_group_member(3, 1, 50) |
152 | 154 | end |
153 | 155 | |
154 | it "gets the correct resource" do | |
155 | expect(a_put("/groups/3/members/1") | |
156 | .with(body: { access_level: '50'})).to have_been_made | |
157 | end | |
158 | ||
159 | it "returns information about the edited member" do | |
156 | it 'gets the correct resource' do | |
157 | expect(a_put('/groups/3/members/1') | |
158 | .with(body: { access_level: '50' })).to have_been_made | |
159 | end | |
160 | ||
161 | it 'returns information about the edited member' do | |
160 | 162 | expect(@member.access_level).to eq(50) |
161 | 163 | end |
162 | 164 | end |
163 | 165 | |
164 | describe ".remove_group_member" do | |
165 | before do | |
166 | stub_delete("/groups/3/members/1", "group_member_delete") | |
166 | describe '.remove_group_member' do | |
167 | before do | |
168 | stub_delete('/groups/3/members/1', 'group_member_delete') | |
167 | 169 | @group = Gitlab.remove_group_member(3, 1) |
168 | 170 | end |
169 | 171 | |
170 | it "gets the correct resource" do | |
171 | expect(a_delete("/groups/3/members/1")).to have_been_made | |
172 | end | |
173 | ||
174 | it "returns information about the group the member was removed from" do | |
172 | it 'gets the correct resource' do | |
173 | expect(a_delete('/groups/3/members/1')).to have_been_made | |
174 | end | |
175 | ||
176 | it 'returns information about the group the member was removed from' do | |
175 | 177 | expect(@group.group_id).to eq(3) |
176 | 178 | end |
177 | 179 | end |
178 | 180 | |
179 | describe ".group_projects" do | |
180 | before do | |
181 | stub_get("/groups/4/projects", "group_projects") | |
181 | describe '.group_projects' do | |
182 | before do | |
183 | stub_get('/groups/4/projects', 'group_projects') | |
182 | 184 | @projects = Gitlab.group_projects(4) |
183 | 185 | end |
184 | 186 | |
185 | it "gets the list of projects" do | |
186 | expect(a_get("/groups/4/projects")).to have_been_made | |
187 | end | |
188 | ||
189 | it "returns a list of of projects under a group" do | |
187 | it 'gets the list of projects' do | |
188 | expect(a_get('/groups/4/projects')).to have_been_made | |
189 | end | |
190 | ||
191 | it 'returns a list of of projects under a group' do | |
190 | 192 | expect(@projects).to be_a Gitlab::PaginatedResponse |
191 | 193 | expect(@projects.size).to eq(1) |
192 | expect(@projects[0].name).to eq("Diaspora Client") | |
193 | end | |
194 | end | |
195 | ||
196 | describe ".group_search" do | |
197 | before do | |
198 | stub_get("/groups?search=Group", "group_search") | |
194 | expect(@projects[0].name).to eq('Diaspora Client') | |
195 | end | |
196 | end | |
197 | ||
198 | describe '.group_search' do | |
199 | before do | |
200 | stub_get('/groups?search=Group', 'group_search') | |
199 | 201 | @groups = Gitlab.group_search('Group') |
200 | 202 | end |
201 | 203 | |
202 | it "gets the correct resource" do | |
203 | expect(a_get("/groups?search=Group")).to have_been_made | |
204 | end | |
205 | ||
206 | it "returns an array of groups found" do | |
204 | it 'gets the correct resource' do | |
205 | expect(a_get('/groups?search=Group')).to have_been_made | |
206 | end | |
207 | ||
208 | it 'returns an array of groups found' do | |
207 | 209 | expect(@groups.first.id).to eq(5) |
208 | 210 | expect(@groups.last.id).to eq(8) |
209 | 211 | end |
210 | 212 | end |
211 | 213 | |
212 | describe ".group_subgroups" do | |
213 | before do | |
214 | stub_get("/groups/4/subgroups", "group_subgroups") | |
214 | describe '.group_subgroups' do | |
215 | before do | |
216 | stub_get('/groups/4/subgroups', 'group_subgroups') | |
215 | 217 | @subgroups = Gitlab.group_subgroups(4) |
216 | 218 | end |
217 | 219 | |
218 | it "gets the list of subroups" do | |
219 | expect(a_get("/groups/4/subgroups")).to have_been_made | |
220 | end | |
221 | ||
222 | it "returns an array of subgroups under a group" do | |
220 | it 'gets the list of subroups' do | |
221 | expect(a_get('/groups/4/subgroups')).to have_been_made | |
222 | end | |
223 | ||
224 | it 'returns an array of subgroups under a group' do | |
223 | 225 | expect(@subgroups).to be_a Gitlab::PaginatedResponse |
224 | 226 | expect(@subgroups.size).to eq(1) |
225 | expect(@subgroups[0].name).to eq("Foobar Group") | |
226 | end | |
227 | end | |
228 | ||
229 | describe ".edit_group" do | |
230 | context "using group ID" do | |
227 | expect(@subgroups[0].name).to eq('Foobar Group') | |
228 | end | |
229 | end | |
230 | ||
231 | describe '.edit_group' do | |
232 | context 'using group ID' do | |
231 | 233 | before do |
232 | stub_put("/groups/1", "group_edit").with(body: { description: "An interesting group" }) | |
233 | @edited_project = Gitlab.edit_group(1, description: "An interesting group") | |
234 | end | |
235 | ||
236 | it "gets the correct resource" do | |
237 | expect(a_put("/groups/1").with(body: { description: "An interesting group" })).to have_been_made | |
238 | end | |
239 | ||
240 | it "returns information about an edited group" do | |
241 | expect(@edited_project.description).to eq("An interesting group") | |
234 | stub_put('/groups/1', 'group_edit').with(body: { description: 'An interesting group' }) | |
235 | @edited_project = Gitlab.edit_group(1, description: 'An interesting group') | |
236 | end | |
237 | ||
238 | it 'gets the correct resource' do | |
239 | expect(a_put('/groups/1').with(body: { description: 'An interesting group' })).to have_been_made | |
240 | end | |
241 | ||
242 | it 'returns information about an edited group' do | |
243 | expect(@edited_project.description).to eq('An interesting group') | |
242 | 244 | end |
243 | 245 | end |
244 | 246 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".issues" do | |
4 | context "with project ID passed" do | |
5 | describe '.issues' do | |
6 | context 'with project ID passed' do | |
5 | 7 | before do |
6 | stub_get("/projects/3/issues", "project_issues") | |
8 | stub_get('/projects/3/issues', 'project_issues') | |
7 | 9 | @issues = Gitlab.issues(3) |
8 | 10 | end |
9 | 11 | |
10 | it "gets the correct resource" do | |
11 | expect(a_get("/projects/3/issues")).to have_been_made | |
12 | it 'gets the correct resource' do | |
13 | expect(a_get('/projects/3/issues')).to have_been_made | |
12 | 14 | end |
13 | 15 | |
14 | 16 | it "returns a paginated response of project's issues" do |
19 | 21 | |
20 | 22 | context 'with literal project ID passed' do |
21 | 23 | before do |
22 | stub_get("/projects/gitlab-org%2Fgitlab-ce/issues", "project_issues") | |
24 | stub_get('/projects/gitlab-org%2Fgitlab-ce/issues', 'project_issues') | |
23 | 25 | @issues = Gitlab.issues('gitlab-org/gitlab-ce') |
24 | 26 | end |
25 | 27 | |
26 | it "gets the correct resource" do | |
27 | expect(a_get("/projects/gitlab-org%2Fgitlab-ce/issues")).to have_been_made | |
28 | it 'gets the correct resource' do | |
29 | expect(a_get('/projects/gitlab-org%2Fgitlab-ce/issues')).to have_been_made | |
28 | 30 | end |
29 | 31 | |
30 | 32 | it "returns a paginated response of project's issues" do |
33 | 35 | end |
34 | 36 | end |
35 | 37 | |
36 | context "without project ID passed" do | |
38 | context 'without project ID passed' do | |
37 | 39 | before do |
38 | stub_get("/issues", "issues") | |
40 | stub_get('/issues', 'issues') | |
39 | 41 | @issues = Gitlab.issues |
40 | 42 | end |
41 | 43 | |
42 | it "gets the correct resource" do | |
43 | expect(a_get("/issues")).to have_been_made | |
44 | it 'gets the correct resource' do | |
45 | expect(a_get('/issues')).to have_been_made | |
44 | 46 | end |
45 | 47 | |
46 | 48 | it "returns a paginated response of user's issues" do |
47 | 49 | expect(@issues).to be_a Gitlab::PaginatedResponse |
48 | 50 | expect(@issues.first.closed).to be_falsey |
49 | expect(@issues.first.author.name).to eq("John Smith") | |
50 | end | |
51 | end | |
52 | end | |
53 | ||
54 | describe ".issue" do | |
55 | before do | |
56 | stub_get("/projects/3/issues/33", "issue") | |
51 | expect(@issues.first.author.name).to eq('John Smith') | |
52 | end | |
53 | end | |
54 | end | |
55 | ||
56 | describe '.issue' do | |
57 | before do | |
58 | stub_get('/projects/3/issues/33', 'issue') | |
57 | 59 | @issue = Gitlab.issue(3, 33) |
58 | 60 | end |
59 | 61 | |
60 | it "gets the correct resource" do | |
61 | expect(a_get("/projects/3/issues/33")).to have_been_made | |
62 | end | |
63 | ||
64 | it "returns information about an issue" do | |
65 | expect(@issue.project_id).to eq(3) | |
66 | expect(@issue.assignee.name).to eq("Jack Smith") | |
67 | end | |
68 | end | |
69 | ||
70 | describe ".create_issue" do | |
71 | before do | |
72 | stub_post("/projects/3/issues", "issue") | |
62 | it 'gets the correct resource' do | |
63 | expect(a_get('/projects/3/issues/33')).to have_been_made | |
64 | end | |
65 | ||
66 | it 'returns information about an issue' do | |
67 | expect(@issue.project_id).to eq(3) | |
68 | expect(@issue.assignee.name).to eq('Jack Smith') | |
69 | end | |
70 | end | |
71 | ||
72 | describe '.create_issue' do | |
73 | before do | |
74 | stub_post('/projects/3/issues', 'issue') | |
73 | 75 | @issue = Gitlab.create_issue(3, 'title') |
74 | 76 | end |
75 | 77 | |
76 | it "gets the correct resource" do | |
77 | expect(a_post("/projects/3/issues"). | |
78 | with(body: { title: 'title' })).to have_been_made | |
79 | end | |
80 | ||
81 | it "returns information about a created issue" do | |
82 | expect(@issue.project_id).to eq(3) | |
83 | expect(@issue.assignee.name).to eq("Jack Smith") | |
84 | end | |
85 | end | |
86 | ||
87 | describe ".edit_issue" do | |
88 | before do | |
89 | stub_put("/projects/3/issues/33", "issue") | |
78 | it 'gets the correct resource' do | |
79 | expect(a_post('/projects/3/issues') | |
80 | .with(body: { title: 'title' })).to have_been_made | |
81 | end | |
82 | ||
83 | it 'returns information about a created issue' do | |
84 | expect(@issue.project_id).to eq(3) | |
85 | expect(@issue.assignee.name).to eq('Jack Smith') | |
86 | end | |
87 | end | |
88 | ||
89 | describe '.edit_issue' do | |
90 | before do | |
91 | stub_put('/projects/3/issues/33', 'issue') | |
90 | 92 | @issue = Gitlab.edit_issue(3, 33, title: 'title') |
91 | 93 | end |
92 | 94 | |
93 | it "gets the correct resource" do | |
94 | expect(a_put("/projects/3/issues/33"). | |
95 | with(body: { title: 'title' })).to have_been_made | |
96 | end | |
97 | ||
98 | it "returns information about an edited issue" do | |
99 | expect(@issue.project_id).to eq(3) | |
100 | expect(@issue.assignee.name).to eq("Jack Smith") | |
101 | end | |
102 | end | |
103 | ||
104 | describe ".close_issue" do | |
105 | before do | |
106 | stub_put("/projects/3/issues/33", "issue") | |
95 | it 'gets the correct resource' do | |
96 | expect(a_put('/projects/3/issues/33') | |
97 | .with(body: { title: 'title' })).to have_been_made | |
98 | end | |
99 | ||
100 | it 'returns information about an edited issue' do | |
101 | expect(@issue.project_id).to eq(3) | |
102 | expect(@issue.assignee.name).to eq('Jack Smith') | |
103 | end | |
104 | end | |
105 | ||
106 | describe '.close_issue' do | |
107 | before do | |
108 | stub_put('/projects/3/issues/33', 'issue') | |
107 | 109 | @issue = Gitlab.close_issue(3, 33) |
108 | 110 | end |
109 | 111 | |
110 | it "gets the correct resource" do | |
111 | expect(a_put("/projects/3/issues/33"). | |
112 | with(body: { state_event: 'close' })).to have_been_made | |
113 | end | |
114 | ||
115 | it "returns information about an closed issue" do | |
116 | expect(@issue.project_id).to eq(3) | |
117 | expect(@issue.assignee.name).to eq("Jack Smith") | |
118 | end | |
119 | end | |
120 | ||
121 | describe ".reopen_issue" do | |
122 | before do | |
123 | stub_put("/projects/3/issues/33", "issue") | |
112 | it 'gets the correct resource' do | |
113 | expect(a_put('/projects/3/issues/33') | |
114 | .with(body: { state_event: 'close' })).to have_been_made | |
115 | end | |
116 | ||
117 | it 'returns information about an closed issue' do | |
118 | expect(@issue.project_id).to eq(3) | |
119 | expect(@issue.assignee.name).to eq('Jack Smith') | |
120 | end | |
121 | end | |
122 | ||
123 | describe '.reopen_issue' do | |
124 | before do | |
125 | stub_put('/projects/3/issues/33', 'issue') | |
124 | 126 | @issue = Gitlab.reopen_issue(3, 33) |
125 | 127 | end |
126 | 128 | |
127 | it "gets the correct resource" do | |
128 | expect(a_put("/projects/3/issues/33"). | |
129 | with(body: { state_event: 'reopen' })).to have_been_made | |
130 | end | |
131 | ||
132 | it "returns information about an reopened issue" do | |
133 | expect(@issue.project_id).to eq(3) | |
134 | expect(@issue.assignee.name).to eq("Jack Smith") | |
135 | end | |
136 | end | |
137 | ||
138 | describe ".subscribe_to_issue" do | |
139 | before do | |
140 | stub_post("/projects/3/issues/33/subscribe", "issue") | |
129 | it 'gets the correct resource' do | |
130 | expect(a_put('/projects/3/issues/33') | |
131 | .with(body: { state_event: 'reopen' })).to have_been_made | |
132 | end | |
133 | ||
134 | it 'returns information about an reopened issue' do | |
135 | expect(@issue.project_id).to eq(3) | |
136 | expect(@issue.assignee.name).to eq('Jack Smith') | |
137 | end | |
138 | end | |
139 | ||
140 | describe '.subscribe_to_issue' do | |
141 | before do | |
142 | stub_post('/projects/3/issues/33/subscribe', 'issue') | |
141 | 143 | @issue = Gitlab.subscribe_to_issue(3, 33) |
142 | 144 | end |
143 | 145 | |
144 | it "gets the correct resource" do | |
145 | expect(a_post("/projects/3/issues/33/subscribe")).to have_been_made | |
146 | end | |
147 | ||
148 | it "returns information about the subscribed issue" do | |
149 | expect(@issue.project_id).to eq(3) | |
150 | expect(@issue.assignee.name).to eq("Jack Smith") | |
151 | end | |
152 | end | |
153 | ||
154 | describe ".unsubscribe_from_issue" do | |
155 | before do | |
156 | stub_post("/projects/3/issues/33/unsubscribe", "issue") | |
146 | it 'gets the correct resource' do | |
147 | expect(a_post('/projects/3/issues/33/subscribe')).to have_been_made | |
148 | end | |
149 | ||
150 | it 'returns information about the subscribed issue' do | |
151 | expect(@issue.project_id).to eq(3) | |
152 | expect(@issue.assignee.name).to eq('Jack Smith') | |
153 | end | |
154 | end | |
155 | ||
156 | describe '.unsubscribe_from_issue' do | |
157 | before do | |
158 | stub_post('/projects/3/issues/33/unsubscribe', 'issue') | |
157 | 159 | @issue = Gitlab.unsubscribe_from_issue(3, 33) |
158 | 160 | end |
159 | 161 | |
160 | it "gets the correct resource" do | |
161 | expect(a_post("/projects/3/issues/33/unsubscribe")).to have_been_made | |
162 | end | |
163 | ||
164 | it "returns information about the unsubscribed issue" do | |
165 | expect(@issue.project_id).to eq(3) | |
166 | expect(@issue.assignee.name).to eq("Jack Smith") | |
167 | end | |
168 | end | |
169 | ||
170 | describe ".delete_issue" do | |
171 | before do | |
172 | stub_delete("/projects/3/issues/33", "issue") | |
162 | it 'gets the correct resource' do | |
163 | expect(a_post('/projects/3/issues/33/unsubscribe')).to have_been_made | |
164 | end | |
165 | ||
166 | it 'returns information about the unsubscribed issue' do | |
167 | expect(@issue.project_id).to eq(3) | |
168 | expect(@issue.assignee.name).to eq('Jack Smith') | |
169 | end | |
170 | end | |
171 | ||
172 | describe '.delete_issue' do | |
173 | before do | |
174 | stub_delete('/projects/3/issues/33', 'issue') | |
173 | 175 | @issue = Gitlab.delete_issue(3, 33) |
174 | 176 | end |
175 | 177 | |
176 | it "gets the correct resource" do | |
177 | expect(a_delete("/projects/3/issues/33")).to have_been_made | |
178 | end | |
179 | ||
180 | it "returns information about a deleted issue" do | |
178 | it 'gets the correct resource' do | |
179 | expect(a_delete('/projects/3/issues/33')).to have_been_made | |
180 | end | |
181 | ||
182 | it 'returns information about a deleted issue' do | |
181 | 183 | expect(@issue.project_id).to eq(3) |
182 | 184 | expect(@issue.id).to eq(33) |
183 | 185 | end |
184 | 186 | end |
185 | 187 | |
186 | describe ".move_issue" do | |
187 | before do | |
188 | stub_post("/projects/3/issues/33/move", "issue") | |
188 | describe '.move_issue' do | |
189 | before do | |
190 | stub_post('/projects/3/issues/33/move', 'issue') | |
189 | 191 | @issue = Gitlab.move_issue(3, 33, to_project_id: '4') |
190 | 192 | end |
191 | 193 | |
192 | it "gets the correct resource" do | |
193 | expect(a_post("/projects/3/issues/33/move"). | |
194 | with(body: { to_project_id: '4' })).to have_been_made | |
195 | end | |
196 | ||
197 | it "returns information about the moved issue" do | |
198 | expect(@issue.project_id).to eq(3) | |
199 | expect(@issue.assignee.name).to eq("Jack Smith") | |
200 | end | |
201 | end | |
202 | ||
203 | describe ".estimate_time_of_issue" do | |
204 | before do | |
205 | stub_post("/projects/3/issues/33/time_estimate", "issue") | |
194 | it 'gets the correct resource' do | |
195 | expect(a_post('/projects/3/issues/33/move') | |
196 | .with(body: { to_project_id: '4' })).to have_been_made | |
197 | end | |
198 | ||
199 | it 'returns information about the moved issue' do | |
200 | expect(@issue.project_id).to eq(3) | |
201 | expect(@issue.assignee.name).to eq('Jack Smith') | |
202 | end | |
203 | end | |
204 | ||
205 | describe '.estimate_time_of_issue' do | |
206 | before do | |
207 | stub_post('/projects/3/issues/33/time_estimate', 'issue') | |
206 | 208 | @issue = Gitlab.estimate_time_of_issue(3, 33, '3h30m') |
207 | 209 | end |
208 | 210 | |
209 | it "gets the correct resource" do | |
210 | expect(a_post("/projects/3/issues/33/time_estimate"). | |
211 | with(body: { duration: '3h30m' })).to have_been_made | |
212 | end | |
213 | ||
214 | it "returns information about the estimated issue" do | |
215 | expect(@issue.project_id).to eq(3) | |
216 | expect(@issue.assignee.name).to eq("Jack Smith") | |
217 | end | |
218 | end | |
219 | ||
220 | describe ".reset_time_estimate_of_issue" do | |
221 | before do | |
222 | stub_post("/projects/3/issues/33/reset_time_estimate", "issue") | |
211 | it 'gets the correct resource' do | |
212 | expect(a_post('/projects/3/issues/33/time_estimate') | |
213 | .with(body: { duration: '3h30m' })).to have_been_made | |
214 | end | |
215 | ||
216 | it 'returns information about the estimated issue' do | |
217 | expect(@issue.project_id).to eq(3) | |
218 | expect(@issue.assignee.name).to eq('Jack Smith') | |
219 | end | |
220 | end | |
221 | ||
222 | describe '.reset_time_estimate_of_issue' do | |
223 | before do | |
224 | stub_post('/projects/3/issues/33/reset_time_estimate', 'issue') | |
223 | 225 | @issue = Gitlab.reset_time_estimate_of_issue(3, 33) |
224 | 226 | end |
225 | 227 | |
226 | it "gets the correct resource" do | |
227 | expect(a_post("/projects/3/issues/33/reset_time_estimate")).to have_been_made | |
228 | end | |
229 | ||
230 | it "returns information about the estimated issue" do | |
231 | expect(@issue.project_id).to eq(3) | |
232 | expect(@issue.assignee.name).to eq("Jack Smith") | |
233 | end | |
234 | end | |
235 | ||
236 | describe ".add_time_spent_on_issue" do | |
237 | before do | |
238 | stub_post("/projects/3/issues/33/add_spent_time", "issue") | |
228 | it 'gets the correct resource' do | |
229 | expect(a_post('/projects/3/issues/33/reset_time_estimate')).to have_been_made | |
230 | end | |
231 | ||
232 | it 'returns information about the estimated issue' do | |
233 | expect(@issue.project_id).to eq(3) | |
234 | expect(@issue.assignee.name).to eq('Jack Smith') | |
235 | end | |
236 | end | |
237 | ||
238 | describe '.add_time_spent_on_issue' do | |
239 | before do | |
240 | stub_post('/projects/3/issues/33/add_spent_time', 'issue') | |
239 | 241 | @issue = Gitlab.add_time_spent_on_issue(3, 33, '3h30m') |
240 | 242 | end |
241 | 243 | |
242 | it "gets the correct resource" do | |
243 | expect(a_post("/projects/3/issues/33/add_spent_time"). | |
244 | with(body: { duration: '3h30m' })).to have_been_made | |
245 | end | |
246 | ||
247 | it "returns information about the estimated issue" do | |
248 | expect(@issue.project_id).to eq(3) | |
249 | expect(@issue.assignee.name).to eq("Jack Smith") | |
250 | end | |
251 | end | |
252 | ||
253 | describe ".reset_time_spent_on_issue" do | |
254 | before do | |
255 | stub_post("/projects/3/issues/33/reset_spent_time", "issue") | |
244 | it 'gets the correct resource' do | |
245 | expect(a_post('/projects/3/issues/33/add_spent_time') | |
246 | .with(body: { duration: '3h30m' })).to have_been_made | |
247 | end | |
248 | ||
249 | it 'returns information about the estimated issue' do | |
250 | expect(@issue.project_id).to eq(3) | |
251 | expect(@issue.assignee.name).to eq('Jack Smith') | |
252 | end | |
253 | end | |
254 | ||
255 | describe '.reset_time_spent_on_issue' do | |
256 | before do | |
257 | stub_post('/projects/3/issues/33/reset_spent_time', 'issue') | |
256 | 258 | @issue = Gitlab.reset_time_spent_on_issue(3, 33) |
257 | 259 | end |
258 | 260 | |
259 | it "gets the correct resource" do | |
260 | expect(a_post("/projects/3/issues/33/reset_spent_time")).to have_been_made | |
261 | end | |
262 | ||
263 | it "returns information about the estimated issue" do | |
264 | expect(@issue.project_id).to eq(3) | |
265 | expect(@issue.assignee.name).to eq("Jack Smith") | |
266 | end | |
267 | end | |
268 | ||
269 | describe ".time_stats_for_issue" do | |
270 | before do | |
271 | stub_get("/projects/3/issues/33/time_stats", "issue") | |
261 | it 'gets the correct resource' do | |
262 | expect(a_post('/projects/3/issues/33/reset_spent_time')).to have_been_made | |
263 | end | |
264 | ||
265 | it 'returns information about the estimated issue' do | |
266 | expect(@issue.project_id).to eq(3) | |
267 | expect(@issue.assignee.name).to eq('Jack Smith') | |
268 | end | |
269 | end | |
270 | ||
271 | describe '.time_stats_for_issue' do | |
272 | before do | |
273 | stub_get('/projects/3/issues/33/time_stats', 'issue') | |
272 | 274 | @issue = Gitlab.time_stats_for_issue(3, 33) |
273 | 275 | end |
274 | 276 | |
275 | it "gets the correct resource" do | |
276 | expect(a_get("/projects/3/issues/33/time_stats")).to have_been_made | |
277 | end | |
278 | ||
279 | it "returns information about the issue" do | |
280 | expect(@issue.project_id).to eq(3) | |
281 | expect(@issue.assignee.name).to eq("Jack Smith") | |
277 | it 'gets the correct resource' do | |
278 | expect(a_get('/projects/3/issues/33/time_stats')).to have_been_made | |
279 | end | |
280 | ||
281 | it 'returns information about the issue' do | |
282 | expect(@issue.project_id).to eq(3) | |
283 | expect(@issue.assignee.name).to eq('Jack Smith') | |
284 | end | |
285 | end | |
286 | ||
287 | describe '.participants_on_issue' do | |
288 | before do | |
289 | stub_get('/projects/3/issues/33/participants', 'participants_on_issue') | |
290 | @participants = Gitlab.participants_on_issue(3, 33) | |
291 | end | |
292 | ||
293 | it 'gets the correct resource' do | |
294 | expect(a_get('/projects/3/issues/33/participants')).to have_been_made | |
295 | end | |
296 | ||
297 | it 'returns information about the participants on issue' do | |
298 | expect(@participants.first.name).to eq('John Doe1') | |
299 | expect(@participants.size).to eq(2) | |
300 | end | |
301 | end | |
302 | ||
303 | describe '.merge_requests_closing_issue_on_merge' do | |
304 | before do | |
305 | stub_get('/projects/3/issues/33/closed_by', 'merge_requests_closing_issue_on_merge') | |
306 | @merge_requests = Gitlab.merge_requests_closing_issue_on_merge(3, 33) | |
307 | end | |
308 | ||
309 | it 'gets the correct resource' do | |
310 | expect(a_get('/projects/3/issues/33/closed_by')).to have_been_made | |
311 | end | |
312 | ||
313 | it 'returns list of merge requests closing issue on merge' do | |
314 | expect(@merge_requests.first.title).to eq('New feature') | |
315 | expect(@merge_requests.size).to eq(2) | |
282 | 316 | end |
283 | 317 | end |
284 | 318 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
27 | 29 | stub_get('/projects/1/pipelines/1/jobs', 'pipeline_jobs') |
28 | 30 | @projects = Gitlab.pipeline_jobs(1, 1) |
29 | 31 | end |
32 | ||
30 | 33 | it 'gets the correct resource' do |
31 | 34 | expect(a_get('/projects/1/pipelines/1/jobs')).to have_been_made |
32 | 35 | end |
37 | 40 | stub_get('/projects/1/pipelines/1/jobs?scope[]=running&scope[]=created', 'pipeline_jobs') |
38 | 41 | @projects = Gitlab.pipeline_jobs(1, 1, scope: %w[running created]) |
39 | 42 | end |
43 | ||
40 | 44 | it 'gets the correct resource' do |
41 | 45 | expect(a_get('/projects/1/pipelines/1/jobs?scope[]=running&scope[]=created')).to have_been_made |
42 | 46 | end |
47 | 51 | stub_get('/projects/1/jobs/1', 'job') |
48 | 52 | @projects = Gitlab.job(1, 1) |
49 | 53 | end |
54 | ||
50 | 55 | it 'gets the correct resource' do |
51 | 56 | expect(a_get('/projects/1/jobs/1')).to have_been_made |
52 | 57 | end |
57 | 62 | stub_get('/projects/1/jobs/1/artifacts', 'job') |
58 | 63 | @projects = Gitlab.job_artifacts(1, 1) |
59 | 64 | end |
65 | ||
60 | 66 | it 'gets the correct resource' do |
61 | 67 | expect(a_get('/projects/1/jobs/1/artifacts')).to have_been_made |
62 | 68 | end |
67 | 73 | stub_get('/projects/1/jobs/artifacts/master/download?job=Release%20Build', 'job') |
68 | 74 | @projects = Gitlab.job_artifacts_download(1, 'master', 'Release Build') |
69 | 75 | end |
76 | ||
70 | 77 | it 'gets the correct resource' do |
71 | 78 | expect(a_get('/projects/1/jobs/artifacts/master/download?job=Release%20Build')).to have_been_made |
72 | 79 | end |
77 | 84 | stub_get('/projects/1/jobs/1/trace', 'job_trace') |
78 | 85 | @projects = Gitlab.job_trace(1, 1) |
79 | 86 | end |
87 | ||
80 | 88 | it 'gets the correct resource' do |
81 | 89 | expect(a_get('/projects/1/jobs/1/trace')).to have_been_made |
82 | 90 | end |
87 | 95 | stub_post('/projects/1/jobs/1/cancel', 'job') |
88 | 96 | @projects = Gitlab.job_cancel(1, 1) |
89 | 97 | end |
98 | ||
90 | 99 | it 'gets the correct resource' do |
91 | 100 | expect(a_post('/projects/1/jobs/1/cancel')).to have_been_made |
92 | 101 | end |
97 | 106 | stub_post('/projects/1/jobs/1/retry', 'job') |
98 | 107 | @projects = Gitlab.job_retry(1, 1) |
99 | 108 | end |
109 | ||
100 | 110 | it 'gets the correct resource' do |
101 | 111 | expect(a_post('/projects/1/jobs/1/retry')).to have_been_made |
102 | 112 | end |
107 | 117 | stub_post('/projects/1/jobs/1/erase', 'job') |
108 | 118 | @projects = Gitlab.job_erase(1, 1) |
109 | 119 | end |
120 | ||
110 | 121 | it 'gets the correct resource' do |
111 | 122 | expect(a_post('/projects/1/jobs/1/erase')).to have_been_made |
112 | 123 | end |
117 | 128 | stub_post('/projects/1/jobs/1/play', 'job') |
118 | 129 | @projects = Gitlab.job_play(1, 1) |
119 | 130 | end |
131 | ||
120 | 132 | it 'gets the correct resource' do |
121 | 133 | expect(a_post('/projects/1/jobs/1/play')).to have_been_made |
122 | 134 | end |
127 | 139 | stub_post('/projects/1/jobs/1/artifacts/keep', 'job') |
128 | 140 | @projects = Gitlab.job_artifacts_keep(1, 1) |
129 | 141 | end |
142 | ||
130 | 143 | it 'gets the correct resource' do |
131 | 144 | expect(a_post('/projects/1/jobs/1/artifacts/keep')).to have_been_made |
132 | 145 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".key" do | |
5 | describe '.key' do | |
4 | 6 | before do |
5 | stub_get("/keys/1", "key") | |
7 | stub_get('/keys/1', 'key') | |
6 | 8 | @key = Gitlab.key(1) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/keys/1")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/keys/1')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | it "returns information about a key" do | |
15 | it 'returns information about a key' do | |
14 | 16 | expect(@key.id).to eq(1) |
15 | expect(@key.title).to eq("narkoz@helium") | |
17 | expect(@key.title).to eq('narkoz@helium') | |
16 | 18 | end |
17 | 19 | end |
18 | 20 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".labels" do | |
5 | describe '.labels' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/labels", "labels") | |
7 | stub_get('/projects/3/labels', 'labels') | |
6 | 8 | @labels = Gitlab.labels(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/labels")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/labels')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of project's labels" do |
14 | 16 | expect(@labels).to be_a Gitlab::PaginatedResponse |
15 | expect(@labels.first.name).to eq("Backlog") | |
17 | expect(@labels.first.name).to eq('Backlog') | |
16 | 18 | end |
17 | 19 | end |
18 | 20 | |
19 | describe ".delete" do | |
21 | describe '.delete' do | |
20 | 22 | before do |
21 | stub_delete("/projects/3/labels", "label") | |
22 | @label = Gitlab.delete_label(3, "Backlog") | |
23 | stub_delete('/projects/3/labels', 'label') | |
24 | @label = Gitlab.delete_label(3, 'Backlog') | |
23 | 25 | end |
24 | 26 | |
25 | it "gets the correct resource" do | |
26 | expect(a_delete("/projects/3/labels"). | |
27 | with(body: { name: 'Backlog' })).to have_been_made | |
27 | it 'gets the correct resource' do | |
28 | expect(a_delete('/projects/3/labels') | |
29 | .with(body: { name: 'Backlog' })).to have_been_made | |
28 | 30 | end |
29 | 31 | |
30 | it "returns information about a deleted snippet" do | |
31 | expect(@label.name).to eq("Backlog") | |
32 | it 'returns information about a deleted snippet' do | |
33 | expect(@label.name).to eq('Backlog') | |
32 | 34 | end |
33 | 35 | end |
34 | 36 | |
35 | describe ".edit_label" do | |
37 | describe '.edit_label' do | |
36 | 38 | before do |
37 | stub_put("/projects/3/labels", "label") | |
38 | @label = Gitlab.edit_label(3, "TODO", new_name: 'Backlog') | |
39 | stub_put('/projects/3/labels', 'label') | |
40 | @label = Gitlab.edit_label(3, 'TODO', new_name: 'Backlog') | |
39 | 41 | end |
40 | 42 | |
41 | it "gets the correct resource" do | |
42 | expect(a_put("/projects/3/labels"). | |
43 | with(body: { name: 'TODO', new_name: "Backlog" })).to have_been_made | |
43 | it 'gets the correct resource' do | |
44 | expect(a_put('/projects/3/labels') | |
45 | .with(body: { name: 'TODO', new_name: 'Backlog' })).to have_been_made | |
44 | 46 | end |
45 | 47 | |
46 | it "returns information about an edited label" do | |
47 | expect(@label.name).to eq("Backlog") | |
48 | it 'returns information about an edited label' do | |
49 | expect(@label.name).to eq('Backlog') | |
48 | 50 | end |
49 | 51 | end |
50 | 52 | |
51 | describe ".create_label" do | |
53 | describe '.create_label' do | |
52 | 54 | before do |
53 | stub_post("/projects/3/labels", "label") | |
55 | stub_post('/projects/3/labels', 'label') | |
54 | 56 | @label = Gitlab.create_label(3, 'Backlog', '#DD10AA') |
55 | 57 | end |
56 | 58 | |
57 | it "gets the correct resource" do | |
58 | expect(a_post("/projects/3/labels"). | |
59 | with(body: { name: 'Backlog', color: '#DD10AA' })).to have_been_made | |
59 | it 'gets the correct resource' do | |
60 | expect(a_post('/projects/3/labels') | |
61 | .with(body: { name: 'Backlog', color: '#DD10AA' })).to have_been_made | |
60 | 62 | end |
61 | 63 | |
62 | it "returns information about a created label" do | |
64 | it 'returns information about a created label' do | |
63 | 65 | expect(@label.name).to eq('Backlog') |
64 | 66 | expect(@label.color).to eq('#DD10AA') |
65 | 67 | end |
66 | 68 | end |
67 | 69 | |
68 | describe ".subscribe_to_label" do | |
70 | describe '.subscribe_to_label' do | |
69 | 71 | before do |
70 | stub_post("/projects/3/labels/Backlog/subscribe", "label") | |
72 | stub_post('/projects/3/labels/Backlog/subscribe', 'label') | |
71 | 73 | @label = Gitlab.subscribe_to_label(3, 'Backlog') |
72 | 74 | end |
73 | 75 | |
74 | it "gets the correct resource" do | |
75 | expect(a_post("/projects/3/labels/Backlog/subscribe")).to have_been_made | |
76 | it 'gets the correct resource' do | |
77 | expect(a_post('/projects/3/labels/Backlog/subscribe')).to have_been_made | |
76 | 78 | end |
77 | 79 | |
78 | it "returns information about the label subscribed to" do | |
80 | it 'returns information about the label subscribed to' do | |
79 | 81 | expect(@label.name).to eq('Backlog') |
80 | 82 | expect(@label.subscribed).to eq(true) |
81 | 83 | end |
82 | 84 | end |
83 | 85 | |
84 | describe ".unsubscribe_from_label" do | |
86 | describe '.unsubscribe_from_label' do | |
85 | 87 | before do |
86 | stub_post("/projects/3/labels/Backlog/unsubscribe", "label_unsubscribe") | |
88 | stub_post('/projects/3/labels/Backlog/unsubscribe', 'label_unsubscribe') | |
87 | 89 | @label = Gitlab.unsubscribe_from_label(3, 'Backlog') |
88 | 90 | end |
89 | 91 | |
90 | it "gets the correct resource" do | |
91 | expect(a_post("/projects/3/labels/Backlog/unsubscribe")).to have_been_made | |
92 | it 'gets the correct resource' do | |
93 | expect(a_post('/projects/3/labels/Backlog/unsubscribe')).to have_been_made | |
92 | 94 | end |
93 | 95 | |
94 | it "returns information about the label subscribed to" do | |
96 | it 'returns information about the label subscribed to' do | |
95 | 97 | expect(@label.name).to eq('Backlog') |
96 | 98 | expect(@label.subscribed).to eq(false) |
97 | 99 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | 5 | describe '.project_merge_request_approvals' do |
4 | 6 | before do |
5 | stub_get("/projects/1/approvals", 'project_merge_request_approvals') | |
7 | stub_get('/projects/1/approvals', 'project_merge_request_approvals') | |
6 | 8 | @project_mr_approvals = Gitlab.project_merge_request_approvals(1) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/1/approvals")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/1/approvals')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | it "returns the correct objectified hash" do | |
15 | it 'returns the correct objectified hash' do | |
14 | 16 | expect(@project_mr_approvals).to be_a Gitlab::ObjectifiedHash |
15 | 17 | end |
16 | 18 | end |
18 | 20 | describe '.edit_project_merge_request_approvals' do |
19 | 21 | before do |
20 | 22 | body = { approvals_before_merge: '3', reset_approvals_on_push: 'false', disable_overriding_approvers_per_merge_request: 'true' } |
21 | stub_post("/projects/1/approvals", 'project_merge_request_approvals').with(body: body) | |
23 | stub_post('/projects/1/approvals', 'project_merge_request_approvals').with(body: body) | |
22 | 24 | @project_mr_approvals = Gitlab.edit_project_merge_request_approvals(1, approvals_before_merge: 3, reset_approvals_on_push: false, disable_overriding_approvers_per_merge_request: true) |
23 | 25 | end |
24 | 26 | |
25 | 27 | it 'gets the correct resource' do |
26 | 28 | body = { approvals_before_merge: '3', reset_approvals_on_push: 'false', disable_overriding_approvers_per_merge_request: 'true' } |
27 | expect(a_post("/projects/1/approvals"). | |
28 | with(body: body)).to have_been_made | |
29 | expect(a_post('/projects/1/approvals') | |
30 | .with(body: body)).to have_been_made | |
29 | 31 | end |
30 | 32 | |
31 | it "returns the correct updated configuration" do | |
33 | it 'returns the correct updated configuration' do | |
32 | 34 | expect(@project_mr_approvals).to be_a Gitlab::ObjectifiedHash |
33 | 35 | expect(@project_mr_approvals.approvals_before_merge).to eq 3 |
34 | 36 | expect(@project_mr_approvals.reset_approvals_on_push).to eq false |
38 | 40 | |
39 | 41 | describe '.edit_project_approvers' do |
40 | 42 | before do |
41 | body = {"approver_ids": ['5'], "approver_group_ids": ['1']} | |
42 | stub_put("/projects/1/approvals", 'project_merge_request_approvals').with(body: body) | |
43 | body = { "approver_ids": ['5'], "approver_group_ids": ['1'] } | |
44 | stub_put('/projects/1/approvals', 'project_merge_request_approvals').with(body: body) | |
43 | 45 | @project_mr_approvals = Gitlab.edit_project_approvers(1, approver_ids: [5], approver_group_ids: [1]) |
44 | 46 | end |
45 | 47 | |
46 | 48 | it 'gets the correct resource' do |
47 | body = {"approver_ids": ['5'], "approver_group_ids": ['1']} | |
48 | expect(a_put("/projects/1/approvals"). | |
49 | with(body: body)).to have_been_made | |
49 | body = { "approver_ids": ['5'], "approver_group_ids": ['1'] } | |
50 | expect(a_put('/projects/1/approvals') | |
51 | .with(body: body)).to have_been_made | |
50 | 52 | end |
51 | 53 | |
52 | 54 | it 'returns the correct updated configuration' do |
53 | 55 | expect(@project_mr_approvals).to be_a Gitlab::ObjectifiedHash |
54 | expect(@project_mr_approvals.approvers.map{|approver| approver['user']['id']}).to eq [5] | |
55 | expect(@project_mr_approvals.approver_groups.map{|approver_group| approver_group['group']['id']}).to eq [1] | |
56 | expect(@project_mr_approvals.approvers.map { |approver| approver['user']['id'] }).to eq [5] | |
57 | expect(@project_mr_approvals.approver_groups.map { |approver_group| approver_group['group']['id'] }).to eq [1] | |
56 | 58 | end |
57 | 59 | end |
58 | 60 | |
59 | 61 | describe '.merge_request_approvals' do |
60 | 62 | before do |
61 | stub_get("/projects/1/merge_requests/5/approvals", 'merge_request_approvals') | |
63 | stub_get('/projects/1/merge_requests/5/approvals', 'merge_request_approvals') | |
62 | 64 | @merge_request_approvals = Gitlab.merge_request_approvals(1, 5) |
63 | 65 | end |
64 | 66 | |
65 | 67 | it 'gets the correct resource' do |
66 | expect(a_get("/projects/1/merge_requests/5/approvals")).to have_been_made | |
68 | expect(a_get('/projects/1/merge_requests/5/approvals')).to have_been_made | |
67 | 69 | end |
68 | 70 | |
69 | 71 | it 'returns the correct objectified hash' do |
76 | 78 | describe '.edit_merge_request_approvals' do |
77 | 79 | before do |
78 | 80 | body = { approvals_required: '2' } |
79 | stub_post("/projects/1/merge_requests/5/approvals", 'merge_request_approvals').with(body: body) | |
81 | stub_post('/projects/1/merge_requests/5/approvals', 'merge_request_approvals').with(body: body) | |
80 | 82 | @merge_request_approvals = Gitlab.edit_merge_request_approvals(1, 5, approvals_required: 2) |
81 | 83 | end |
82 | 84 | |
83 | 85 | it 'gets the correct resource' do |
84 | 86 | body = { approvals_required: '2' } |
85 | expect(a_post("/projects/1/merge_requests/5/approvals").with(body: body)).to have_been_made | |
87 | expect(a_post('/projects/1/merge_requests/5/approvals').with(body: body)).to have_been_made | |
86 | 88 | end |
87 | 89 | |
88 | 90 | it 'returns the correct objectified hash' do |
93 | 95 | |
94 | 96 | describe '.edit_merge_request_approvers' do |
95 | 97 | before do |
96 | body = {"approver_ids": ['1'], "approver_group_ids": ['5']} | |
97 | stub_put("/projects/1/merge_requests/5/approvals", 'merge_request_approvals').with(body: body) | |
98 | body = { "approver_ids": ['1'], "approver_group_ids": ['5'] } | |
99 | stub_put('/projects/1/merge_requests/5/approvals', 'merge_request_approvals').with(body: body) | |
98 | 100 | @merge_request_approvals = Gitlab.edit_merge_request_approvers(1, 5, approver_ids: [1], approver_group_ids: [5]) |
99 | 101 | end |
100 | 102 | |
101 | 103 | it 'gets the correct resource' do |
102 | body = {"approver_ids": ['1'], "approver_group_ids": ['5']} | |
103 | expect(a_put("/projects/1/merge_requests/5/approvals"). | |
104 | with(body: body)).to have_been_made | |
104 | body = { "approver_ids": ['1'], "approver_group_ids": ['5'] } | |
105 | expect(a_put('/projects/1/merge_requests/5/approvals') | |
106 | .with(body: body)).to have_been_made | |
105 | 107 | end |
106 | 108 | |
107 | 109 | it 'returns the correct updated configuration' do |
108 | 110 | expect(@merge_request_approvals).to be_a Gitlab::ObjectifiedHash |
109 | expect(@merge_request_approvals.approvers.map{|approver| approver['user']['id']}).to eq [1] | |
110 | expect(@merge_request_approvals.approver_groups.map{|approver_group| approver_group['group']['id']}).to eq [5] | |
111 | expect(@merge_request_approvals.approvers.map { |approver| approver['user']['id'] }).to eq [1] | |
112 | expect(@merge_request_approvals.approver_groups.map { |approver_group| approver_group['group']['id'] }).to eq [5] | |
111 | 113 | end |
112 | 114 | end |
113 | 115 | |
114 | 116 | describe '.approve_merge_request' do |
115 | 117 | before do |
116 | stub_post("/projects/1/merge_requests/5/approve", 'merge_request_approvals') | |
118 | stub_post('/projects/1/merge_requests/5/approve', 'merge_request_approvals') | |
117 | 119 | @merge_request_approvals = Gitlab.approve_merge_request(1, 5) |
118 | 120 | end |
119 | 121 | |
120 | 122 | it 'gets the correct resource' do |
121 | expect(a_post("/projects/1/merge_requests/5/approve")).to have_been_made | |
123 | expect(a_post('/projects/1/merge_requests/5/approve')).to have_been_made | |
122 | 124 | end |
123 | 125 | |
124 | 126 | it 'returns the correct updated configuration' do |
129 | 131 | |
130 | 132 | describe '.unapprove_merge_request' do |
131 | 133 | before do |
132 | stub_post("/projects/1/merge_requests/5/unapprove", 'merge_request_approvals') | |
134 | stub_post('/projects/1/merge_requests/5/unapprove', 'merge_request_approvals') | |
133 | 135 | @merge_request_approvals = Gitlab.unapprove_merge_request(1, 5) |
134 | 136 | end |
135 | 137 | |
136 | 138 | it 'gets the correct resource' do |
137 | expect(a_post("/projects/1/merge_requests/5/unapprove")).to have_been_made | |
139 | expect(a_post('/projects/1/merge_requests/5/unapprove')).to have_been_made | |
138 | 140 | end |
139 | 141 | end |
140 | end⏎ | |
142 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".user_merge_requests" do | |
4 | before do | |
5 | stub_get("/merge_requests", "merge_requests") | |
5 | describe '.user_merge_requests' do | |
6 | before do | |
7 | stub_get('/merge_requests', 'merge_requests') | |
6 | 8 | @user_merge_requests = Gitlab.user_merge_requests |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/merge_requests")).to have_been_made | |
11 | end | |
12 | ||
13 | it "returns a paginated response of user merge requests" do | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/merge_requests')).to have_been_made | |
13 | end | |
14 | ||
15 | it 'returns a paginated response of user merge requests' do | |
14 | 16 | expect(@user_merge_requests).to be_a Gitlab::PaginatedResponse |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".merge_requests" do | |
19 | before do | |
20 | stub_get("/projects/3/merge_requests", "merge_requests") | |
20 | describe '.merge_requests' do | |
21 | before do | |
22 | stub_get('/projects/3/merge_requests', 'merge_requests') | |
21 | 23 | @merge_requests = Gitlab.merge_requests(3) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/projects/3/merge_requests")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/3/merge_requests')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | 30 | it "returns a paginated response of project's merge requests" do |
31 | 33 | end |
32 | 34 | end |
33 | 35 | |
34 | describe ".merge_request" do | |
35 | before do | |
36 | stub_get("/projects/3/merge_requests/1", "merge_request") | |
36 | describe '.merge_request' do | |
37 | before do | |
38 | stub_get('/projects/3/merge_requests/1', 'merge_request') | |
37 | 39 | @merge_request = Gitlab.merge_request(3, 1) |
38 | 40 | end |
39 | 41 | |
40 | it "gets the correct resource" do | |
41 | expect(a_get("/projects/3/merge_requests/1")).to have_been_made | |
42 | end | |
43 | ||
44 | it "returns information about a merge request" do | |
45 | expect(@merge_request.project_id).to eq(3) | |
46 | expect(@merge_request.assignee.name).to eq("Jack Smith") | |
47 | end | |
48 | end | |
49 | ||
50 | describe ".create_merge_request" do | |
51 | before do | |
52 | stub_post("/projects/3/merge_requests", "merge_request") | |
53 | end | |
54 | ||
55 | it "returns information about a merge request" do | |
42 | it 'gets the correct resource' do | |
43 | expect(a_get('/projects/3/merge_requests/1')).to have_been_made | |
44 | end | |
45 | ||
46 | it 'returns information about a merge request' do | |
47 | expect(@merge_request.project_id).to eq(3) | |
48 | expect(@merge_request.assignee.name).to eq('Jack Smith') | |
49 | end | |
50 | end | |
51 | ||
52 | describe '.merge_request_pipelines' do | |
53 | before do | |
54 | stub_get('/projects/3/merge_requests/1/pipelines', 'pipelines') | |
55 | @pipelines = Gitlab.merge_request_pipelines(3, 1) | |
56 | end | |
57 | ||
58 | it 'gets the correct resource' do | |
59 | expect(a_get('/projects/3/merge_requests/1/pipelines')).to have_been_made | |
60 | end | |
61 | ||
62 | it 'returns information about all pipelines in merge request' do | |
63 | expect(@pipelines.first.id).to eq(47) | |
64 | expect(@pipelines.first.status).to eq('pending') | |
65 | end | |
66 | end | |
67 | ||
68 | describe '.create_merge_request' do | |
69 | before do | |
70 | stub_post('/projects/3/merge_requests', 'merge_request') | |
71 | end | |
72 | ||
73 | it 'returns information about a merge request' do | |
56 | 74 | @merge_request = Gitlab.create_merge_request(3, 'New feature', |
57 | 75 | source_branch: 'api', |
58 | target_branch: 'master' | |
59 | ) | |
60 | expect(@merge_request.project_id).to eq(3) | |
61 | expect(@merge_request.assignee.name).to eq("Jack Smith") | |
62 | end | |
63 | end | |
64 | ||
65 | describe ".update_merge_request" do | |
66 | before do | |
67 | stub_put("/projects/3/merge_requests/2", "merge_request"). | |
68 | with(body: { | |
69 | assignee_id: '1', | |
70 | target_branch: 'master', | |
71 | title: 'A different new feature' | |
72 | }) | |
76 | target_branch: 'master') | |
77 | expect(@merge_request.project_id).to eq(3) | |
78 | expect(@merge_request.assignee.name).to eq('Jack Smith') | |
79 | end | |
80 | end | |
81 | ||
82 | describe '.update_merge_request' do | |
83 | before do | |
84 | stub_put('/projects/3/merge_requests/2', 'merge_request') | |
85 | .with(body: { | |
86 | assignee_id: '1', | |
87 | target_branch: 'master', | |
88 | title: 'A different new feature' | |
89 | }) | |
73 | 90 | @merge_request = Gitlab.update_merge_request(3, 2, |
74 | 91 | assignee_id: '1', |
75 | 92 | target_branch: 'master', |
76 | title: 'A different new feature' | |
77 | ) | |
78 | end | |
79 | ||
80 | it "gets the correct resource" do | |
81 | expect(a_put("/projects/3/merge_requests/2"). | |
82 | with(body: { | |
83 | assignee_id: '1', | |
84 | target_branch: 'master', | |
85 | title: 'A different new feature' | |
86 | })).to have_been_made | |
87 | end | |
88 | ||
89 | it "returns information about a merge request" do | |
90 | expect(@merge_request.project_id).to eq(3) | |
91 | expect(@merge_request.assignee.name).to eq("Jack Smith") | |
92 | end | |
93 | end | |
94 | ||
95 | describe ".accept_merge_request" do | |
96 | before do | |
97 | stub_put("/projects/5/merge_requests/42/merge", "merge_request"). | |
98 | with(body: { merge_commit_message: 'Nice!' }) | |
93 | title: 'A different new feature') | |
94 | end | |
95 | ||
96 | it 'gets the correct resource' do | |
97 | expect(a_put('/projects/3/merge_requests/2') | |
98 | .with(body: { | |
99 | assignee_id: '1', | |
100 | target_branch: 'master', | |
101 | title: 'A different new feature' | |
102 | })).to have_been_made | |
103 | end | |
104 | ||
105 | it 'returns information about a merge request' do | |
106 | expect(@merge_request.project_id).to eq(3) | |
107 | expect(@merge_request.assignee.name).to eq('Jack Smith') | |
108 | end | |
109 | end | |
110 | ||
111 | describe '.accept_merge_request' do | |
112 | before do | |
113 | stub_put('/projects/5/merge_requests/42/merge', 'merge_request') | |
114 | .with(body: { merge_commit_message: 'Nice!' }) | |
99 | 115 | @merge_request = Gitlab.accept_merge_request(5, 42, merge_commit_message: 'Nice!') |
100 | 116 | end |
101 | 117 | |
102 | it "gets the correct resource" do | |
103 | expect(a_put("/projects/5/merge_requests/42/merge"). | |
104 | with(body: { merge_commit_message: 'Nice!' })).to have_been_made | |
105 | end | |
106 | ||
107 | it "returns information about merged merge request" do | |
108 | expect(@merge_request.project_id).to eq(3) | |
109 | expect(@merge_request.assignee.name).to eq("Jack Smith") | |
110 | end | |
111 | end | |
112 | ||
113 | describe ".merge_request_comments" do | |
114 | before do | |
115 | stub_get("/projects/3/merge_requests/2/notes", "merge_request_comments") | |
118 | it 'gets the correct resource' do | |
119 | expect(a_put('/projects/5/merge_requests/42/merge') | |
120 | .with(body: { merge_commit_message: 'Nice!' })).to have_been_made | |
121 | end | |
122 | ||
123 | it 'returns information about merged merge request' do | |
124 | expect(@merge_request.project_id).to eq(3) | |
125 | expect(@merge_request.assignee.name).to eq('Jack Smith') | |
126 | end | |
127 | end | |
128 | ||
129 | describe '.merge_request_comments' do | |
130 | before do | |
131 | stub_get('/projects/3/merge_requests/2/notes', 'merge_request_comments') | |
116 | 132 | @merge_request = Gitlab.merge_request_comments(3, 2) |
117 | 133 | end |
118 | 134 | |
119 | it "gets the correct resource" do | |
120 | expect(a_get("/projects/3/merge_requests/2/notes")).to have_been_made | |
135 | it 'gets the correct resource' do | |
136 | expect(a_get('/projects/3/merge_requests/2/notes')).to have_been_made | |
121 | 137 | end |
122 | 138 | |
123 | 139 | it "returns merge request's comments" do |
124 | 140 | expect(@merge_request).to be_an Gitlab::PaginatedResponse |
125 | 141 | expect(@merge_request.length).to eq(2) |
126 | expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request") | |
142 | expect(@merge_request[0].note).to eq('this is the 1st comment on the 2merge merge request') | |
127 | 143 | expect(@merge_request[0].author.id).to eq(11) |
128 | expect(@merge_request[1].note).to eq("another discussion point on the 2merge request") | |
144 | expect(@merge_request[1].note).to eq('another discussion point on the 2merge request') | |
129 | 145 | expect(@merge_request[1].author.id).to eq(12) |
130 | 146 | end |
131 | 147 | end |
132 | 148 | |
133 | describe ".create_merge_request_comment" do | |
134 | before do | |
135 | stub_post("/projects/3/merge_requests/2/notes", "merge_request_comment") | |
149 | describe '.create_merge_request_comment' do | |
150 | before do | |
151 | stub_post('/projects/3/merge_requests/2/notes', 'merge_request_comment') | |
136 | 152 | @merge_request = Gitlab.create_merge_request_comment(3, 2, 'Cool Merge Request!') |
137 | 153 | end |
138 | 154 | |
139 | it "gets the correct resource" do | |
140 | expect(a_post("/projects/3/merge_requests/2/notes")).to have_been_made | |
141 | end | |
142 | ||
143 | it "returns information about a merge request" do | |
155 | it 'gets the correct resource' do | |
156 | expect(a_post('/projects/3/merge_requests/2/notes')).to have_been_made | |
157 | end | |
158 | ||
159 | it 'returns information about a merge request' do | |
144 | 160 | expect(@merge_request.note).to eq('Cool Merge Request!') |
145 | 161 | expect(@merge_request.author.id).to eq(1) |
146 | 162 | end |
147 | 163 | end |
148 | 164 | |
149 | describe ".merge_request_changes" do | |
150 | before do | |
151 | stub_get("/projects/3/merge_requests/2/changes", "merge_request_changes") | |
165 | describe '.merge_request_changes' do | |
166 | before do | |
167 | stub_get('/projects/3/merge_requests/2/changes', 'merge_request_changes') | |
152 | 168 | @mr_changes = Gitlab.merge_request_changes(3, 2) |
153 | 169 | end |
154 | 170 | |
155 | it "gets the correct resource" do | |
156 | expect(a_get("/projects/3/merge_requests/2/changes")).to have_been_made | |
157 | end | |
158 | ||
159 | it "returns the merge request changes" do | |
171 | it 'gets the correct resource' do | |
172 | expect(a_get('/projects/3/merge_requests/2/changes')).to have_been_made | |
173 | end | |
174 | ||
175 | it 'returns the merge request changes' do | |
160 | 176 | expect(@mr_changes.changes).to be_a Array |
161 | 177 | expect(@mr_changes.changes.first['old_path']).to eq('lib/omniauth/builder.rb') |
162 | 178 | expect(@mr_changes.id).to eq(2) |
166 | 182 | end |
167 | 183 | end |
168 | 184 | |
169 | describe ".merge_request_commits" do | |
170 | before do | |
171 | stub_get("/projects/3/merge_requests/2/commits", "merge_request_commits") | |
185 | describe '.merge_request_commits' do | |
186 | before do | |
187 | stub_get('/projects/3/merge_requests/2/commits', 'merge_request_commits') | |
172 | 188 | @mr_commits = Gitlab.merge_request_commits(3, 2) |
173 | 189 | end |
174 | 190 | |
175 | it "gets the correct resource" do | |
176 | expect(a_get("/projects/3/merge_requests/2/commits")).to have_been_made | |
177 | end | |
178 | ||
179 | it "returns the merge request commits" do | |
191 | it 'gets the correct resource' do | |
192 | expect(a_get('/projects/3/merge_requests/2/commits')).to have_been_made | |
193 | end | |
194 | ||
195 | it 'returns the merge request commits' do | |
180 | 196 | expect(@mr_commits).to be_a Gitlab::PaginatedResponse |
181 | 197 | expect(@mr_commits.size).to eq 2 |
182 | expect(@mr_commits.first.id).to eq "a2da7552f26d5b46a6a09bb8b7b066e3a102be7d" | |
183 | expect(@mr_commits.first.short_id).to eq "a2da7552" | |
184 | expect(@mr_commits.first.title).to eq "piyo" | |
185 | expect(@mr_commits.first.author_name).to eq "example" | |
186 | expect(@mr_commits.first.author_email).to eq "example@example.com" | |
187 | expect(@mr_commits[1].short_id).to eq "3ce50959" | |
188 | expect(@mr_commits[1].title).to eq "hoge" | |
189 | end | |
190 | end | |
191 | ||
192 | describe ".merge_request_closes_issues" do | |
193 | before do | |
194 | stub_get("/projects/5/merge_requests/1/closes_issues", "merge_request_closes_issues") | |
198 | expect(@mr_commits.first.id).to eq 'a2da7552f26d5b46a6a09bb8b7b066e3a102be7d' | |
199 | expect(@mr_commits.first.short_id).to eq 'a2da7552' | |
200 | expect(@mr_commits.first.title).to eq 'piyo' | |
201 | expect(@mr_commits.first.author_name).to eq 'example' | |
202 | expect(@mr_commits.first.author_email).to eq 'example@example.com' | |
203 | expect(@mr_commits[1].short_id).to eq '3ce50959' | |
204 | expect(@mr_commits[1].title).to eq 'hoge' | |
205 | end | |
206 | end | |
207 | ||
208 | describe '.merge_request_closes_issues' do | |
209 | before do | |
210 | stub_get('/projects/5/merge_requests/1/closes_issues', 'merge_request_closes_issues') | |
195 | 211 | @issues = Gitlab.merge_request_closes_issues(5, 1) |
196 | 212 | end |
197 | 213 | |
198 | it "gets the correct resource" do | |
199 | expect(a_get("/projects/5/merge_requests/1/closes_issues")).to have_been_made | |
200 | end | |
201 | ||
202 | it "returns a paginated response of the issues the merge_request will close" do | |
214 | it 'gets the correct resource' do | |
215 | expect(a_get('/projects/5/merge_requests/1/closes_issues')).to have_been_made | |
216 | end | |
217 | ||
218 | it 'returns a paginated response of the issues the merge_request will close' do | |
203 | 219 | expect(@issues).to be_a(Gitlab::PaginatedResponse) |
204 | expect(@issues.first.title).to eq("Merge request 1 issue 1") | |
220 | expect(@issues.first.title).to eq('Merge request 1 issue 1') | |
205 | 221 | expect(@issues.size).to eq(2) |
206 | 222 | end |
207 | 223 | end |
208 | 224 | |
209 | describe ".subscribe_to_merge_request" do | |
210 | before do | |
211 | stub_post("/projects/3/merge_requests/2/subscribe", "merge_request") | |
225 | describe '.subscribe_to_merge_request' do | |
226 | before do | |
227 | stub_post('/projects/3/merge_requests/2/subscribe', 'merge_request') | |
212 | 228 | @merge_request = Gitlab.subscribe_to_merge_request(3, 2) |
213 | 229 | end |
214 | 230 | |
215 | it "gets the correct resource" do | |
216 | expect(a_post("/projects/3/merge_requests/2/subscribe")).to have_been_made | |
217 | end | |
218 | ||
219 | it "returns information about a merge request" do | |
220 | expect(@merge_request.project_id).to eq(3) | |
221 | end | |
222 | end | |
223 | ||
224 | describe ".unsubscribe_from_merge_request" do | |
225 | before do | |
226 | stub_post("/projects/3/merge_requests/2/unsubscribe", "merge_request") | |
231 | it 'gets the correct resource' do | |
232 | expect(a_post('/projects/3/merge_requests/2/subscribe')).to have_been_made | |
233 | end | |
234 | ||
235 | it 'returns information about a merge request' do | |
236 | expect(@merge_request.project_id).to eq(3) | |
237 | end | |
238 | end | |
239 | ||
240 | describe '.unsubscribe_from_merge_request' do | |
241 | before do | |
242 | stub_post('/projects/3/merge_requests/2/unsubscribe', 'merge_request') | |
227 | 243 | @merge_request = Gitlab.unsubscribe_from_merge_request(3, 2) |
228 | 244 | end |
229 | 245 | |
230 | it "gets the correct resource" do | |
231 | expect(a_post("/projects/3/merge_requests/2/unsubscribe")).to have_been_made | |
232 | end | |
233 | ||
234 | it "returns information about a merge request" do | |
235 | expect(@merge_request.project_id).to eq(3) | |
236 | end | |
237 | end | |
238 | ||
239 | describe ".merge_request_discussions" do | |
240 | before do | |
241 | stub_get("/projects/3/merge_requests/2/discussions", "merge_request_discussions") | |
246 | it 'gets the correct resource' do | |
247 | expect(a_post('/projects/3/merge_requests/2/unsubscribe')).to have_been_made | |
248 | end | |
249 | ||
250 | it 'returns information about a merge request' do | |
251 | expect(@merge_request.project_id).to eq(3) | |
252 | end | |
253 | end | |
254 | ||
255 | describe '.merge_request_discussions' do | |
256 | before do | |
257 | stub_get('/projects/3/merge_requests/2/discussions', 'merge_request_discussions') | |
242 | 258 | @discussions = Gitlab.merge_request_discussions(3, 2) |
243 | 259 | end |
244 | 260 | |
245 | it "gets the correct resource" do | |
246 | expect(a_get("/projects/3/merge_requests/2/discussions")).to have_been_made | |
247 | end | |
248 | ||
249 | it "returns information about the discussions" do | |
261 | it 'gets the correct resource' do | |
262 | expect(a_get('/projects/3/merge_requests/2/discussions')).to have_been_made | |
263 | end | |
264 | ||
265 | it 'returns information about the discussions' do | |
250 | 266 | expect(@discussions.length).to eq(1) |
251 | 267 | expect(@discussions.first.id).to eq('7d66bf19bf835e6a4666130544ba1b5c343fc705') |
252 | 268 | end |
253 | 269 | end |
254 | 270 | |
255 | describe ".merge_request_discussion" do | |
256 | before do | |
257 | stub_get("/projects/3/merge_requests/2/discussions/1", "merge_request_discussion") | |
271 | describe '.merge_request_discussion' do | |
272 | before do | |
273 | stub_get('/projects/3/merge_requests/2/discussions/1', 'merge_request_discussion') | |
258 | 274 | @discussion = Gitlab.merge_request_discussion(3, 2, 1) |
259 | 275 | end |
260 | 276 | |
261 | it "gets the correct resource" do | |
262 | expect(a_get("/projects/3/merge_requests/2/discussions/1")).to have_been_made | |
263 | end | |
264 | ||
265 | it "returns information about the discussions" do | |
277 | it 'gets the correct resource' do | |
278 | expect(a_get('/projects/3/merge_requests/2/discussions/1')).to have_been_made | |
279 | end | |
280 | ||
281 | it 'returns information about the discussions' do | |
266 | 282 | expect(@discussion.id).to eq('7d66bf19bf835e6a4666130544ba1b5c343fc705') |
267 | 283 | end |
268 | 284 | end |
269 | 285 | |
270 | describe ".create_merge_request_discussion" do | |
271 | before do | |
272 | stub_post("/projects/3/merge_requests/2/discussions", "merge_request_discussion") | |
273 | @discussion = Gitlab.create_merge_request_discussion(3, 2, body: 'Discussion', position: {old_line: 1}) | |
274 | end | |
275 | ||
276 | it "posts the correct resource" do | |
277 | expect(a_post("/projects/3/merge_requests/2/discussions"). | |
278 | with(body: 'body=Discussion&position[old_line]=1')).to have_been_made | |
279 | end | |
280 | ||
281 | it "returns information about the discussions" do | |
286 | describe '.create_merge_request_discussion' do | |
287 | before do | |
288 | stub_post('/projects/3/merge_requests/2/discussions', 'merge_request_discussion') | |
289 | @discussion = Gitlab.create_merge_request_discussion(3, 2, body: 'Discussion', position: { old_line: 1 }) | |
290 | end | |
291 | ||
292 | it 'posts the correct resource' do | |
293 | expect(a_post('/projects/3/merge_requests/2/discussions') | |
294 | .with(body: 'body=Discussion&position[old_line]=1')).to have_been_made | |
295 | end | |
296 | ||
297 | it 'returns information about the discussions' do | |
282 | 298 | expect(@discussion.id).to eq('7d66bf19bf835e6a4666130544ba1b5c343fc705') |
283 | 299 | end |
284 | 300 | end |
285 | 301 | |
286 | describe ".resolve_merge_request_discussion" do | |
287 | before do | |
288 | stub_put("/projects/3/merge_requests/2/discussions/1", "merge_request_discussion") | |
302 | describe '.resolve_merge_request_discussion' do | |
303 | before do | |
304 | stub_put('/projects/3/merge_requests/2/discussions/1', 'merge_request_discussion') | |
289 | 305 | @discussion = Gitlab.resolve_merge_request_discussion(3, 2, 1, resolved: true) |
290 | 306 | end |
291 | 307 | |
292 | it "puts the correct resource" do | |
293 | expect(a_put("/projects/3/merge_requests/2/discussions/1"). | |
294 | with(body: 'resolved=true')).to have_been_made | |
295 | end | |
296 | ||
297 | it "returns information about the discussions" do | |
308 | it 'puts the correct resource' do | |
309 | expect(a_put('/projects/3/merge_requests/2/discussions/1') | |
310 | .with(body: 'resolved=true')).to have_been_made | |
311 | end | |
312 | ||
313 | it 'returns information about the discussions' do | |
298 | 314 | expect(@discussion.id).to eq('7d66bf19bf835e6a4666130544ba1b5c343fc705') |
299 | 315 | note = @discussion.notes.first |
300 | 316 | expect(note['id']).to eq(1758) |
301 | 317 | end |
302 | 318 | end |
303 | 319 | |
304 | describe ".create_merge_request_discussion_note" do | |
305 | before do | |
306 | stub_post("/projects/3/merge_requests/2/discussions/1/notes", "merge_request_discussion_note") | |
320 | describe '.create_merge_request_discussion_note' do | |
321 | before do | |
322 | stub_post('/projects/3/merge_requests/2/discussions/1/notes', 'merge_request_discussion_note') | |
307 | 323 | @note = Gitlab.create_merge_request_discussion_note(3, 2, 1, body: 'note') |
308 | 324 | end |
309 | 325 | |
310 | it "posts the correct resource" do | |
311 | expect(a_post("/projects/3/merge_requests/2/discussions/1/notes"). | |
312 | with(body: 'body=note')).to have_been_made | |
313 | end | |
314 | ||
315 | it "returns information about the note" do | |
326 | it 'posts the correct resource' do | |
327 | expect(a_post('/projects/3/merge_requests/2/discussions/1/notes') | |
328 | .with(body: 'body=note')).to have_been_made | |
329 | end | |
330 | ||
331 | it 'returns information about the note' do | |
316 | 332 | expect(@note.id).to eq(1775) |
317 | 333 | end |
318 | 334 | end |
319 | 335 | |
320 | describe ".update_merge_request_discussion_note" do | |
321 | before do | |
322 | stub_put("/projects/3/merge_requests/2/discussions/1/notes/1", "merge_request_discussion_note") | |
336 | describe '.update_merge_request_discussion_note' do | |
337 | before do | |
338 | stub_put('/projects/3/merge_requests/2/discussions/1/notes/1', 'merge_request_discussion_note') | |
323 | 339 | @note = Gitlab.update_merge_request_discussion_note(3, 2, 1, 1, body: 'note2') |
324 | 340 | end |
325 | 341 | |
326 | it "puts the correct resource" do | |
327 | expect(a_put("/projects/3/merge_requests/2/discussions/1/notes/1"). | |
328 | with(body: 'body=note2')).to have_been_made | |
329 | end | |
330 | ||
331 | it "returns information about the note" do | |
342 | it 'puts the correct resource' do | |
343 | expect(a_put('/projects/3/merge_requests/2/discussions/1/notes/1') | |
344 | .with(body: 'body=note2')).to have_been_made | |
345 | end | |
346 | ||
347 | it 'returns information about the note' do | |
332 | 348 | expect(@note.id).to eq(1775) |
333 | 349 | end |
334 | 350 | end |
335 | 351 | |
336 | describe ".delete_merge_request_discussion_note" do | |
337 | before do | |
338 | stub_request(:delete, "https://api.example.com/projects/3/merge_requests/2/discussions/1/notes/1").to_return(body: '') | |
352 | describe '.delete_merge_request_discussion_note' do | |
353 | before do | |
354 | stub_request(:delete, 'https://api.example.com/projects/3/merge_requests/2/discussions/1/notes/1').to_return(body: '') | |
339 | 355 | @note = Gitlab.delete_merge_request_discussion_note(3, 2, 1, 1) |
340 | 356 | end |
341 | 357 | |
342 | it "deletes the correct resource" do | |
343 | expect(a_delete("/projects/3/merge_requests/2/discussions/1/notes/1")).to have_been_made | |
344 | end | |
345 | ||
346 | it "returns nothing" do | |
358 | it 'deletes the correct resource' do | |
359 | expect(a_delete('/projects/3/merge_requests/2/discussions/1/notes/1')).to have_been_made | |
360 | end | |
361 | ||
362 | it 'returns nothing' do | |
347 | 363 | expect(@note).to be_falsy |
348 | 364 | end |
349 | 365 | end |
366 | ||
367 | describe '.merge_request_diff_versions' do | |
368 | before do | |
369 | stub_get('/projects/3/merge_requests/105/versions', 'merge_request_diff_versions') | |
370 | @versions = Gitlab.merge_request_diff_versions(3, 105) | |
371 | end | |
372 | ||
373 | it 'gets the correct resource' do | |
374 | expect(a_get('/projects/3/merge_requests/105/versions')).to have_been_made | |
375 | end | |
376 | ||
377 | it 'returns an array of the versions' do | |
378 | expect(@versions.length).to eq(2) | |
379 | expect(@versions.first.head_commit_sha).to eq('33e2ee8579fda5bc36accc9c6fbd0b4fefda9e30') | |
380 | end | |
381 | end | |
382 | ||
383 | describe '.merge_request_diff_version' do | |
384 | before do | |
385 | stub_get('/projects/3/merge_requests/105/versions/1', 'merge_request_diff_version') | |
386 | @diff = Gitlab.merge_request_diff_version(3, 105, 1) | |
387 | end | |
388 | ||
389 | it 'gets the correct resource' do | |
390 | expect(a_get('/projects/3/merge_requests/105/versions/1')).to have_been_made | |
391 | end | |
392 | ||
393 | it 'returns diff, with array of diffs in version' do | |
394 | expect(@diff.diffs).to be_a Array | |
395 | expect(@diff.diffs.first['old_path']).to eq('LICENSE') | |
396 | end | |
397 | end | |
350 | 398 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".milestones" do | |
5 | describe '.milestones' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/milestones", "milestones") | |
7 | stub_get('/projects/3/milestones', 'milestones') | |
6 | 8 | @milestones = Gitlab.milestones(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/milestones")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/milestones')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of project's milestones" do |
16 | 18 | end |
17 | 19 | end |
18 | 20 | |
19 | describe ".milestone" do | |
21 | describe '.milestone' do | |
20 | 22 | before do |
21 | stub_get("/projects/3/milestones/1", "milestone") | |
23 | stub_get('/projects/3/milestones/1', 'milestone') | |
22 | 24 | @milestone = Gitlab.milestone(3, 1) |
23 | 25 | end |
24 | 26 | |
25 | it "gets the correct resource" do | |
26 | expect(a_get("/projects/3/milestones/1")).to have_been_made | |
27 | it 'gets the correct resource' do | |
28 | expect(a_get('/projects/3/milestones/1')).to have_been_made | |
27 | 29 | end |
28 | 30 | |
29 | it "returns information about a milestone" do | |
31 | it 'returns information about a milestone' do | |
30 | 32 | expect(@milestone.project_id).to eq(3) |
31 | 33 | end |
32 | 34 | end |
33 | 35 | |
34 | describe ".milestone_issues" do | |
36 | describe '.milestone_issues' do | |
35 | 37 | before do |
36 | stub_get("/projects/3/milestones/1/issues", "milestone_issues") | |
38 | stub_get('/projects/3/milestones/1/issues', 'milestone_issues') | |
37 | 39 | @milestone_issues = Gitlab.milestone_issues(3, 1) |
38 | 40 | end |
39 | 41 | |
40 | it "gets the correct resource" do | |
41 | expect(a_get("/projects/3/milestones/1/issues")).to have_been_made | |
42 | it 'gets the correct resource' do | |
43 | expect(a_get('/projects/3/milestones/1/issues')).to have_been_made | |
42 | 44 | end |
43 | 45 | |
44 | 46 | it "returns a paginated response of milestone's issues" do |
47 | 49 | end |
48 | 50 | end |
49 | 51 | |
50 | describe ".milestone_merge_requests" do | |
52 | describe '.milestone_merge_requests' do | |
51 | 53 | before do |
52 | stub_get("/projects/3/milestones/1/merge_requests", "milestone_merge_requests") | |
54 | stub_get('/projects/3/milestones/1/merge_requests', 'milestone_merge_requests') | |
53 | 55 | @milestone_merge_requests = Gitlab.milestone_merge_requests(3, 1) |
54 | 56 | end |
55 | 57 | |
56 | it "gets the correct resource" do | |
57 | expect(a_get("/projects/3/milestones/1/merge_requests")).to have_been_made | |
58 | it 'gets the correct resource' do | |
59 | expect(a_get('/projects/3/milestones/1/merge_requests')).to have_been_made | |
58 | 60 | end |
59 | 61 | |
60 | 62 | it "returns a paginated response of milestone's merge_requests" do |
63 | 65 | end |
64 | 66 | end |
65 | 67 | |
66 | describe ".create_milestone" do | |
68 | describe '.create_milestone' do | |
67 | 69 | before do |
68 | stub_post("/projects/3/milestones", "milestone") | |
70 | stub_post('/projects/3/milestones', 'milestone') | |
69 | 71 | @milestone = Gitlab.create_milestone(3, 'title') |
70 | 72 | end |
71 | 73 | |
72 | it "gets the correct resource" do | |
73 | expect(a_post("/projects/3/milestones"). | |
74 | with(body: { title: 'title' })).to have_been_made | |
74 | it 'gets the correct resource' do | |
75 | expect(a_post('/projects/3/milestones') | |
76 | .with(body: { title: 'title' })).to have_been_made | |
75 | 77 | end |
76 | 78 | |
77 | it "returns information about a created milestone" do | |
79 | it 'returns information about a created milestone' do | |
78 | 80 | expect(@milestone.project_id).to eq(3) |
79 | 81 | end |
80 | 82 | end |
81 | 83 | |
82 | describe ".edit_milestone" do | |
84 | describe '.edit_milestone' do | |
83 | 85 | before do |
84 | stub_put("/projects/3/milestones/33", "milestone") | |
86 | stub_put('/projects/3/milestones/33', 'milestone') | |
85 | 87 | @milestone = Gitlab.edit_milestone(3, 33, title: 'title') |
86 | 88 | end |
87 | 89 | |
88 | it "gets the correct resource" do | |
89 | expect(a_put("/projects/3/milestones/33"). | |
90 | with(body: { title: 'title' })).to have_been_made | |
90 | it 'gets the correct resource' do | |
91 | expect(a_put('/projects/3/milestones/33') | |
92 | .with(body: { title: 'title' })).to have_been_made | |
91 | 93 | end |
92 | 94 | |
93 | it "returns information about an edited milestone" do | |
95 | it 'returns information about an edited milestone' do | |
94 | 96 | expect(@milestone.project_id).to eq(3) |
95 | 97 | end |
96 | 98 | end |
99 | ||
100 | describe '.delete_milestone' do | |
101 | before do | |
102 | stub_delete('/projects/3/milestones/33', 'empty') | |
103 | @milestone = Gitlab.delete_milestone(3, 33) | |
104 | end | |
105 | ||
106 | it 'gets the correct resource' do | |
107 | expect(a_delete('/projects/3/milestones/33')).to have_been_made | |
108 | end | |
109 | end | |
97 | 110 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | 5 | it { is_expected.to respond_to :namespaces } |
4 | 6 | |
5 | describe ".namespaces" do | |
7 | describe '.namespaces' do | |
6 | 8 | before do |
7 | stub_get("/namespaces", "namespaces") | |
9 | stub_get('/namespaces', 'namespaces') | |
8 | 10 | @namespaces = Gitlab.namespaces |
9 | 11 | end |
10 | 12 | |
11 | it "gets the correct resource" do | |
12 | expect(a_get("/namespaces")).to have_been_made | |
13 | it 'gets the correct resource' do | |
14 | expect(a_get('/namespaces')).to have_been_made | |
13 | 15 | end |
14 | 16 | |
15 | it "returns a paginated response of namespaces" do | |
17 | it 'returns a paginated response of namespaces' do | |
16 | 18 | expect(@namespaces).to be_a Gitlab::PaginatedResponse |
17 | expect(@namespaces.first.path).to eq("john") | |
18 | expect(@namespaces.first.kind).to eq("user") | |
19 | expect(@namespaces.first.path).to eq('john') | |
20 | expect(@namespaces.first.kind).to eq('user') | |
19 | 21 | end |
20 | 22 | end |
21 | 23 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe "notes" do | |
4 | context "when wall notes" do | |
5 | before do | |
6 | stub_get("/projects/3/notes", "notes") | |
5 | describe 'notes' do | |
6 | context 'when wall notes' do | |
7 | before do | |
8 | stub_get('/projects/3/notes', 'notes') | |
7 | 9 | @notes = Gitlab.notes(3) |
8 | 10 | end |
9 | 11 | |
10 | it "gets the correct resource" do | |
11 | expect(a_get("/projects/3/notes")).to have_been_made | |
12 | end | |
13 | ||
14 | it "returns a paginated response of notes" do | |
12 | it 'gets the correct resource' do | |
13 | expect(a_get('/projects/3/notes')).to have_been_made | |
14 | end | |
15 | ||
16 | it 'returns a paginated response of notes' do | |
15 | 17 | expect(@notes).to be_a Gitlab::PaginatedResponse |
16 | expect(@notes.first.author.name).to eq("John Smith") | |
17 | end | |
18 | end | |
19 | ||
20 | context "when issue notes" do | |
21 | before do | |
22 | stub_get("/projects/3/issues/7/notes", "notes") | |
18 | expect(@notes.first.author.name).to eq('John Smith') | |
19 | end | |
20 | end | |
21 | ||
22 | context 'when issue notes' do | |
23 | before do | |
24 | stub_get('/projects/3/issues/7/notes', 'notes') | |
23 | 25 | @notes = Gitlab.issue_notes(3, 7) |
24 | 26 | end |
25 | 27 | |
26 | it "gets the correct resource" do | |
27 | expect(a_get("/projects/3/issues/7/notes")).to have_been_made | |
28 | end | |
29 | ||
30 | it "returns a paginated response of notes" do | |
28 | it 'gets the correct resource' do | |
29 | expect(a_get('/projects/3/issues/7/notes')).to have_been_made | |
30 | end | |
31 | ||
32 | it 'returns a paginated response of notes' do | |
31 | 33 | expect(@notes).to be_a Gitlab::PaginatedResponse |
32 | expect(@notes.first.author.name).to eq("John Smith") | |
33 | end | |
34 | end | |
35 | ||
36 | context "when snippet notes" do | |
37 | before do | |
38 | stub_get("/projects/3/snippets/7/notes", "notes") | |
34 | expect(@notes.first.author.name).to eq('John Smith') | |
35 | end | |
36 | end | |
37 | ||
38 | context 'when snippet notes' do | |
39 | before do | |
40 | stub_get('/projects/3/snippets/7/notes', 'notes') | |
39 | 41 | @notes = Gitlab.snippet_notes(3, 7) |
40 | 42 | end |
41 | 43 | |
42 | it "gets the correct resource" do | |
43 | expect(a_get("/projects/3/snippets/7/notes")).to have_been_made | |
44 | end | |
45 | ||
46 | it "returns a paginated response of notes" do | |
44 | it 'gets the correct resource' do | |
45 | expect(a_get('/projects/3/snippets/7/notes')).to have_been_made | |
46 | end | |
47 | ||
48 | it 'returns a paginated response of notes' do | |
47 | 49 | expect(@notes).to be_a Gitlab::PaginatedResponse |
48 | expect(@notes.first.author.name).to eq("John Smith") | |
49 | end | |
50 | end | |
51 | ||
52 | context "when merge_request notes" do | |
53 | before do | |
54 | stub_get("/projects/3/merge_requests/7/notes", "notes") | |
50 | expect(@notes.first.author.name).to eq('John Smith') | |
51 | end | |
52 | end | |
53 | ||
54 | context 'when merge_request notes' do | |
55 | before do | |
56 | stub_get('/projects/3/merge_requests/7/notes', 'notes') | |
55 | 57 | @notes = Gitlab.merge_request_notes(3, 7) |
56 | 58 | end |
57 | 59 | |
58 | it "gets the correct resource" do | |
59 | expect(a_get("/projects/3/merge_requests/7/notes")).to have_been_made | |
60 | end | |
61 | ||
62 | it "returns a paginated response of notes" do | |
60 | it 'gets the correct resource' do | |
61 | expect(a_get('/projects/3/merge_requests/7/notes')).to have_been_made | |
62 | end | |
63 | ||
64 | it 'returns a paginated response of notes' do | |
63 | 65 | expect(@notes).to be_a Gitlab::PaginatedResponse |
64 | expect(@notes.first.author.name).to eq("John Smith") | |
65 | end | |
66 | end | |
67 | end | |
68 | ||
69 | describe "note" do | |
70 | context "when wall note" do | |
71 | before do | |
72 | stub_get("/projects/3/notes/1201", "note") | |
66 | expect(@notes.first.author.name).to eq('John Smith') | |
67 | end | |
68 | end | |
69 | end | |
70 | ||
71 | describe 'note' do | |
72 | context 'when wall note' do | |
73 | before do | |
74 | stub_get('/projects/3/notes/1201', 'note') | |
73 | 75 | @note = Gitlab.note(3, 1201) |
74 | 76 | end |
75 | 77 | |
76 | it "gets the correct resource" do | |
77 | expect(a_get("/projects/3/notes/1201")).to have_been_made | |
78 | end | |
79 | ||
80 | it "returns information about a note" do | |
81 | expect(@note.body).to eq("The solution is rather tricky") | |
82 | expect(@note.author.name).to eq("John Smith") | |
83 | end | |
84 | end | |
85 | ||
86 | context "when issue note" do | |
87 | before do | |
88 | stub_get("/projects/3/issues/7/notes/1201", "note") | |
78 | it 'gets the correct resource' do | |
79 | expect(a_get('/projects/3/notes/1201')).to have_been_made | |
80 | end | |
81 | ||
82 | it 'returns information about a note' do | |
83 | expect(@note.body).to eq('The solution is rather tricky') | |
84 | expect(@note.author.name).to eq('John Smith') | |
85 | end | |
86 | end | |
87 | ||
88 | context 'when issue note' do | |
89 | before do | |
90 | stub_get('/projects/3/issues/7/notes/1201', 'note') | |
89 | 91 | @note = Gitlab.issue_note(3, 7, 1201) |
90 | 92 | end |
91 | 93 | |
92 | it "gets the correct resource" do | |
93 | expect(a_get("/projects/3/issues/7/notes/1201")).to have_been_made | |
94 | end | |
95 | ||
96 | it "returns information about a note" do | |
97 | expect(@note.body).to eq("The solution is rather tricky") | |
98 | expect(@note.author.name).to eq("John Smith") | |
99 | end | |
100 | end | |
101 | ||
102 | context "when snippet note" do | |
103 | before do | |
104 | stub_get("/projects/3/snippets/7/notes/1201", "note") | |
94 | it 'gets the correct resource' do | |
95 | expect(a_get('/projects/3/issues/7/notes/1201')).to have_been_made | |
96 | end | |
97 | ||
98 | it 'returns information about a note' do | |
99 | expect(@note.body).to eq('The solution is rather tricky') | |
100 | expect(@note.author.name).to eq('John Smith') | |
101 | end | |
102 | end | |
103 | ||
104 | context 'when snippet note' do | |
105 | before do | |
106 | stub_get('/projects/3/snippets/7/notes/1201', 'note') | |
105 | 107 | @note = Gitlab.snippet_note(3, 7, 1201) |
106 | 108 | end |
107 | 109 | |
108 | it "gets the correct resource" do | |
109 | expect(a_get("/projects/3/snippets/7/notes/1201")).to have_been_made | |
110 | end | |
111 | ||
112 | it "returns information about a note" do | |
113 | expect(@note.body).to eq("The solution is rather tricky") | |
114 | expect(@note.author.name).to eq("John Smith") | |
115 | end | |
116 | end | |
117 | ||
118 | context "when merge request note" do | |
119 | before do | |
120 | stub_get("/projects/3/merge_requests/7/notes/1201", "note") | |
110 | it 'gets the correct resource' do | |
111 | expect(a_get('/projects/3/snippets/7/notes/1201')).to have_been_made | |
112 | end | |
113 | ||
114 | it 'returns information about a note' do | |
115 | expect(@note.body).to eq('The solution is rather tricky') | |
116 | expect(@note.author.name).to eq('John Smith') | |
117 | end | |
118 | end | |
119 | ||
120 | context 'when merge request note' do | |
121 | before do | |
122 | stub_get('/projects/3/merge_requests/7/notes/1201', 'note') | |
121 | 123 | @note = Gitlab.merge_request_note(3, 7, 1201) |
122 | 124 | end |
123 | 125 | |
124 | it "gets the correct resource" do | |
125 | expect(a_get("/projects/3/merge_requests/7/notes/1201")).to have_been_made | |
126 | end | |
127 | ||
128 | it "returns information about a note" do | |
129 | expect(@note.body).to eq("The solution is rather tricky") | |
130 | expect(@note.author.name).to eq("John Smith") | |
131 | end | |
132 | end | |
133 | end | |
134 | ||
135 | describe "create note" do | |
136 | context "when wall note" do | |
137 | before do | |
138 | stub_post("/projects/3/notes", "note") | |
139 | @note = Gitlab.create_note(3, "The solution is rather tricky") | |
140 | end | |
141 | ||
142 | it "gets the correct resource" do | |
143 | expect(a_post("/projects/3/notes"). | |
144 | with(body: { body: 'The solution is rather tricky' })).to have_been_made | |
145 | end | |
146 | ||
147 | it "returns information about a created note" do | |
148 | expect(@note.body).to eq("The solution is rather tricky") | |
149 | expect(@note.author.name).to eq("John Smith") | |
150 | end | |
151 | end | |
152 | ||
153 | context "when issue note" do | |
154 | before do | |
155 | stub_post("/projects/3/issues/7/notes", "note") | |
156 | @note = Gitlab.create_issue_note(3, 7, "The solution is rather tricky") | |
157 | end | |
158 | ||
159 | it "gets the correct resource" do | |
160 | expect(a_post("/projects/3/issues/7/notes"). | |
161 | with(body: { body: 'The solution is rather tricky' })).to have_been_made | |
162 | end | |
163 | ||
164 | it "returns information about a created note" do | |
165 | expect(@note.body).to eq("The solution is rather tricky") | |
166 | expect(@note.author.name).to eq("John Smith") | |
167 | end | |
168 | end | |
169 | ||
170 | context "when snippet note" do | |
171 | before do | |
172 | stub_post("/projects/3/snippets/7/notes", "note") | |
173 | @note = Gitlab.create_snippet_note(3, 7, "The solution is rather tricky") | |
174 | end | |
175 | ||
176 | it "gets the correct resource" do | |
177 | expect(a_post("/projects/3/snippets/7/notes"). | |
178 | with(body: { body: 'The solution is rather tricky' })).to have_been_made | |
179 | end | |
180 | ||
181 | it "returns information about a created note" do | |
182 | expect(@note.body).to eq("The solution is rather tricky") | |
183 | expect(@note.author.name).to eq("John Smith") | |
184 | end | |
185 | end | |
186 | ||
187 | context "when merge_request note" do | |
188 | before do | |
189 | stub_post("/projects/3/merge_requests/7/notes", "note") | |
190 | @note = Gitlab.create_merge_request_note(3, 7, "The solution is rather tricky") | |
191 | end | |
192 | ||
193 | it "gets the correct resource" do | |
194 | expect(a_post("/projects/3/merge_requests/7/notes"). | |
195 | with(body: { body: 'The solution is rather tricky' })).to have_been_made | |
196 | end | |
197 | ||
198 | it "returns information about a created note" do | |
199 | expect(@note.body).to eq("The solution is rather tricky") | |
200 | expect(@note.author.name).to eq("John Smith") | |
201 | end | |
202 | end | |
203 | end | |
204 | ||
205 | describe "delete note" do | |
206 | context "when wall note" do | |
207 | before do | |
208 | stub_delete("/projects/3/notes/1201", "note") | |
126 | it 'gets the correct resource' do | |
127 | expect(a_get('/projects/3/merge_requests/7/notes/1201')).to have_been_made | |
128 | end | |
129 | ||
130 | it 'returns information about a note' do | |
131 | expect(@note.body).to eq('The solution is rather tricky') | |
132 | expect(@note.author.name).to eq('John Smith') | |
133 | end | |
134 | end | |
135 | end | |
136 | ||
137 | describe 'create note' do | |
138 | context 'when wall note' do | |
139 | before do | |
140 | stub_post('/projects/3/notes', 'note') | |
141 | @note = Gitlab.create_note(3, 'The solution is rather tricky') | |
142 | end | |
143 | ||
144 | it 'gets the correct resource' do | |
145 | expect(a_post('/projects/3/notes') | |
146 | .with(body: { body: 'The solution is rather tricky' })).to have_been_made | |
147 | end | |
148 | ||
149 | it 'returns information about a created note' do | |
150 | expect(@note.body).to eq('The solution is rather tricky') | |
151 | expect(@note.author.name).to eq('John Smith') | |
152 | end | |
153 | end | |
154 | ||
155 | context 'when issue note' do | |
156 | before do | |
157 | stub_post('/projects/3/issues/7/notes', 'note') | |
158 | @note = Gitlab.create_issue_note(3, 7, 'The solution is rather tricky') | |
159 | end | |
160 | ||
161 | it 'gets the correct resource' do | |
162 | expect(a_post('/projects/3/issues/7/notes') | |
163 | .with(body: { body: 'The solution is rather tricky' })).to have_been_made | |
164 | end | |
165 | ||
166 | it 'returns information about a created note' do | |
167 | expect(@note.body).to eq('The solution is rather tricky') | |
168 | expect(@note.author.name).to eq('John Smith') | |
169 | end | |
170 | end | |
171 | ||
172 | context 'when snippet note' do | |
173 | before do | |
174 | stub_post('/projects/3/snippets/7/notes', 'note') | |
175 | @note = Gitlab.create_snippet_note(3, 7, 'The solution is rather tricky') | |
176 | end | |
177 | ||
178 | it 'gets the correct resource' do | |
179 | expect(a_post('/projects/3/snippets/7/notes') | |
180 | .with(body: { body: 'The solution is rather tricky' })).to have_been_made | |
181 | end | |
182 | ||
183 | it 'returns information about a created note' do | |
184 | expect(@note.body).to eq('The solution is rather tricky') | |
185 | expect(@note.author.name).to eq('John Smith') | |
186 | end | |
187 | end | |
188 | ||
189 | context 'when merge_request note' do | |
190 | before do | |
191 | stub_post('/projects/3/merge_requests/7/notes', 'note') | |
192 | @note = Gitlab.create_merge_request_note(3, 7, 'The solution is rather tricky') | |
193 | end | |
194 | ||
195 | it 'gets the correct resource' do | |
196 | expect(a_post('/projects/3/merge_requests/7/notes') | |
197 | .with(body: { body: 'The solution is rather tricky' })).to have_been_made | |
198 | end | |
199 | ||
200 | it 'returns information about a created note' do | |
201 | expect(@note.body).to eq('The solution is rather tricky') | |
202 | expect(@note.author.name).to eq('John Smith') | |
203 | end | |
204 | end | |
205 | end | |
206 | ||
207 | describe 'delete note' do | |
208 | context 'when wall note' do | |
209 | before do | |
210 | stub_delete('/projects/3/notes/1201', 'note') | |
209 | 211 | @note = Gitlab.delete_note(3, 1201) |
210 | 212 | end |
211 | 213 | |
212 | it "gets the correct resource" do | |
213 | expect(a_delete("/projects/3/notes/1201")).to have_been_made | |
214 | end | |
215 | ||
216 | it "returns information about a deleted note" do | |
217 | expect(@note.id).to eq(1201) | |
218 | end | |
219 | end | |
220 | ||
221 | context "when issue note" do | |
222 | before do | |
223 | stub_delete("/projects/3/issues/7/notes/1201", "note") | |
214 | it 'gets the correct resource' do | |
215 | expect(a_delete('/projects/3/notes/1201')).to have_been_made | |
216 | end | |
217 | ||
218 | it 'returns information about a deleted note' do | |
219 | expect(@note.id).to eq(1201) | |
220 | end | |
221 | end | |
222 | ||
223 | context 'when issue note' do | |
224 | before do | |
225 | stub_delete('/projects/3/issues/7/notes/1201', 'note') | |
224 | 226 | @note = Gitlab.delete_issue_note(3, 7, 1201) |
225 | 227 | end |
226 | 228 | |
227 | it "gets the correct resource" do | |
228 | expect(a_delete("/projects/3/issues/7/notes/1201")).to have_been_made | |
229 | end | |
230 | ||
231 | it "returns information about a deleted issue note" do | |
232 | expect(@note.id).to eq(1201) | |
233 | end | |
234 | end | |
235 | ||
236 | context "when snippet note" do | |
237 | before do | |
238 | stub_delete("/projects/3/snippets/7/notes/1201", "note") | |
229 | it 'gets the correct resource' do | |
230 | expect(a_delete('/projects/3/issues/7/notes/1201')).to have_been_made | |
231 | end | |
232 | ||
233 | it 'returns information about a deleted issue note' do | |
234 | expect(@note.id).to eq(1201) | |
235 | end | |
236 | end | |
237 | ||
238 | context 'when snippet note' do | |
239 | before do | |
240 | stub_delete('/projects/3/snippets/7/notes/1201', 'note') | |
239 | 241 | @note = Gitlab.delete_snippet_note(3, 7, 1201) |
240 | 242 | end |
241 | 243 | |
242 | it "gets the correct resource" do | |
243 | expect(a_delete("/projects/3/snippets/7/notes/1201")).to have_been_made | |
244 | end | |
245 | ||
246 | it "returns information about a deleted snippet note" do | |
247 | expect(@note.id).to eq(1201) | |
248 | end | |
249 | end | |
250 | ||
251 | context "when merge request note" do | |
252 | before do | |
253 | stub_delete("/projects/3/merge_requests/7/notes/1201", "note") | |
244 | it 'gets the correct resource' do | |
245 | expect(a_delete('/projects/3/snippets/7/notes/1201')).to have_been_made | |
246 | end | |
247 | ||
248 | it 'returns information about a deleted snippet note' do | |
249 | expect(@note.id).to eq(1201) | |
250 | end | |
251 | end | |
252 | ||
253 | context 'when merge request note' do | |
254 | before do | |
255 | stub_delete('/projects/3/merge_requests/7/notes/1201', 'note') | |
254 | 256 | @note = Gitlab.delete_merge_request_note(3, 7, 1201) |
255 | 257 | end |
256 | 258 | |
257 | it "gets the correct resource" do | |
258 | expect(a_delete("/projects/3/merge_requests/7/notes/1201")).to have_been_made | |
259 | end | |
260 | ||
261 | it "returns information about a deleted merge request note" do | |
262 | expect(@note.id).to eq(1201) | |
263 | end | |
264 | end | |
265 | end | |
266 | ||
267 | describe "modify note" do | |
268 | context "when wall note" do | |
269 | before do | |
270 | stub_put("/projects/3/notes/1201", "note") | |
271 | @note = Gitlab.edit_note(3, 1201, "edited wall note content") | |
272 | end | |
273 | ||
274 | it "gets the correct resource" do | |
275 | expect(a_put("/projects/3/notes/1201"). | |
276 | with(body: {body: 'edited wall note content'})).to have_been_made | |
277 | end | |
278 | ||
279 | it "returns information about a modified note" do | |
280 | expect(@note.id).to eq(1201) | |
281 | end | |
282 | end | |
283 | ||
284 | context "when issue note" do | |
285 | before do | |
286 | stub_put("/projects/3/issues/7/notes/1201", "note") | |
287 | @note = Gitlab.edit_issue_note(3, 7, 1201, "edited issue note content") | |
288 | end | |
289 | ||
290 | it "gets the correct resource" do | |
291 | expect(a_put("/projects/3/issues/7/notes/1201"). | |
292 | with(body: {body: 'edited issue note content'})).to have_been_made | |
293 | end | |
294 | ||
295 | it "returns information about a modified issue note" do | |
296 | expect(@note.id).to eq(1201) | |
297 | end | |
298 | end | |
299 | ||
300 | context "when snippet note" do | |
301 | before do | |
302 | stub_put("/projects/3/snippets/7/notes/1201", "note") | |
303 | @note = Gitlab.edit_snippet_note(3, 7, 1201, "edited snippet note content") | |
304 | end | |
305 | ||
306 | it "gets the correct resource" do | |
307 | expect(a_put("/projects/3/snippets/7/notes/1201"). | |
308 | with(body: {body: 'edited snippet note content'})).to have_been_made | |
309 | end | |
310 | ||
311 | it "returns information about a modified snippet note" do | |
312 | expect(@note.id).to eq(1201) | |
313 | end | |
314 | end | |
315 | ||
316 | context "when merge request note" do | |
317 | before do | |
318 | stub_put("/projects/3/merge_requests/7/notes/1201", "note") | |
319 | @note = Gitlab.edit_merge_request_note(3, 7, 1201, "edited merge request note content") | |
320 | end | |
321 | ||
322 | it "gets the correct resource" do | |
323 | expect(a_put("/projects/3/merge_requests/7/notes/1201"). | |
324 | with(body: {body: 'edited merge request note content'})).to have_been_made | |
325 | end | |
326 | ||
327 | it "returns information about a modified request note" do | |
259 | it 'gets the correct resource' do | |
260 | expect(a_delete('/projects/3/merge_requests/7/notes/1201')).to have_been_made | |
261 | end | |
262 | ||
263 | it 'returns information about a deleted merge request note' do | |
264 | expect(@note.id).to eq(1201) | |
265 | end | |
266 | end | |
267 | end | |
268 | ||
269 | describe 'modify note' do | |
270 | context 'when wall note' do | |
271 | before do | |
272 | stub_put('/projects/3/notes/1201', 'note') | |
273 | @note = Gitlab.edit_note(3, 1201, 'edited wall note content') | |
274 | end | |
275 | ||
276 | it 'gets the correct resource' do | |
277 | expect(a_put('/projects/3/notes/1201') | |
278 | .with(body: { body: 'edited wall note content' })).to have_been_made | |
279 | end | |
280 | ||
281 | it 'returns information about a modified note' do | |
282 | expect(@note.id).to eq(1201) | |
283 | end | |
284 | end | |
285 | ||
286 | context 'when issue note' do | |
287 | before do | |
288 | stub_put('/projects/3/issues/7/notes/1201', 'note') | |
289 | @note = Gitlab.edit_issue_note(3, 7, 1201, 'edited issue note content') | |
290 | end | |
291 | ||
292 | it 'gets the correct resource' do | |
293 | expect(a_put('/projects/3/issues/7/notes/1201') | |
294 | .with(body: { body: 'edited issue note content' })).to have_been_made | |
295 | end | |
296 | ||
297 | it 'returns information about a modified issue note' do | |
298 | expect(@note.id).to eq(1201) | |
299 | end | |
300 | end | |
301 | ||
302 | context 'when snippet note' do | |
303 | before do | |
304 | stub_put('/projects/3/snippets/7/notes/1201', 'note') | |
305 | @note = Gitlab.edit_snippet_note(3, 7, 1201, 'edited snippet note content') | |
306 | end | |
307 | ||
308 | it 'gets the correct resource' do | |
309 | expect(a_put('/projects/3/snippets/7/notes/1201') | |
310 | .with(body: { body: 'edited snippet note content' })).to have_been_made | |
311 | end | |
312 | ||
313 | it 'returns information about a modified snippet note' do | |
314 | expect(@note.id).to eq(1201) | |
315 | end | |
316 | end | |
317 | ||
318 | context 'when merge request note' do | |
319 | before do | |
320 | stub_put('/projects/3/merge_requests/7/notes/1201', 'note') | |
321 | @note = Gitlab.edit_merge_request_note(3, 7, 1201, 'edited merge request note content') | |
322 | end | |
323 | ||
324 | it 'gets the correct resource' do | |
325 | expect(a_put('/projects/3/merge_requests/7/notes/1201') | |
326 | .with(body: { body: 'edited merge request note content' })).to have_been_made | |
327 | end | |
328 | ||
329 | it 'returns information about a modified request note' do | |
328 | 330 | expect(@note.id).to eq(1201) |
329 | 331 | end |
330 | 332 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".pipeline_schedules" do | |
5 | describe '.pipeline_schedules' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/pipeline_schedules", "pipeline_schedules") | |
7 | stub_get('/projects/3/pipeline_schedules', 'pipeline_schedules') | |
6 | 8 | @pipeline_schedules = Gitlab.pipeline_schedules(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/pipeline_schedules")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/pipeline_schedules')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a response of project's pipeline schedules" do |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".pipeline_schedule" do | |
20 | describe '.pipeline_schedule' do | |
19 | 21 | before do |
20 | stub_get("/projects/3/pipeline_schedules/5", "pipeline_schedule") | |
22 | stub_get('/projects/3/pipeline_schedules/5', 'pipeline_schedule') | |
21 | 23 | @pipeline_schedule = Gitlab.pipeline_schedule(3, 5) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/projects/3/pipeline_schedules/5")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/3/pipeline_schedules/5')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | 30 | it "returns a response of project's pipeline schedules" do |
30 | 32 | end |
31 | 33 | end |
32 | 34 | |
33 | describe ".create_pipeline_schedule" do | |
35 | describe '.create_pipeline_schedule' do | |
34 | 36 | before do |
35 | stub_post("/projects/3/pipeline_schedules", "pipeline_schedule_create") | |
37 | stub_post('/projects/3/pipeline_schedules', 'pipeline_schedule_create') | |
36 | 38 | @pipeline_schedule_create = Gitlab.create_pipeline_schedule(3) |
37 | 39 | end |
38 | 40 | |
39 | it "gets the correct resource" do | |
40 | expect(a_post("/projects/3/pipeline_schedules")).to have_been_made | |
41 | it 'gets the correct resource' do | |
42 | expect(a_post('/projects/3/pipeline_schedules')).to have_been_made | |
41 | 43 | end |
42 | 44 | |
43 | it "returns a single pipeline schedule" do | |
45 | it 'returns a single pipeline schedule' do | |
44 | 46 | expect(@pipeline_schedule_create).to be_a Gitlab::ObjectifiedHash |
45 | 47 | end |
46 | 48 | |
47 | it "returns information about a pipeline schedule" do | |
48 | expect(@pipeline_schedule_create.owner.name).to eq("Administrator") | |
49 | it 'returns information about a pipeline schedule' do | |
50 | expect(@pipeline_schedule_create.owner.name).to eq('Administrator') | |
49 | 51 | end |
50 | 52 | end |
51 | 53 | |
52 | describe ".edit_pipeline_schedule" do | |
54 | describe '.edit_pipeline_schedule' do | |
53 | 55 | before do |
54 | stub_put("/projects/3/pipeline_schedules/13", "pipeline_schedule_update") | |
56 | stub_put('/projects/3/pipeline_schedules/13', 'pipeline_schedule_update') | |
55 | 57 | @pipeline_schedule_update = Gitlab.edit_pipeline_schedule(3, 13) |
56 | 58 | end |
57 | 59 | |
58 | it "gets the correct resource" do | |
59 | expect(a_put("/projects/3/pipeline_schedules/13")).to have_been_made | |
60 | it 'gets the correct resource' do | |
61 | expect(a_put('/projects/3/pipeline_schedules/13')).to have_been_made | |
60 | 62 | end |
61 | 63 | |
62 | it "returns a single pipeline schedule" do | |
64 | it 'returns a single pipeline schedule' do | |
63 | 65 | expect(@pipeline_schedule_update).to be_a Gitlab::ObjectifiedHash |
64 | 66 | end |
65 | 67 | |
66 | it "returns information about a pipeline schedule" do | |
67 | expect(@pipeline_schedule_update.owner.name).to eq("Administrator") | |
68 | it 'returns information about a pipeline schedule' do | |
69 | expect(@pipeline_schedule_update.owner.name).to eq('Administrator') | |
68 | 70 | end |
69 | 71 | end |
70 | 72 | |
71 | describe ".pipeline_schedule_take_ownership" do | |
73 | describe '.pipeline_schedule_take_ownership' do | |
72 | 74 | before do |
73 | stub_post("/projects/3/pipeline_schedules/13/take_ownership", "pipeline_schedule") | |
75 | stub_post('/projects/3/pipeline_schedules/13/take_ownership', 'pipeline_schedule') | |
74 | 76 | @pipeline_schedule = Gitlab.pipeline_schedule_take_ownership(3, 13) |
75 | 77 | end |
76 | 78 | |
77 | it "gets the correct resource" do | |
78 | expect(a_post("/projects/3/pipeline_schedules/13/take_ownership")).to have_been_made | |
79 | it 'gets the correct resource' do | |
80 | expect(a_post('/projects/3/pipeline_schedules/13/take_ownership')).to have_been_made | |
79 | 81 | end |
80 | 82 | |
81 | it "returns information about the pipeline schedule" do | |
82 | expect(@pipeline_schedule.created_at).to eq("2017-05-19T13:31:08.849Z") | |
83 | expect(@pipeline_schedule.description).to eq("Test schedule pipeline") | |
83 | it 'returns information about the pipeline schedule' do | |
84 | expect(@pipeline_schedule.created_at).to eq('2017-05-19T13:31:08.849Z') | |
85 | expect(@pipeline_schedule.description).to eq('Test schedule pipeline') | |
84 | 86 | end |
85 | 87 | end |
86 | 88 | |
87 | describe ".delete_pipeline_schedule" do | |
89 | describe '.delete_pipeline_schedule' do | |
88 | 90 | before do |
89 | stub_delete("/projects/3/pipeline_schedules/13", "pipeline_schedule") | |
90 | @pipeline_schedule = Gitlab.delete_pipeline_schedule(3,13) | |
91 | stub_delete('/projects/3/pipeline_schedules/13', 'pipeline_schedule') | |
92 | @pipeline_schedule = Gitlab.delete_pipeline_schedule(3, 13) | |
91 | 93 | end |
92 | 94 | |
93 | it "gets the correct resource" do | |
94 | expect(a_delete("/projects/3/pipeline_schedules/13")).to have_been_made | |
95 | it 'gets the correct resource' do | |
96 | expect(a_delete('/projects/3/pipeline_schedules/13')).to have_been_made | |
95 | 97 | end |
96 | 98 | |
97 | it "returns a single pipeline" do | |
99 | it 'returns a single pipeline' do | |
98 | 100 | expect(@pipeline_schedule).to be_a Gitlab::ObjectifiedHash |
99 | 101 | end |
100 | 102 | |
101 | it "returns information about the deleted pipeline" do | |
103 | it 'returns information about the deleted pipeline' do | |
102 | 104 | # expect(@pipeline_schedule.id).to eq(13) |
103 | 105 | end |
104 | 106 | end |
105 | 107 | |
106 | describe ".create_pipeline_schedule_variable" do | |
108 | describe '.create_pipeline_schedule_variable' do | |
107 | 109 | before do |
108 | stub_post("/projects/3/pipeline_schedules/13/variables?key=NEW%20VARIABLE&value=new%20value", "pipeline_schedule_variable") | |
109 | @pipeline_schedule_variable = Gitlab.create_pipeline_schedule_variable(3, 13, { | |
110 | key: "NEW VARIABLE", | |
111 | value: "new value" | |
112 | }) | |
110 | stub_post('/projects/3/pipeline_schedules/13/variables?key=NEW%20VARIABLE&value=new%20value', 'pipeline_schedule_variable') | |
111 | @pipeline_schedule_variable = Gitlab.create_pipeline_schedule_variable(3, 13, | |
112 | key: 'NEW VARIABLE', | |
113 | value: 'new value') | |
113 | 114 | end |
114 | 115 | |
115 | it "gets the correct resource" do | |
116 | expect(a_post("/projects/3/pipeline_schedules/13/variables?key=NEW%20VARIABLE&value=new%20value")).to have_been_made | |
116 | it 'gets the correct resource' do | |
117 | expect(a_post('/projects/3/pipeline_schedules/13/variables?key=NEW%20VARIABLE&value=new%20value')).to have_been_made | |
117 | 118 | end |
118 | 119 | |
119 | it "returns a single variable" do | |
120 | it 'returns a single variable' do | |
120 | 121 | expect(@pipeline_schedule_variable).to be_a Gitlab::ObjectifiedHash |
121 | 122 | end |
122 | 123 | |
123 | it "returns the created variable" do | |
124 | expect(@pipeline_schedule_variable.value).to eq("new value") | |
124 | it 'returns the created variable' do | |
125 | expect(@pipeline_schedule_variable.value).to eq('new value') | |
125 | 126 | end |
126 | 127 | end |
127 | 128 | |
128 | describe ".edit_pipeline_schedule_variable" do | |
129 | describe '.edit_pipeline_schedule_variable' do | |
129 | 130 | before do |
130 | stub_put("/projects/3/pipeline_schedules/13/variables/NEW%20VARIABLE?value=update%20value", "pipeline_schedule_variable_update") | |
131 | @pipeline_schedule_variable = Gitlab.edit_pipeline_schedule_variable(3, 13, "NEW VARIABLE", { value: "update value" }) | |
131 | stub_put('/projects/3/pipeline_schedules/13/variables/NEW%20VARIABLE?value=update%20value', 'pipeline_schedule_variable_update') | |
132 | @pipeline_schedule_variable = Gitlab.edit_pipeline_schedule_variable(3, 13, 'NEW VARIABLE', value: 'update value') | |
132 | 133 | end |
133 | 134 | |
134 | it "returns a single variable" do | |
135 | it 'returns a single variable' do | |
135 | 136 | expect(@pipeline_schedule_variable).to be_a Gitlab::ObjectifiedHash |
136 | 137 | end |
137 | 138 | |
138 | it "has the updated value" do | |
139 | expect(@pipeline_schedule_variable.value).to eq("update value") | |
139 | it 'has the updated value' do | |
140 | expect(@pipeline_schedule_variable.value).to eq('update value') | |
140 | 141 | end |
141 | 142 | end |
142 | 143 | |
143 | describe ".delete_pipeline_schedule_variable" do | |
144 | describe '.delete_pipeline_schedule_variable' do | |
144 | 145 | before do |
145 | stub_delete("/projects/3/pipeline_schedules/13/variables/NEW%20VARIABLE", "pipeline_schedule_variable") | |
146 | @pipeline_schedule_variable = Gitlab.delete_pipeline_schedule_variable(3, 13, "NEW VARIABLE") | |
146 | stub_delete('/projects/3/pipeline_schedules/13/variables/NEW%20VARIABLE', 'pipeline_schedule_variable') | |
147 | @pipeline_schedule_variable = Gitlab.delete_pipeline_schedule_variable(3, 13, 'NEW VARIABLE') | |
147 | 148 | end |
148 | 149 | |
149 | it "returns a single variable" do | |
150 | it 'returns a single variable' do | |
150 | 151 | expect(@pipeline_schedule_variable).to be_a Gitlab::ObjectifiedHash |
151 | 152 | end |
152 | 153 | |
153 | it "has the value of the deleted variable" do | |
154 | expect(@pipeline_schedule_variable.value).to eq("new value") | |
154 | it 'has the value of the deleted variable' do | |
155 | expect(@pipeline_schedule_variable.value).to eq('new value') | |
155 | 156 | end |
156 | 157 | end |
157 | 158 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | 5 | it { is_expected.to respond_to :delete_trigger } |
4 | 6 | |
5 | describe ".triggers" do | |
7 | describe '.triggers' do | |
6 | 8 | before do |
7 | stub_get("/projects/3/triggers", "triggers") | |
9 | stub_get('/projects/3/triggers', 'triggers') | |
8 | 10 | @triggers = Gitlab.triggers(3) |
9 | 11 | end |
10 | 12 | |
11 | it "gets the correct resource" do | |
12 | expect(a_get("/projects/3/triggers")).to have_been_made | |
13 | it 'gets the correct resource' do | |
14 | expect(a_get('/projects/3/triggers')).to have_been_made | |
13 | 15 | end |
14 | 16 | |
15 | 17 | it "returns an array of project's triggers" do |
16 | 18 | expect(@triggers).to be_a Gitlab::PaginatedResponse |
17 | expect(@triggers.first.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7") | |
19 | expect(@triggers.first.token).to eq('6d056f63e50fe6f8c5f8f4aa10edb7') | |
18 | 20 | end |
19 | 21 | end |
20 | 22 | |
21 | describe ".trigger" do | |
23 | describe '.trigger' do | |
22 | 24 | before do |
23 | stub_get("/projects/3/triggers/10", "trigger") | |
25 | stub_get('/projects/3/triggers/10', 'trigger') | |
24 | 26 | @trigger = Gitlab.trigger(3, 10) |
25 | 27 | end |
26 | 28 | |
27 | it "gets the correct resource" do | |
28 | expect(a_get("/projects/3/triggers/10")).to have_been_made | |
29 | it 'gets the correct resource' do | |
30 | expect(a_get('/projects/3/triggers/10')).to have_been_made | |
29 | 31 | end |
30 | 32 | |
31 | it "returns information about a trigger" do | |
32 | expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z") | |
33 | expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7") | |
33 | it 'returns information about a trigger' do | |
34 | expect(@trigger.created_at).to eq('2016-01-07T09:53:58.235Z') | |
35 | expect(@trigger.token).to eq('6d056f63e50fe6f8c5f8f4aa10edb7') | |
34 | 36 | end |
35 | 37 | end |
36 | 38 | |
37 | describe ".create_trigger" do | |
39 | describe '.create_trigger' do | |
38 | 40 | before do |
39 | stub_post("/projects/3/triggers", "trigger") | |
40 | @trigger = Gitlab.create_trigger(3, "my description") | |
41 | stub_post('/projects/3/triggers', 'trigger') | |
42 | @trigger = Gitlab.create_trigger(3, 'my description') | |
41 | 43 | end |
42 | 44 | |
43 | it "gets the correct resource" do | |
44 | expect(a_post("/projects/3/triggers"). | |
45 | with(body: { description: "my description" })).to have_been_made | |
45 | it 'gets the correct resource' do | |
46 | expect(a_post('/projects/3/triggers') | |
47 | .with(body: { description: 'my description' })).to have_been_made | |
46 | 48 | end |
47 | 49 | |
48 | it "returns information about a new trigger" do | |
49 | expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z") | |
50 | expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7") | |
50 | it 'returns information about a new trigger' do | |
51 | expect(@trigger.created_at).to eq('2016-01-07T09:53:58.235Z') | |
52 | expect(@trigger.token).to eq('6d056f63e50fe6f8c5f8f4aa10edb7') | |
51 | 53 | end |
52 | 54 | end |
53 | 55 | |
54 | describe ".update_trigger" do | |
56 | describe '.update_trigger' do | |
55 | 57 | before do |
56 | stub_put("/projects/3/triggers/1", "trigger") | |
57 | @trigger = Gitlab.update_trigger(3, 1, description: "my description") | |
58 | stub_put('/projects/3/triggers/1', 'trigger') | |
59 | @trigger = Gitlab.update_trigger(3, 1, description: 'my description') | |
58 | 60 | end |
59 | 61 | |
60 | it "gets the correct resource" do | |
61 | expect(a_put("/projects/3/triggers/1"). | |
62 | with(body: { description: "my description" })).to have_been_made | |
62 | it 'gets the correct resource' do | |
63 | expect(a_put('/projects/3/triggers/1') | |
64 | .with(body: { description: 'my description' })).to have_been_made | |
63 | 65 | end |
64 | 66 | |
65 | it "returns information about the trigger" do | |
66 | expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z") | |
67 | expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7") | |
67 | it 'returns information about the trigger' do | |
68 | expect(@trigger.created_at).to eq('2016-01-07T09:53:58.235Z') | |
69 | expect(@trigger.token).to eq('6d056f63e50fe6f8c5f8f4aa10edb7') | |
68 | 70 | end |
69 | 71 | end |
70 | 72 | |
71 | describe ".trigger_take_ownership" do | |
73 | describe '.trigger_take_ownership' do | |
72 | 74 | before do |
73 | stub_post("/projects/3/triggers/1/take_ownership", "trigger") | |
75 | stub_post('/projects/3/triggers/1/take_ownership', 'trigger') | |
74 | 76 | @trigger = Gitlab.trigger_take_ownership(3, 1) |
75 | 77 | end |
76 | 78 | |
77 | it "gets the correct resource" do | |
78 | expect(a_post("/projects/3/triggers/1/take_ownership")).to have_been_made | |
79 | it 'gets the correct resource' do | |
80 | expect(a_post('/projects/3/triggers/1/take_ownership')).to have_been_made | |
79 | 81 | end |
80 | 82 | |
81 | it "returns information about the trigger" do | |
82 | expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z") | |
83 | expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7") | |
83 | it 'returns information about the trigger' do | |
84 | expect(@trigger.created_at).to eq('2016-01-07T09:53:58.235Z') | |
85 | expect(@trigger.token).to eq('6d056f63e50fe6f8c5f8f4aa10edb7') | |
84 | 86 | end |
85 | 87 | end |
86 | 88 | |
87 | describe ".remove_trigger" do | |
89 | describe '.remove_trigger' do | |
88 | 90 | before do |
89 | stub_delete("/projects/3/triggers/10", "empty") | |
91 | stub_delete('/projects/3/triggers/10', 'empty') | |
90 | 92 | @trigger = Gitlab.remove_trigger(3, 10) |
91 | 93 | end |
92 | 94 | |
93 | it "gets the correct resource" do | |
94 | expect(a_delete("/projects/3/triggers/10")).to have_been_made | |
95 | it 'gets the correct resource' do | |
96 | expect(a_delete('/projects/3/triggers/10')).to have_been_made | |
95 | 97 | end |
96 | 98 | end |
97 | 99 | |
98 | describe ".run_trigger" do | |
100 | describe '.run_trigger' do | |
99 | 101 | before do |
100 | stub_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline"). | |
101 | to_return(body: load_fixture("run_trigger"), status: 200) | |
102 | stub_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline") | |
103 | .to_return(body: load_fixture('run_trigger'), status: 200) | |
102 | 104 | end |
103 | 105 | |
104 | context "when private_token is not set" do | |
106 | context 'when private_token is not set' do | |
105 | 107 | before do |
106 | 108 | Gitlab.private_token = nil |
107 | 109 | end |
108 | 110 | |
109 | it "does not raise Error::MissingCredentials" do | |
110 | expect { Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master", {a: 10}) }.to_not raise_error | |
111 | it 'does not raise Error::MissingCredentials' do | |
112 | expect { Gitlab.run_trigger(3, '7b9148c158980bbd9bcea92c17522d', 'master', a: 10) }.not_to raise_error | |
111 | 113 | end |
112 | 114 | |
113 | 115 | after do |
115 | 117 | end |
116 | 118 | end |
117 | 119 | |
118 | context "without variables" do | |
120 | context 'without variables' do | |
119 | 121 | before do |
120 | @trigger = Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master") | |
122 | @trigger = Gitlab.run_trigger(3, '7b9148c158980bbd9bcea92c17522d', 'master') | |
121 | 123 | end |
122 | 124 | |
123 | it "gets the correct resource" do | |
124 | expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline"). | |
125 | with(body: { | |
126 | token: "7b9148c158980bbd9bcea92c17522d", | |
127 | ref: "master" | |
128 | })).to have_been_made | |
125 | it 'gets the correct resource' do | |
126 | expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline") | |
127 | .with(body: { | |
128 | token: '7b9148c158980bbd9bcea92c17522d', | |
129 | ref: 'master' | |
130 | })).to have_been_made | |
129 | 131 | end |
130 | 132 | |
131 | it "returns information about the triggered build" do | |
133 | it 'returns information about the triggered build' do | |
132 | 134 | expect(@trigger.id).to eq(8) |
133 | 135 | end |
134 | 136 | end |
135 | 137 | |
136 | context "with variables" do | |
138 | context 'with variables' do | |
137 | 139 | before do |
138 | @trigger = Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master", {a: 10}) | |
140 | @trigger = Gitlab.run_trigger(3, '7b9148c158980bbd9bcea92c17522d', 'master', a: 10) | |
139 | 141 | end |
140 | 142 | |
141 | it "gets the correct resource" do | |
142 | expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline"). | |
143 | with(body: { | |
144 | token: "7b9148c158980bbd9bcea92c17522d", | |
145 | ref: "master", | |
146 | variables: {a: "10"} | |
147 | })).to have_been_made | |
143 | it 'gets the correct resource' do | |
144 | expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline") | |
145 | .with(body: { | |
146 | token: '7b9148c158980bbd9bcea92c17522d', | |
147 | ref: 'master', | |
148 | variables: { a: '10' } | |
149 | })).to have_been_made | |
148 | 150 | end |
149 | 151 | |
150 | it "returns information about the triggered build" do | |
152 | it 'returns information about the triggered build' do | |
151 | 153 | expect(@trigger.id).to eq(8) |
152 | expect(@trigger.variables.a).to eq("10") | |
154 | expect(@trigger.variables.a).to eq('10') | |
153 | 155 | end |
154 | 156 | end |
155 | 157 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".pipelines" do | |
5 | describe '.pipelines' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/pipelines", "pipelines") | |
7 | stub_get('/projects/3/pipelines', 'pipelines') | |
6 | 8 | @pipelines = Gitlab.pipelines(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/pipelines")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/pipelines')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of project's pipelines" do |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".pipeline" do | |
20 | describe '.pipeline' do | |
19 | 21 | before do |
20 | stub_get("/projects/3/pipelines/46", "pipeline") | |
22 | stub_get('/projects/3/pipelines/46', 'pipeline') | |
21 | 23 | @pipeline = Gitlab.pipeline(3, 46) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/projects/3/pipelines/46")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/3/pipelines/46')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | it "returns a single pipeline" do | |
30 | it 'returns a single pipeline' do | |
29 | 31 | expect(@pipeline).to be_a Gitlab::ObjectifiedHash |
30 | 32 | end |
31 | 33 | |
32 | it "returns information about a pipeline" do | |
34 | it 'returns information about a pipeline' do | |
33 | 35 | expect(@pipeline.id).to eq(46) |
34 | expect(@pipeline.user.name).to eq("Administrator") | |
36 | expect(@pipeline.user.name).to eq('Administrator') | |
35 | 37 | end |
36 | 38 | end |
37 | 39 | |
38 | describe ".create_pipeline" do | |
40 | describe '.create_pipeline' do | |
41 | let(:pipeline_path) { '/projects/3/pipeline?ref=master' } | |
42 | ||
39 | 43 | before do |
40 | stub_post("/projects/3/pipeline?ref=master", "pipeline_create") | |
44 | stub_post(pipeline_path, 'pipeline_create') | |
41 | 45 | @pipeline_create = Gitlab.create_pipeline(3, 'master') |
42 | 46 | end |
43 | 47 | |
44 | it "gets the correct resource" do | |
45 | expect(a_post("/projects/3/pipeline?ref=master")).to have_been_made | |
48 | it 'gets the correct resource' do | |
49 | expect(a_post(pipeline_path)).to have_been_made | |
46 | 50 | end |
47 | 51 | |
48 | it "returns a single pipeline" do | |
52 | it 'returns a single pipeline' do | |
49 | 53 | expect(@pipeline_create).to be_a Gitlab::ObjectifiedHash |
50 | 54 | end |
51 | 55 | |
52 | it "returns information about a pipeline" do | |
53 | expect(@pipeline_create.user.name).to eq("Administrator") | |
56 | it 'returns information about a pipeline' do | |
57 | expect(@pipeline_create.user.name).to eq('Administrator') | |
58 | end | |
59 | ||
60 | context 'when variables are passed' do | |
61 | before do | |
62 | stub_post(pipeline_path, 'pipeline_create') | |
63 | variables = { 'VAR1' => 'value', VAR2: :value } | |
64 | @pipeline_create = Gitlab.create_pipeline(3, 'master', variables) | |
65 | end | |
66 | ||
67 | it 'calls with the correct body' do | |
68 | expected_body = 'variables[][key]=VAR1&variables[][value]=value&variables[][key]=VAR2&variables[][value]=value' | |
69 | expect(a_post(pipeline_path).with(body: expected_body)).to have_been_made | |
70 | end | |
54 | 71 | end |
55 | 72 | end |
56 | 73 | |
57 | describe ".cancel_pipeline" do | |
74 | describe '.cancel_pipeline' do | |
58 | 75 | before do |
59 | stub_post("/projects/3/pipelines/46/cancel", "pipeline_cancel") | |
76 | stub_post('/projects/3/pipelines/46/cancel', 'pipeline_cancel') | |
60 | 77 | @pipeline_cancel = Gitlab.cancel_pipeline(3, 46) |
61 | 78 | end |
62 | 79 | |
63 | it "gets the correct resource" do | |
64 | expect(a_post("/projects/3/pipelines/46/cancel")).to have_been_made | |
80 | it 'gets the correct resource' do | |
81 | expect(a_post('/projects/3/pipelines/46/cancel')).to have_been_made | |
65 | 82 | end |
66 | 83 | |
67 | it "returns a single pipeline" do | |
84 | it 'returns a single pipeline' do | |
68 | 85 | expect(@pipeline_cancel).to be_a Gitlab::ObjectifiedHash |
69 | 86 | end |
70 | 87 | |
71 | it "returns information about a pipeline" do | |
72 | expect(@pipeline_cancel.user.name).to eq("Administrator") | |
88 | it 'returns information about a pipeline' do | |
89 | expect(@pipeline_cancel.user.name).to eq('Administrator') | |
73 | 90 | end |
74 | 91 | end |
75 | 92 | |
76 | describe ".retry_pipeline" do | |
93 | describe '.retry_pipeline' do | |
77 | 94 | before do |
78 | stub_post("/projects/3/pipelines/46/retry", "pipeline_retry") | |
95 | stub_post('/projects/3/pipelines/46/retry', 'pipeline_retry') | |
79 | 96 | @pipeline_retry = Gitlab.retry_pipeline(3, 46) |
80 | 97 | end |
81 | 98 | |
82 | it "gets the correct resource" do | |
83 | expect(a_post("/projects/3/pipelines/46/retry")).to have_been_made | |
99 | it 'gets the correct resource' do | |
100 | expect(a_post('/projects/3/pipelines/46/retry')).to have_been_made | |
84 | 101 | end |
85 | 102 | |
86 | it "returns a single pipeline" do | |
103 | it 'returns a single pipeline' do | |
87 | 104 | expect(@pipeline_retry).to be_a Gitlab::ObjectifiedHash |
88 | 105 | end |
89 | 106 | |
90 | it "returns information about a pipeline" do | |
91 | expect(@pipeline_retry.user.name).to eq("Administrator") | |
107 | it 'returns information about a pipeline' do | |
108 | expect(@pipeline_retry.user.name).to eq('Administrator') | |
92 | 109 | end |
93 | 110 | end |
94 | 111 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | # rubocop:disable Style/FormatStringToken | |
3 | ||
4 | require 'spec_helper' | |
5 | ||
6 | describe Gitlab::Client do | |
7 | describe '.project_badges' do | |
8 | before do | |
9 | stub_get('/projects/3/badges', 'project_badges') | |
10 | @project_badges = Gitlab.project_badges(3) | |
11 | end | |
12 | ||
13 | it 'gets the correct resource' do | |
14 | expect(a_get('/projects/3/badges')).to have_been_made | |
15 | end | |
16 | ||
17 | it "returns a paginated response of project's badges" do | |
18 | expect(@project_badges).to be_a Gitlab::PaginatedResponse | |
19 | end | |
20 | end | |
21 | ||
22 | describe '.project_badge' do | |
23 | before do | |
24 | stub_get('/projects/3/badges/3', 'project_badge') | |
25 | @project_badge = Gitlab.project_badge(3, 3) | |
26 | end | |
27 | ||
28 | it 'gets the correct resource' do | |
29 | expect(a_get('/projects/3/badges/3')).to have_been_made | |
30 | end | |
31 | ||
32 | it 'returns information about a badge' do | |
33 | expect(@project_badge.id).to eq(1) | |
34 | end | |
35 | end | |
36 | ||
37 | describe '.add_project_badge' do | |
38 | before do | |
39 | stub_post('/projects/3/badges', 'project_badge') | |
40 | @project_badge = Gitlab.add_project_badge(3, link_url: 'http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}', image_url: 'https://shields.io/my/badge') | |
41 | end | |
42 | ||
43 | it 'gets the correct resource' do | |
44 | expect(a_post('/projects/3/badges') | |
45 | .with(body: { link_url: 'http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}', image_url: 'https://shields.io/my/badge' })).to have_been_made | |
46 | end | |
47 | ||
48 | it 'returns information about an added project badge' do | |
49 | expect(@project_badge.link_url).to eq('http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}') | |
50 | expect(@project_badge.image_url).to eq('https://shields.io/my/badge') | |
51 | end | |
52 | end | |
53 | ||
54 | describe '.edit_project_badge' do | |
55 | before do | |
56 | stub_put('/projects/3/badges/1', 'project_badge') | |
57 | @project_badge = Gitlab.edit_project_badge(3, 1, link_url: 'http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}', image_url: 'https://shields.io/my/badge') | |
58 | end | |
59 | ||
60 | it 'gets the correct resource' do | |
61 | expect(a_put('/projects/3/badges/1') | |
62 | .with(body: { link_url: 'http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}', image_url: 'https://shields.io/my/badge' })).to have_been_made | |
63 | end | |
64 | ||
65 | it 'returns information about an edited project badge' do | |
66 | expect(@project_badge.link_url).to eq('http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}') | |
67 | expect(@project_badge.image_url).to eq('https://shields.io/my/badge') | |
68 | end | |
69 | end | |
70 | ||
71 | describe '.remove_project_badge' do | |
72 | before do | |
73 | stub_delete('/projects/3/badges/3', 'empty') | |
74 | @project_badge = Gitlab.remove_project_badge(3, 3) | |
75 | end | |
76 | ||
77 | it 'gets the correct resource' do | |
78 | expect(a_delete('/projects/3/badges/3')).to have_been_made | |
79 | end | |
80 | end | |
81 | ||
82 | describe '.preview_project_badge' do | |
83 | before do | |
84 | stub_get('/projects/3/badges/render?image_url=https://shields.io/my/badge&link_url=http://example.com/ci_status.svg?project=%25%7Bproject_path%7D%26ref=%25%7Bdefault_branch%7D', 'preview_project_badge') | |
85 | @preview_project_badge = Gitlab.preview_project_badge(3, 'http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}', 'https://shields.io/my/badge') | |
86 | end | |
87 | ||
88 | it 'gets the correct resource' do | |
89 | expect(a_get('/projects/3/badges/render?image_url=https://shields.io/my/badge&link_url=http://example.com/ci_status.svg?project=%25%7Bproject_path%7D%26ref=%25%7Bdefault_branch%7D')).to have_been_made | |
90 | end | |
91 | ||
92 | it 'returns information about the rendered values of a badge' do | |
93 | expect(@preview_project_badge.link_url).to eq('http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}') | |
94 | expect(@preview_project_badge.image_url).to eq('https://shields.io/my/badge') | |
95 | end | |
96 | end | |
97 | end | |
98 | # rubocop:enable Style/FormatStringToken |
0 | # frozen_string_literal: true | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe Gitlab::Client do | |
5 | describe '.project_templates' do | |
6 | before do | |
7 | stub_get('/projects/3/templates/licenses', 'project_templates') | |
8 | @project_templates = Gitlab.project_templates(3, 'licenses') | |
9 | end | |
10 | ||
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/templates/licenses')).to have_been_made | |
13 | end | |
14 | ||
15 | it "returns a paginated response of project's templates" do | |
16 | expect(@project_templates).to be_a Gitlab::PaginatedResponse | |
17 | end | |
18 | end | |
19 | ||
20 | describe '.project_template' do | |
21 | context 'when dockerfiles' do | |
22 | before do | |
23 | stub_get('/projects/3/templates/dockerfiles/dock', 'dockerfile_project_template') | |
24 | @project_template = Gitlab.project_template(3, 'dockerfiles', 'dock') | |
25 | end | |
26 | ||
27 | it 'gets the correct resource' do | |
28 | expect(a_get('/projects/3/templates/dockerfiles/dock')).to have_been_made | |
29 | end | |
30 | end | |
31 | ||
32 | context 'when licenses' do | |
33 | before do | |
34 | stub_get('/projects/3/templates/licenses/mit', 'license_project_template') | |
35 | @project_template = Gitlab.project_template(3, 'licenses', 'mit') | |
36 | end | |
37 | ||
38 | it 'gets the correct resource' do | |
39 | expect(a_get('/projects/3/templates/licenses/mit')).to have_been_made | |
40 | end | |
41 | end | |
42 | end | |
43 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | 5 | it { is_expected.to respond_to :search_projects } |
4 | 6 | |
5 | describe ".projects" do | |
6 | before do | |
7 | stub_get("/projects", "projects") | |
7 | describe '.projects' do | |
8 | before do | |
9 | stub_get('/projects', 'projects') | |
8 | 10 | @projects = Gitlab.projects |
9 | 11 | end |
10 | 12 | |
11 | it "gets the correct resource" do | |
12 | expect(a_get("/projects")).to have_been_made | |
13 | end | |
14 | ||
15 | it "returns a paginated response of projects" do | |
13 | it 'gets the correct resource' do | |
14 | expect(a_get('/projects')).to have_been_made | |
15 | end | |
16 | ||
17 | it 'returns a paginated response of projects' do | |
16 | 18 | expect(@projects).to be_a Gitlab::PaginatedResponse |
17 | expect(@projects.first.name).to eq("Brute") | |
18 | expect(@projects.first.owner.name).to eq("John Smith") | |
19 | end | |
20 | end | |
21 | ||
22 | describe ".project_search" do | |
23 | before do | |
24 | stub_get("/projects?search=Gitlab", "project_search") | |
25 | @project_search = Gitlab.project_search("Gitlab") | |
26 | end | |
27 | ||
28 | it "gets the correct resource" do | |
29 | expect(a_get("/projects?search=Gitlab")).to have_been_made | |
30 | end | |
31 | ||
32 | it "returns a paginated response of projects found" do | |
19 | expect(@projects.first.name).to eq('Brute') | |
20 | expect(@projects.first.owner.name).to eq('John Smith') | |
21 | end | |
22 | end | |
23 | ||
24 | describe '.project_search' do | |
25 | before do | |
26 | stub_get('/projects?search=Gitlab', 'project_search') | |
27 | @project_search = Gitlab.project_search('Gitlab') | |
28 | end | |
29 | ||
30 | it 'gets the correct resource' do | |
31 | expect(a_get('/projects?search=Gitlab')).to have_been_made | |
32 | end | |
33 | ||
34 | it 'returns a paginated response of projects found' do | |
33 | 35 | expect(@project_search).to be_a Gitlab::PaginatedResponse |
34 | expect(@project_search.first.name).to eq("Gitlab") | |
35 | expect(@project_search.first.owner.name).to eq("John Smith") | |
36 | end | |
37 | end | |
38 | ||
39 | describe ".project" do | |
40 | before do | |
41 | stub_get("/projects/3", "project") | |
36 | expect(@project_search.first.name).to eq('Gitlab') | |
37 | expect(@project_search.first.owner.name).to eq('John Smith') | |
38 | end | |
39 | end | |
40 | ||
41 | describe '.project' do | |
42 | before do | |
43 | stub_get('/projects/3', 'project') | |
42 | 44 | @project = Gitlab.project(3) |
43 | 45 | end |
44 | 46 | |
45 | it "gets the correct resource" do | |
46 | expect(a_get("/projects/3")).to have_been_made | |
47 | end | |
48 | ||
49 | it "returns information about a project" do | |
50 | expect(@project.name).to eq("Gitlab") | |
51 | expect(@project.owner.name).to eq("John Smith") | |
52 | end | |
53 | end | |
54 | ||
55 | describe ".create_project" do | |
56 | before do | |
57 | stub_post("/projects", "project") | |
47 | it 'gets the correct resource' do | |
48 | expect(a_get('/projects/3')).to have_been_made | |
49 | end | |
50 | ||
51 | it 'returns information about a project' do | |
52 | expect(@project.name).to eq('Gitlab') | |
53 | expect(@project.owner.name).to eq('John Smith') | |
54 | end | |
55 | end | |
56 | ||
57 | describe '.create_project' do | |
58 | before do | |
59 | stub_post('/projects', 'project') | |
58 | 60 | @project = Gitlab.create_project('Gitlab') |
59 | 61 | end |
60 | 62 | |
61 | it "gets the correct resource" do | |
62 | expect(a_post("/projects")).to have_been_made | |
63 | end | |
64 | ||
65 | it "returns information about a created project" do | |
66 | expect(@project.name).to eq("Gitlab") | |
67 | expect(@project.owner.name).to eq("John Smith") | |
68 | end | |
69 | end | |
70 | ||
71 | describe ".create_project for user" do | |
72 | before do | |
73 | stub_post("/users", "user") | |
74 | @owner = Gitlab.create_user("john@example.com", "pass", name: 'John Owner') | |
75 | stub_post("/projects/user/#{@owner.id}", "project_for_user") | |
63 | it 'gets the correct resource' do | |
64 | expect(a_post('/projects')).to have_been_made | |
65 | end | |
66 | ||
67 | it 'returns information about a created project' do | |
68 | expect(@project.name).to eq('Gitlab') | |
69 | expect(@project.owner.name).to eq('John Smith') | |
70 | end | |
71 | end | |
72 | ||
73 | describe '.create_project for user' do | |
74 | before do | |
75 | stub_post('/users', 'user') | |
76 | @owner = Gitlab.create_user('john@example.com', 'pass', name: 'John Owner') | |
77 | stub_post("/projects/user/#{@owner.id}", 'project_for_user') | |
76 | 78 | @project = Gitlab.create_project('Brute', user_id: @owner.id) |
77 | 79 | end |
78 | 80 | |
79 | it "returns information about a created project" do | |
80 | expect(@project.name).to eq("Brute") | |
81 | expect(@project.owner.name).to eq("John Owner") | |
82 | end | |
83 | end | |
84 | ||
85 | describe ".delete_project" do | |
86 | before do | |
87 | stub_delete("/projects/Gitlab", "project") | |
81 | it 'returns information about a created project' do | |
82 | expect(@project.name).to eq('Brute') | |
83 | expect(@project.owner.name).to eq('John Owner') | |
84 | end | |
85 | end | |
86 | ||
87 | describe '.delete_project' do | |
88 | before do | |
89 | stub_delete('/projects/Gitlab', 'project') | |
88 | 90 | @project = Gitlab.delete_project('Gitlab') |
89 | 91 | end |
90 | 92 | |
91 | it "gets the correct resource" do | |
92 | expect(a_delete("/projects/Gitlab")).to have_been_made | |
93 | end | |
94 | ||
95 | it "returns information about a deleted project" do | |
96 | expect(@project.name).to eq("Gitlab") | |
97 | expect(@project.owner.name).to eq("John Smith") | |
98 | end | |
99 | end | |
100 | ||
101 | describe ".create_fork" do | |
102 | context "without sudo option" do | |
103 | before do | |
104 | stub_post("/projects/3/fork", "project_fork") | |
93 | it 'gets the correct resource' do | |
94 | expect(a_delete('/projects/Gitlab')).to have_been_made | |
95 | end | |
96 | ||
97 | it 'returns information about a deleted project' do | |
98 | expect(@project.name).to eq('Gitlab') | |
99 | expect(@project.owner.name).to eq('John Smith') | |
100 | end | |
101 | end | |
102 | ||
103 | describe '.create_fork' do | |
104 | context 'without sudo option' do | |
105 | before do | |
106 | stub_post('/projects/3/fork', 'project_fork') | |
105 | 107 | @project = Gitlab.create_fork(3) |
106 | 108 | end |
107 | 109 | |
108 | it "posts to the correct resource" do | |
109 | expect(a_post("/projects/3/fork")).to have_been_made | |
110 | end | |
111 | ||
112 | it "returns information about the forked project" do | |
110 | it 'posts to the correct resource' do | |
111 | expect(a_post('/projects/3/fork')).to have_been_made | |
112 | end | |
113 | ||
114 | it 'returns information about the forked project' do | |
113 | 115 | expect(@project.forked_from_project.id).to eq(3) |
114 | 116 | expect(@project.id).to eq(20) |
115 | 117 | end |
116 | 118 | end |
117 | 119 | |
118 | context "with the sudo option" do | |
119 | before do | |
120 | stub_post("/projects/3/fork", "project_forked_for_user") | |
120 | context 'with the sudo option' do | |
121 | before do | |
122 | stub_post('/projects/3/fork', 'project_forked_for_user') | |
121 | 123 | @sudoed_username = 'jack.smith' |
122 | 124 | @project = Gitlab.create_fork(3, sudo: @sudoed_username) |
123 | 125 | end |
124 | 126 | |
125 | it "posts to the correct resource" do | |
126 | expect(a_post("/projects/3/fork")).to have_been_made | |
127 | end | |
128 | ||
129 | it "returns information about the forked project" do | |
127 | it 'posts to the correct resource' do | |
128 | expect(a_post('/projects/3/fork')).to have_been_made | |
129 | end | |
130 | ||
131 | it 'returns information about the forked project' do | |
130 | 132 | expect(@project.forked_from_project.id).to eq(3) |
131 | 133 | expect(@project.id).to eq(20) |
132 | 134 | expect(@project.owner.username).to eq(@sudoed_username) |
134 | 136 | end |
135 | 137 | end |
136 | 138 | |
137 | describe ".project_forks" do | |
138 | before do | |
139 | stub_get("/projects/3/forks", "project_forks") | |
139 | describe '.project_forks' do | |
140 | before do | |
141 | stub_get('/projects/3/forks', 'project_forks') | |
140 | 142 | @project_forks = Gitlab.project_forks(3) |
141 | 143 | end |
142 | 144 | |
143 | it "gets the correct resource" do | |
144 | expect(a_get("/projects/3/forks")).to have_been_made | |
145 | end | |
146 | ||
147 | it "returns a paginated response of projects found" do | |
145 | it 'gets the correct resource' do | |
146 | expect(a_get('/projects/3/forks')).to have_been_made | |
147 | end | |
148 | ||
149 | it 'returns a paginated response of projects found' do | |
148 | 150 | expect(@project_forks).to be_a Gitlab::PaginatedResponse |
149 | expect(@project_forks.first.name).to eq("gitlab") | |
150 | expect(@project_forks.first.owner.name).to eq("Administrator") | |
151 | end | |
152 | end | |
153 | ||
154 | describe ".team_members" do | |
155 | before do | |
156 | stub_get("/projects/3/members", "team_members") | |
151 | expect(@project_forks.first.name).to eq('gitlab') | |
152 | expect(@project_forks.first.owner.name).to eq('Administrator') | |
153 | end | |
154 | end | |
155 | ||
156 | describe '.team_members' do | |
157 | before do | |
158 | stub_get('/projects/3/members', 'team_members') | |
157 | 159 | @team_members = Gitlab.team_members(3) |
158 | 160 | end |
159 | 161 | |
160 | it "gets the correct resource" do | |
161 | expect(a_get("/projects/3/members")).to have_been_made | |
162 | end | |
163 | ||
164 | it "returns a paginated response of team members" do | |
162 | it 'gets the correct resource' do | |
163 | expect(a_get('/projects/3/members')).to have_been_made | |
164 | end | |
165 | ||
166 | it 'returns a paginated response of team members' do | |
165 | 167 | expect(@team_members).to be_a Gitlab::PaginatedResponse |
166 | expect(@team_members.first.name).to eq("John Smith") | |
167 | end | |
168 | end | |
169 | ||
170 | describe ".team_member" do | |
171 | before do | |
172 | stub_get("/projects/3/members/1", "team_member") | |
168 | expect(@team_members.first.name).to eq('John Smith') | |
169 | end | |
170 | end | |
171 | ||
172 | describe '.team_member' do | |
173 | before do | |
174 | stub_get('/projects/3/members/1', 'team_member') | |
173 | 175 | @team_member = Gitlab.team_member(3, 1) |
174 | 176 | end |
175 | 177 | |
176 | it "gets the correct resource" do | |
177 | expect(a_get("/projects/3/members/1")).to have_been_made | |
178 | end | |
179 | ||
180 | it "returns information about a team member" do | |
181 | expect(@team_member.name).to eq("John Smith") | |
182 | end | |
183 | end | |
184 | ||
185 | describe ".add_team_member" do | |
186 | before do | |
187 | stub_post("/projects/3/members", "team_member") | |
188 | @team_member = Gitlab.add_team_member(3, 1, 40) | |
189 | end | |
190 | ||
191 | it "gets the correct resource" do | |
192 | expect(a_post("/projects/3/members"). | |
193 | with(body: { user_id: '1', access_level: '40' })).to have_been_made | |
194 | end | |
195 | ||
196 | it "returns information about an added team member" do | |
197 | expect(@team_member.name).to eq("John Smith") | |
198 | end | |
199 | end | |
200 | ||
201 | describe ".edit_team_member" do | |
202 | before do | |
203 | stub_put("/projects/3/members/1", "team_member") | |
204 | @team_member = Gitlab.edit_team_member(3, 1, 40) | |
205 | end | |
206 | ||
207 | it "gets the correct resource" do | |
208 | expect(a_put("/projects/3/members/1"). | |
209 | with(body: { access_level: '40' })).to have_been_made | |
210 | end | |
211 | ||
212 | it "returns information about an edited team member" do | |
213 | expect(@team_member.name).to eq("John Smith") | |
214 | end | |
215 | end | |
216 | ||
217 | describe ".remove_team_member" do | |
218 | before do | |
219 | stub_delete("/projects/3/members/1", "team_member") | |
178 | it 'gets the correct resource' do | |
179 | expect(a_get('/projects/3/members/1')).to have_been_made | |
180 | end | |
181 | ||
182 | it 'returns information about a team member' do | |
183 | expect(@team_member.name).to eq('John Smith') | |
184 | end | |
185 | end | |
186 | ||
187 | describe '.add_team_member' do | |
188 | before do | |
189 | stub_post('/projects/3/members', 'team_member') | |
190 | @team_member = Gitlab.add_team_member(3, 1, 40, expires_at: '2018-12-31') | |
191 | end | |
192 | ||
193 | it 'gets the correct resource' do | |
194 | expect(a_post('/projects/3/members') | |
195 | .with(body: { user_id: '1', access_level: '40', expires_at: '2018-12-31' })).to have_been_made | |
196 | end | |
197 | ||
198 | it 'returns information about an added team member' do | |
199 | expect(@team_member.name).to eq('John Smith') | |
200 | expect(@team_member.expires_at).to eq('2018-12-31T00:00:00Z') | |
201 | end | |
202 | end | |
203 | ||
204 | describe '.edit_team_member' do | |
205 | before do | |
206 | stub_put('/projects/3/members/1', 'team_member') | |
207 | @team_member = Gitlab.edit_team_member(3, 1, 40, expires_at: '2018-12-31') | |
208 | end | |
209 | ||
210 | it 'gets the correct resource' do | |
211 | expect(a_put('/projects/3/members/1') | |
212 | .with(body: { access_level: '40', expires_at: '2018-12-31' })).to have_been_made | |
213 | end | |
214 | ||
215 | it 'returns information about an edited team member' do | |
216 | expect(@team_member.name).to eq('John Smith') | |
217 | expect(@team_member.expires_at).to eq('2018-12-31T00:00:00Z') | |
218 | end | |
219 | end | |
220 | ||
221 | describe '.remove_team_member' do | |
222 | before do | |
223 | stub_delete('/projects/3/members/1', 'team_member') | |
220 | 224 | @team_member = Gitlab.remove_team_member(3, 1) |
221 | 225 | end |
222 | 226 | |
223 | it "gets the correct resource" do | |
224 | expect(a_delete("/projects/3/members/1")).to have_been_made | |
225 | end | |
226 | ||
227 | it "returns information about a removed team member" do | |
228 | expect(@team_member.name).to eq("John Smith") | |
229 | end | |
230 | end | |
231 | ||
232 | describe ".project_hooks" do | |
233 | before do | |
234 | stub_get("/projects/1/hooks", "project_hooks") | |
227 | it 'gets the correct resource' do | |
228 | expect(a_delete('/projects/3/members/1')).to have_been_made | |
229 | end | |
230 | ||
231 | it 'returns information about a removed team member' do | |
232 | expect(@team_member.name).to eq('John Smith') | |
233 | end | |
234 | end | |
235 | ||
236 | describe '.project_hooks' do | |
237 | before do | |
238 | stub_get('/projects/1/hooks', 'project_hooks') | |
235 | 239 | @hooks = Gitlab.project_hooks(1) |
236 | 240 | end |
237 | 241 | |
238 | it "gets the correct resource" do | |
239 | expect(a_get("/projects/1/hooks")).to have_been_made | |
240 | end | |
241 | ||
242 | it "returns a paginated response of hooks" do | |
242 | it 'gets the correct resource' do | |
243 | expect(a_get('/projects/1/hooks')).to have_been_made | |
244 | end | |
245 | ||
246 | it 'returns a paginated response of hooks' do | |
243 | 247 | expect(@hooks).to be_a Gitlab::PaginatedResponse |
244 | expect(@hooks.first.url).to eq("https://api.example.net/v1/webhooks/ci") | |
245 | end | |
246 | end | |
247 | ||
248 | describe ".project_hook" do | |
249 | before do | |
250 | stub_get("/projects/1/hooks/1", "project_hook") | |
248 | expect(@hooks.first.url).to eq('https://api.example.net/v1/webhooks/ci') | |
249 | end | |
250 | end | |
251 | ||
252 | describe '.project_hook' do | |
253 | before do | |
254 | stub_get('/projects/1/hooks/1', 'project_hook') | |
251 | 255 | @hook = Gitlab.project_hook(1, 1) |
252 | 256 | end |
253 | 257 | |
254 | it "gets the correct resource" do | |
255 | expect(a_get("/projects/1/hooks/1")).to have_been_made | |
256 | end | |
257 | ||
258 | it "returns information about a hook" do | |
259 | expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci") | |
260 | end | |
261 | end | |
262 | ||
263 | describe ".add_project_hook" do | |
264 | context "without specified events" do | |
265 | before do | |
266 | stub_post("/projects/1/hooks", "project_hook") | |
267 | @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci") | |
268 | end | |
269 | ||
270 | it "gets the correct resource" do | |
271 | body = { url: "https://api.example.net/v1/webhooks/ci" } | |
272 | expect(a_post("/projects/1/hooks").with(body: body)).to have_been_made | |
273 | end | |
274 | ||
275 | it "returns information about an added hook" do | |
276 | expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci") | |
277 | end | |
278 | end | |
279 | ||
280 | context "with specified events" do | |
281 | before do | |
282 | stub_post("/projects/1/hooks", "project_hook") | |
283 | @hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci", push_events: true, merge_requests_events: true) | |
284 | end | |
285 | ||
286 | it "gets the correct resource" do | |
287 | body = { url: "https://api.example.net/v1/webhooks/ci", push_events: "true", merge_requests_events: "true" } | |
288 | expect(a_post("/projects/1/hooks").with(body: body)).to have_been_made | |
289 | end | |
290 | ||
291 | it "returns information about an added hook" do | |
292 | expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci") | |
293 | end | |
294 | end | |
295 | end | |
296 | ||
297 | describe ".edit_project_hook" do | |
298 | before do | |
299 | stub_put("/projects/1/hooks/1", "project_hook") | |
300 | @hook = Gitlab.edit_project_hook(1, 1, "https://api.example.net/v1/webhooks/ci") | |
301 | end | |
302 | ||
303 | it "gets the correct resource" do | |
304 | body = { url: "https://api.example.net/v1/webhooks/ci" } | |
305 | expect(a_put("/projects/1/hooks/1").with(body: body)).to have_been_made | |
306 | end | |
307 | ||
308 | it "returns information about an edited hook" do | |
309 | expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci") | |
310 | end | |
311 | end | |
312 | ||
313 | describe ".edit_project" do | |
314 | context "using project ID" do | |
315 | before do | |
316 | stub_put("/projects/3", "project_edit").with(body: { name: "Gitlab-edit" }) | |
317 | @edited_project = Gitlab.edit_project(3, name: "Gitlab-edit") | |
318 | end | |
319 | ||
320 | it "gets the correct resource" do | |
321 | expect(a_put("/projects/3").with(body: { name: "Gitlab-edit" })).to have_been_made | |
322 | end | |
323 | ||
324 | it "returns information about an edited project" do | |
325 | expect(@edited_project.name).to eq("Gitlab-edit") | |
326 | end | |
327 | end | |
328 | ||
329 | context "using namespaced project path" do | |
330 | it "encodes the path properly" do | |
331 | stub = stub_put("/projects/namespace%2Fpath", "project_edit").with(body: { name: "Gitlab-edit" }) | |
332 | Gitlab.edit_project('namespace/path', name: "Gitlab-edit") | |
258 | it 'gets the correct resource' do | |
259 | expect(a_get('/projects/1/hooks/1')).to have_been_made | |
260 | end | |
261 | ||
262 | it 'returns information about a hook' do | |
263 | expect(@hook.url).to eq('https://api.example.net/v1/webhooks/ci') | |
264 | end | |
265 | end | |
266 | ||
267 | describe '.add_project_hook' do | |
268 | context 'without specified events' do | |
269 | before do | |
270 | stub_post('/projects/1/hooks', 'project_hook') | |
271 | @hook = Gitlab.add_project_hook(1, 'https://api.example.net/v1/webhooks/ci') | |
272 | end | |
273 | ||
274 | it 'gets the correct resource' do | |
275 | body = { url: 'https://api.example.net/v1/webhooks/ci' } | |
276 | expect(a_post('/projects/1/hooks').with(body: body)).to have_been_made | |
277 | end | |
278 | ||
279 | it 'returns information about an added hook' do | |
280 | expect(@hook.url).to eq('https://api.example.net/v1/webhooks/ci') | |
281 | end | |
282 | end | |
283 | ||
284 | context 'with specified events' do | |
285 | before do | |
286 | stub_post('/projects/1/hooks', 'project_hook') | |
287 | @hook = Gitlab.add_project_hook(1, 'https://api.example.net/v1/webhooks/ci', push_events: true, merge_requests_events: true) | |
288 | end | |
289 | ||
290 | it 'gets the correct resource' do | |
291 | body = { url: 'https://api.example.net/v1/webhooks/ci', push_events: 'true', merge_requests_events: 'true' } | |
292 | expect(a_post('/projects/1/hooks').with(body: body)).to have_been_made | |
293 | end | |
294 | ||
295 | it 'returns information about an added hook' do | |
296 | expect(@hook.url).to eq('https://api.example.net/v1/webhooks/ci') | |
297 | end | |
298 | end | |
299 | end | |
300 | ||
301 | describe '.edit_project_hook' do | |
302 | before do | |
303 | stub_put('/projects/1/hooks/1', 'project_hook') | |
304 | @hook = Gitlab.edit_project_hook(1, 1, 'https://api.example.net/v1/webhooks/ci') | |
305 | end | |
306 | ||
307 | it 'gets the correct resource' do | |
308 | body = { url: 'https://api.example.net/v1/webhooks/ci' } | |
309 | expect(a_put('/projects/1/hooks/1').with(body: body)).to have_been_made | |
310 | end | |
311 | ||
312 | it 'returns information about an edited hook' do | |
313 | expect(@hook.url).to eq('https://api.example.net/v1/webhooks/ci') | |
314 | end | |
315 | end | |
316 | ||
317 | describe '.edit_project' do | |
318 | context 'using project ID' do | |
319 | before do | |
320 | stub_put('/projects/3', 'project_edit').with(body: { name: 'Gitlab-edit' }) | |
321 | @edited_project = Gitlab.edit_project(3, name: 'Gitlab-edit') | |
322 | end | |
323 | ||
324 | it 'gets the correct resource' do | |
325 | expect(a_put('/projects/3').with(body: { name: 'Gitlab-edit' })).to have_been_made | |
326 | end | |
327 | ||
328 | it 'returns information about an edited project' do | |
329 | expect(@edited_project.name).to eq('Gitlab-edit') | |
330 | end | |
331 | end | |
332 | ||
333 | context 'using namespaced project path' do | |
334 | it 'encodes the path properly' do | |
335 | stub = stub_put('/projects/namespace%2Fpath', 'project_edit').with(body: { name: 'Gitlab-edit' }) | |
336 | Gitlab.edit_project('namespace/path', name: 'Gitlab-edit') | |
333 | 337 | expect(stub).to have_been_requested |
334 | 338 | end |
335 | 339 | end |
336 | 340 | end |
337 | 341 | |
338 | describe ".delete_project_hook" do | |
339 | context "when empty response" do | |
340 | before do | |
341 | stub_request(:delete, "#{Gitlab.endpoint}/projects/1/hooks/1"). | |
342 | with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }). | |
343 | to_return(body: '') | |
342 | describe '.delete_project_hook' do | |
343 | context 'when empty response' do | |
344 | before do | |
345 | stub_request(:delete, "#{Gitlab.endpoint}/projects/1/hooks/1") | |
346 | .with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }) | |
347 | .to_return(body: '') | |
344 | 348 | @hook = Gitlab.delete_project_hook(1, 1) |
345 | 349 | end |
346 | 350 | |
347 | it "gets the correct resource" do | |
348 | expect(a_delete("/projects/1/hooks/1")).to have_been_made | |
349 | end | |
350 | ||
351 | it "returns false" do | |
351 | it 'gets the correct resource' do | |
352 | expect(a_delete('/projects/1/hooks/1')).to have_been_made | |
353 | end | |
354 | ||
355 | it 'returns false' do | |
352 | 356 | expect(@hook).to be(false) |
353 | 357 | end |
354 | 358 | end |
355 | 359 | |
356 | context "when JSON response" do | |
357 | before do | |
358 | stub_delete("/projects/1/hooks/1", "project_hook") | |
360 | context 'when JSON response' do | |
361 | before do | |
362 | stub_delete('/projects/1/hooks/1', 'project_hook') | |
359 | 363 | @hook = Gitlab.delete_project_hook(1, 1) |
360 | 364 | end |
361 | 365 | |
362 | it "gets the correct resource" do | |
363 | expect(a_delete("/projects/1/hooks/1")).to have_been_made | |
364 | end | |
365 | ||
366 | it "returns information about a deleted hook" do | |
367 | expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci") | |
368 | end | |
369 | end | |
370 | end | |
371 | ||
372 | describe ".push_rule" do | |
373 | before do | |
374 | stub_get("/projects/1/push_rule", "push_rule") | |
366 | it 'gets the correct resource' do | |
367 | expect(a_delete('/projects/1/hooks/1')).to have_been_made | |
368 | end | |
369 | ||
370 | it 'returns information about a deleted hook' do | |
371 | expect(@hook.url).to eq('https://api.example.net/v1/webhooks/ci') | |
372 | end | |
373 | end | |
374 | end | |
375 | ||
376 | describe '.push_rule' do | |
377 | before do | |
378 | stub_get('/projects/1/push_rule', 'push_rule') | |
375 | 379 | @push_rule = Gitlab.push_rule(1) |
376 | 380 | end |
377 | 381 | |
378 | it "gets the correct resource" do | |
379 | expect(a_get("/projects/1/push_rule")).to have_been_made | |
380 | end | |
381 | ||
382 | it "returns information about a push rule" do | |
383 | expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b") | |
384 | end | |
385 | end | |
386 | ||
387 | describe ".add_push_rule" do | |
388 | before do | |
389 | stub_post("/projects/1/push_rule", "push_rule") | |
390 | @push_rule = Gitlab.add_push_rule(1, { deny_delete_tag: false, commit_message_regex: "\\b[A-Z]{3}-[0-9]+\\b" }) | |
391 | end | |
392 | ||
393 | it "gets the correct resource" do | |
394 | expect(a_post("/projects/1/push_rule")).to have_been_made | |
395 | end | |
396 | ||
397 | it "returns information about an added push rule" do | |
398 | expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b") | |
399 | end | |
400 | end | |
401 | ||
402 | describe ".edit_push_rule" do | |
403 | before do | |
404 | stub_put("/projects/1/push_rule", "push_rule") | |
405 | @push_rule = Gitlab.edit_push_rule(1, { deny_delete_tag: false, commit_message_regex: "\\b[A-Z]{3}-[0-9]+\\b" }) | |
406 | end | |
407 | ||
408 | it "gets the correct resource" do | |
409 | expect(a_put("/projects/1/push_rule")).to have_been_made | |
410 | end | |
411 | ||
412 | it "returns information about an edited push rule" do | |
413 | expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b") | |
414 | end | |
415 | end | |
416 | ||
417 | describe ".delete_push_rule" do | |
418 | context "when empty response" do | |
419 | before do | |
420 | stub_request(:delete, "#{Gitlab.endpoint}/projects/1/push_rule"). | |
421 | with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }). | |
422 | to_return(body: '') | |
382 | it 'gets the correct resource' do | |
383 | expect(a_get('/projects/1/push_rule')).to have_been_made | |
384 | end | |
385 | ||
386 | it 'returns information about a push rule' do | |
387 | expect(@push_rule.commit_message_regex).to eq('\\b[A-Z]{3}-[0-9]+\\b') | |
388 | end | |
389 | end | |
390 | ||
391 | describe '.add_push_rule' do | |
392 | before do | |
393 | stub_post('/projects/1/push_rule', 'push_rule') | |
394 | @push_rule = Gitlab.add_push_rule(1, deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b') | |
395 | end | |
396 | ||
397 | it 'gets the correct resource' do | |
398 | expect(a_post('/projects/1/push_rule')).to have_been_made | |
399 | end | |
400 | ||
401 | it 'returns information about an added push rule' do | |
402 | expect(@push_rule.commit_message_regex).to eq('\\b[A-Z]{3}-[0-9]+\\b') | |
403 | end | |
404 | end | |
405 | ||
406 | describe '.edit_push_rule' do | |
407 | before do | |
408 | stub_put('/projects/1/push_rule', 'push_rule') | |
409 | @push_rule = Gitlab.edit_push_rule(1, deny_delete_tag: false, commit_message_regex: '\\b[A-Z]{3}-[0-9]+\\b') | |
410 | end | |
411 | ||
412 | it 'gets the correct resource' do | |
413 | expect(a_put('/projects/1/push_rule')).to have_been_made | |
414 | end | |
415 | ||
416 | it 'returns information about an edited push rule' do | |
417 | expect(@push_rule.commit_message_regex).to eq('\\b[A-Z]{3}-[0-9]+\\b') | |
418 | end | |
419 | end | |
420 | ||
421 | describe '.delete_push_rule' do | |
422 | context 'when empty response' do | |
423 | before do | |
424 | stub_request(:delete, "#{Gitlab.endpoint}/projects/1/push_rule") | |
425 | .with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }) | |
426 | .to_return(body: '') | |
423 | 427 | @push_rule = Gitlab.delete_push_rule(1) |
424 | 428 | end |
425 | 429 | |
426 | it "gets the correct resource" do | |
427 | expect(a_delete("/projects/1/push_rule")).to have_been_made | |
428 | end | |
429 | ||
430 | it "returns false" do | |
430 | it 'gets the correct resource' do | |
431 | expect(a_delete('/projects/1/push_rule')).to have_been_made | |
432 | end | |
433 | ||
434 | it 'returns false' do | |
431 | 435 | expect(@push_rule).to be(false) |
432 | 436 | end |
433 | 437 | end |
434 | 438 | |
435 | context "when JSON response" do | |
436 | before do | |
437 | stub_delete("/projects/1/push_rule", "push_rule") | |
439 | context 'when JSON response' do | |
440 | before do | |
441 | stub_delete('/projects/1/push_rule', 'push_rule') | |
438 | 442 | @push_rule = Gitlab.delete_push_rule(1) |
439 | 443 | end |
440 | 444 | |
441 | it "gets the correct resource" do | |
442 | expect(a_delete("/projects/1/push_rule")).to have_been_made | |
443 | end | |
444 | ||
445 | it "returns information about a deleted push rule" do | |
446 | expect(@push_rule.commit_message_regex).to eq("\\b[A-Z]{3}-[0-9]+\\b") | |
447 | end | |
448 | end | |
449 | end | |
450 | ||
451 | describe ".make_forked_from" do | |
452 | before do | |
453 | stub_post("/projects/42/fork/24", "project_fork_link") | |
445 | it 'gets the correct resource' do | |
446 | expect(a_delete('/projects/1/push_rule')).to have_been_made | |
447 | end | |
448 | ||
449 | it 'returns information about a deleted push rule' do | |
450 | expect(@push_rule.commit_message_regex).to eq('\\b[A-Z]{3}-[0-9]+\\b') | |
451 | end | |
452 | end | |
453 | end | |
454 | ||
455 | describe '.make_forked_from' do | |
456 | before do | |
457 | stub_post('/projects/42/fork/24', 'project_fork_link') | |
454 | 458 | @forked_project_link = Gitlab.make_forked_from(42, 24) |
455 | 459 | end |
456 | 460 | |
457 | it "gets the correct resource" do | |
458 | expect(a_post("/projects/42/fork/24")).to have_been_made | |
459 | end | |
460 | ||
461 | it "returns information about a forked project" do | |
461 | it 'gets the correct resource' do | |
462 | expect(a_post('/projects/42/fork/24')).to have_been_made | |
463 | end | |
464 | ||
465 | it 'returns information about a forked project' do | |
462 | 466 | expect(@forked_project_link.forked_from_project_id).to eq(24) |
463 | 467 | expect(@forked_project_link.forked_to_project_id).to eq(42) |
464 | 468 | end |
465 | 469 | end |
466 | 470 | |
467 | describe ".remove_forked" do | |
468 | before do | |
469 | stub_delete("/projects/42/fork", "project_fork_link") | |
471 | describe '.remove_forked' do | |
472 | before do | |
473 | stub_delete('/projects/42/fork', 'project_fork_link') | |
470 | 474 | @forked_project_link = Gitlab.remove_forked(42) |
471 | 475 | end |
472 | 476 | |
473 | it "gets the correct resource" do | |
474 | expect(a_delete("/projects/42/fork")).to have_been_made | |
475 | end | |
476 | ||
477 | it "returns information about an unforked project" do | |
477 | it 'gets the correct resource' do | |
478 | expect(a_delete('/projects/42/fork')).to have_been_made | |
479 | end | |
480 | ||
481 | it 'returns information about an unforked project' do | |
478 | 482 | expect(@forked_project_link.forked_to_project_id).to eq(42) |
479 | 483 | end |
480 | 484 | end |
481 | 485 | |
482 | describe ".deploy_keys" do | |
483 | before do | |
484 | stub_get("/projects/42/deploy_keys", "project_keys") | |
486 | describe '.deploy_keys' do | |
487 | before do | |
488 | stub_get('/projects/42/deploy_keys', 'project_keys') | |
485 | 489 | @deploy_keys = Gitlab.deploy_keys(42) |
486 | 490 | end |
487 | 491 | |
488 | it "gets the correct resource" do | |
489 | expect(a_get("/projects/42/deploy_keys")).to have_been_made | |
490 | end | |
491 | ||
492 | it "returns project deploy keys" do | |
492 | it 'gets the correct resource' do | |
493 | expect(a_get('/projects/42/deploy_keys')).to have_been_made | |
494 | end | |
495 | ||
496 | it 'returns project deploy keys' do | |
493 | 497 | expect(@deploy_keys).to be_a Gitlab::PaginatedResponse |
494 | 498 | expect(@deploy_keys.first.id).to eq 2 |
495 | expect(@deploy_keys.first.title).to eq "Key Title" | |
499 | expect(@deploy_keys.first.title).to eq 'Key Title' | |
496 | 500 | expect(@deploy_keys.first.key).to match(/ssh-rsa/) |
497 | 501 | end |
498 | 502 | end |
499 | 503 | |
500 | describe ".deploy_key" do | |
501 | before do | |
502 | stub_get("/projects/42/deploy_keys/2", "project_key") | |
504 | describe '.deploy_key' do | |
505 | before do | |
506 | stub_get('/projects/42/deploy_keys/2', 'project_key') | |
503 | 507 | @deploy_key = Gitlab.deploy_key(42, 2) |
504 | 508 | end |
505 | 509 | |
506 | it "gets the correct resource" do | |
507 | expect(a_get("/projects/42/deploy_keys/2")).to have_been_made | |
508 | end | |
509 | ||
510 | it "returns project deploy key" do | |
510 | it 'gets the correct resource' do | |
511 | expect(a_get('/projects/42/deploy_keys/2')).to have_been_made | |
512 | end | |
513 | ||
514 | it 'returns project deploy key' do | |
511 | 515 | expect(@deploy_key.id).to eq 2 |
512 | expect(@deploy_key.title).to eq "Key Title" | |
516 | expect(@deploy_key.title).to eq 'Key Title' | |
513 | 517 | expect(@deploy_key.key).to match(/ssh-rsa/) |
514 | 518 | end |
515 | 519 | end |
516 | 520 | |
517 | describe ".create_deploy_key" do | |
521 | describe '.create_deploy_key' do | |
518 | 522 | context 'no options' do |
519 | 523 | before do |
520 | stub_post("/projects/42/deploy_keys", "project_key") | |
524 | stub_post('/projects/42/deploy_keys', 'project_key') | |
521 | 525 | @deploy_key = Gitlab.create_deploy_key(42, 'My Key', 'Key contents') |
522 | 526 | end |
523 | 527 | |
524 | it "gets the correct resource" do | |
525 | expect(a_post("/projects/42/deploy_keys"). | |
526 | with(body: { title: 'My Key', key: 'Key contents' })).to have_been_made | |
527 | end | |
528 | ||
529 | it "returns information about a created key" do | |
528 | it 'gets the correct resource' do | |
529 | expect(a_post('/projects/42/deploy_keys') | |
530 | .with(body: { title: 'My Key', key: 'Key contents' })).to have_been_made | |
531 | end | |
532 | ||
533 | it 'returns information about a created key' do | |
530 | 534 | expect(@deploy_key.id).to eq(2) |
531 | 535 | end |
532 | 536 | end |
533 | 537 | |
534 | 538 | context 'some options' do |
535 | 539 | before do |
536 | stub_post("/projects/42/deploy_keys", "project_key") | |
540 | stub_post('/projects/42/deploy_keys', 'project_key') | |
537 | 541 | @deploy_key = Gitlab.create_deploy_key(42, 'My Key', 'Key contents', can_push: true) |
538 | 542 | end |
539 | 543 | |
540 | it "gets the correct resource" do | |
541 | expect(a_post("/projects/42/deploy_keys"). | |
542 | with(body: { title: 'My Key', key: 'Key contents', can_push: true })).to have_been_made | |
543 | end | |
544 | ||
545 | it "returns information about a created key" do | |
544 | it 'gets the correct resource' do | |
545 | expect(a_post('/projects/42/deploy_keys') | |
546 | .with(body: { title: 'My Key', key: 'Key contents', can_push: true })).to have_been_made | |
547 | end | |
548 | ||
549 | it 'returns information about a created key' do | |
546 | 550 | expect(@deploy_key.id).to eq(2) |
547 | 551 | end |
548 | 552 | end |
549 | 553 | end |
550 | 554 | |
551 | describe ".delete_deploy_key" do | |
552 | before do | |
553 | stub_delete("/projects/42/deploy_keys/2", "project_key") | |
555 | describe '.delete_deploy_key' do | |
556 | before do | |
557 | stub_delete('/projects/42/deploy_keys/2', 'project_key') | |
554 | 558 | @deploy_key = Gitlab.delete_deploy_key(42, 2) |
555 | 559 | end |
556 | 560 | |
557 | it "gets the correct resource" do | |
558 | expect(a_delete("/projects/42/deploy_keys/2")).to have_been_made | |
559 | end | |
560 | ||
561 | it "returns information about a deleted key" do | |
561 | it 'gets the correct resource' do | |
562 | expect(a_delete('/projects/42/deploy_keys/2')).to have_been_made | |
563 | end | |
564 | ||
565 | it 'returns information about a deleted key' do | |
562 | 566 | expect(@deploy_key.id).to eq(2) |
563 | 567 | end |
564 | 568 | end |
565 | 569 | |
566 | describe ".enable_deploy_key" do | |
567 | before do | |
568 | stub_post("/projects/42/deploy_keys/2/enable", "project_key") | |
570 | describe '.enable_deploy_key' do | |
571 | before do | |
572 | stub_post('/projects/42/deploy_keys/2/enable', 'project_key') | |
569 | 573 | @deploy_key = Gitlab.enable_deploy_key(42, 2) |
570 | 574 | end |
571 | 575 | |
572 | it "gets the correct resource" do | |
573 | expect(a_post("/projects/42/deploy_keys/2/enable"). | |
574 | with(body: { id: '42', key_id: '2' })).to have_been_made | |
575 | end | |
576 | ||
577 | it "returns information about an enabled key" do | |
576 | it 'gets the correct resource' do | |
577 | expect(a_post('/projects/42/deploy_keys/2/enable') | |
578 | .with(body: { id: '42', key_id: '2' })).to have_been_made | |
579 | end | |
580 | ||
581 | it 'returns information about an enabled key' do | |
578 | 582 | expect(@deploy_key.id).to eq(2) |
579 | 583 | end |
580 | 584 | end |
581 | 585 | |
582 | describe ".disable_deploy_key" do | |
583 | before do | |
584 | stub_post("/projects/42/deploy_keys/2/disable", "project_key") | |
586 | describe '.disable_deploy_key' do | |
587 | before do | |
588 | stub_post('/projects/42/deploy_keys/2/disable', 'project_key') | |
585 | 589 | @deploy_key = Gitlab.disable_deploy_key(42, 2) |
586 | 590 | end |
587 | 591 | |
588 | it "gets the correct resource" do | |
589 | expect(a_post("/projects/42/deploy_keys/2/disable"). | |
590 | with(body: { id: '42', key_id: '2' })).to have_been_made | |
591 | end | |
592 | ||
593 | it "returns information about a disabled key" do | |
592 | it 'gets the correct resource' do | |
593 | expect(a_post('/projects/42/deploy_keys/2/disable') | |
594 | .with(body: { id: '42', key_id: '2' })).to have_been_made | |
595 | end | |
596 | ||
597 | it 'returns information about a disabled key' do | |
594 | 598 | expect(@deploy_key.id).to eq(2) |
595 | 599 | end |
596 | 600 | end |
597 | 601 | |
598 | describe ".share_project_with_group" do | |
599 | before do | |
600 | stub_post("/projects/3/share", "group") | |
602 | describe '.share_project_with_group' do | |
603 | before do | |
604 | stub_post('/projects/3/share', 'group') | |
601 | 605 | @group = Gitlab.share_project_with_group(3, 10, 40) |
602 | 606 | end |
603 | 607 | |
604 | it "gets the correct resource" do | |
605 | expect(a_post("/projects/3/share"). | |
606 | with(body: { group_id: '10', group_access: '40' })).to have_been_made | |
607 | end | |
608 | ||
609 | it "returns information about an added group" do | |
608 | it 'gets the correct resource' do | |
609 | expect(a_post('/projects/3/share') | |
610 | .with(body: { group_id: '10', group_access: '40' })).to have_been_made | |
611 | end | |
612 | ||
613 | it 'returns information about an added group' do | |
610 | 614 | expect(@group.id).to eq(10) |
611 | 615 | end |
612 | 616 | end |
613 | 617 | |
614 | describe ".unshare_project_with_group" do | |
615 | before do | |
616 | stub_delete("/projects/3/share/10", "group") | |
618 | describe '.unshare_project_with_group' do | |
619 | before do | |
620 | stub_delete('/projects/3/share/10', 'group') | |
617 | 621 | @group = Gitlab.unshare_project_with_group(3, 10) |
618 | 622 | end |
619 | 623 | |
620 | it "gets the correct resource" do | |
621 | expect(a_delete("/projects/3/share/10")).to have_been_made | |
622 | end | |
623 | end | |
624 | ||
625 | describe ".star_project" do | |
626 | before do | |
627 | stub_post("/projects/3/star", "project_star") | |
624 | it 'gets the correct resource' do | |
625 | expect(a_delete('/projects/3/share/10')).to have_been_made | |
626 | end | |
627 | end | |
628 | ||
629 | describe '.transfer_project' do | |
630 | before do | |
631 | stub_put('/projects/3/transfer', 'transfer_project') | |
632 | @transfered_project = Gitlab.transfer_project(3, 'yolo') | |
633 | end | |
634 | ||
635 | it 'gets the correct resource' do | |
636 | expect(a_put('/projects/3/transfer') | |
637 | .with(body: { namespace: 'yolo' })).to have_been_made | |
638 | end | |
639 | ||
640 | it 'returns information about the transfered project' do | |
641 | expect(@transfered_project.id).to eq(1) | |
642 | end | |
643 | end | |
644 | ||
645 | describe '.star_project' do | |
646 | before do | |
647 | stub_post('/projects/3/star', 'project_star') | |
628 | 648 | @starred_project = Gitlab.star_project(3) |
629 | 649 | end |
630 | 650 | |
631 | it "gets the correct resource" do | |
632 | expect(a_post("/projects/3/star")).to have_been_made | |
633 | end | |
634 | ||
635 | it "returns information about the starred project" do | |
651 | it 'gets the correct resource' do | |
652 | expect(a_post('/projects/3/star')).to have_been_made | |
653 | end | |
654 | ||
655 | it 'returns information about the starred project' do | |
636 | 656 | expect(@starred_project.id).to eq(3) |
637 | 657 | end |
638 | 658 | end |
639 | 659 | |
640 | describe ".unstar_project" do | |
641 | before do | |
642 | stub_delete("/projects/3/star", "project_unstar") | |
660 | describe '.unstar_project' do | |
661 | before do | |
662 | stub_delete('/projects/3/star', 'project_unstar') | |
643 | 663 | @unstarred_project = Gitlab.unstar_project(3) |
644 | 664 | end |
645 | 665 | |
646 | it "gets the correct resource" do | |
647 | expect(a_delete("/projects/3/star")).to have_been_made | |
648 | end | |
649 | ||
650 | it "returns information about the unstarred project" do | |
666 | it 'gets the correct resource' do | |
667 | expect(a_delete('/projects/3/star')).to have_been_made | |
668 | end | |
669 | ||
670 | it 'returns information about the unstarred project' do | |
651 | 671 | expect(@unstarred_project.id).to eq(3) |
652 | 672 | end |
653 | 673 | end |
654 | 674 | |
655 | describe ".user_projects" do | |
675 | describe '.user_projects' do | |
656 | 676 | let(:user_id) { 1 } |
657 | 677 | let(:project_id) { 1 } |
658 | 678 | |
659 | 679 | before do |
660 | stub_get("/users/#{user_id}/projects", "user_projects") | |
680 | stub_get("/users/#{user_id}/projects", 'user_projects') | |
661 | 681 | @user_projects = Gitlab.user_projects(user_id) |
662 | 682 | end |
663 | 683 | |
664 | it "gets the correct resource" do | |
684 | it 'gets the correct resource' do | |
665 | 685 | expect(a_get("/users/#{user_id}/projects")).to have_been_made |
666 | 686 | end |
667 | 687 | |
668 | it "returns a paginated response of projects" do | |
688 | it 'returns a paginated response of projects' do | |
669 | 689 | expect(@user_projects).to be_a Gitlab::PaginatedResponse |
670 | 690 | expect(@user_projects.first.id).to eq(project_id) |
671 | 691 | expect(@user_projects.first.owner.id).to eq(user_id) |
672 | 692 | end |
673 | 693 | end |
694 | ||
695 | describe '.upload_file' do | |
696 | let(:id) { 1 } | |
697 | let(:file) { File.open(File::NULL, 'r') } | |
698 | ||
699 | before do | |
700 | stub_post("/projects/#{id}/uploads", 'upload_file') | |
701 | @file = Gitlab.upload_file(id, file) | |
702 | end | |
703 | ||
704 | it 'gets the correct resource' do | |
705 | expect(a_post("/projects/#{id}/uploads")).to have_been_made | |
706 | end | |
707 | ||
708 | it 'returns information about the uploaded file' do | |
709 | expect(@file.alt).to eq('null') | |
710 | expect(@file.url).to eq('/uploads/f22e67e35e1bcb339058212c54bb8772/null') | |
711 | expect(@file.markdown).to eq('[null](/uploads/f22e67e35e1bcb339058212c54bb8772/null)') | |
712 | end | |
713 | end | |
714 | ||
715 | describe '.project_templates' do | |
716 | before do | |
717 | stub_get('/projects/3/templates/licenses', 'project_templates') | |
718 | @project_templates = Gitlab.project_templates(3, 'licenses') | |
719 | end | |
720 | ||
721 | it 'gets the correct resource' do | |
722 | expect(a_get('/projects/3/templates/licenses')).to have_been_made | |
723 | end | |
724 | ||
725 | it "returns a paginated response of project's templates" do | |
726 | expect(@project_templates).to be_a Gitlab::PaginatedResponse | |
727 | end | |
728 | end | |
729 | ||
730 | describe '.project_template' do | |
731 | context 'when dockerfiles' do | |
732 | before do | |
733 | stub_get('/projects/3/templates/dockerfiles/dock', 'dockerfile_project_template') | |
734 | @project_template = Gitlab.project_template(3, 'dockerfiles', 'dock') | |
735 | end | |
736 | ||
737 | it 'gets the correct resource' do | |
738 | expect(a_get('/projects/3/templates/dockerfiles/dock')).to have_been_made | |
739 | end | |
740 | end | |
741 | ||
742 | context 'when licenses' do | |
743 | before do | |
744 | stub_get('/projects/3/templates/licenses/mit', 'license_project_template') | |
745 | @project_template = Gitlab.project_template(3, 'licenses', 'mit') | |
746 | end | |
747 | ||
748 | it 'gets the correct resource' do | |
749 | expect(a_get('/projects/3/templates/licenses/mit')).to have_been_made | |
750 | end | |
751 | end | |
752 | end | |
674 | 753 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe Gitlab::Client do | |
5 | describe '.protected_tags' do | |
6 | before do | |
7 | stub_get('/projects/1/protected_tags', 'protected_tags') | |
8 | @protected_tags = Gitlab.protected_tags(1) | |
9 | end | |
10 | ||
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/1/protected_tags')).to have_been_made | |
13 | end | |
14 | ||
15 | it "returns a response of a project's protected_tags" do | |
16 | expect(@protected_tags).to be_a Gitlab::PaginatedResponse | |
17 | end | |
18 | end | |
19 | ||
20 | describe '.protected_tag' do | |
21 | before do | |
22 | stub_get('/projects/1/protected_tags/release-1-0', 'protected_tag') | |
23 | @protected_tag = Gitlab.protected_tag(1, 'release-1-0') | |
24 | end | |
25 | ||
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/1/protected_tags/release-1-0')).to have_been_made | |
28 | end | |
29 | ||
30 | it 'returns correct information about the protected_tag' do | |
31 | expect(@protected_tag.name).to eq 'release-1-0' | |
32 | end | |
33 | end | |
34 | ||
35 | describe '.protect_repository_tag' do | |
36 | before do | |
37 | stub_post('/projects/1/protected_tags', 'protected_tag') | |
38 | @protected_tag = Gitlab.protect_repository_tag(1, 'release-1-0') | |
39 | end | |
40 | ||
41 | it 'gets the correct resource' do | |
42 | expect(a_post('/projects/1/protected_tags') | |
43 | .with(body: { name: 'release-1-0' })).to have_been_made | |
44 | end | |
45 | ||
46 | it 'returns correct information about the protected repository tag' do | |
47 | expect(@protected_tag.name).to eq 'release-1-0' | |
48 | end | |
49 | end | |
50 | ||
51 | describe '.unprotect_repository_tag' do | |
52 | before do | |
53 | stub_delete('/projects/1/protected_tags/release-1-0', 'empty') | |
54 | Gitlab.unprotect_repository_tag(1, 'release-1-0') | |
55 | end | |
56 | ||
57 | it 'gets the correct resource' do | |
58 | expect(a_delete('/projects/1/protected_tags/release-1-0')).to have_been_made | |
59 | end | |
60 | end | |
61 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
7 | 9 | it { is_expected.to respond_to :repo_tree } |
8 | 10 | it { is_expected.to respond_to :repo_compare } |
9 | 11 | |
10 | describe ".tags" do | |
12 | describe '.tags' do | |
11 | 13 | before do |
12 | stub_get("/projects/3/repository/tags", "project_tags") | |
14 | stub_get('/projects/3/repository/tags', 'project_tags') | |
13 | 15 | @tags = Gitlab.tags(3) |
14 | 16 | end |
15 | 17 | |
16 | it "gets the correct resource" do | |
17 | expect(a_get("/projects/3/repository/tags")).to have_been_made | |
18 | it 'gets the correct resource' do | |
19 | expect(a_get('/projects/3/repository/tags')).to have_been_made | |
18 | 20 | end |
19 | 21 | |
20 | it "returns a paginated response of repository tags" do | |
22 | it 'returns a paginated response of repository tags' do | |
21 | 23 | expect(@tags).to be_a Gitlab::PaginatedResponse |
22 | expect(@tags.first.name).to eq("v2.8.2") | |
24 | expect(@tags.first.name).to eq('v2.8.2') | |
23 | 25 | end |
24 | 26 | end |
25 | 27 | |
26 | describe ".create_tag" do | |
27 | context "when lightweight" do | |
28 | describe '.create_tag' do | |
29 | context 'when lightweight' do | |
28 | 30 | before do |
29 | stub_post("/projects/3/repository/tags", "project_tag_lightweight") | |
31 | stub_post('/projects/3/repository/tags', 'project_tag_lightweight') | |
30 | 32 | @tag = Gitlab.create_tag(3, 'v1.0.0', '2695effb5807a22ff3d138d593fd856244e155e7') |
31 | 33 | end |
32 | 34 | |
33 | it "gets the correct resource" do | |
34 | expect(a_post("/projects/3/repository/tags")).to have_been_made | |
35 | it 'gets the correct resource' do | |
36 | expect(a_post('/projects/3/repository/tags')).to have_been_made | |
35 | 37 | end |
36 | 38 | |
37 | it "returns information about a new repository tag" do | |
38 | expect(@tag.name).to eq("v1.0.0") | |
39 | it 'returns information about a new repository tag' do | |
40 | expect(@tag.name).to eq('v1.0.0') | |
39 | 41 | expect(@tag.message).to eq(nil) |
40 | 42 | end |
41 | 43 | end |
42 | 44 | |
43 | context "when annotated" do | |
45 | context 'when annotated' do | |
44 | 46 | before do |
45 | stub_post("/projects/3/repository/tags", "project_tag_annotated") | |
47 | stub_post('/projects/3/repository/tags', 'project_tag_annotated') | |
46 | 48 | @tag = Gitlab.create_tag(3, 'v1.1.0', '2695effb5807a22ff3d138d593fd856244e155e7', 'Release 1.1.0') |
47 | 49 | end |
48 | 50 | |
49 | it "gets the correct resource" do | |
50 | expect(a_post("/projects/3/repository/tags")).to have_been_made | |
51 | it 'gets the correct resource' do | |
52 | expect(a_post('/projects/3/repository/tags')).to have_been_made | |
51 | 53 | end |
52 | 54 | |
53 | it "returns information about a new repository tag" do | |
54 | expect(@tag.name).to eq("v1.1.0") | |
55 | expect(@tag.message).to eq("Release 1.1.0") | |
55 | it 'returns information about a new repository tag' do | |
56 | expect(@tag.name).to eq('v1.1.0') | |
57 | expect(@tag.message).to eq('Release 1.1.0') | |
56 | 58 | end |
57 | 59 | end |
58 | 60 | end |
59 | 61 | |
60 | describe ".tree" do | |
62 | describe '.tree' do | |
61 | 63 | before do |
62 | stub_get("/projects/3/repository/tree", "tree") | |
64 | stub_get('/projects/3/repository/tree', 'tree') | |
63 | 65 | @tree = Gitlab.tree(3) |
64 | 66 | end |
65 | 67 | |
66 | it "gets the correct resource" do | |
67 | expect(a_get("/projects/3/repository/tree")).to have_been_made | |
68 | it 'gets the correct resource' do | |
69 | expect(a_get('/projects/3/repository/tree')).to have_been_made | |
68 | 70 | end |
69 | 71 | |
70 | it "returns a paginated response of repository tree files (root level)" do | |
72 | it 'returns a paginated response of repository tree files (root level)' do | |
71 | 73 | expect(@tree).to be_a Gitlab::PaginatedResponse |
72 | expect(@tree.first.name).to eq("app") | |
74 | expect(@tree.first.name).to eq('app') | |
73 | 75 | end |
74 | 76 | end |
75 | 77 | |
76 | describe ".compare" do | |
78 | describe '.compare' do | |
77 | 79 | before do |
78 | stub_get("/projects/3/repository/compare", "compare_merge_request_diff"). | |
79 | with(query: { from: "master", to: "feature" }) | |
80 | stub_get('/projects/3/repository/compare', 'compare_merge_request_diff') | |
81 | .with(query: { from: 'master', to: 'feature' }) | |
80 | 82 | @diff = Gitlab.compare(3, 'master', 'feature') |
81 | 83 | end |
82 | 84 | |
83 | it "gets the correct resource" do | |
84 | expect(a_get("/projects/3/repository/compare"). | |
85 | with(query: { from: "master", to: "feature" })).to have_been_made | |
85 | it 'gets the correct resource' do | |
86 | expect(a_get('/projects/3/repository/compare') | |
87 | .with(query: { from: 'master', to: 'feature' })).to have_been_made | |
86 | 88 | end |
87 | 89 | |
88 | it "gets diffs of a merge request" do | |
90 | it 'gets diffs of a merge request' do | |
89 | 91 | expect(@diff.diffs).to be_kind_of Array |
90 | expect(@diff.diffs.last["new_path"]).to eq "files/js/application.js" | |
92 | expect(@diff.diffs.last['new_path']).to eq 'files/js/application.js' | |
93 | end | |
94 | end | |
95 | ||
96 | describe '.merge_base' do | |
97 | before do | |
98 | stub_get('/projects/3/repository/merge_base', 'merge_base') | |
99 | .with(query: { refs: %w[master feature] }) | |
100 | @response = Gitlab.merge_base(3, %w[master feature]) | |
101 | end | |
102 | ||
103 | it 'gets the correct resource' do | |
104 | expect(a_get('/projects/3/repository/merge_base') | |
105 | .with(query: { refs: %w[master feature] })).to have_been_made | |
106 | end | |
107 | ||
108 | it 'gets common ancestor of the two refs' do | |
109 | expect(@response).to be_kind_of Gitlab::ObjectifiedHash | |
110 | expect(@response.id).to eq '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863' | |
91 | 111 | end |
92 | 112 | end |
93 | 113 | end |
0 | require "spec_helper" | |
0 | # frozen_string_literal: true | |
1 | ||
2 | require 'spec_helper' | |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".file_contents" do | |
5 | describe '.file_contents' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/repository/files/Gemfile/raw?ref=master", "raw_file") | |
6 | @file_contents = Gitlab.file_contents(3, "Gemfile") | |
7 | stub_get('/projects/3/repository/files/Gemfile/raw?ref=master', 'raw_file') | |
8 | @file_contents = Gitlab.file_contents(3, 'Gemfile') | |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/repository/files/Gemfile/raw?ref=master")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/repository/files/Gemfile/raw?ref=master')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | it "returns file contents" do | |
15 | it 'returns file contents' do | |
14 | 16 | expect(@file_contents).to eq("source 'https://rubygems.org'\ngem 'rails', '4.1.2'\n") |
15 | 17 | end |
16 | 18 | end |
17 | 19 | |
18 | describe ".get_file" do | |
20 | describe '.get_file' do | |
19 | 21 | before do |
20 | stub_get("/projects/3/repository/files/README%2Emd?ref=master", "get_repository_file") | |
22 | stub_get('/projects/3/repository/files/README%2Emd?ref=master', 'get_repository_file') | |
21 | 23 | @file = Gitlab.get_file(3, 'README.md', 'master') |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_get("/projects/3/repository/files/README%2Emd?ref=master")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/3/repository/files/README%2Emd?ref=master')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | it "returns the base64 encoded file" do | |
29 | expect(@file.file_path).to eq "README.md" | |
30 | expect(@file.ref).to eq "master" | |
30 | it 'returns the base64 encoded file' do | |
31 | expect(@file.file_path).to eq 'README.md' | |
32 | expect(@file.ref).to eq 'master' | |
31 | 33 | expect(@file.content).to eq "VGhpcyBpcyBhICpSRUFETUUqIQ==\n" |
32 | 34 | end |
33 | 35 | end |
34 | 36 | |
35 | describe ".create_file" do | |
36 | let(:api_path) { "/projects/3/repository/files/path" } | |
37 | let!(:request_stub) { stub_post(api_path, "repository_file") } | |
38 | let!(:file) { Gitlab.create_file(3, "path", "branch", "content", "commit message", author_name: "joe") } | |
37 | describe '.create_file' do | |
38 | let(:api_path) { '/projects/3/repository/files/path' } | |
39 | let!(:request_stub) { stub_post(api_path, 'repository_file') } | |
40 | let!(:file) { Gitlab.create_file(3, 'path', 'branch', 'content', 'commit message', author_name: 'joe') } | |
39 | 41 | |
40 | it "creates the correct resource" do | |
42 | it 'creates the correct resource' do | |
41 | 43 | expected_parameters = { |
42 | author_name: "joe", | |
43 | branch: "branch", | |
44 | commit_message: "commit message" | |
44 | author_name: 'joe', | |
45 | branch: 'branch', | |
46 | commit_message: 'commit message' | |
45 | 47 | } |
46 | 48 | expect(a_post(api_path).with(body: hash_including(expected_parameters))).to have_been_made |
47 | 49 | end |
48 | 50 | |
49 | it "returns information about the new file" do | |
50 | expect(file.file_path).to eq "path" | |
51 | expect(file.branch_name).to eq "branch" | |
51 | it 'returns information about the new file' do | |
52 | expect(file.file_path).to eq 'path' | |
53 | expect(file.branch_name).to eq 'branch' | |
52 | 54 | end |
53 | 55 | end |
54 | 56 | |
55 | describe ".edit_file" do | |
56 | let(:api_path) { "/projects/3/repository/files/path" } | |
57 | let!(:request_stub) { stub_put(api_path, "repository_file") } | |
58 | let!(:file) { Gitlab.edit_file(3, "path", "branch", "content", "commit message", author_name: "joe") } | |
57 | describe '.edit_file' do | |
58 | let(:api_path) { '/projects/3/repository/files/path' } | |
59 | let!(:request_stub) { stub_put(api_path, 'repository_file') } | |
60 | let!(:file) { Gitlab.edit_file(3, 'path', 'branch', 'content', 'commit message', author_name: 'joe') } | |
59 | 61 | |
60 | it "updates the correct resource" do | |
62 | it 'updates the correct resource' do | |
61 | 63 | expected_parameters = { |
62 | author_name: "joe", | |
63 | branch: "branch", | |
64 | commit_message: "commit message" | |
64 | author_name: 'joe', | |
65 | branch: 'branch', | |
66 | commit_message: 'commit message' | |
65 | 67 | } |
66 | 68 | expect(a_put(api_path).with(body: hash_including(expected_parameters))).to have_been_made |
67 | 69 | end |
68 | 70 | |
69 | it "returns information about the new file" do | |
70 | expect(file.file_path).to eq "path" | |
71 | expect(file.branch_name).to eq "branch" | |
71 | it 'returns information about the new file' do | |
72 | expect(file.file_path).to eq 'path' | |
73 | expect(file.branch_name).to eq 'branch' | |
72 | 74 | end |
73 | 75 | end |
74 | 76 | |
75 | describe ".remove_file" do | |
76 | let(:api_path) { "/projects/3/repository/files/path" } | |
77 | let!(:request_stub) { stub_delete(api_path, "repository_file") } | |
78 | let!(:file) { Gitlab.remove_file(3, "path", "branch", "commit message", author_name: "joe") } | |
77 | describe '.remove_file' do | |
78 | let(:api_path) { '/projects/3/repository/files/path' } | |
79 | let!(:request_stub) { stub_delete(api_path, 'repository_file') } | |
80 | let!(:file) { Gitlab.remove_file(3, 'path', 'branch', 'commit message', author_name: 'joe') } | |
79 | 81 | |
80 | it "updates the correct resource" do | |
82 | it 'updates the correct resource' do | |
81 | 83 | expected_parameters = { |
82 | author_name: "joe", | |
83 | branch: "branch", | |
84 | commit_message: "commit message" | |
84 | author_name: 'joe', | |
85 | branch: 'branch', | |
86 | commit_message: 'commit message' | |
85 | 87 | } |
86 | 88 | expect(a_delete(api_path).with(body: hash_including(expected_parameters))).to have_been_made |
87 | 89 | end |
88 | 90 | |
89 | it "returns information about the new file" do | |
90 | expect(file.file_path).to eq "path" | |
91 | expect(file.branch_name).to eq "branch" | |
91 | it 'returns information about the new file' do | |
92 | expect(file.file_path).to eq 'path' | |
93 | expect(file.branch_name).to eq 'branch' | |
92 | 94 | end |
93 | 95 | end |
94 | 96 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe Gitlab::Client do | |
5 | describe '.edit_submodule' do | |
6 | let(:api_path) { '/projects/3/repository/submodules/submodule' } | |
7 | let(:options) do | |
8 | { | |
9 | branch: 'branch', | |
10 | commit_sha: '3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88', | |
11 | commit_message: 'commit message' | |
12 | } | |
13 | end | |
14 | ||
15 | before do | |
16 | stub_put(api_path, 'repository_submodule') | |
17 | @submodule = Gitlab.edit_submodule(3, 'submodule', options) | |
18 | end | |
19 | ||
20 | it 'updates the correct resource' do | |
21 | expect(a_put(api_path).with(body: hash_including(options))).to have_been_made | |
22 | end | |
23 | ||
24 | it 'returns information about the updated submodule' do | |
25 | expect(@submodule.short_id).to eq 'ed899a2f4b5' | |
26 | expect(@submodule.status).to be_nil | |
27 | end | |
28 | end | |
29 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | ||
4 | describe ".runners" do | |
5 | describe '.runners' do | |
5 | 6 | before do |
6 | stub_get("/runners", "runners") | |
7 | stub_get('/runners', 'runners') | |
7 | 8 | end |
8 | 9 | |
9 | 10 | context 'without scope' do |
11 | 12 | @runner = Gitlab.runners |
12 | 13 | end |
13 | 14 | |
14 | it "gets the correct resource" do | |
15 | expect(a_get("/runners")).to have_been_made | |
15 | it 'gets the correct resource' do | |
16 | expect(a_get('/runners')).to have_been_made | |
16 | 17 | end |
17 | 18 | |
18 | it "returns a paginated response of runners" do | |
19 | it 'returns a paginated response of runners' do | |
19 | 20 | expect(@runner).to be_a Gitlab::PaginatedResponse |
20 | 21 | expect(@runner.first.id).to eq(6) |
21 | 22 | expect(@runner.first.description).to eq('test-1-20150125') |
24 | 25 | |
25 | 26 | context 'with scope' do |
26 | 27 | before do |
27 | stub_get("/runners?scope=online", "runners") | |
28 | @runner = Gitlab.runners({scope: :online}) | |
28 | stub_get('/runners?scope=online', 'runners') | |
29 | @runner = Gitlab.runners(scope: :online) | |
29 | 30 | end |
30 | 31 | |
31 | it "gets the correct resource" do | |
32 | expect(a_get("/runners").with(query: { scope: :online })).to have_been_made | |
32 | it 'gets the correct resource' do | |
33 | expect(a_get('/runners').with(query: { scope: :online })).to have_been_made | |
33 | 34 | end |
34 | 35 | |
35 | it "returns a paginated response of runners" do | |
36 | it 'returns a paginated response of runners' do | |
36 | 37 | expect(@runner).to be_a Gitlab::PaginatedResponse |
37 | 38 | expect(@runner.first.id).to eq(6) |
38 | 39 | expect(@runner.first.description).to eq('test-1-20150125') |
39 | 40 | end |
40 | 41 | end |
41 | ||
42 | 42 | end |
43 | 43 | |
44 | describe ".all_runners" do | |
44 | describe '.all_runners' do | |
45 | 45 | before do |
46 | stub_get("/runners/all", "runners") | |
46 | stub_get('/runners/all', 'runners') | |
47 | 47 | end |
48 | 48 | |
49 | 49 | context 'without scope' do |
51 | 51 | @runner = Gitlab.all_runners |
52 | 52 | end |
53 | 53 | |
54 | it "gets the correct resource" do | |
55 | expect(a_get("/runners/all")).to have_been_made | |
54 | it 'gets the correct resource' do | |
55 | expect(a_get('/runners/all')).to have_been_made | |
56 | 56 | end |
57 | 57 | |
58 | it "returns a paginated response of runners" do | |
58 | it 'returns a paginated response of runners' do | |
59 | 59 | expect(@runner).to be_a Gitlab::PaginatedResponse |
60 | 60 | expect(@runner.first.id).to eq(6) |
61 | 61 | expect(@runner.first.description).to eq('test-1-20150125') |
64 | 64 | |
65 | 65 | context 'with scope' do |
66 | 66 | before do |
67 | stub_get("/runners/all?scope=online", "runners") | |
68 | @runner = Gitlab.all_runners({scope: :online}) | |
67 | stub_get('/runners/all?scope=online', 'runners') | |
68 | @runner = Gitlab.all_runners(scope: :online) | |
69 | 69 | end |
70 | 70 | |
71 | it "gets the correct resource" do | |
72 | expect(a_get("/runners/all").with(query: { scope: :online })).to have_been_made | |
71 | it 'gets the correct resource' do | |
72 | expect(a_get('/runners/all').with(query: { scope: :online })).to have_been_made | |
73 | 73 | end |
74 | 74 | |
75 | it "returns a paginated response of runners" do | |
75 | it 'returns a paginated response of runners' do | |
76 | 76 | expect(@runner).to be_a Gitlab::PaginatedResponse |
77 | 77 | expect(@runner.first.id).to eq(6) |
78 | 78 | expect(@runner.first.description).to eq('test-1-20150125') |
80 | 80 | end |
81 | 81 | end |
82 | 82 | |
83 | describe ".runner" do | |
83 | describe '.runner' do | |
84 | 84 | before do |
85 | stub_get("/runners/6", "runner") | |
85 | stub_get('/runners/6', 'runner') | |
86 | 86 | @runners = Gitlab.runner(6) |
87 | 87 | end |
88 | 88 | |
89 | it "gets the correct resource" do | |
90 | expect(a_get("/runners/6")).to have_been_made | |
89 | it 'gets the correct resource' do | |
90 | expect(a_get('/runners/6')).to have_been_made | |
91 | 91 | end |
92 | 92 | |
93 | it "returns a response of a runner" do | |
93 | it 'returns a response of a runner' do | |
94 | 94 | expect(@runners).to be_a Gitlab::ObjectifiedHash |
95 | 95 | expect(@runners.id).to eq(6) |
96 | 96 | expect(@runners.description).to eq('test-1-20150125') |
97 | 97 | end |
98 | 98 | end |
99 | 99 | |
100 | describe ".update_runner" do | |
100 | describe '.update_runner' do | |
101 | 101 | before do |
102 | stub_put("/runners/6", "runner_edit").with(query: { description: "abcefg" }) | |
103 | @runner = Gitlab.update_runner(6, description: "abcefg" ) | |
102 | stub_put('/runners/6', 'runner_edit').with(query: { description: 'abcefg' }) | |
103 | @runner = Gitlab.update_runner(6, description: 'abcefg') | |
104 | 104 | end |
105 | 105 | |
106 | it "gets the correct resource" do | |
107 | expect(a_put("/runners/6").with(query: { description: "abcefg" })).to have_been_made | |
106 | it 'gets the correct resource' do | |
107 | expect(a_put('/runners/6').with(query: { description: 'abcefg' })).to have_been_made | |
108 | 108 | end |
109 | 109 | |
110 | it "returns an updated response of a runner" do | |
110 | it 'returns an updated response of a runner' do | |
111 | 111 | expect(@runner).to be_a Gitlab::ObjectifiedHash |
112 | 112 | expect(@runner.description).to eq('abcefg') |
113 | 113 | end |
114 | 114 | end |
115 | 115 | |
116 | describe ".delete_runner" do | |
116 | describe '.delete_runner' do | |
117 | 117 | before do |
118 | stub_delete("/runners/6", "runner_delete") | |
118 | stub_delete('/runners/6', 'runner_delete') | |
119 | 119 | @runner = Gitlab.delete_runner(6) |
120 | 120 | end |
121 | 121 | |
122 | it "gets the correct resource" do | |
123 | expect(a_delete("/runners/6")).to have_been_made | |
122 | it 'gets the correct resource' do | |
123 | expect(a_delete('/runners/6')).to have_been_made | |
124 | 124 | end |
125 | 125 | |
126 | it "returns a response of the deleted runner" do | |
126 | it 'returns a response of the deleted runner' do | |
127 | 127 | expect(@runner).to be_a Gitlab::ObjectifiedHash |
128 | 128 | expect(@runner.id).to eq(6) |
129 | 129 | end |
134 | 134 | stub_get('/runners/1/jobs', 'runner_jobs') |
135 | 135 | @jobs = Gitlab.runner_jobs(1) |
136 | 136 | end |
137 | ||
137 | 138 | it 'gets the correct resource' do |
138 | 139 | expect(a_get('/runners/1/jobs')).to have_been_made |
139 | 140 | end |
140 | 141 | end |
141 | 142 | |
142 | describe ".project_runners" do | |
143 | describe '.project_runners' do | |
143 | 144 | before do |
144 | stub_get("/projects/1/runners", "project_runners") | |
145 | stub_get('/projects/1/runners', 'project_runners') | |
145 | 146 | @runners = Gitlab.project_runners(1) |
146 | 147 | end |
147 | 148 | |
148 | it "gets the correct resource" do | |
149 | expect(a_get("/projects/1/runners")).to have_been_made | |
149 | it 'gets the correct resource' do | |
150 | expect(a_get('/projects/1/runners')).to have_been_made | |
150 | 151 | end |
151 | 152 | |
152 | it "returns a paginated response of runners" do | |
153 | it 'returns a paginated response of runners' do | |
153 | 154 | expect(@runners).to be_a Gitlab::PaginatedResponse |
154 | 155 | expect(@runners.first.id).to eq(8) |
155 | 156 | expect(@runners.first.description).to eq('test-2-20150125') |
156 | 157 | end |
157 | 158 | end |
158 | 159 | |
159 | describe ".project_enable_runner" do | |
160 | describe '.project_enable_runner' do | |
160 | 161 | before do |
161 | stub_post("/projects/1/runners", "runner") | |
162 | stub_post('/projects/1/runners', 'runner') | |
162 | 163 | @runner = Gitlab.project_enable_runner(1, 6) |
163 | 164 | end |
164 | 165 | |
165 | it "gets the correct resource" do | |
166 | expect(a_post("/projects/1/runners")).to have_been_made | |
166 | it 'gets the correct resource' do | |
167 | expect(a_post('/projects/1/runners')).to have_been_made | |
167 | 168 | end |
168 | 169 | |
169 | it "returns a response of the enabled runner" do | |
170 | it 'returns a response of the enabled runner' do | |
170 | 171 | expect(@runner).to be_a Gitlab::ObjectifiedHash |
171 | 172 | expect(@runner.id).to eq(6) |
172 | 173 | expect(@runner.description).to eq('test-1-20150125') |
173 | 174 | end |
174 | 175 | end |
175 | 176 | |
176 | describe ".project_disable_runner" do | |
177 | describe '.project_disable_runner' do | |
177 | 178 | before do |
178 | stub_delete("/projects/1/runners/6", "runner") | |
179 | stub_delete('/projects/1/runners/6', 'runner') | |
179 | 180 | @runner = Gitlab.project_disable_runner(1, 6) |
180 | 181 | end |
181 | 182 | |
182 | it "gets the correct resource" do | |
183 | expect(a_delete("/projects/1/runners/6")).to have_been_made | |
183 | it 'gets the correct resource' do | |
184 | expect(a_delete('/projects/1/runners/6')).to have_been_made | |
184 | 185 | end |
185 | 186 | |
186 | it "returns a response of the disabled runner" do | |
187 | it 'returns a response of the disabled runner' do | |
187 | 188 | expect(@runner).to be_a Gitlab::ObjectifiedHash |
188 | 189 | expect(@runner.id).to eq(6) |
189 | 190 | expect(@runner.description).to eq('test-1-20150125') |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".service" do | |
5 | describe '.service' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/services/redmine", "service") | |
7 | stub_get('/projects/3/services/redmine', 'service') | |
6 | 8 | @service = Gitlab.service(3, :redmine) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/services/redmine")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/services/redmine')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | it "returns a information about a service of project" do | |
15 | it 'returns a information about a service of project' do | |
14 | 16 | expect(@service.id).to eq 38 |
15 | expect(@service.title).to eq("Redmine") | |
16 | expect(@service.properties.project_url).to eq("https://example.com/projects/test_project/issue") | |
17 | expect(@service.title).to eq('Redmine') | |
18 | expect(@service.properties.project_url).to eq('https://example.com/projects/test_project/issue') | |
17 | 19 | end |
18 | 20 | end |
19 | 21 | |
20 | describe ".change_service" do | |
22 | describe '.change_service' do | |
21 | 23 | before do |
22 | stub_put("/projects/3/services/redmine", "service") | |
24 | stub_put('/projects/3/services/redmine', 'service') | |
23 | 25 | @service = Gitlab.change_service(3, :redmine, new_issue_url: 'https://example.com/projects/test_project/issues/new', |
24 | 26 | project_url: 'https://example.com/projects/test_project/issues', |
25 | 27 | issues_url: 'https://example.com/issues/:id') |
26 | 28 | end |
27 | 29 | |
28 | it "gets the correct resource" do | |
29 | body = {new_issue_url: 'https://example.com/projects/test_project/issues/new', | |
30 | project_url: 'https://example.com/projects/test_project/issues', | |
31 | issues_url: 'https://example.com/issues/:id'} | |
32 | expect(a_put("/projects/3/services/redmine").with(body: body)).to have_been_made | |
30 | it 'gets the correct resource' do | |
31 | body = { new_issue_url: 'https://example.com/projects/test_project/issues/new', | |
32 | project_url: 'https://example.com/projects/test_project/issues', | |
33 | issues_url: 'https://example.com/issues/:id' } | |
34 | expect(a_put('/projects/3/services/redmine').with(body: body)).to have_been_made | |
33 | 35 | end |
34 | 36 | |
35 | it "returns information about a new service" do | |
37 | it 'returns information about a new service' do | |
36 | 38 | expect(@service).to be_truthy |
37 | 39 | end |
38 | 40 | end |
39 | 41 | |
40 | describe ".delete_servoce" do | |
42 | describe '.delete_servoce' do | |
41 | 43 | before do |
42 | stub_delete("/projects/3/services/redmine", "service") | |
44 | stub_delete('/projects/3/services/redmine', 'service') | |
43 | 45 | @service = Gitlab.delete_service(3, :redmine) |
44 | 46 | end |
45 | 47 | |
46 | it "gets the correct resource" do | |
47 | expect(a_delete("/projects/3/services/redmine")).to have_been_made | |
48 | it 'gets the correct resource' do | |
49 | expect(a_delete('/projects/3/services/redmine')).to have_been_made | |
48 | 50 | end |
49 | 51 | |
50 | it "returns information about a deleted service" do | |
52 | it 'returns information about a deleted service' do | |
51 | 53 | expect(@service).to be_truthy |
52 | 54 | end |
53 | 55 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".sidekiq_queue_metrics" do | |
5 | describe '.sidekiq_queue_metrics' do | |
4 | 6 | before do |
5 | stub_get("/sidekiq/queue_metrics", 'sidekiq_queue_metrics') | |
7 | stub_get('/sidekiq/queue_metrics', 'sidekiq_queue_metrics') | |
6 | 8 | @sidekiq_queue_metrics = Gitlab.sidekiq_queue_metrics |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/sidekiq/queue_metrics")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/sidekiq/queue_metrics')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | it "returns a information about a sidekiq default queue" do | |
15 | it 'returns a information about a sidekiq default queue' do | |
14 | 16 | expect(@sidekiq_queue_metrics.queues.default.backlog).to eq 0 |
15 | 17 | expect(@sidekiq_queue_metrics.queues.default.latency).to eq 0 |
16 | 18 | end |
17 | 19 | end |
18 | 20 | |
19 | describe ".sidekiq_process_metrics" do | |
21 | describe '.sidekiq_process_metrics' do | |
20 | 22 | before do |
21 | stub_get("/sidekiq/process_metrics", 'sidekiq_process_metrics') | |
23 | stub_get('/sidekiq/process_metrics', 'sidekiq_process_metrics') | |
22 | 24 | @sidekiq_process_metrics = Gitlab.sidekiq_process_metrics |
23 | 25 | end |
24 | 26 | |
25 | it "gets the correct resource" do | |
26 | expect(a_get("/sidekiq/process_metrics")).to have_been_made | |
27 | it 'gets the correct resource' do | |
28 | expect(a_get('/sidekiq/process_metrics')).to have_been_made | |
27 | 29 | end |
28 | 30 | |
29 | it "returns a information about a sidekiq process metrics" do | |
31 | it 'returns a information about a sidekiq process metrics' do | |
30 | 32 | expect(@sidekiq_process_metrics.processes.first['busy']).to eq 0 |
31 | 33 | end |
32 | 34 | end |
33 | 35 | |
34 | describe ".sidekiq_job_stats" do | |
36 | describe '.sidekiq_job_stats' do | |
35 | 37 | before do |
36 | stub_get("/sidekiq/job_stats", 'sidekiq_job_stats') | |
38 | stub_get('/sidekiq/job_stats', 'sidekiq_job_stats') | |
37 | 39 | @sidekiq_job_stats = Gitlab.sidekiq_job_stats |
38 | 40 | end |
39 | 41 | |
40 | it "gets the correct resource" do | |
41 | expect(a_get("/sidekiq/job_stats")).to have_been_made | |
42 | it 'gets the correct resource' do | |
43 | expect(a_get('/sidekiq/job_stats')).to have_been_made | |
42 | 44 | end |
43 | 45 | |
44 | it "returns a information about a sidekiq process metrics" do | |
46 | it 'returns a information about a sidekiq process metrics' do | |
45 | 47 | expect(@sidekiq_job_stats.jobs.processed).to eq 2 |
46 | 48 | end |
47 | 49 | end |
48 | 50 | |
49 | describe ".sidekiq_compound_metrics" do | |
51 | describe '.sidekiq_compound_metrics' do | |
50 | 52 | before do |
51 | stub_get("/sidekiq/compound_metrics", 'sidekiq_compound_metrics') | |
53 | stub_get('/sidekiq/compound_metrics', 'sidekiq_compound_metrics') | |
52 | 54 | @sidekiq_compound_metrics = Gitlab.sidekiq_compound_metrics |
53 | 55 | end |
54 | 56 | |
55 | it "gets the correct resource" do | |
56 | expect(a_get("/sidekiq/compound_metrics")).to have_been_made | |
57 | it 'gets the correct resource' do | |
58 | expect(a_get('/sidekiq/compound_metrics')).to have_been_made | |
57 | 59 | end |
58 | 60 | |
59 | it "returns a information about a sidekiq process metrics" do | |
61 | it 'returns a information about a sidekiq process metrics' do | |
60 | 62 | expect(@sidekiq_compound_metrics.jobs.processed).to eq 2 |
61 | 63 | end |
62 | 64 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".snippets" do | |
5 | describe '.snippets' do | |
4 | 6 | before do |
5 | stub_get("/projects/3/snippets", "snippets") | |
7 | stub_get('/projects/3/snippets', 'snippets') | |
6 | 8 | @snippets = Gitlab.snippets(3) |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/projects/3/snippets")).to have_been_made | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/3/snippets')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of project's snippets" do |
14 | 16 | expect(@snippets).to be_a Gitlab::PaginatedResponse |
15 | expect(@snippets.first.file_name).to eq("mailer_test.rb") | |
17 | expect(@snippets.first.file_name).to eq('mailer_test.rb') | |
16 | 18 | end |
17 | 19 | end |
18 | 20 | |
19 | describe ".snippet" do | |
21 | describe '.snippet' do | |
20 | 22 | before do |
21 | stub_get("/projects/3/snippets/1", "snippet") | |
23 | stub_get('/projects/3/snippets/1', 'snippet') | |
22 | 24 | @snippet = Gitlab.snippet(3, 1) |
23 | 25 | end |
24 | 26 | |
25 | it "gets the correct resource" do | |
26 | expect(a_get("/projects/3/snippets/1")).to have_been_made | |
27 | it 'gets the correct resource' do | |
28 | expect(a_get('/projects/3/snippets/1')).to have_been_made | |
27 | 29 | end |
28 | 30 | |
29 | it "returns information about a snippet" do | |
30 | expect(@snippet.file_name).to eq("mailer_test.rb") | |
31 | expect(@snippet.author.name).to eq("John Smith") | |
31 | it 'returns information about a snippet' do | |
32 | expect(@snippet.file_name).to eq('mailer_test.rb') | |
33 | expect(@snippet.author.name).to eq('John Smith') | |
32 | 34 | end |
33 | 35 | end |
34 | 36 | |
35 | describe ".create_snippet" do | |
37 | describe '.create_snippet' do | |
36 | 38 | before do |
37 | stub_post("/projects/3/snippets", "snippet") | |
39 | stub_post('/projects/3/snippets', 'snippet') | |
38 | 40 | @snippet = Gitlab.create_snippet(3, title: 'API', file_name: 'api.rb', code: 'code', visibility: 'public') |
39 | 41 | end |
40 | 42 | |
41 | it "gets the correct resource" do | |
43 | it 'gets the correct resource' do | |
42 | 44 | body = { title: 'API', file_name: 'api.rb', code: 'code', visibility: 'public' } |
43 | expect(a_post("/projects/3/snippets").with(body: body)).to have_been_made | |
45 | expect(a_post('/projects/3/snippets').with(body: body)).to have_been_made | |
44 | 46 | end |
45 | 47 | |
46 | it "returns information about a new snippet" do | |
47 | expect(@snippet.file_name).to eq("mailer_test.rb") | |
48 | expect(@snippet.author.name).to eq("John Smith") | |
48 | it 'returns information about a new snippet' do | |
49 | expect(@snippet.file_name).to eq('mailer_test.rb') | |
50 | expect(@snippet.author.name).to eq('John Smith') | |
49 | 51 | end |
50 | 52 | end |
51 | 53 | |
52 | describe ".edit_snippet" do | |
54 | describe '.edit_snippet' do | |
53 | 55 | before do |
54 | stub_put("/projects/3/snippets/1", "snippet") | |
56 | stub_put('/projects/3/snippets/1', 'snippet') | |
55 | 57 | @snippet = Gitlab.edit_snippet(3, 1, file_name: 'mailer_test.rb') |
56 | 58 | end |
57 | 59 | |
58 | it "gets the correct resource" do | |
59 | expect(a_put("/projects/3/snippets/1"). | |
60 | with(body: { file_name: 'mailer_test.rb' })).to have_been_made | |
60 | it 'gets the correct resource' do | |
61 | expect(a_put('/projects/3/snippets/1') | |
62 | .with(body: { file_name: 'mailer_test.rb' })).to have_been_made | |
61 | 63 | end |
62 | 64 | |
63 | it "returns information about an edited snippet" do | |
64 | expect(@snippet.file_name).to eq("mailer_test.rb") | |
65 | expect(@snippet.author.name).to eq("John Smith") | |
65 | it 'returns information about an edited snippet' do | |
66 | expect(@snippet.file_name).to eq('mailer_test.rb') | |
67 | expect(@snippet.author.name).to eq('John Smith') | |
66 | 68 | end |
67 | 69 | end |
68 | 70 | |
69 | describe ".delete_snippet" do | |
71 | describe '.delete_snippet' do | |
70 | 72 | before do |
71 | stub_delete("/projects/3/snippets/1", "snippet") | |
73 | stub_delete('/projects/3/snippets/1', 'snippet') | |
72 | 74 | @snippet = Gitlab.delete_snippet(3, 1) |
73 | 75 | end |
74 | 76 | |
75 | it "gets the correct resource" do | |
76 | expect(a_delete("/projects/3/snippets/1")).to have_been_made | |
77 | it 'gets the correct resource' do | |
78 | expect(a_delete('/projects/3/snippets/1')).to have_been_made | |
77 | 79 | end |
78 | 80 | |
79 | it "returns information about a deleted snippet" do | |
80 | expect(@snippet.file_name).to eq("mailer_test.rb") | |
81 | expect(@snippet.author.name).to eq("John Smith") | |
81 | it 'returns information about a deleted snippet' do | |
82 | expect(@snippet.file_name).to eq('mailer_test.rb') | |
83 | expect(@snippet.author.name).to eq('John Smith') | |
82 | 84 | end |
83 | 85 | end |
84 | 86 | |
85 | describe ".snippet_content" do | |
87 | describe '.snippet_content' do | |
86 | 88 | before do |
87 | stub_get("/projects/3/snippets/1/raw", "snippet_content") | |
89 | stub_get('/projects/3/snippets/1/raw', 'snippet_content') | |
88 | 90 | @snippet_content = Gitlab.snippet_content(3, 1) |
89 | 91 | end |
90 | 92 | |
91 | it "gets the correct resource" do | |
92 | expect(a_get("/projects/3/snippets/1/raw")).to have_been_made | |
93 | it 'gets the correct resource' do | |
94 | expect(a_get('/projects/3/snippets/1/raw')).to have_been_made | |
93 | 95 | end |
94 | 96 | |
95 | it "returns raw content of a snippet" do | |
97 | it 'returns raw content of a snippet' do | |
96 | 98 | expect(@snippet_content).to eq("#!/usr/bin/env ruby\n\nputs \"Cool snippet!\"\n") |
97 | 99 | end |
98 | 100 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
5 | 7 | it { is_expected.to respond_to :system_hook } |
6 | 8 | it { is_expected.to respond_to :delete_system_hook } |
7 | 9 | |
8 | describe ".hooks" do | |
10 | describe '.hooks' do | |
9 | 11 | before do |
10 | stub_get("/hooks", "system_hooks") | |
12 | stub_get('/hooks', 'system_hooks') | |
11 | 13 | @hooks = Gitlab.hooks |
12 | 14 | end |
13 | 15 | |
14 | it "gets the correct resource" do | |
15 | expect(a_get("/hooks")).to have_been_made | |
16 | it 'gets the correct resource' do | |
17 | expect(a_get('/hooks')).to have_been_made | |
16 | 18 | end |
17 | 19 | |
18 | it "returns a paginated response of system hooks" do | |
20 | it 'returns a paginated response of system hooks' do | |
19 | 21 | expect(@hooks).to be_a Gitlab::PaginatedResponse |
20 | expect(@hooks.first.url).to eq("http://example.com/hook") | |
22 | expect(@hooks.first.url).to eq('http://example.com/hook') | |
21 | 23 | end |
22 | 24 | end |
23 | 25 | |
24 | describe ".add_hook" do | |
26 | describe '.add_hook' do | |
25 | 27 | before do |
26 | stub_post("/hooks", "system_hook") | |
27 | @hook = Gitlab.add_hook("http://example.com/hook", token: 'secret-token') | |
28 | stub_post('/hooks', 'system_hook') | |
29 | @hook = Gitlab.add_hook('http://example.com/hook', token: 'secret-token') | |
28 | 30 | end |
29 | 31 | |
30 | it "gets the correct resource" do | |
31 | expect(a_post("/hooks").with(body: hash_including(token: 'secret-token'))).to have_been_made | |
32 | it 'gets the correct resource' do | |
33 | expect(a_post('/hooks').with(body: hash_including(token: 'secret-token'))).to have_been_made | |
32 | 34 | end |
33 | 35 | |
34 | it "returns information about a added system hook" do | |
35 | expect(@hook.url).to eq("http://example.com/hook") | |
36 | it 'returns information about a added system hook' do | |
37 | expect(@hook.url).to eq('http://example.com/hook') | |
36 | 38 | end |
37 | 39 | end |
38 | 40 | |
39 | describe ".hook" do | |
41 | describe '.hook' do | |
40 | 42 | before do |
41 | stub_get("/hooks/3", "system_hook") | |
43 | stub_get('/hooks/3', 'system_hook') | |
42 | 44 | @hook = Gitlab.hook(3) |
43 | 45 | end |
44 | 46 | |
45 | it "gets the correct resource" do | |
46 | expect(a_get("/hooks/3")).to have_been_made | |
47 | it 'gets the correct resource' do | |
48 | expect(a_get('/hooks/3')).to have_been_made | |
47 | 49 | end |
48 | 50 | |
49 | it "returns information about a added system hook" do | |
50 | expect(@hook.url).to eq("http://example.com/hook") | |
51 | it 'returns information about a added system hook' do | |
52 | expect(@hook.url).to eq('http://example.com/hook') | |
51 | 53 | end |
52 | 54 | end |
53 | 55 | |
54 | describe ".delete_hook" do | |
56 | describe '.delete_hook' do | |
55 | 57 | before do |
56 | stub_delete("/hooks/3", "system_hook") | |
58 | stub_delete('/hooks/3', 'system_hook') | |
57 | 59 | @hook = Gitlab.delete_hook(3) |
58 | 60 | end |
59 | 61 | |
60 | it "gets the correct resource" do | |
61 | expect(a_delete("/hooks/3")).to have_been_made | |
62 | it 'gets the correct resource' do | |
63 | expect(a_delete('/hooks/3')).to have_been_made | |
62 | 64 | end |
63 | 65 | |
64 | it "returns information about a deleted system hook" do | |
65 | expect(@hook.url).to eq("http://example.com/hook") | |
66 | it 'returns information about a deleted system hook' do | |
67 | expect(@hook.url).to eq('http://example.com/hook') | |
66 | 68 | end |
67 | 69 | end |
68 | 70 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
9 | 11 | |
10 | 12 | describe '.tags' do |
11 | 13 | before do |
12 | stub_get("/projects/3/repository/tags", "tags") | |
14 | stub_get('/projects/3/repository/tags', 'tags') | |
13 | 15 | @tags = Gitlab.tags(3) |
14 | 16 | end |
15 | 17 | |
16 | it "gets the correct resource" do | |
17 | expect(a_get("/projects/3/repository/tags")).to have_been_made | |
18 | it 'gets the correct resource' do | |
19 | expect(a_get('/projects/3/repository/tags')).to have_been_made | |
18 | 20 | end |
19 | 21 | |
20 | it "returns a paginated response of repository tags" do | |
22 | it 'returns a paginated response of repository tags' do | |
21 | 23 | expect(@tags).to be_a Gitlab::PaginatedResponse |
22 | 24 | expect(@tags.map(&:name)).to eq(%w[0.0.2 0.0.1]) |
23 | 25 | end |
24 | 26 | end |
25 | 27 | |
26 | describe ".tag" do | |
28 | describe '.tag' do | |
27 | 29 | before do |
28 | stub_get("/projects/3/repository/tags/0.0.1", "tag") | |
29 | @tag = Gitlab.tag(3, "0.0.1") | |
30 | stub_get('/projects/3/repository/tags/0.0.1', 'tag') | |
31 | @tag = Gitlab.tag(3, '0.0.1') | |
30 | 32 | end |
31 | 33 | |
32 | it "gets the correct resource" do | |
33 | expect(a_get("/projects/3/repository/tags/0.0.1")).to have_been_made | |
34 | it 'gets the correct resource' do | |
35 | expect(a_get('/projects/3/repository/tags/0.0.1')).to have_been_made | |
34 | 36 | end |
35 | 37 | |
36 | it "returns information about a repository tag" do | |
37 | expect(@tag.name).to eq("0.0.1") | |
38 | it 'returns information about a repository tag' do | |
39 | expect(@tag.name).to eq('0.0.1') | |
38 | 40 | end |
39 | 41 | |
40 | context "tag with special character" do | |
42 | context 'tag with special character' do | |
41 | 43 | before do |
42 | stub_get("/projects/3/repository/tags/test%2Fme", "tag") | |
43 | @tag = Gitlab.tag(3, "test/me") | |
44 | stub_get('/projects/3/repository/tags/test%2Fme', 'tag') | |
45 | @tag = Gitlab.tag(3, 'test/me') | |
44 | 46 | end |
45 | 47 | |
46 | it "gets the correct resource" do | |
47 | expect(a_get("/projects/3/repository/tags/test%2Fme")).to have_been_made | |
48 | it 'gets the correct resource' do | |
49 | expect(a_get('/projects/3/repository/tags/test%2Fme')).to have_been_made | |
48 | 50 | end |
49 | 51 | end |
50 | 52 | end |
51 | 53 | |
52 | describe ".create_tag" do | |
54 | describe '.create_tag' do | |
53 | 55 | before do |
54 | stub_post("/projects/3/repository/tags", "tag_create") | |
55 | @tag = Gitlab.create_tag(3, "0.0.1", "master", 'this tag is annotated', 'and it has release notes') | |
56 | stub_post('/projects/3/repository/tags', 'tag_create') | |
57 | @tag = Gitlab.create_tag(3, '0.0.1', 'master', 'this tag is annotated', 'and it has release notes') | |
56 | 58 | end |
57 | 59 | |
58 | it "gets the correct resource" do | |
59 | expect(a_post("/projects/3/repository/tags")).to have_been_made | |
60 | it 'gets the correct resource' do | |
61 | expect(a_post('/projects/3/repository/tags')).to have_been_made | |
60 | 62 | end |
61 | 63 | |
62 | it "returns information about a new repository tag" do | |
63 | expect(@tag.name).to eq("0.0.1") | |
64 | it 'returns information about a new repository tag' do | |
65 | expect(@tag.name).to eq('0.0.1') | |
64 | 66 | expect(@tag.message).to eq('this tag is annotated') |
65 | 67 | end |
66 | 68 | |
67 | it "returns detailed information" do | |
69 | it 'returns detailed information' do | |
68 | 70 | expect(@tag.release.description).to eq('and it has release notes') |
69 | 71 | end |
70 | 72 | end |
71 | 73 | |
72 | describe ".delete_tag" do | |
74 | describe '.delete_tag' do | |
73 | 75 | before do |
74 | stub_delete("/projects/3/repository/tags/0.0.1", "tag_delete") | |
75 | @tag = Gitlab.delete_tag(3, "0.0.1") | |
76 | stub_delete('/projects/3/repository/tags/0.0.1', 'tag_delete') | |
77 | @tag = Gitlab.delete_tag(3, '0.0.1') | |
76 | 78 | end |
77 | 79 | |
78 | it "gets the correct resource" do | |
79 | expect(a_delete("/projects/3/repository/tags/0.0.1")).to have_been_made | |
80 | it 'gets the correct resource' do | |
81 | expect(a_delete('/projects/3/repository/tags/0.0.1')).to have_been_made | |
80 | 82 | end |
81 | 83 | |
82 | it "returns information about the deleted repository tag" do | |
83 | expect(@tag.tag_name).to eq("0.0.1") | |
84 | it 'returns information about the deleted repository tag' do | |
85 | expect(@tag.tag_name).to eq('0.0.1') | |
84 | 86 | end |
85 | 87 | |
86 | context "tag with special character" do | |
88 | context 'tag with special character' do | |
87 | 89 | before do |
88 | stub_delete("/projects/3/repository/tags/test%2Fme", "tag_delete") | |
89 | @tag = Gitlab.delete_tag(3, "test/me") | |
90 | stub_delete('/projects/3/repository/tags/test%2Fme', 'tag_delete') | |
91 | @tag = Gitlab.delete_tag(3, 'test/me') | |
90 | 92 | end |
91 | 93 | |
92 | it "gets the correct resource" do | |
93 | expect(a_delete("/projects/3/repository/tags/test%2Fme")).to have_been_made | |
94 | it 'gets the correct resource' do | |
95 | expect(a_delete('/projects/3/repository/tags/test%2Fme')).to have_been_made | |
94 | 96 | end |
95 | 97 | end |
96 | 98 | end |
97 | 99 | |
98 | describe ".create_release" do | |
100 | describe '.create_release' do | |
99 | 101 | before do |
100 | stub_post("/projects/3/repository/tags/0.0.1/release", "release_create") | |
101 | @tag = Gitlab.create_release(3, "0.0.1", "Amazing release. Wow") | |
102 | stub_post('/projects/3/repository/tags/0.0.1/release', 'release_create') | |
103 | @tag = Gitlab.create_release(3, '0.0.1', 'Amazing release. Wow') | |
102 | 104 | end |
103 | 105 | |
104 | it "gets the correct resource" do | |
105 | expect(a_post("/projects/3/repository/tags/0.0.1/release")).to have_been_made | |
106 | it 'gets the correct resource' do | |
107 | expect(a_post('/projects/3/repository/tags/0.0.1/release')).to have_been_made | |
106 | 108 | end |
107 | 109 | |
108 | it "returns information about the tag and the release" do | |
109 | expect(@tag.tag_name).to eq("0.0.1") | |
110 | expect(@tag.description).to eq("Amazing release. Wow") | |
110 | it 'returns information about the tag and the release' do | |
111 | expect(@tag.tag_name).to eq('0.0.1') | |
112 | expect(@tag.description).to eq('Amazing release. Wow') | |
111 | 113 | end |
112 | 114 | |
113 | context "tag with special character" do | |
115 | context 'tag with special character' do | |
114 | 116 | before do |
115 | stub_post("/projects/3/repository/tags/test%2Fme/release", "release_create") | |
116 | @tag = Gitlab.create_release(3, "test/me", "Amazing release. Wow") | |
117 | stub_post('/projects/3/repository/tags/test%2Fme/release', 'release_create') | |
118 | @tag = Gitlab.create_release(3, 'test/me', 'Amazing release. Wow') | |
117 | 119 | end |
118 | 120 | |
119 | it "gets the correct resource" do | |
120 | expect(a_post("/projects/3/repository/tags/test%2Fme/release")).to have_been_made | |
121 | it 'gets the correct resource' do | |
122 | expect(a_post('/projects/3/repository/tags/test%2Fme/release')).to have_been_made | |
121 | 123 | end |
122 | 124 | end |
123 | 125 | end |
124 | 126 | |
125 | describe ".update_release" do | |
127 | describe '.update_release' do | |
126 | 128 | before do |
127 | stub_put("/projects/3/repository/tags/0.0.1/release", "release_update") | |
128 | @tag = Gitlab.update_release(3, "0.0.1", 'Amazing release. Wow') | |
129 | stub_put('/projects/3/repository/tags/0.0.1/release', 'release_update') | |
130 | @tag = Gitlab.update_release(3, '0.0.1', 'Amazing release. Wow') | |
129 | 131 | end |
130 | 132 | |
131 | it "updates the correct resource" do | |
132 | expect(a_put("/projects/3/repository/tags/0.0.1/release")).to have_been_made | |
133 | it 'updates the correct resource' do | |
134 | expect(a_put('/projects/3/repository/tags/0.0.1/release')).to have_been_made | |
133 | 135 | end |
134 | 136 | |
135 | it "returns information about the tag" do | |
136 | expect(@tag.tag_name).to eq("0.0.1") | |
137 | it 'returns information about the tag' do | |
138 | expect(@tag.tag_name).to eq('0.0.1') | |
137 | 139 | expect(@tag.description).to eq('Amazing release. Wow') |
138 | 140 | end |
139 | 141 | |
140 | context "tag with special character" do | |
142 | context 'tag with special character' do | |
141 | 143 | before do |
142 | stub_put("/projects/3/repository/tags/test%2Fme/release", "release_update") | |
143 | @tag = Gitlab.update_release(3, "test/me", 'Amazing release. Wow') | |
144 | stub_put('/projects/3/repository/tags/test%2Fme/release', 'release_update') | |
145 | @tag = Gitlab.update_release(3, 'test/me', 'Amazing release. Wow') | |
144 | 146 | end |
145 | 147 | |
146 | it "updates the correct resource" do | |
147 | expect(a_put("/projects/3/repository/tags/test%2Fme/release")).to have_been_made | |
148 | it 'updates the correct resource' do | |
149 | expect(a_put('/projects/3/repository/tags/test%2Fme/release')).to have_been_made | |
148 | 150 | end |
149 | 151 | end |
150 | 152 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe Gitlab::Client do | |
5 | describe '.dockerfile_templates' do | |
6 | before do | |
7 | stub_get('/templates/dockerfiles', 'dockerfile_templates') | |
8 | @dockerfile_templates = Gitlab.dockerfile_templates | |
9 | end | |
10 | ||
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/templates/dockerfiles')).to have_been_made | |
13 | end | |
14 | ||
15 | it 'returns a paginated response of dockerfile templates' do | |
16 | expect(@dockerfile_templates).to be_a Gitlab::PaginatedResponse | |
17 | end | |
18 | end | |
19 | ||
20 | describe '.dockerfile_template' do | |
21 | before do | |
22 | stub_get('/templates/dockerfiles/Binary', 'dockerfile_project_template') | |
23 | @dockerfile_template = Gitlab.dockerfile_template('Binary') | |
24 | end | |
25 | ||
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/templates/dockerfiles/Binary')).to have_been_made | |
28 | end | |
29 | ||
30 | it 'returns the correct information about the dockerfile template' do | |
31 | expect(@dockerfile_template.name).to eq 'Binary' | |
32 | end | |
33 | end | |
34 | ||
35 | describe '.gitignore_templates' do | |
36 | before do | |
37 | stub_get('/templates/gitignores', 'gitignore_templates') | |
38 | @gitignore_templates = Gitlab.gitignore_templates | |
39 | end | |
40 | ||
41 | it 'gets the correct resource' do | |
42 | expect(a_get('/templates/gitignores')).to have_been_made | |
43 | end | |
44 | ||
45 | it 'returns a paginated response of gitignore templates' do | |
46 | expect(@gitignore_templates).to be_a Gitlab::PaginatedResponse | |
47 | end | |
48 | end | |
49 | ||
50 | describe '.gitignore_template' do | |
51 | before do | |
52 | stub_get('/templates/gitignores/Ruby', 'gitignore_template') | |
53 | @gitignore_template = Gitlab.gitignore_template('Ruby') | |
54 | end | |
55 | ||
56 | it 'gets the correct resource' do | |
57 | expect(a_get('/templates/gitignores/Ruby')).to have_been_made | |
58 | end | |
59 | ||
60 | it 'returns the correct information about the gitignore template' do | |
61 | expect(@gitignore_template.name).to eq 'Ruby' | |
62 | end | |
63 | end | |
64 | ||
65 | describe '.gitlab_ci_yml_templates' do | |
66 | before do | |
67 | stub_get('/templates/gitlab_ci_ymls', 'gitlab_ci_yml_templates') | |
68 | @gitlab_ci_yml_templates = Gitlab.gitlab_ci_yml_templates | |
69 | end | |
70 | ||
71 | it 'gets the correct resource' do | |
72 | expect(a_get('/templates/gitlab_ci_ymls')).to have_been_made | |
73 | end | |
74 | ||
75 | it 'returns a paginated response of gitlab_ci_yml templates' do | |
76 | expect(@gitlab_ci_yml_templates).to be_a Gitlab::PaginatedResponse | |
77 | end | |
78 | end | |
79 | ||
80 | describe '.gitlab_ci_yml_template' do | |
81 | before do | |
82 | stub_get('/templates/gitlab_ci_ymls/Ruby', 'gitlab_ci_yml_template') | |
83 | @gitlab_ci_yml_template = Gitlab.gitlab_ci_yml_template('Ruby') | |
84 | end | |
85 | ||
86 | it 'gets the correct resource' do | |
87 | expect(a_get('/templates/gitlab_ci_ymls/Ruby')).to have_been_made | |
88 | end | |
89 | ||
90 | it 'returns the correct information about the gitlab_ci_yml template' do | |
91 | expect(@gitlab_ci_yml_template.name).to eq 'Ruby' | |
92 | end | |
93 | end | |
94 | ||
95 | describe '.license_templates' do | |
96 | before do | |
97 | stub_get('/templates/licenses', 'license_templates') | |
98 | @license_templates = Gitlab.license_templates | |
99 | end | |
100 | ||
101 | it 'gets the correct resource' do | |
102 | expect(a_get('/templates/licenses')).to have_been_made | |
103 | end | |
104 | ||
105 | it 'returns a paginated response of license templates' do | |
106 | expect(@license_templates).to be_a Gitlab::PaginatedResponse | |
107 | end | |
108 | end | |
109 | ||
110 | describe '.license_template' do | |
111 | before do | |
112 | stub_get('/templates/licenses/mit', 'license_template') | |
113 | @license_template = Gitlab.license_template('mit') | |
114 | end | |
115 | ||
116 | it 'gets the correct resource' do | |
117 | expect(a_get('/templates/licenses/mit')).to have_been_made | |
118 | end | |
119 | ||
120 | it 'returns the correct information about the license template' do | |
121 | expect(@license_template.key).to eq 'mit' | |
122 | end | |
123 | end | |
124 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | 5 | describe '.todos' do |
4 | 6 | before do |
5 | stub_get("/todos", "todos") | |
7 | stub_get('/todos', 'todos') | |
6 | 8 | @todos = Gitlab.todos |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resources" do | |
10 | expect(a_get("/todos")).to have_been_made | |
11 | it 'gets the correct resources' do | |
12 | expect(a_get('/todos')).to have_been_made | |
11 | 13 | end |
12 | 14 | |
13 | 15 | it "returns a paginated response of user's todos" do |
17 | 19 | |
18 | 20 | describe '.mark_todo_as_done' do |
19 | 21 | before do |
20 | stub_post("/todos/102/mark_as_done", "todo") | |
22 | stub_post('/todos/102/mark_as_done', 'todo') | |
21 | 23 | @todo = Gitlab.mark_todo_as_done(102) |
22 | 24 | end |
23 | 25 | |
24 | it "gets the correct resource" do | |
25 | expect(a_post("/todos/102/mark_as_done")).to have_been_made | |
26 | it 'gets the correct resource' do | |
27 | expect(a_post('/todos/102/mark_as_done')).to have_been_made | |
26 | 28 | end |
27 | 29 | |
28 | it "returns information about the todo marked as done" do | |
30 | it 'returns information about the todo marked as done' do | |
29 | 31 | expect(@todo.id).to eq(102) |
30 | 32 | expect(@todo.state).to eq('done') |
31 | 33 | end |
33 | 35 | |
34 | 36 | describe '.mark_all_todos_as_done' do |
35 | 37 | before do |
36 | stub_post("/todos/mark_as_done", "todos") | |
38 | stub_post('/todos/mark_as_done', 'todos') | |
37 | 39 | @todos = Gitlab.mark_all_todos_as_done |
38 | 40 | end |
39 | 41 | |
40 | it "gets the correct resources" do | |
41 | expect(a_post("/todos/mark_as_done")).to have_been_made | |
42 | it 'gets the correct resources' do | |
43 | expect(a_post('/todos/mark_as_done')).to have_been_made | |
42 | 44 | end |
43 | 45 | end |
44 | 46 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Client do |
3 | describe ".users" do | |
4 | before do | |
5 | stub_get("/users", "users") | |
5 | describe '.users' do | |
6 | before do | |
7 | stub_get('/users', 'users') | |
6 | 8 | @users = Gitlab.users |
7 | 9 | end |
8 | 10 | |
9 | it "gets the correct resource" do | |
10 | expect(a_get("/users")).to have_been_made | |
11 | end | |
12 | ||
13 | it "returns a paginated response of users" do | |
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/users')).to have_been_made | |
13 | end | |
14 | ||
15 | it 'returns a paginated response of users' do | |
14 | 16 | expect(@users).to be_a Gitlab::PaginatedResponse |
15 | expect(@users.first.email).to eq("john@example.com") | |
16 | end | |
17 | end | |
18 | ||
19 | describe ".user" do | |
20 | context "with user ID passed" do | |
21 | before do | |
22 | stub_get("/users/1", "user") | |
17 | expect(@users.first.email).to eq('john@example.com') | |
18 | end | |
19 | end | |
20 | ||
21 | describe '.user' do | |
22 | context 'with user ID passed' do | |
23 | before do | |
24 | stub_get('/users/1', 'user') | |
23 | 25 | @user = Gitlab.user(1) |
24 | 26 | end |
25 | 27 | |
26 | it "gets the correct resource" do | |
27 | expect(a_get("/users/1")).to have_been_made | |
28 | end | |
29 | ||
30 | it "returns information about a user" do | |
31 | expect(@user.email).to eq("john@example.com") | |
32 | end | |
33 | end | |
34 | ||
35 | context "without user ID passed" do | |
36 | before do | |
37 | stub_get("/user", "user") | |
28 | it 'gets the correct resource' do | |
29 | expect(a_get('/users/1')).to have_been_made | |
30 | end | |
31 | ||
32 | it 'returns information about a user' do | |
33 | expect(@user.email).to eq('john@example.com') | |
34 | end | |
35 | end | |
36 | ||
37 | context 'without user ID passed' do | |
38 | before do | |
39 | stub_get('/user', 'user') | |
38 | 40 | @user = Gitlab.user |
39 | 41 | end |
40 | 42 | |
41 | it "gets the correct resource" do | |
42 | expect(a_get("/user")).to have_been_made | |
43 | end | |
44 | ||
45 | it "returns information about an authorized user" do | |
46 | expect(@user.email).to eq("john@example.com") | |
47 | end | |
48 | end | |
49 | end | |
50 | ||
51 | describe ".create_user" do | |
52 | context "when successful request" do | |
53 | before do | |
54 | stub_post("/users", "user") | |
55 | @user = Gitlab.create_user("email", "pass") | |
56 | end | |
57 | ||
58 | it "gets the correct resource" do | |
59 | body = { email: "email", password: "pass", name: "email" } | |
60 | expect(a_post("/users").with(body: body)).to have_been_made | |
61 | end | |
62 | ||
63 | it "returns information about a created user" do | |
64 | expect(@user.email).to eq("john@example.com") | |
65 | end | |
66 | end | |
67 | ||
68 | context "when bad request" do | |
69 | it "throws an exception" do | |
70 | stub_post("/users", "error_already_exists", 409) | |
43 | it 'gets the correct resource' do | |
44 | expect(a_get('/user')).to have_been_made | |
45 | end | |
46 | ||
47 | it 'returns information about an authorized user' do | |
48 | expect(@user.email).to eq('john@example.com') | |
49 | end | |
50 | end | |
51 | end | |
52 | ||
53 | describe '.create_user' do | |
54 | context 'when successful request' do | |
55 | before do | |
56 | stub_post('/users', 'user') | |
57 | @user = Gitlab.create_user('email', 'pass') | |
58 | end | |
59 | ||
60 | it 'gets the correct resource' do | |
61 | body = { email: 'email', password: 'pass', name: 'email' } | |
62 | expect(a_post('/users').with(body: body)).to have_been_made | |
63 | end | |
64 | ||
65 | it 'returns information about a created user' do | |
66 | expect(@user.email).to eq('john@example.com') | |
67 | end | |
68 | end | |
69 | ||
70 | context 'when bad request' do | |
71 | it 'throws an exception' do | |
72 | stub_post('/users', 'error_already_exists', 409) | |
71 | 73 | expect do |
72 | Gitlab.create_user("email", "pass") | |
74 | Gitlab.create_user('email', 'pass') | |
73 | 75 | end.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users") |
74 | 76 | end |
75 | 77 | end |
76 | 78 | end |
77 | 79 | |
78 | describe ".create_user_with_userame" do | |
79 | context "when successful request" do | |
80 | before do | |
81 | stub_post("/users", "user") | |
82 | @user = Gitlab.create_user("email", "pass", "username") | |
83 | end | |
84 | ||
85 | it "gets the correct resource" do | |
86 | body = { email: "email", password: "pass", username: "username" } | |
87 | expect(a_post("/users").with(body: body)).to have_been_made | |
88 | end | |
89 | ||
90 | it "returns information about a created user" do | |
91 | expect(@user.email).to eq("john@example.com") | |
92 | end | |
93 | end | |
94 | ||
95 | context "when bad request" do | |
96 | it "throws an exception" do | |
97 | stub_post("/users", "error_already_exists", 409) | |
80 | describe '.create_user_with_userame' do | |
81 | context 'when successful request' do | |
82 | before do | |
83 | stub_post('/users', 'user') | |
84 | @user = Gitlab.create_user('email', 'pass', 'username') | |
85 | end | |
86 | ||
87 | it 'gets the correct resource' do | |
88 | body = { email: 'email', password: 'pass', username: 'username' } | |
89 | expect(a_post('/users').with(body: body)).to have_been_made | |
90 | end | |
91 | ||
92 | it 'returns information about a created user' do | |
93 | expect(@user.email).to eq('john@example.com') | |
94 | end | |
95 | end | |
96 | ||
97 | context 'when bad request' do | |
98 | it 'throws an exception' do | |
99 | stub_post('/users', 'error_already_exists', 409) | |
98 | 100 | expect do |
99 | Gitlab.create_user("email", "pass", "username") | |
101 | Gitlab.create_user('email', 'pass', 'username') | |
100 | 102 | end.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users") |
101 | 103 | end |
102 | 104 | end |
103 | 105 | end |
104 | 106 | |
105 | describe ".edit_user" do | |
106 | before do | |
107 | @options = { name: "Roberto" } | |
108 | stub_put("/users/1", "user").with(body: @options) | |
107 | describe '.edit_user' do | |
108 | before do | |
109 | @options = { name: 'Roberto' } | |
110 | stub_put('/users/1', 'user').with(body: @options) | |
109 | 111 | @user = Gitlab.edit_user(1, @options) |
110 | 112 | end |
111 | 113 | |
112 | it "gets the correct resource" do | |
113 | expect(a_put("/users/1").with(body: @options)).to have_been_made | |
114 | end | |
115 | end | |
116 | ||
117 | describe ".delete_user" do | |
118 | before do | |
119 | stub_delete("/users/1", "user") | |
114 | it 'gets the correct resource' do | |
115 | expect(a_put('/users/1').with(body: @options)).to have_been_made | |
116 | end | |
117 | end | |
118 | ||
119 | describe '.delete_user' do | |
120 | before do | |
121 | stub_delete('/users/1', 'user') | |
120 | 122 | @user = Gitlab.delete_user(1) |
121 | 123 | end |
122 | 124 | |
123 | it "gets the correct resource" do | |
124 | expect(a_delete("/users/1")).to have_been_made | |
125 | end | |
126 | ||
127 | it "returns information about a deleted user" do | |
128 | expect(@user.email).to eq("john@example.com") | |
129 | end | |
130 | end | |
131 | ||
132 | describe ".block_user" do | |
133 | before do | |
134 | stub_post("/users/1/block", "user_block_unblock") | |
125 | it 'gets the correct resource' do | |
126 | expect(a_delete('/users/1')).to have_been_made | |
127 | end | |
128 | ||
129 | it 'returns information about a deleted user' do | |
130 | expect(@user.email).to eq('john@example.com') | |
131 | end | |
132 | end | |
133 | ||
134 | describe '.block_user' do | |
135 | before do | |
136 | stub_post('/users/1/block', 'user_block_unblock') | |
135 | 137 | @result = Gitlab.block_user(1) |
136 | 138 | end |
137 | 139 | |
138 | it "gets the correct resource" do | |
139 | expect(a_post("/users/1/block")).to have_been_made | |
140 | end | |
141 | ||
142 | it "returns boolean" do | |
140 | it 'gets the correct resource' do | |
141 | expect(a_post('/users/1/block')).to have_been_made | |
142 | end | |
143 | ||
144 | it 'returns boolean' do | |
143 | 145 | expect(@result).to eq(true) |
144 | 146 | end |
145 | 147 | end |
146 | 148 | |
147 | describe ".unblock_user" do | |
148 | before do | |
149 | stub_post("/users/1/unblock", "user_block_unblock") | |
149 | describe '.unblock_user' do | |
150 | before do | |
151 | stub_post('/users/1/unblock', 'user_block_unblock') | |
150 | 152 | @result = Gitlab.unblock_user(1) |
151 | 153 | end |
152 | 154 | |
153 | it "gets the correct resource" do | |
154 | expect(a_post("/users/1/unblock")).to have_been_made | |
155 | end | |
156 | ||
157 | it "returns boolean" do | |
155 | it 'gets the correct resource' do | |
156 | expect(a_post('/users/1/unblock')).to have_been_made | |
157 | end | |
158 | ||
159 | it 'returns boolean' do | |
158 | 160 | expect(@result).to eq(true) |
159 | 161 | end |
160 | 162 | end |
161 | 163 | |
162 | describe ".session" do | |
164 | describe '.session' do | |
163 | 165 | after do |
164 | 166 | Gitlab.endpoint = 'https://api.example.com' |
165 | 167 | Gitlab.private_token = 'secret' |
166 | 168 | end |
167 | 169 | |
168 | 170 | before do |
169 | stub_request(:post, "#{Gitlab.endpoint}/session"). | |
170 | to_return(body: load_fixture('session'), status: 200) | |
171 | @session = Gitlab.session("email", "pass") | |
172 | end | |
173 | ||
174 | context "when endpoint is not set" do | |
175 | it "raises Error::MissingCredentials" do | |
171 | stub_request(:post, "#{Gitlab.endpoint}/session") | |
172 | .to_return(body: load_fixture('session'), status: 200) | |
173 | @session = Gitlab.session('email', 'pass') | |
174 | end | |
175 | ||
176 | context 'when endpoint is not set' do | |
177 | it 'raises Error::MissingCredentials' do | |
176 | 178 | Gitlab.endpoint = nil |
177 | 179 | expect do |
178 | Gitlab.session("email", "pass") | |
180 | Gitlab.session('email', 'pass') | |
179 | 181 | end.to raise_error(Gitlab::Error::MissingCredentials, 'Please set an endpoint to API') |
180 | 182 | end |
181 | 183 | end |
182 | 184 | |
183 | context "when private_token is not set" do | |
184 | it "does not raise Error::MissingCredentials" do | |
185 | context 'when private_token is not set' do | |
186 | it 'does not raise Error::MissingCredentials' do | |
185 | 187 | Gitlab.private_token = nil |
186 | expect { Gitlab.session("email", "pass") }.to_not raise_error | |
187 | end | |
188 | end | |
189 | ||
190 | context "when endpoint is set" do | |
191 | it "gets the correct resource" do | |
188 | expect { Gitlab.session('email', 'pass') }.not_to raise_error | |
189 | end | |
190 | end | |
191 | ||
192 | context 'when endpoint is set' do | |
193 | it 'gets the correct resource' do | |
192 | 194 | expect(a_request(:post, "#{Gitlab.endpoint}/session")).to have_been_made |
193 | 195 | end |
194 | 196 | |
195 | it "returns information about a created session" do | |
196 | expect(@session.email).to eq("john@example.com") | |
197 | expect(@session.private_token).to eq("qEsq1pt6HJPaNciie3MG") | |
198 | end | |
199 | end | |
200 | end | |
201 | ||
202 | describe ".ssh_keys" do | |
203 | context "with user ID passed" do | |
204 | before do | |
205 | stub_get("/users/1/keys", "keys") | |
206 | @keys = Gitlab.ssh_keys({ user_id: 1 }) | |
207 | end | |
208 | ||
209 | it "gets the correct resource" do | |
210 | expect(a_get("/users/1/keys")).to have_been_made | |
211 | end | |
212 | ||
213 | it "returns a paginated response of SSH keys" do | |
197 | it 'returns information about a created session' do | |
198 | expect(@session.email).to eq('john@example.com') | |
199 | expect(@session.private_token).to eq('qEsq1pt6HJPaNciie3MG') | |
200 | end | |
201 | end | |
202 | end | |
203 | ||
204 | describe '.ssh_keys' do | |
205 | context 'with user ID passed' do | |
206 | before do | |
207 | stub_get('/users/1/keys', 'keys') | |
208 | @keys = Gitlab.ssh_keys(user_id: 1) | |
209 | end | |
210 | ||
211 | it 'gets the correct resource' do | |
212 | expect(a_get('/users/1/keys')).to have_been_made | |
213 | end | |
214 | ||
215 | it 'returns a paginated response of SSH keys' do | |
214 | 216 | expect(@keys).to be_a Gitlab::PaginatedResponse |
215 | expect(@keys.first.title).to eq("narkoz@helium") | |
216 | end | |
217 | end | |
218 | ||
219 | context "without user ID passed" do | |
220 | before do | |
221 | stub_get("/user/keys", "keys") | |
217 | expect(@keys.first.title).to eq('narkoz@helium') | |
218 | end | |
219 | end | |
220 | ||
221 | context 'without user ID passed' do | |
222 | before do | |
223 | stub_get('/user/keys', 'keys') | |
222 | 224 | @keys = Gitlab.ssh_keys |
223 | 225 | end |
224 | 226 | |
225 | it "gets the correct resource" do | |
226 | expect(a_get("/user/keys")).to have_been_made | |
227 | end | |
228 | ||
229 | it "returns a paginated response of SSH keys" do | |
227 | it 'gets the correct resource' do | |
228 | expect(a_get('/user/keys')).to have_been_made | |
229 | end | |
230 | ||
231 | it 'returns a paginated response of SSH keys' do | |
230 | 232 | expect(@keys).to be_a Gitlab::PaginatedResponse |
231 | expect(@keys.first.title).to eq("narkoz@helium") | |
232 | end | |
233 | end | |
234 | end | |
235 | ||
236 | describe ".ssh_key" do | |
237 | before do | |
238 | stub_get("/user/keys/1", "key") | |
233 | expect(@keys.first.title).to eq('narkoz@helium') | |
234 | end | |
235 | end | |
236 | end | |
237 | ||
238 | describe '.ssh_key' do | |
239 | before do | |
240 | stub_get('/user/keys/1', 'key') | |
239 | 241 | @key = Gitlab.ssh_key(1) |
240 | 242 | end |
241 | 243 | |
242 | it "gets the correct resource" do | |
243 | expect(a_get("/user/keys/1")).to have_been_made | |
244 | end | |
245 | ||
246 | it "returns information about an SSH key" do | |
247 | expect(@key.title).to eq("narkoz@helium") | |
248 | end | |
249 | end | |
250 | ||
251 | describe ".create_ssh_key" do | |
252 | before do | |
253 | stub_post("/user/keys", "key") | |
254 | @key = Gitlab.create_ssh_key("title", "body") | |
255 | end | |
256 | ||
257 | it "gets the correct resource" do | |
258 | body = { title: "title", key: "body" } | |
259 | expect(a_post("/user/keys").with(body: body)).to have_been_made | |
260 | end | |
261 | ||
262 | it "returns information about a created SSH key" do | |
263 | expect(@key.title).to eq("narkoz@helium") | |
264 | end | |
265 | end | |
266 | ||
267 | describe ".delete_ssh_key" do | |
268 | before do | |
269 | stub_delete("/user/keys/1", "key") | |
270 | @key = Gitlab.delete_ssh_key(1) | |
271 | end | |
272 | ||
273 | it "gets the correct resource" do | |
274 | expect(a_delete("/user/keys/1")).to have_been_made | |
275 | end | |
276 | ||
277 | it "returns information about a deleted SSH key" do | |
278 | expect(@key.title).to eq("narkoz@helium") | |
279 | end | |
280 | end | |
281 | ||
282 | describe ".emails" do | |
283 | describe "without user ID" do | |
284 | before do | |
285 | stub_get("/user/emails", "user_emails") | |
244 | it 'gets the correct resource' do | |
245 | expect(a_get('/user/keys/1')).to have_been_made | |
246 | end | |
247 | ||
248 | it 'returns information about an SSH key' do | |
249 | expect(@key.title).to eq('narkoz@helium') | |
250 | end | |
251 | end | |
252 | ||
253 | describe '.create_ssh_key' do | |
254 | describe 'without user ID' do | |
255 | before do | |
256 | stub_post('/user/keys', 'key') | |
257 | @key = Gitlab.create_ssh_key('title', 'body') | |
258 | end | |
259 | ||
260 | it 'gets the correct resource' do | |
261 | body = { title: 'title', key: 'body' } | |
262 | expect(a_post('/user/keys').with(body: body)).to have_been_made | |
263 | end | |
264 | ||
265 | it 'returns information about a created SSH key' do | |
266 | expect(@key.title).to eq('narkoz@helium') | |
267 | end | |
268 | end | |
269 | ||
270 | describe 'with user ID' do | |
271 | before do | |
272 | stub_post('/users/1/keys', 'key') | |
273 | @options = { user_id: 1 } | |
274 | @key = Gitlab.create_ssh_key('title', 'body', @options) | |
275 | end | |
276 | ||
277 | it 'gets the correct resource' do | |
278 | body = { title: 'title', key: 'body' } | |
279 | expect(a_post('/users/1/keys').with(body: body)).to have_been_made | |
280 | end | |
281 | ||
282 | it 'returns information about a created SSH key' do | |
283 | expect(@key.title).to eq('narkoz@helium') | |
284 | end | |
285 | end | |
286 | end | |
287 | ||
288 | describe '.delete_ssh_key' do | |
289 | describe 'without user ID' do | |
290 | before do | |
291 | stub_delete('/user/keys/1', 'key') | |
292 | @key = Gitlab.delete_ssh_key(1) | |
293 | end | |
294 | ||
295 | it 'gets the correct resource' do | |
296 | expect(a_delete('/user/keys/1')).to have_been_made | |
297 | end | |
298 | ||
299 | it 'returns information about a deleted SSH key' do | |
300 | expect(@key.title).to eq('narkoz@helium') | |
301 | end | |
302 | end | |
303 | ||
304 | describe 'with user ID' do | |
305 | before do | |
306 | stub_delete('/users/1/keys/1', 'key') | |
307 | @options = { user_id: 1 } | |
308 | @key = Gitlab.delete_ssh_key(1, @options) | |
309 | end | |
310 | ||
311 | it 'gets the correct resource' do | |
312 | expect(a_delete('/users/1/keys/1')).to have_been_made | |
313 | end | |
314 | ||
315 | it 'returns information about a deleted SSH key' do | |
316 | expect(@key.title).to eq('narkoz@helium') | |
317 | end | |
318 | end | |
319 | end | |
320 | ||
321 | describe '.emails' do | |
322 | describe 'without user ID' do | |
323 | before do | |
324 | stub_get('/user/emails', 'user_emails') | |
286 | 325 | @emails = Gitlab.emails |
287 | 326 | end |
288 | 327 | |
289 | it "gets the correct resource" do | |
290 | expect(a_get("/user/emails")).to have_been_made | |
291 | end | |
292 | ||
293 | it "returns a information about a emails of user" do | |
328 | it 'gets the correct resource' do | |
329 | expect(a_get('/user/emails')).to have_been_made | |
330 | end | |
331 | ||
332 | it 'returns a information about a emails of user' do | |
294 | 333 | email = @emails.first |
295 | 334 | expect(email.id).to eq 1 |
296 | expect(email.email).to eq("email@example.com") | |
297 | end | |
298 | end | |
299 | ||
300 | describe "with user ID" do | |
301 | before do | |
302 | stub_get("/users/2/emails", "user_emails") | |
335 | expect(email.email).to eq('email@example.com') | |
336 | end | |
337 | end | |
338 | ||
339 | describe 'with user ID' do | |
340 | before do | |
341 | stub_get('/users/2/emails', 'user_emails') | |
303 | 342 | @emails = Gitlab.emails(2) |
304 | 343 | end |
305 | 344 | |
306 | it "gets the correct resource" do | |
307 | expect(a_get("/users/2/emails")).to have_been_made | |
308 | end | |
309 | ||
310 | it "returns a information about a emails of user" do | |
345 | it 'gets the correct resource' do | |
346 | expect(a_get('/users/2/emails')).to have_been_made | |
347 | end | |
348 | ||
349 | it 'returns a information about a emails of user' do | |
311 | 350 | email = @emails.first |
312 | 351 | expect(email.id).to eq 1 |
313 | expect(email.email).to eq("email@example.com") | |
314 | end | |
315 | end | |
316 | end | |
317 | ||
318 | describe ".email" do | |
319 | before do | |
320 | stub_get("/user/emails/2", "user_email") | |
352 | expect(email.email).to eq('email@example.com') | |
353 | end | |
354 | end | |
355 | end | |
356 | ||
357 | describe '.email' do | |
358 | before do | |
359 | stub_get('/user/emails/2', 'user_email') | |
321 | 360 | @email = Gitlab.email(2) |
322 | 361 | end |
323 | 362 | |
324 | it "gets the correct resource" do | |
325 | expect(a_get("/user/emails/2")).to have_been_made | |
326 | end | |
327 | ||
328 | it "returns a information about a email of user" do | |
363 | it 'gets the correct resource' do | |
364 | expect(a_get('/user/emails/2')).to have_been_made | |
365 | end | |
366 | ||
367 | it 'returns a information about a email of user' do | |
329 | 368 | expect(@email.id).to eq 1 |
330 | expect(@email.email).to eq("email@example.com") | |
331 | end | |
332 | end | |
333 | ||
334 | describe ".add_email" do | |
335 | describe "without user ID" do | |
336 | before do | |
337 | stub_post("/user/emails", "user_email") | |
338 | @email = Gitlab.add_email("email@example.com") | |
339 | end | |
340 | ||
341 | it "gets the correct resource" do | |
342 | body = { email: "email@example.com" } | |
343 | expect(a_post("/user/emails").with(body: body)).to have_been_made | |
344 | end | |
345 | ||
346 | it "returns information about a new email" do | |
369 | expect(@email.email).to eq('email@example.com') | |
370 | end | |
371 | end | |
372 | ||
373 | describe '.add_email' do | |
374 | describe 'without user ID' do | |
375 | before do | |
376 | stub_post('/user/emails', 'user_email') | |
377 | @email = Gitlab.add_email('email@example.com') | |
378 | end | |
379 | ||
380 | it 'gets the correct resource' do | |
381 | body = { email: 'email@example.com' } | |
382 | expect(a_post('/user/emails').with(body: body)).to have_been_made | |
383 | end | |
384 | ||
385 | it 'returns information about a new email' do | |
347 | 386 | expect(@email.id).to eq(1) |
348 | expect(@email.email).to eq("email@example.com") | |
349 | end | |
350 | end | |
351 | ||
352 | describe "with user ID" do | |
353 | before do | |
354 | stub_post("/users/2/emails", "user_email") | |
355 | @email = Gitlab.add_email("email@example.com", 2) | |
356 | end | |
357 | ||
358 | it "gets the correct resource" do | |
359 | body = { email: "email@example.com" } | |
360 | expect(a_post("/users/2/emails").with(body: body)).to have_been_made | |
361 | end | |
362 | ||
363 | it "returns information about a new email" do | |
387 | expect(@email.email).to eq('email@example.com') | |
388 | end | |
389 | end | |
390 | ||
391 | describe 'with user ID' do | |
392 | before do | |
393 | stub_post('/users/2/emails', 'user_email') | |
394 | @email = Gitlab.add_email('email@example.com', 2) | |
395 | end | |
396 | ||
397 | it 'gets the correct resource' do | |
398 | body = { email: 'email@example.com' } | |
399 | expect(a_post('/users/2/emails').with(body: body)).to have_been_made | |
400 | end | |
401 | ||
402 | it 'returns information about a new email' do | |
364 | 403 | expect(@email.id).to eq(1) |
365 | expect(@email.email).to eq("email@example.com") | |
366 | end | |
367 | end | |
368 | end | |
369 | ||
370 | describe ".delete_email" do | |
371 | describe "without user ID" do | |
372 | before do | |
373 | stub_delete("/user/emails/1", "user_email") | |
404 | expect(@email.email).to eq('email@example.com') | |
405 | end | |
406 | end | |
407 | end | |
408 | ||
409 | describe '.delete_email' do | |
410 | describe 'without user ID' do | |
411 | before do | |
412 | stub_delete('/user/emails/1', 'user_email') | |
374 | 413 | @email = Gitlab.delete_email(1) |
375 | 414 | end |
376 | 415 | |
377 | it "gets the correct resource" do | |
378 | expect(a_delete("/user/emails/1")).to have_been_made | |
379 | end | |
380 | ||
381 | it "returns information about a deleted email" do | |
416 | it 'gets the correct resource' do | |
417 | expect(a_delete('/user/emails/1')).to have_been_made | |
418 | end | |
419 | ||
420 | it 'returns information about a deleted email' do | |
382 | 421 | expect(@email).to be_truthy |
383 | 422 | end |
384 | 423 | end |
385 | 424 | |
386 | describe "with user ID" do | |
387 | before do | |
388 | stub_delete("/users/2/emails/1", "user_email") | |
425 | describe 'with user ID' do | |
426 | before do | |
427 | stub_delete('/users/2/emails/1', 'user_email') | |
389 | 428 | @email = Gitlab.delete_email(1, 2) |
390 | 429 | end |
391 | 430 | |
392 | it "gets the correct resource" do | |
393 | expect(a_delete("/users/2/emails/1")).to have_been_made | |
394 | end | |
395 | ||
396 | it "returns information about a deleted email" do | |
431 | it 'gets the correct resource' do | |
432 | expect(a_delete('/users/2/emails/1')).to have_been_made | |
433 | end | |
434 | ||
435 | it 'returns information about a deleted email' do | |
397 | 436 | expect(@email).to be_truthy |
398 | 437 | end |
399 | 438 | end |
400 | 439 | end |
401 | 440 | |
402 | describe ".user_search" do | |
403 | before do | |
404 | stub_get("/users?search=User", "user_search") | |
441 | describe '.user_search' do | |
442 | before do | |
443 | stub_get('/users?search=User', 'user_search') | |
405 | 444 | @users = Gitlab.user_search('User') |
406 | 445 | end |
407 | 446 | |
408 | it "gets the correct resource" do | |
409 | expect(a_get("/users?search=User")).to have_been_made | |
410 | end | |
411 | ||
412 | it "returns an array of users found" do | |
447 | it 'gets the correct resource' do | |
448 | expect(a_get('/users?search=User')).to have_been_made | |
449 | end | |
450 | ||
451 | it 'returns an array of users found' do | |
413 | 452 | expect(@users.first.id).to eq(1) |
414 | 453 | expect(@users.last.id).to eq(2) |
415 | 454 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe Gitlab::Client do | |
5 | describe '.version' do | |
6 | before do | |
7 | stub_get('/version', 'version') | |
8 | end | |
9 | ||
10 | let!(:version) { Gitlab.version } | |
11 | ||
12 | it 'gets the correct resource' do | |
13 | expect(a_get('/version')).to have_been_made | |
14 | end | |
15 | ||
16 | it 'returns information about gitlab server' do | |
17 | expect(version.version).to eq('8.13.0-pre') | |
18 | expect(version.revision).to eq('4e963fe') | |
19 | end | |
20 | end | |
21 | end |
0 | # frozen_string_literal: true | |
1 | ||
2 | require 'spec_helper' | |
3 | ||
4 | describe Gitlab::Client do | |
5 | describe '.wikis' do | |
6 | before do | |
7 | stub_get('/projects/1/wikis', 'wikis') | |
8 | @wikis = Gitlab.wikis(1) | |
9 | end | |
10 | ||
11 | it 'gets the correct resource' do | |
12 | expect(a_get('/projects/1/wikis')).to have_been_made | |
13 | end | |
14 | ||
15 | it "returns a response of a project's wikis" do | |
16 | expect(@wikis).to be_a Gitlab::PaginatedResponse | |
17 | end | |
18 | end | |
19 | ||
20 | describe '.wiki' do | |
21 | before do | |
22 | stub_get('/projects/1/wikis/home', 'wiki') | |
23 | @wiki = Gitlab.wiki(1, 'home') | |
24 | end | |
25 | ||
26 | it 'gets the correct resource' do | |
27 | expect(a_get('/projects/1/wikis/home')).to have_been_made | |
28 | end | |
29 | ||
30 | it 'returns correct information about the wiki' do | |
31 | expect(@wiki.slug).to eq 'home' | |
32 | end | |
33 | end | |
34 | ||
35 | describe '.create_wiki' do | |
36 | before do | |
37 | stub_post('/projects/1/wikis', 'wiki') | |
38 | @wiki = Gitlab.create_wiki(1, 'home', 'home page') | |
39 | end | |
40 | ||
41 | it 'gets the correct resource' do | |
42 | expect(a_post('/projects/1/wikis') | |
43 | .with(body: { content: 'home page', title: 'home' })).to have_been_made | |
44 | end | |
45 | ||
46 | it 'returns correct information about the created wiki' do | |
47 | expect(@wiki.content).to eq 'home page' | |
48 | expect(@wiki.title).to eq 'home' | |
49 | end | |
50 | end | |
51 | ||
52 | describe '.update_wiki' do | |
53 | before do | |
54 | stub_put('/projects/1/wikis/home', 'wiki') | |
55 | @wiki = Gitlab.update_wiki(1, 'home', format: 'markdown') | |
56 | end | |
57 | ||
58 | it 'gets the correct resource' do | |
59 | expect(a_put('/projects/1/wikis/home') | |
60 | .with(body: { format: 'markdown' })).to have_been_made | |
61 | end | |
62 | ||
63 | it 'returns correct information about the updated wiki' do | |
64 | expect(@wiki.format).to eq 'markdown' | |
65 | end | |
66 | end | |
67 | ||
68 | describe '.delete_wiki' do | |
69 | before do | |
70 | stub_delete('/projects/1/wikis/home', 'empty') | |
71 | @wiki = Gitlab.delete_wiki(1, 'home') | |
72 | end | |
73 | ||
74 | it 'gets the correct resource' do | |
75 | expect(a_delete('/projects/1/wikis/home')).to have_been_made | |
76 | end | |
77 | end | |
78 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Error::ResponseError do |
11 | 13 | %r{Server responded with code \d+, message: Displayed error. Request URI: https://gitlab.com/api/v3/foo}, |
12 | 14 | %r{Server responded with code \d+, message: 'embed_entity' \(foo: bar\) \(sna: fu\), 'password' too short. Request URI: https://gitlab.com/api/v3/foo}, |
13 | 15 | %r{Server responded with code \d+, message: First message. Second message.. Request URI: https://gitlab.com/api/v3/foo}, |
16 | %r{Server responded with code \d+, message: 'error' Spam detected. Request URI: https://gitlab.com/api/v3/foo} | |
14 | 17 | ] |
15 | 18 | end |
16 | 19 | |
17 | 20 | # Set up some response scenarios to test. |
18 | 21 | [ |
19 | { code: 401, parsed_response: Gitlab::ObjectifiedHash.new(message: 'Displayed message', error_description: 'should not be displayed', error: 'also will not be displayed')}, | |
20 | { code: 404, parsed_response: Gitlab::ObjectifiedHash.new(error_description: 'Displayed error_description', error: 'also will not be displayed')}, | |
21 | { code: 401, parsed_response: Gitlab::ObjectifiedHash.new(error: 'Displayed error')}, | |
22 | { code: 500, parsed_response: Gitlab::ObjectifiedHash.new(embed_entity: { foo: ['bar'], sna: ['fu']}, password: ['too short'])}, | |
23 | { code: 403, parsed_response: Array.new(['First message.', 'Second message.'])}, | |
22 | { code: 401, parsed_response: Gitlab::ObjectifiedHash.new(message: 'Displayed message', error_description: 'should not be displayed', error: 'also will not be displayed') }, | |
23 | { code: 404, parsed_response: Gitlab::ObjectifiedHash.new(error_description: 'Displayed error_description', error: 'also will not be displayed') }, | |
24 | { code: 401, parsed_response: Gitlab::ObjectifiedHash.new(error: 'Displayed error') }, | |
25 | { code: 500, parsed_response: Gitlab::ObjectifiedHash.new(embed_entity: { foo: ['bar'], sna: ['fu'] }, password: ['too short']) }, | |
26 | { code: 403, parsed_response: Array.new(['First message.', 'Second message.']) }, | |
27 | { code: 400, parsed_response: Gitlab::ObjectifiedHash.new(message: { error: 'Spam detected' }) } | |
28 | ||
24 | 29 | ].each_with_index do |data, index| |
25 | 30 | it 'returns the expected message' do |
26 | 31 | response_double = double(**data, request: @request_double) |
1 | 1 | |
2 | 2 | describe Gitlab::FileResponse do |
3 | 3 | before do |
4 | @file_response = Gitlab::FileResponse.new StringIO.new("", 'rb+') | |
4 | @file_response = described_class.new StringIO.new('', 'rb+') | |
5 | 5 | end |
6 | 6 | |
7 | 7 | context '.empty?' do |
8 | it "returns false" do | |
8 | it 'returns false' do | |
9 | 9 | expect(@file_response.empty?).to be false |
10 | 10 | end |
11 | 11 | end |
12 | 12 | |
13 | 13 | context '.to_hash' do |
14 | it "has `filename` key and `data` key" do | |
14 | it 'has `filename` key and `data` key' do | |
15 | 15 | h = @file_response.to_hash |
16 | expect(h.key?(:filename)).to be_truthy | |
17 | expect(h.key?(:data)).to be_truthy | |
16 | expect(h).to be_key(:filename) | |
17 | expect(h).to be_key(:data) | |
18 | 18 | end |
19 | 19 | end |
20 | 20 | |
21 | 21 | context '.parse_headers!' do |
22 | it "parses headers" do | |
22 | it 'parses headers' do | |
23 | 23 | @file_response.parse_headers!('Content-Disposition' => 'attachment; filename=artifacts.zip') |
24 | expect(@file_response.filename).to eq "artifacts.zip" | |
24 | expect(@file_response.filename).to eq 'artifacts.zip' | |
25 | 25 | end |
26 | 26 | |
27 | it "handles quoted filenames" do | |
27 | it 'handles quoted filenames' do | |
28 | 28 | @file_response.parse_headers!('Content-Disposition' => 'attachment; filename="artifacts.zip"') |
29 | expect(@file_response.filename).to eq "artifacts.zip" | |
29 | expect(@file_response.filename).to eq 'artifacts.zip' | |
30 | 30 | end |
31 | 31 | end |
32 | 32 | end |
0 | 0 | require 'spec_helper' |
1 | 1 | |
2 | 2 | describe Gitlab::Help do |
3 | describe ".ri_cmd" do | |
4 | context "ri command found" do | |
5 | it "returns the path to RI" do | |
6 | allow(Gitlab::Help).to receive(:`).with(/which ri/).and_return('/usr/bin/ri') | |
7 | expect(Gitlab::Help.ri_cmd).to eq('/usr/bin/ri') | |
3 | describe '.ri_cmd' do | |
4 | context 'ri command found' do | |
5 | it 'returns the path to RI' do | |
6 | allow(described_class).to receive(:`).with(/which ri/).and_return('/usr/bin/ri') | |
7 | expect(described_class.ri_cmd).to eq('/usr/bin/ri') | |
8 | 8 | end |
9 | 9 | end |
10 | 10 | |
11 | context "ri command NOT found" do | |
12 | it "raises RuntimeError" do | |
13 | allow(Gitlab::Help).to receive(:`).with(/which ri/).and_return('') | |
14 | expect { Gitlab::Help.ri_cmd }.to raise_error RuntimeError | |
11 | context 'ri command NOT found' do | |
12 | it 'raises RuntimeError' do | |
13 | allow(described_class).to receive(:`).with(/which ri/).and_return('') | |
14 | expect { described_class.ri_cmd }.to raise_error RuntimeError | |
15 | 15 | end |
16 | 16 | end |
17 | 17 | end |
18 | 18 | |
19 | describe ".change_help_output!" do | |
19 | describe '.change_help_output!' do | |
20 | 20 | before do |
21 | @cmd = "create_branch" | |
21 | @cmd = 'create_branch' | |
22 | 22 | @help_output = "Gitlab.#{@cmd}(4, 'new-branch', 'master')" |
23 | @help_output_with_options = "Gitlab.groups({ per_page: 3 })" | |
23 | @help_output_with_options = 'Gitlab.groups({ per_page: 3 })' | |
24 | 24 | end |
25 | it "returns a String of modified output" do | |
26 | Gitlab::Help.change_help_output! @cmd, @help_output | |
25 | ||
26 | it 'returns a String of modified output' do | |
27 | described_class.change_help_output! @cmd, @help_output | |
27 | 28 | expect(@help_output).to eq("Gitlab.create_branch 4 'new-branch' 'master'") |
28 | 29 | end |
29 | it "formats options hash and return a String of modified output" do | |
30 | Gitlab::Help.change_help_output! 'groups', @help_output_with_options | |
31 | expect(@help_output_with_options).to eq("Gitlab.groups \"{ per_page: 3 }\"") | |
30 | it 'formats options hash and return a String of modified output' do | |
31 | described_class.change_help_output! 'groups', @help_output_with_options | |
32 | expect(@help_output_with_options).to eq('Gitlab.groups "{ per_page: 3 }"') | |
32 | 33 | end |
33 | 34 | end |
34 | 35 | |
35 | describe ".namespace" do | |
36 | describe '.namespace' do | |
36 | 37 | before do |
37 | 38 | @cmd = 'create_tag' |
38 | @namespace = Gitlab::Help.namespace @cmd | |
39 | @namespace = described_class.namespace @cmd | |
39 | 40 | end |
40 | it "returns the full namespace for a command" do | |
41 | ||
42 | it 'returns the full namespace for a command' do | |
41 | 43 | expect(@namespace).to be_a String |
42 | 44 | expect(@namespace).to eq("Gitlab::Client::Tags.#{@cmd}") |
43 | 45 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::ObjectifiedHash do |
3 | 5 | before do |
4 | 6 | @hash = { a: 1, b: 2, 'string' => 'string', symbol: :symbol } |
5 | @oh = Gitlab::ObjectifiedHash.new @hash | |
7 | @oh = described_class.new @hash | |
6 | 8 | end |
7 | 9 | |
8 | it "objectifies a hash" do | |
10 | it 'objectifies a hash' do | |
9 | 11 | expect(@oh.a).to eq(@hash[:a]) |
10 | 12 | expect(@oh.b).to eq(@hash[:b]) |
11 | 13 | end |
12 | 14 | |
13 | describe "#to_hash" do | |
14 | it "returns an original hash" do | |
15 | describe '#to_hash' do | |
16 | it 'returns an original hash' do | |
15 | 17 | expect(@oh.to_hash).to eq(@hash) |
16 | 18 | end |
17 | 19 | |
18 | it "has an alias #to_h" do | |
19 | expect(@oh.respond_to?(:to_h)).to be_truthy | |
20 | it 'has an alias #to_h' do | |
21 | expect(@oh).to respond_to(:to_h) | |
20 | 22 | end |
21 | 23 | end |
22 | 24 | |
23 | describe "#inspect" do | |
24 | it "returns a formatted string" do | |
25 | describe '#inspect' do | |
26 | it 'returns a formatted string' do | |
25 | 27 | pretty_string = "#<#{@oh.class.name}:#{@oh.object_id} {hash: #{@hash}}" |
26 | 28 | expect(@oh.inspect).to eq(pretty_string) |
27 | 29 | end |
28 | 30 | end |
29 | 31 | |
30 | describe "#respond_to" do | |
31 | it "returns true for methods this object responds to through method_missing as sym" do | |
32 | expect(@oh.respond_to?(:a)).to be_truthy | |
32 | describe '#respond_to' do | |
33 | it 'returns true for methods this object responds to through method_missing as sym' do | |
34 | expect(@oh).to respond_to(:a) | |
33 | 35 | end |
34 | 36 | |
35 | it "returns true for methods this object responds to through method_missing as string" do | |
36 | expect(@oh.respond_to?('string')).to be_truthy | |
37 | it 'returns true for methods this object responds to through method_missing as string' do | |
38 | expect(@oh).to respond_to('string') | |
37 | 39 | end |
38 | 40 | |
39 | it "does not care if you use a string or symbol to reference a method" do | |
40 | expect(@oh.respond_to?(:string)).to be_truthy | |
41 | it 'does not care if you use a string or symbol to reference a method' do | |
42 | expect(@oh).to respond_to(:string) | |
41 | 43 | end |
42 | 44 | |
43 | it "does not care if you use a string or symbol to reference a method" do | |
44 | expect(@oh.respond_to?('symbol')).to be_truthy | |
45 | it 'does not care if you use a string or symbol to reference a method' do | |
46 | expect(@oh).to respond_to('symbol') | |
45 | 47 | end |
46 | 48 | end |
47 | 49 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::PageLinks do |
3 | 5 | before do |
4 | @page_links = Gitlab::PageLinks.new('Link' => "<http://example.com/api/v3/projects?page=1&per_page=5>; rel=\"first\", <http://example.com/api/v3/projects?page=20&per_page=5>; rel=\"last\", <http://example.com/api/v3/projects?page=7&per_page=5>; rel=\"prev\", <http://example.com/api/v3/projects?page=9&per_page=5>; rel=\"next\"") | |
6 | @page_links = described_class.new('Link' => '<http://example.com/api/v3/projects?page=1&per_page=5>; rel="first", <http://example.com/api/v3/projects?page=20&per_page=5>; rel="last", <http://example.com/api/v3/projects?page=7&per_page=5>; rel="prev", <http://example.com/api/v3/projects?page=9&per_page=5>; rel="next"') | |
5 | 7 | end |
6 | 8 | |
7 | 9 | context '.extract_links' do |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::PaginatedResponse do |
3 | 5 | before do |
4 | 6 | array = [1, 2, 3, 4] |
5 | @paginated_response = Gitlab::PaginatedResponse.new array | |
7 | @paginated_response = described_class.new array | |
6 | 8 | end |
7 | 9 | |
8 | it "responds to *_page and has_*_page methods" do | |
10 | it 'responds to *_page and has_*_page methods' do | |
9 | 11 | expect(@paginated_response).to respond_to :first_page |
10 | 12 | expect(@paginated_response).to respond_to :last_page |
11 | 13 | expect(@paginated_response).to respond_to :next_page |
17 | 19 | end |
18 | 20 | |
19 | 21 | context '.parse_headers!' do |
20 | it "parses headers" do | |
21 | @paginated_response.parse_headers!('Link' => "<http://example.com/api/v3/projects?page=1&per_page=5>; rel=\"first\", <http://example.com/api/v3/projects?page=20&per_page=5>; rel=\"last\"") | |
22 | it 'parses headers' do | |
23 | @paginated_response.parse_headers!('Link' => '<http://example.com/api/v3/projects?page=1&per_page=5>; rel="first", <http://example.com/api/v3/projects?page=20&per_page=5>; rel="last"') | |
22 | 24 | client = @paginated_response.client = double('client') |
23 | 25 | first_page_response = double('first_page_response') |
24 | 26 | last_page_response = double('last_page_response') |
25 | allow(client).to receive(:endpoint).and_return("http://example.com/api/v3") | |
26 | allow(client).to receive(:get).with("/projects?page=1&per_page=5").and_return(first_page_response) | |
27 | allow(client).to receive(:get).with("/projects?page=20&per_page=5").and_return(last_page_response) | |
27 | allow(client).to receive(:endpoint).and_return('http://example.com/api/v3') | |
28 | allow(client).to receive(:get).with('/projects?page=1&per_page=5').and_return(first_page_response) | |
29 | allow(client).to receive(:get).with('/projects?page=20&per_page=5').and_return(last_page_response) | |
28 | 30 | expect(@paginated_response.has_first_page?).to be true |
29 | 31 | expect(@paginated_response.has_last_page?).to be true |
30 | 32 | expect(@paginated_response.has_next_page?).to be false |
37 | 39 | end |
38 | 40 | |
39 | 41 | context '.each_page' do |
40 | it "iterates pages" do | |
42 | it 'iterates pages' do | |
41 | 43 | next_page = double('next_page') |
42 | 44 | allow(@paginated_response).to receive(:has_next_page?).and_return(true) |
43 | 45 | allow(@paginated_response).to receive(:next_page).and_return(next_page) |
47 | 49 | end |
48 | 50 | |
49 | 51 | context '.auto_paginate' do |
50 | it "returns an array if block is not given" do | |
52 | it 'returns an array if block is not given' do | |
51 | 53 | next_page = double('next_page') |
52 | 54 | allow(@paginated_response).to receive(:has_next_page?).and_return(true) |
53 | 55 | allow(@paginated_response).to receive(:next_page).and_return(next_page) |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Request do |
5 | 7 | it { is_expected.to respond_to :put } |
6 | 8 | it { is_expected.to respond_to :delete } |
7 | 9 | before do |
8 | @request = Gitlab::Request.new | |
10 | @request = described_class.new | |
9 | 11 | end |
10 | 12 | |
11 | describe ".default_options" do | |
12 | it "has default values" do | |
13 | default_options = Gitlab::Request.default_options | |
13 | describe '.default_options' do | |
14 | it 'has default values' do | |
15 | default_options = described_class.default_options | |
14 | 16 | expect(default_options).to be_a Hash |
15 | 17 | expect(default_options[:parser]).to be_a Proc |
16 | 18 | expect(default_options[:format]).to eq(:json) |
19 | 21 | end |
20 | 22 | end |
21 | 23 | |
22 | describe ".parse" do | |
23 | it "returns ObjectifiedHash" do | |
24 | describe '.parse' do | |
25 | it 'returns ObjectifiedHash' do | |
24 | 26 | body = JSON.unparse(a: 1, b: 2) |
25 | expect(Gitlab::Request.parse(body)).to be_an Gitlab::ObjectifiedHash | |
26 | expect(Gitlab::Request.parse("true")).to be true | |
27 | expect(Gitlab::Request.parse("false")).to be false | |
27 | expect(described_class.parse(body)).to be_an Gitlab::ObjectifiedHash | |
28 | expect(described_class.parse('true')).to be true | |
29 | expect(described_class.parse('false')).to be false | |
28 | 30 | |
29 | expect { Gitlab::Request.parse("string") }.to raise_error(Gitlab::Error::Parsing) | |
31 | expect { described_class.parse('string') }.to raise_error(Gitlab::Error::Parsing) | |
30 | 32 | end |
31 | 33 | end |
32 | 34 | |
33 | describe "#request_defaults" do | |
34 | context "when endpoint is not set" do | |
35 | it "raises Error::MissingCredentials" do | |
35 | describe '#request_defaults' do | |
36 | context 'when endpoint is not set' do | |
37 | it 'raises Error::MissingCredentials' do | |
36 | 38 | @request.endpoint = nil |
37 | 39 | expect do |
38 | 40 | @request.request_defaults |
40 | 42 | end |
41 | 43 | end |
42 | 44 | |
43 | context "when endpoint is set" do | |
44 | before(:each) do | |
45 | context 'when endpoint is set' do | |
46 | before do | |
45 | 47 | @request.endpoint = 'http://rabbit-hole.example.com' |
46 | 48 | end |
47 | 49 | |
48 | it "sets default_params" do | |
50 | it 'sets default_params' do | |
49 | 51 | @request.request_defaults('sudoer') |
50 | expect(Gitlab::Request.default_params).to eq(sudo: 'sudoer') | |
52 | expect(described_class.default_params).to eq(sudo: 'sudoer') | |
51 | 53 | end |
52 | 54 | end |
53 | 55 | end |
54 | 56 | |
55 | describe "#authorization_header" do | |
56 | it "raises MissingCredentials when auth_token and private_token are not set" do | |
57 | describe '#authorization_header' do | |
58 | it 'raises MissingCredentials when auth_token and private_token are not set' do | |
57 | 59 | expect do |
58 | 60 | @request.send(:authorization_header, {}) |
59 | 61 | end.to raise_error(Gitlab::Error::MissingCredentials) |
60 | 62 | end |
61 | 63 | |
62 | it "sets the correct header when given a private_token" do | |
64 | it 'sets the correct header when given a private_token' do | |
63 | 65 | @request.private_token = 'ys9BtunN3rDKbaJCYXaN' |
64 | expect(@request.send(:authorization_header, {})).to eq("PRIVATE-TOKEN" => 'ys9BtunN3rDKbaJCYXaN') | |
66 | expect(@request.send(:authorization_header, {})).to eq('PRIVATE-TOKEN' => 'ys9BtunN3rDKbaJCYXaN') | |
65 | 67 | end |
66 | 68 | |
67 | it "sets the correct header when setting an auth_token via the private_token config option" do | |
69 | it 'sets the correct header when setting an auth_token via the private_token config option' do | |
68 | 70 | @request.private_token = '3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603' |
69 | expect(@request.send(:authorization_header, {})).to eq("Authorization" => "Bearer 3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603") | |
71 | expect(@request.send(:authorization_header, {})).to eq('Authorization' => 'Bearer 3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603') | |
70 | 72 | end |
71 | 73 | end |
72 | 74 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | require 'tempfile' |
2 | 4 | |
4 | 6 | context 'saving to a file' do |
5 | 7 | before do |
6 | 8 | @file = Tempfile.new('.gitlab_shell_history') |
7 | @history = Gitlab::Shell::History.new(file_path: @file.path) | |
9 | @history = described_class.new(file_path: @file.path) | |
8 | 10 | end |
9 | 11 | |
10 | 12 | after { @file.close(true) } |
13 | 15 | @history << 'party on, dudes' |
14 | 16 | @history << 'be excellent to each other' |
15 | 17 | @history.save |
16 | expect(File.read @file.path). | |
17 | to eq("party on, dudes\nbe excellent to each other\n") | |
18 | expect(File.read(@file.path)) | |
19 | .to eq("party on, dudes\nbe excellent to each other\n") | |
18 | 20 | end |
19 | 21 | |
20 | 22 | it 'has the lines' do |
21 | 23 | @history << 'party on, dudes' |
22 | 24 | @history << 'be excellent to each other' |
23 | expect(@history.lines). | |
24 | to eq(["party on, dudes", "be excellent to each other"]) | |
25 | expect(@history.lines) | |
26 | .to eq(['party on, dudes', 'be excellent to each other']) | |
25 | 27 | end |
26 | 28 | |
27 | 29 | it 'limits the lines to GITLAB_HISTFILESIZE' do |
30 | 32 | @history << 'party on, dudes' |
31 | 33 | @history << 'be excellent to each other' |
32 | 34 | @history.save |
33 | expect(@history.lines). | |
34 | to eq(["party on, dudes", "be excellent to each other"]) | |
35 | expect(File.read @file.path). | |
36 | to eq("party on, dudes\nbe excellent to each other\n") | |
35 | expect(@history.lines) | |
36 | .to eq(['party on, dudes', 'be excellent to each other']) | |
37 | expect(File.read(@file.path)) | |
38 | .to eq("party on, dudes\nbe excellent to each other\n") | |
37 | 39 | end |
38 | 40 | end |
39 | 41 | |
40 | 42 | context 'loading a file' do |
41 | 43 | before do |
42 | 44 | @file = load_fixture('shell_history') |
43 | @history = Gitlab::Shell::History.new(file_path: @file.path) | |
45 | @history = described_class.new(file_path: @file.path) | |
44 | 46 | end |
45 | 47 | |
46 | 48 | it 'has the lines' do |
47 | 49 | @history.load |
48 | expect(@history.lines). | |
49 | to eq(["party on, dudes", "be excellent to each other"]) | |
50 | expect(@history.lines) | |
51 | .to eq(['party on, dudes', 'be excellent to each other']) | |
50 | 52 | end |
51 | 53 | end |
52 | 54 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab::Shell do |
3 | 5 | before do |
4 | Gitlab::Shell.setup | |
6 | described_class.setup | |
5 | 7 | end |
6 | 8 | |
7 | describe ".execute" do | |
8 | context "invalid command" do | |
9 | it "raises RuntimeError" do | |
10 | expect { Gitlab::Shell.execute 'foobar', [] }.to raise_error(RuntimeError) | |
9 | describe '.execute' do | |
10 | context 'invalid command' do | |
11 | it 'raises RuntimeError' do | |
12 | expect { described_class.execute 'foobar', [] }.to raise_error(RuntimeError) | |
11 | 13 | end |
12 | 14 | end |
13 | 15 | end |
14 | 16 | |
15 | describe ".history" do | |
17 | describe '.history' do | |
16 | 18 | before do |
17 | @history = Gitlab::Shell.history | |
19 | @history = described_class.history | |
18 | 20 | end |
19 | 21 | |
20 | it "returns a Gitlab::Shell::History instance" do | |
22 | it 'returns a Gitlab::Shell::History instance' do | |
21 | 23 | expect(@history).to be_a Gitlab::Shell::History |
22 | 24 | end |
23 | it "responds to :save" do | |
25 | it 'responds to :save' do | |
24 | 26 | expect(@history).to respond_to :save |
25 | 27 | end |
26 | it "responds to :load" do | |
28 | it 'responds to :load' do | |
27 | 29 | expect(@history).to respond_to :load |
28 | 30 | end |
29 | it "responds to :<<" do | |
31 | it 'responds to :<<' do | |
30 | 32 | expect(@history).to respond_to :<< |
31 | 33 | end |
32 | 34 | end |
33 | 35 | |
34 | describe ".setup" do | |
35 | it "sets the Readline completion_proc" do | |
36 | describe '.setup' do | |
37 | it 'sets the Readline completion_proc' do | |
36 | 38 | completion = Readline.completion_proc |
37 | 39 | expect(completion).to be_truthy |
38 | 40 | expect(completion).to be_a Proc |
39 | 41 | end |
40 | it "sets the Readline completion_append_character" do | |
42 | it 'sets the Readline completion_append_character' do | |
41 | 43 | completion_character = Readline.completion_append_character |
42 | 44 | expect(completion_character).to eq(' ') |
43 | 45 | end |
44 | 46 | end |
45 | 47 | |
46 | describe ".completion" do | |
48 | describe '.completion' do | |
47 | 49 | before do |
48 | @comp = Gitlab::Shell.completion | |
50 | @comp = described_class.completion | |
49 | 51 | end |
50 | it "returns a Proc object" do | |
52 | ||
53 | it 'returns a Proc object' do | |
51 | 54 | expect(@comp).to be_a Proc |
52 | 55 | end |
53 | context "called with an argument" do | |
54 | it "returns an Array of matching commands" do | |
56 | context 'called with an argument' do | |
57 | it 'returns an Array of matching commands' do | |
55 | 58 | completed_cmds = @comp.call 'group' |
56 | 59 | expect(completed_cmds).to be_a Array |
57 | expect(completed_cmds.sort).to eq(%w(group group_access_requests group_member group_members group_milestone group_milestone_issues group_milestone_merge_requests group_milestones group_projects group_search group_subgroups group_variable group_variables groups)) | |
60 | expect(completed_cmds.sort).to eq(%w[group group_access_requests group_member group_members group_milestone group_milestone_issues group_milestone_merge_requests group_milestones group_projects group_search group_subgroups group_variable group_variables groups]) | |
58 | 61 | end |
59 | 62 | end |
60 | 63 | end |
61 | 64 | |
62 | describe ".parse_input" do | |
63 | context "with arguments" do | |
64 | it "sets command & arguments" do | |
65 | Gitlab::Shell.parse_input('create_branch 1 "api" "master"') | |
66 | expect(Gitlab::Shell.command).to eq('create_branch') | |
67 | expect(Gitlab::Shell.arguments).to eq(%w(1 api master)) | |
65 | describe '.parse_input' do | |
66 | context 'with arguments' do | |
67 | it 'sets command & arguments' do | |
68 | described_class.parse_input('create_branch 1 "api" "master"') | |
69 | expect(described_class.command).to eq('create_branch') | |
70 | expect(described_class.arguments).to eq(%w[1 api master]) | |
68 | 71 | end |
69 | 72 | end |
70 | 73 | |
71 | context "without arguments" do | |
74 | context 'without arguments' do | |
72 | 75 | it 'sets command & empty arguments' do |
73 | Gitlab::Shell.parse_input('exit') | |
74 | expect(Gitlab::Shell.command).to eq('exit') | |
75 | expect(Gitlab::Shell.arguments).to be_empty | |
76 | described_class.parse_input('exit') | |
77 | expect(described_class.command).to eq('exit') | |
78 | expect(described_class.arguments).to be_empty | |
76 | 79 | end |
77 | 80 | end |
78 | 81 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'spec_helper' |
1 | 3 | |
2 | 4 | describe Gitlab do |
3 | after { Gitlab.reset } | |
5 | after { described_class.reset } | |
4 | 6 | |
5 | describe ".client" do | |
6 | it "is a Gitlab::Client" do | |
7 | expect(Gitlab.client).to be_a Gitlab::Client | |
7 | describe '.client' do | |
8 | it 'is a Gitlab::Client' do | |
9 | expect(described_class.client).to be_a Gitlab::Client | |
8 | 10 | end |
9 | 11 | |
10 | it "does not override each other" do | |
11 | client1 = Gitlab.client(endpoint: 'https://api1.example.com', private_token: '001') | |
12 | client2 = Gitlab.client(endpoint: 'https://api2.example.com', private_token: '002') | |
12 | it 'does not override each other' do | |
13 | client1 = described_class.client(endpoint: 'https://api1.example.com', private_token: '001') | |
14 | client2 = described_class.client(endpoint: 'https://api2.example.com', private_token: '002') | |
13 | 15 | expect(client1.endpoint).to eq('https://api1.example.com') |
14 | 16 | expect(client2.endpoint).to eq('https://api2.example.com') |
15 | 17 | expect(client1.private_token).to eq('001') |
16 | 18 | expect(client2.private_token).to eq('002') |
17 | 19 | end |
18 | 20 | |
19 | it "sets private_token to the auth_token when provided" do | |
20 | client = Gitlab.client(endpoint: 'https://api2.example.com', auth_token: '3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603') | |
21 | it 'sets private_token to the auth_token when provided' do | |
22 | client = described_class.client(endpoint: 'https://api2.example.com', auth_token: '3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603') | |
21 | 23 | expect(client.private_token).to eq('3225e2804d31fea13fc41fc83bffef00cfaedc463118646b154acc6f94747603') |
22 | 24 | end |
23 | 25 | end |
24 | 26 | |
25 | describe ".actions" do | |
26 | it "returns an array of client methods" do | |
27 | actions = Gitlab.actions | |
27 | describe '.actions' do | |
28 | it 'returns an array of client methods' do | |
29 | actions = described_class.actions | |
28 | 30 | expect(actions).to be_an Array |
29 | 31 | expect(actions.first).to be_a Symbol |
30 | expect(actions.sort.first).to eq(:accept_merge_request) | |
32 | expect(actions.min).to eq(:accept_merge_request) | |
31 | 33 | end |
32 | 34 | end |
33 | 35 | |
34 | describe ".endpoint=" do | |
35 | it "sets endpoint" do | |
36 | Gitlab.endpoint = 'https://api.example.com' | |
37 | expect(Gitlab.endpoint).to eq('https://api.example.com') | |
36 | describe '.endpoint=' do | |
37 | it 'sets endpoint' do | |
38 | described_class.endpoint = 'https://api.example.com' | |
39 | expect(described_class.endpoint).to eq('https://api.example.com') | |
38 | 40 | end |
39 | 41 | end |
40 | 42 | |
41 | describe ".private_token=" do | |
42 | it "sets private_token" do | |
43 | Gitlab.private_token = 'secret' | |
44 | expect(Gitlab.private_token).to eq('secret') | |
43 | describe '.private_token=' do | |
44 | it 'sets private_token' do | |
45 | described_class.private_token = 'secret' | |
46 | expect(described_class.private_token).to eq('secret') | |
45 | 47 | end |
46 | 48 | end |
47 | 49 | |
48 | describe ".auth_token=" do | |
49 | it "sets auth_token", focus: true do | |
50 | Gitlab.auth_token = 'auth_secret' | |
51 | expect(Gitlab.private_token).to eq('auth_secret') | |
50 | describe '.auth_token=' do | |
51 | it 'sets auth_token', focus: true do | |
52 | described_class.auth_token = 'auth_secret' | |
53 | expect(described_class.private_token).to eq('auth_secret') | |
52 | 54 | end |
53 | 55 | end |
54 | 56 | |
55 | describe ".sudo=" do | |
56 | it "sets sudo" do | |
57 | Gitlab.sudo = 'user' | |
58 | expect(Gitlab.sudo).to eq('user') | |
57 | describe '.sudo=' do | |
58 | it 'sets sudo' do | |
59 | described_class.sudo = 'user' | |
60 | expect(described_class.sudo).to eq('user') | |
59 | 61 | end |
60 | 62 | end |
61 | 63 | |
62 | describe ".user_agent" do | |
63 | it "returns default user_agent" do | |
64 | expect(Gitlab.user_agent).to eq(Gitlab::Configuration::DEFAULT_USER_AGENT) | |
64 | describe '.user_agent' do | |
65 | it 'returns default user_agent' do | |
66 | expect(described_class.user_agent).to eq(Gitlab::Configuration::DEFAULT_USER_AGENT) | |
65 | 67 | end |
66 | 68 | end |
67 | 69 | |
68 | describe ".user_agent=" do | |
69 | it "sets user_agent" do | |
70 | Gitlab.user_agent = 'Custom User Agent' | |
71 | expect(Gitlab.user_agent).to eq('Custom User Agent') | |
70 | describe '.user_agent=' do | |
71 | it 'sets user_agent' do | |
72 | described_class.user_agent = 'Custom User Agent' | |
73 | expect(described_class.user_agent).to eq('Custom User Agent') | |
72 | 74 | end |
73 | 75 | end |
74 | 76 | |
75 | describe ".configure" do | |
77 | describe '.configure' do | |
76 | 78 | Gitlab::Configuration::VALID_OPTIONS_KEYS.each do |key| |
77 | 79 | it "sets #{key}" do |
78 | Gitlab.configure do |config| | |
80 | described_class.configure do |config| | |
79 | 81 | config.send("#{key}=", key) |
80 | expect(Gitlab.send(key)).to eq(key) | |
82 | expect(described_class.send(key)).to eq(key) | |
81 | 83 | end |
82 | 84 | end |
83 | 85 | end |
84 | 86 | end |
85 | 87 | |
86 | describe ".http_proxy" do | |
87 | it "delegates the method to Gitlab::Request" do | |
88 | Gitlab.endpoint = 'https://api.example.com' | |
88 | describe '.http_proxy' do | |
89 | it 'delegates the method to Gitlab::Request' do | |
90 | described_class.endpoint = 'https://api.example.com' | |
89 | 91 | request = class_spy(Gitlab::Request).as_stubbed_const |
90 | 92 | |
91 | Gitlab.http_proxy('proxy.example.net', 1987, 'user', 'pass') | |
93 | described_class.http_proxy('proxy.example.net', 1987, 'user', 'pass') | |
92 | 94 | expect(request).to have_received(:http_proxy).with('proxy.example.net', 1987, 'user', 'pass') |
93 | 95 | end |
94 | 96 | end |
0 | # frozen_string_literal: true | |
1 | ||
0 | 2 | require 'rspec' |
1 | 3 | require 'webmock/rspec' |
2 | 4 | |
3 | require File.expand_path('../../lib/gitlab', __FILE__) | |
4 | require File.expand_path('../../lib/gitlab/cli', __FILE__) | |
5 | require File.expand_path('../lib/gitlab', __dir__) | |
6 | require File.expand_path('../lib/gitlab/cli', __dir__) | |
5 | 7 | |
6 | 8 | def capture_output |
7 | 9 | out = StringIO.new |
24 | 26 | end |
25 | 27 | end |
26 | 28 | |
27 | %i(get post put delete).each do |method| | |
28 | define_method "stub_#{method}" do |path, fixture, status_code=200| | |
29 | %i[get post put delete].each do |method| | |
30 | define_method "stub_#{method}" do |path, fixture, status_code = 200| | |
29 | 31 | stub_request(method, "#{Gitlab.endpoint}#{path}") |
30 | 32 | .with(headers: { 'PRIVATE-TOKEN' => Gitlab.private_token }) |
31 | 33 | .to_return(body: load_fixture(fixture), status: status_code) |