Updated version 4.2.0 from 'upstream/4.2.0'
with Debian dir 59ee0f7e5c41b2d780833e3d16a7c58b5617f30e
Sophie Brun
5 years ago
0 | 0 | ## Change Log |
1 | 1 | |
2 | 2 | ### Unreleased |
3 | ||
4 | ### 4.2.0 (13/07/2017) | |
5 | - Use `url_encode` in all `Commit` resources (@grodowski) | |
6 | - Fix `project_search` path for APIv4 (@edaubert) | |
7 | - Add options to `Labels#create_label` (@hlidotbe) | |
8 | - Add `Board` API support (@hlidotbe) | |
9 | - `Award Emoji` API (@akkee) | |
10 | - Subscribe and unsubscribe actions for labels (@akkee) | |
11 | - Add `options` hash to `add_hook` method (@mltsy) | |
12 | - Update repository files endpoint APIv4 (@mltsy) | |
13 | - Update `Branch` docs and add `options` param to `protect_branch` (@mltsy) | |
14 | - Fix and clarify `edit_project` option docs (@mltsy) | |
15 | - Add `TODO` API (@akkee) | |
16 | - Use `body` parameter to send POST data (@sr189) | |
17 | - Add `Environments` module (@mltsy) | |
18 | - Edit and Delete methods for `Notes` API (@akkee) | |
19 | - Rename `branch_name` parameter to `branch` in `create_branch` & `create_commit` methods (@sr189) | |
3 | 20 | |
4 | 21 | ### 4.1.0 (26/05/2017) |
5 | 22 | - Add appropriate Content-Type header (@mltsy) |
0 | class Gitlab::Client | |
1 | # Defines methods related to Award Emojis. | |
2 | # @see https://docs.gitlab.com/ce/api/award_emoji.html | |
3 | module AwardEmojis | |
4 | # Gets a list of all award emoji for an awardable(issue, merge request or snippet) | |
5 | # | |
6 | # @example | |
7 | # Gitlab.award_emojis(1, 80, 'issue') | |
8 | # Gitlab.award_emojis(1, 60, 'merge_request') | |
9 | # Gitlab.award_emojis(1, 40, 'snippet') | |
10 | # | |
11 | # @param [Integer] project The ID of a project. | |
12 | # @param [Integer] awardable_id The ID of an awardable(issue, merge request or snippet). | |
13 | # @param [String] awardable_type The type of the awardable(can be 'issue', 'merge_request' or 'snippet') | |
14 | # @return [Array<Gitlab::ObjectifiedHash>] | |
15 | def award_emojis(project, awardable_id, awardable_type) | |
16 | get("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/award_emoji") | |
17 | end | |
18 | ||
19 | # Gets a list of all award emoji for a single note on an awardable(issue, merge request or snippet) | |
20 | # | |
21 | # @example | |
22 | # Gitlab.note_award_emojis(1, 80, 'issue', 1) | |
23 | # Gitlab.note_award_emojis(1, 60, 'merge_request', 1) | |
24 | # Gitlab.note_award_emojis(1, 40, 'snippet', 1) | |
25 | # | |
26 | # @param [Integer] project The ID of a project. | |
27 | # @param [Integer] awardable_id The ID of an awardable(issue, merge request or snippet). | |
28 | # @param [String] awardable_type The type of the awardable(can be 'issue', 'merge_request' or 'snippet') | |
29 | # @param [Integer] note_id The ID of a note. | |
30 | # @return [Array<Gitlab::ObjectifiedHash>] | |
31 | def note_award_emojis(project, awardable_id, awardable_type, note_id) | |
32 | get("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/notes/#{note_id}/award_emoji") | |
33 | end | |
34 | ||
35 | # Gets a single award emoji for an awardable(issue, merge request or snippet) | |
36 | # | |
37 | # @example | |
38 | # Gitlab.award_emoji(1, 80, 'issue', 4) | |
39 | # Gitlab.award_emoji(1, 60, 'merge_request', 4) | |
40 | # Gitlab.award_emoji(1, 40, 'snippet', 4) | |
41 | # | |
42 | # @param [Integer] project The ID of a project. | |
43 | # @param [Integer] awardable_id The ID of an awardable(issue, merge request or snippet). | |
44 | # @param [String] awardable_type The type of the awardable(can be 'issue', 'merge_request' or 'snippet') | |
45 | # @param [Integer] award_id The ID of an award emoji. | |
46 | # @return [Gitlab::ObjectifiedHash] | |
47 | def award_emoji(project, awardable_id, awardable_type, award_id) | |
48 | get("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/award_emoji/#{award_id}") | |
49 | end | |
50 | ||
51 | # Gets a single award emoji from a single note on an awardable(issue, merge request or snippet) | |
52 | # | |
53 | # @example | |
54 | # Gitlab.note_award_emoji(1, 80, 'issue', 1, 4) | |
55 | # Gitlab.note_award_emoji(1, 60, 'merge_request', 1, 4) | |
56 | # Gitlab.note_award_emoji(1, 40, 'snippet', 1, 4) | |
57 | # | |
58 | # @param [Integer] project The ID of a project. | |
59 | # @param [Integer] awardable_id The ID of an awardable(issue, merge request or snippet). | |
60 | # @param [String] awardable_type The type of the awardable(can be 'issue', 'merge_request' or 'snippet') | |
61 | # @param [Integer] note_id The ID of a note. | |
62 | # @param [Integer] award_id The ID of an award emoji. | |
63 | # @return [Gitlab::ObjectifiedHash] | |
64 | def note_award_emoji(project, awardable_id, awardable_type, note_id, award_id) | |
65 | get("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/notes/#{note_id}/award_emoji/#{award_id}") | |
66 | end | |
67 | ||
68 | # Awards a new emoji to an awardable(issue, merge request or snippet) | |
69 | # | |
70 | # @example | |
71 | # Gitlab.create_award_emoji(1, 80, 'issue', 'blowfish') | |
72 | # Gitlab.create_award_emoji(1, 80, 'merge_request', 'blowfish') | |
73 | # Gitlab.create_award_emoji(1, 80, 'snippet', 'blowfish') | |
74 | # | |
75 | # @param [Integer] project The ID of a project. | |
76 | # @param [Integer] awardable_id The ID of an awardable(issue, merge request or snippet). | |
77 | # @param [String] awardable_type The type of the awardable(can be 'issue', 'merge_request' or 'snippet') | |
78 | # @param [String] emoji_name The name of the emoji, without colons. | |
79 | # @return [Gitlab::ObjectifiedHash] | |
80 | 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}) | |
82 | end | |
83 | ||
84 | # Awards a new emoji to a note on an awardable(issue, merge request or snippet) | |
85 | # | |
86 | # @example | |
87 | # Gitlab.create_note_award_emoji(1, 80, 'issue', 1, 'blowfish') | |
88 | # Gitlab.create_note_award_emoji(1, 80, 'merge_request', 1, 'blowfish') | |
89 | # Gitlab.create_note_award_emoji(1, 80, 'snippet', 1, 'blowfish') | |
90 | # | |
91 | # @param [Integer] project The ID of a project. | |
92 | # @param [Integer] awardable_id The ID of an awardable(issue, merge request or snippet). | |
93 | # @param [String] awardable_type The type of the awardable(can be 'issue', 'merge_request' or 'snippet') | |
94 | # @param [Integer] note_id The ID of a note. | |
95 | # @param [String] emoji_name The name of the emoji, without colons. | |
96 | # @return [Gitlab::ObjectifiedHash] | |
97 | 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}) | |
99 | end | |
100 | ||
101 | # Deletes a single award emoji from an awardable(issue, merge request or snippet) | |
102 | # | |
103 | # @example | |
104 | # Gitlab.delete_award_emoji(1, 80, 'issue', 4) | |
105 | # Gitlab.delete_award_emoji(1, 60, 'merge_request', 4) | |
106 | # Gitlab.delete_award_emoji(1, 40, 'snippet', 4) | |
107 | # | |
108 | # @param [Integer] project The ID of a project. | |
109 | # @param [Integer] awardable_id The ID of an awardable(issue, merge request or snippet). | |
110 | # @param [String] awardable_type The type of the awardable(can be 'issue', 'merge_request' or 'snippet') | |
111 | # @param [Integer] award_id The ID of an award emoji. | |
112 | # @return [void] This API call returns an empty response body. | |
113 | def delete_award_emoji(project, awardable_id, awardable_type, award_id) | |
114 | delete("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/award_emoji/#{award_id}") | |
115 | end | |
116 | ||
117 | # Deletes a single award emoji from a single note on an awardable(issue, merge request or snippet) | |
118 | # | |
119 | # @example | |
120 | # Gitlab.delete_note_award_emoji(1, 80, 'issue', 1, 4) | |
121 | # Gitlab.delete_note_award_emoji(1, 60, 'merge_request', 1, 4) | |
122 | # Gitlab.delete_note_award_emoji(1, 40, 'snippet', 1, 4) | |
123 | # | |
124 | # @param [Integer] project The ID of a project. | |
125 | # @param [Integer] awardable_id The ID of an awardable(issue, merge request or snippet). | |
126 | # @param [String] awardable_type The type of the awardable(can be 'issue', 'merge_request' or 'snippet') | |
127 | # @param [Integer] note_id The ID of a note. | |
128 | # @param [Integer] award_id The ID of an award emoji. | |
129 | # @return [void] This API call returns an empty response body. | |
130 | def delete_note_award_emoji(project, awardable_id, awardable_type, note_id, award_id) | |
131 | delete("/projects/#{url_encode project}/#{awardable_type}s/#{awardable_id}/notes/#{note_id}/award_emoji/#{award_id}") | |
132 | end | |
133 | end | |
134 | end⏎ |
0 | class Gitlab::Client | |
1 | # Defines methods related to issue boards. | |
2 | # @see https://docs.gitlab.com/ce/api/boards.html | |
3 | module Boards | |
4 | # Gets a list of project's boards. | |
5 | # | |
6 | # @example | |
7 | # Gitlab.boards(5) | |
8 | # Gitlab.boards({ per_page: 40 }) | |
9 | # | |
10 | # @param [Integer, String] project The ID or name of a project. | |
11 | # @param [Hash] options A customizable set of options. | |
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>] | |
15 | def boards(project, options={}) | |
16 | get("/projects/#{url_encode project}/boards", query: options) | |
17 | end | |
18 | ||
19 | # Gets a board lists | |
20 | # | |
21 | # @example | |
22 | # Gitlab.board_lists(5, 42) | |
23 | # | |
24 | # @param [Integer, String] project The ID or name of a project. | |
25 | # @param [Integer] id The ID of a board. | |
26 | # @return [Gitlab::ObjectifiedHash] | |
27 | def board_lists(project, id) | |
28 | get("/projects/#{url_encode project}/boards/#{id}/lists") | |
29 | end | |
30 | # | |
31 | # Gets a single board list | |
32 | # | |
33 | # @example | |
34 | # Gitlab.board_list(5, 42, 25) | |
35 | # | |
36 | # @param [Integer, String] project The ID or name of a project. | |
37 | # @param [Integer] board_id The ID of a board. | |
38 | # @param [Integer] id The ID of a list. | |
39 | # @return [Gitlab::ObjectifiedHash] | |
40 | def board_list(project, board_id, id) | |
41 | get("/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}") | |
42 | end | |
43 | ||
44 | # Creates a new board list. | |
45 | # Only for admins and project owners | |
46 | # | |
47 | # @example | |
48 | # Gitlab.create_board_list(5, 42, 25) | |
49 | # | |
50 | # @param [Integer, String] project The ID or name of a project. | |
51 | # @param [Integer] id The ID of a board. | |
52 | # @param [Integer] label_id The ID of a label. | |
53 | # @return [Gitlab::ObjectifiedHash] Information about created list. | |
54 | def create_board_list(project, board_id, label_id) | |
55 | post("/projects/#{url_encode project}/boards/#{board_id}/lists", body: {label_id: label_id}) | |
56 | end | |
57 | ||
58 | # Updates a board list. | |
59 | # Only for admins and project owners | |
60 | # | |
61 | # @example | |
62 | # Gitlab.edit_board_list(6, 1, 12, 5) | |
63 | # | |
64 | # @param [Integer, String] project The ID or name of a project. | |
65 | # @param [Integer] board_id The ID of a board. | |
66 | # @param [Integer] id The ID of a list. | |
67 | # @return [Gitlab::ObjectifiedHash] Information about updated board list. | |
68 | def edit_board_list(project, board_id, id, position) | |
69 | put("/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}", body: {position: position}) | |
70 | end | |
71 | ||
72 | # Deletes a board list. | |
73 | # Only for admins and project owners | |
74 | # | |
75 | # @example | |
76 | # Gitlab.delete_board_list(3, 42, 32) | |
77 | # | |
78 | # @param [Integer, String] project The ID or name of a project. | |
79 | # @param [Integer] board_id The ID of a board. | |
80 | # @param [Integer] id The ID of a list. | |
81 | # @return [Gitlab::ObjectifiedHash] Information about deleted board list. | |
82 | def delete_board_list(project, board_id, id) | |
83 | delete("/projects/#{url_encode project}/boards/#{board_id}/lists/#{id}") | |
84 | end | |
85 | end | |
86 | end | |
87 |
35 | 35 | # @example |
36 | 36 | # Gitlab.protect_branch(3, 'api') |
37 | 37 | # Gitlab.repo_protect_branch(5, 'master') |
38 | # Gitlab.protect_branch(5, 'api', developers_can_push: true) | |
39 | # | |
40 | # To update options, call `protect_branch` again with new options (i.e. `developers_can_push: false`) | |
38 | 41 | # |
39 | 42 | # @param [Integer, String] project The ID or name of a project. |
40 | 43 | # @param [String] branch The name of the branch. |
41 | # @return [Gitlab::ObjectifiedHash] | |
42 | def protect_branch(project, branch) | |
43 | put("/projects/#{url_encode project}/repository/branches/#{branch}/protect") | |
44 | # @param [Hash] options A customizable set of options. | |
45 | # @option options [Boolean] :developers_can_push True to allow developers to push to the branch (default = false) | |
46 | # @option options [Boolean] :developers_can_merge True to allow developers to merge into the branch (default = false) | |
47 | # @return [Gitlab::ObjectifiedHash] Details about the branch | |
48 | def protect_branch(project, branch, options = {}) | |
49 | put("/projects/#{url_encode project}/repository/branches/#{branch}/protect", body: options) | |
44 | 50 | end |
45 | 51 | alias_method :repo_protect_branch, :protect_branch |
46 | 52 | |
52 | 58 | # |
53 | 59 | # @param [Integer, String] project The ID or name of a project. |
54 | 60 | # @param [String] branch The name of the branch. |
55 | # @return [Gitlab::ObjectifiedHash] | |
61 | # @return [Gitlab::ObjectifiedHash] Details about the branch | |
56 | 62 | def unprotect_branch(project, branch) |
57 | 63 | put("/projects/#{url_encode project}/repository/branches/#{branch}/unprotect") |
58 | 64 | end |
67 | 73 | # @param [Integer, String] project The ID or name of a project. |
68 | 74 | # @param [String] branch The name of the new branch. |
69 | 75 | # @param [String] ref Create branch from commit sha or existing branch |
70 | # @return [Gitlab::ObjectifiedHash] | |
76 | # @return [Gitlab::ObjectifiedHash] Details about the branch | |
71 | 77 | def create_branch(project, branch, ref) |
72 | post("/projects/#{url_encode project}/repository/branches", body: { branch_name: branch, ref: ref }) | |
78 | post("/projects/#{url_encode project}/repository/branches", body: { branch: branch, ref: ref }) | |
73 | 79 | end |
74 | 80 | alias_method :repo_create_branch, :create_branch |
75 | 81 | |
81 | 87 | # |
82 | 88 | # @param [Integer, String] project The ID or name of a project. |
83 | 89 | # @param [String] branch The name of the branch to delete |
84 | # @return [Gitlab::ObjectifiedHash] | |
85 | 90 | def delete_branch(project, branch) |
86 | 91 | delete("/projects/#{url_encode project}/repository/branches/#{branch}") |
87 | 92 | end |
93 | 93 | # @option options [String] :stage Filter by stage |
94 | 94 | # @option options [String] :name Filter by status name, eg. jenkins |
95 | 95 | # @option options [Boolean] :all The flag to return all statuses, not only latest ones |
96 | def commit_status(id, sha, options={}) | |
97 | get("/projects/#{id}/repository/commits/#{sha}/statuses", query: options) | |
96 | def commit_status(project, sha, options={}) | |
97 | get("/projects/#{url_encode project}/repository/commits/#{sha}/statuses", query: options) | |
98 | 98 | end |
99 | 99 | alias_method :repo_commit_status, :commit_status |
100 | 100 | |
112 | 112 | # @option options [String] :ref The ref (branch or tag) to which the status refers |
113 | 113 | # @option options [String] :name Filter by status name, eg. jenkins |
114 | 114 | # @option options [String] :target_url The target URL to associate with this status |
115 | def update_commit_status(id, sha, state, options={}) | |
116 | post("/projects/#{id}/statuses/#{sha}", query: options.merge(state: state)) | |
115 | def update_commit_status(project, sha, state, options={}) | |
116 | post("/projects/#{url_encode project}/statuses/#{sha}", query: options.merge(state: state)) | |
117 | 117 | end |
118 | 118 | alias_method :repo_update_commit_status, :update_commit_status |
119 | 119 | |
135 | 135 | # @return [Gitlab::ObjectifiedHash] hash of commit related data |
136 | 136 | def create_commit(project, branch, message, actions, options={}) |
137 | 137 | payload = { |
138 | branch_name: branch, | |
138 | branch: branch, | |
139 | 139 | commit_message: message, |
140 | 140 | actions: actions, |
141 | 141 | }.merge(options) |
142 | post("/projects/#{url_encode project}/repository/commits", query: payload) | |
142 | post("/projects/#{url_encode project}/repository/commits", body: payload) | |
143 | 143 | end |
144 | 144 | end |
145 | 145 | end |
0 | class Gitlab::Client | |
1 | # Defines methods related to environments. | |
2 | # @see https://docs.gitlab.com/ce/api/environments.html | |
3 | module Environments | |
4 | # Gets a list of project environments. | |
5 | # | |
6 | # @example | |
7 | # Gitlab.environments(5) | |
8 | # Gitlab.environments(5, { per_page: 10, page: 2 }) | |
9 | # | |
10 | # @param [Integer, String] project The ID or name of a project. | |
11 | # @param [Hash] options A customizable set of options. | |
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>] | |
15 | def environments(project, options={}) | |
16 | get("/projects/#{url_encode project}/environments", query: options) | |
17 | end | |
18 | ||
19 | # Gets a single environment. | |
20 | # | |
21 | # @example | |
22 | # Gitlab.environment(5, 36) | |
23 | # | |
24 | # @param [Integer, String] project The ID or name of a project. | |
25 | # @param [Integer] id The ID of an environment. | |
26 | # @return [Gitlab::ObjectifiedHash] | |
27 | def environment(project, id) | |
28 | get("/projects/#{url_encode project}/environments/#{id}") | |
29 | end | |
30 | ||
31 | # Create an environment. | |
32 | # | |
33 | # @examples | |
34 | # Gitlab.create_environment(5, 'test-branch') | |
35 | # Gitlab.create_environment(5, 'test-branch', external_url: 'https://test-branch.example.host.com') | |
36 | # | |
37 | # @param [Integer, String] project The ID or name of a project. | |
38 | # @param [String] env_name Name for the environment | |
39 | # @option options [String] :external_url Optional URL for viewing the deployed project in this environment | |
40 | # @return [Gitlab::ObjectifiedHash] The updated environment. | |
41 | def create_environment(project, env_name, options = {}) | |
42 | body = {name: env_name}.merge(options) | |
43 | post("/projects/#{url_encode project}/environments", body: body) | |
44 | end | |
45 | ||
46 | # Update an environment. | |
47 | # | |
48 | # @examples | |
49 | # Gitlab.edit_environment(5, 36, name: 'test-branch') | |
50 | # Gitlab.edit_environment(5, 36, external_url: 'https://test-branch.example.host.com') | |
51 | # | |
52 | # @param [Integer, String] project The ID or name of a project. | |
53 | # @param [Integer] id The ID of an environment. | |
54 | # @param [Hash] options A hash of the attribute keys & values to update. | |
55 | # @option options [String] env_name Name for the environment | |
56 | # @option options [String] external_url Optional URL for viewing the deployed project in this environment | |
57 | # @return [Gitlab::ObjectifiedHash] The updated environment. | |
58 | def edit_environment(project, id, options={}) | |
59 | put("/projects/#{url_encode project}/environments/#{id}", body: options) | |
60 | end | |
61 | ||
62 | # Deletes an environment. | |
63 | # | |
64 | # @example | |
65 | # Gitlab.delete_environment(5, 36) | |
66 | # | |
67 | # @param [Integer, String] project The ID or name of a project. | |
68 | # @param [Integer] id The ID of an environment. | |
69 | # @return [Gitlab::ObjectifiedHash] Information about the deleted environment. | |
70 | def delete_environment(project, id) | |
71 | delete("/projects/#{url_encode project}/environments/#{id}") | |
72 | end | |
73 | ||
74 | # Stop an environment. | |
75 | # | |
76 | # @example | |
77 | # Gitlab.stop_environment(5, 36) | |
78 | # | |
79 | # @param [Integer, String] project The ID or name of a project. | |
80 | # @param [Integer] id The ID of an environment. | |
81 | # @return [Array<Gitlab::ObjectifiedHash>] The stopped environment. | |
82 | def stop_environment(project, id) | |
83 | post("/projects/#{url_encode project}/environments/#{id}/stop") | |
84 | end | |
85 | end | |
86 | end |
18 | 18 | # Gitlab.create_label(42, "Backlog", '#DD10AA') |
19 | 19 | # |
20 | 20 | # @param [Integer, String] project The ID or name of a project. |
21 | # @option [String] name The name of a label. | |
22 | # @option [String] color The color of a label. | |
21 | # @param [String] name The name of a label. | |
22 | # @param [String] color The color of a label. | |
23 | # @param [Hash] options A customizable set of options. | |
24 | # @option options [String] :description The description of the label. | |
25 | # @option options [String] :priority The priority of the label. Must be greater or equal than zero or null to remove the priority. | |
23 | 26 | # @return [Gitlab::ObjectifiedHash] Information about created label. |
24 | def create_label(project, name, color) | |
25 | post("/projects/#{url_encode project}/labels", body: { name: name, color: color }) | |
27 | def create_label(project, name, color, options = {}) | |
28 | post("/projects/#{url_encode project}/labels", body: options.merge(name: name, color: color)) | |
26 | 29 | end |
27 | 30 | |
28 | 31 | # Updates a label. |
36 | 39 | # @param [Hash] options A customizable set of options. |
37 | 40 | # @option options [String] :new_name The new name of a label. |
38 | 41 | # @option options [String] :color The color of a label. |
42 | # @option options [String] :description The description of the label. | |
43 | # @option options [String] :priority The priority of the label. Must be greater or equal than zero or null to remove the priority. | |
39 | 44 | # @return [Gitlab::ObjectifiedHash] Information about updated label. |
40 | 45 | def edit_label(project, name, options={}) |
41 | 46 | put("/projects/#{url_encode project}/labels", body: options.merge(name: name)) |
52 | 57 | def delete_label(project, name) |
53 | 58 | delete("/projects/#{url_encode project}/labels", body: { name: name }) |
54 | 59 | end |
60 | ||
61 | # Subscribes the user to a label to receive notifications | |
62 | # | |
63 | # @example | |
64 | # Gitlab.subscribe_to_label(2, 'Backlog') | |
65 | # | |
66 | # @param [Integer, String] project The ID or name of a project. | |
67 | # @param [String] name The name of a label. | |
68 | # @return [Gitlab::ObjectifiedHash] Information about the label subscribed to. | |
69 | def subscribe_to_label(project, name) | |
70 | post("/projects/#{url_encode project}/labels/#{url_encode name}/subscribe") | |
71 | end | |
72 | ||
73 | # Unsubscribes the user from a label to not receive notifications from it | |
74 | # | |
75 | # @example | |
76 | # Gitlab.unsubscribe_from_label(2, 'Backlog') | |
77 | # | |
78 | # @param [Integer, String] project The ID or name of a project. | |
79 | # @param [String] name The name of a label. | |
80 | # @return [Gitlab::ObjectifiedHash] Information about the label unsubscribed from. | |
81 | def unsubscribe_from_label(project, name) | |
82 | post("/projects/#{url_encode project}/labels/#{url_encode name}/unsubscribe") | |
83 | end | |
55 | 84 | end |
56 | 85 | end |
81 | 81 | put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options) |
82 | 82 | end |
83 | 83 | |
84 | # Adds a comment to a merge request. | |
85 | # | |
86 | # @example | |
87 | # Gitlab.create_merge_request_comment(5, 1, "Awesome merge!") | |
88 | # Gitlab.create_merge_request_comment('gitlab', 1, "Awesome merge!") | |
89 | # | |
90 | # @param [Integer, String] project The ID or name of a project. | |
91 | # @param [Integer] id The ID of a merge request. | |
92 | # @param [String] note The content of a comment. | |
93 | # @return [Gitlab::ObjectifiedHash] Information about created merge request comment. | |
94 | def create_merge_request_comment(project, id, note) | |
95 | post("/projects/#{url_encode project}/merge_requests/#{id}/notes", body: { body: note }) | |
96 | end | |
97 | ||
98 | # Adds a comment to a merge request. | |
99 | # | |
100 | # @example | |
101 | # Gitlab.edit_merge_request_comment(5, 1,2, "Awesome merge!") | |
102 | # Gitlab.edit_merge_request_comment('gitlab', 1, 2, "Awesome merge!") | |
103 | # | |
104 | # @param [Integer, String] project The ID or name of a project. | |
105 | # @param [Integer] id The ID of a merge request. | |
106 | # @param [Integer] id The ID of the merge-request comment | |
107 | # @param [String] note The content of a comment. | |
108 | # @return [Gitlab::ObjectifiedHash] Information about created merge request comment. | |
109 | def edit_merge_request_comment(project, id, note_id , note) | |
110 | put("/projects/#{url_encode project}/merge_requests/#{id}/notes/#{note_id}", body: { body: note }) | |
111 | end | |
112 | ||
113 | # Deletes a comment from a merge request. | |
114 | # | |
115 | # @example | |
116 | # Gitlab.delete_merge_request_comment(5, 1,2) | |
117 | # Gitlab.delete_merge_request_comment('gitlab', 1, 2) | |
118 | # | |
119 | # @param [Integer, String] project The ID or name of a project. | |
120 | # @param [Integer] id The ID of a merge request. | |
121 | # @param [Integer] id The ID of the merge-request comment | |
122 | # @return [Gitlab::ObjectifiedHash] Information about created merge request comment. | |
123 | def delete_merge_request_comment(project, id, note_id) | |
124 | delete("/projects/#{url_encode project}/merge_requests/#{id}/notes/#{note_id}") | |
125 | end | |
126 | ||
127 | # Gets the comments on a merge request. | |
128 | # | |
129 | # @example | |
130 | # Gitlab.merge_request_comments(5, 1) | |
131 | # Gitlab.merge_request_comments(5, 1, { per_page: 10, page: 2 }) | |
132 | # | |
133 | # @param [Integer, String] project The ID or name of a project. | |
134 | # @param [Integer] id The ID of a merge request. | |
135 | # @param [Hash] options A customizable set of options. | |
136 | # @option options [Integer] :page The page number. | |
137 | # @option options [Integer] :per_page The number of results per page. | |
138 | # @return [Gitlab::ObjectifiedHash] The merge request's comments. | |
139 | def merge_request_comments(project, id, options={}) | |
140 | get("/projects/#{url_encode project}/merge_requests/#{id}/notes", query: options) | |
141 | end | |
142 | ||
143 | 84 | # Gets the changes of a merge request. |
144 | 85 | # |
145 | 86 | # @example |
55 | 55 | def merge_request_notes(project, merge_request, options={}) |
56 | 56 | get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options) |
57 | 57 | end |
58 | alias_method :merge_request_comments, :merge_request_notes | |
58 | 59 | |
59 | 60 | # Gets a single wall note. |
60 | 61 | # |
156 | 157 | def create_merge_request_note(project, merge_request, body) |
157 | 158 | post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body }) |
158 | 159 | end |
160 | alias_method :create_merge_request_comment, :create_merge_request_note | |
161 | ||
162 | # Deletes a wall note. | |
163 | # | |
164 | # @example | |
165 | # Gitlab.delete_note(5, 15) | |
166 | # | |
167 | # @param [Integer] project The ID of a project. | |
168 | # @param [Integer] id The ID of a note. | |
169 | # @return [Gitlab::ObjectifiedHash] | |
170 | def delete_note(project, id) | |
171 | delete("/projects/#{url_encode project}/notes/#{id}") | |
172 | end | |
173 | ||
174 | # Deletes an issue note. | |
175 | # | |
176 | # @example | |
177 | # Gitlab.delete_issue_note(5, 10, 1) | |
178 | # | |
179 | # @param [Integer] project The ID of a project. | |
180 | # @param [Integer] issue The ID of an issue. | |
181 | # @param [Integer] id The ID of a note. | |
182 | # @return [Gitlab::ObjectifiedHash] | |
183 | def delete_issue_note(project, issue, id) | |
184 | delete("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}") | |
185 | end | |
186 | ||
187 | # Deletes a snippet note. | |
188 | # | |
189 | # @example | |
190 | # Gitlab.delete_snippet_note(5, 11, 3) | |
191 | # | |
192 | # @param [Integer] project The ID of a project. | |
193 | # @param [Integer] snippet The ID of a snippet. | |
194 | # @param [Integer] id The ID of a note. | |
195 | # @return [Gitlab::ObjectifiedHash] | |
196 | def delete_snippet_note(project, snippet, id) | |
197 | delete("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}") | |
198 | end | |
199 | ||
200 | # Deletes a merge_request note. | |
201 | # | |
202 | # @example | |
203 | # Gitlab.delete_merge_request_note(5, 11, 3) | |
204 | # | |
205 | # @param [Integer] project The ID of a project. | |
206 | # @param [Integer] merge_request The ID of a merge_request. | |
207 | # @param [Integer] id The ID of a note. | |
208 | # @return [Gitlab::ObjectifiedHash] | |
209 | def delete_merge_request_note(project, merge_request, id) | |
210 | delete("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}") | |
211 | end | |
212 | alias_method :delete_merge_request_comment, :delete_merge_request_note | |
213 | ||
214 | # Modifies a wall note. | |
215 | # | |
216 | # @example | |
217 | # Gitlab.edit_note(5, 15, 'This is an edited note') | |
218 | # | |
219 | # @param [Integer] project The ID of a project. | |
220 | # @param [Integer] id The ID of a note. | |
221 | # @return [Gitlab::ObjectifiedHash] | |
222 | def edit_note(project, id, body) | |
223 | put("/projects/#{url_encode project}/notes/#{id}", body: body) | |
224 | end | |
225 | ||
226 | # Modifies an issue note. | |
227 | # | |
228 | # @example | |
229 | # Gitlab.edit_issue_note(5, 10, 1, 'This is an edited issue note') | |
230 | # | |
231 | # @param [Integer] project The ID of a project. | |
232 | # @param [Integer] issue The ID of an issue. | |
233 | # @param [Integer] id The ID of a note. | |
234 | # @return [Gitlab::ObjectifiedHash] | |
235 | def edit_issue_note(project, issue, id, body) | |
236 | put("/projects/#{url_encode project}/issues/#{issue}/notes/#{id}", body: body) | |
237 | end | |
238 | ||
239 | # Modifies a snippet note. | |
240 | # | |
241 | # @example | |
242 | # Gitlab.edit_snippet_note(5, 11, 3, 'This is an edited snippet note') | |
243 | # | |
244 | # @param [Integer] project The ID of a project. | |
245 | # @param [Integer] snippet The ID of a snippet. | |
246 | # @param [Integer] id The ID of a note. | |
247 | # @return [Gitlab::ObjectifiedHash] | |
248 | def edit_snippet_note(project, snippet, id, body) | |
249 | put("/projects/#{url_encode project}/snippets/#{snippet}/notes/#{id}", body: body) | |
250 | end | |
251 | ||
252 | # Modifies a merge_request note. | |
253 | # | |
254 | # @example | |
255 | # Gitlab.edit_merge_request_note(5, 11, 3, 'This is an edited merge request note') | |
256 | # | |
257 | # @param [Integer] project The ID of a project. | |
258 | # @param [Integer] merge_request The ID of a merge_request. | |
259 | # @param [Integer] id The ID of a note. | |
260 | # @return [Gitlab::ObjectifiedHash] | |
261 | def edit_merge_request_note(project, merge_request, id, body) | |
262 | put("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes/#{id}", body: body) | |
263 | end | |
264 | alias_method :edit_merge_request_comment, :edit_merge_request_note | |
159 | 265 | end |
160 | 266 | end |
33 | 33 | # @option options [String] :sort Return requests sorted in asc or desc order |
34 | 34 | # @return [Array<Gitlab::ObjectifiedHash>] |
35 | 35 | def project_search(query, options={}) |
36 | get("/projects/search/#{query}", query: options) | |
36 | get("/projects", query: options.merge(search:query)) | |
37 | 37 | end |
38 | 38 | alias_method :search_projects, :project_search |
39 | 39 | |
43 | 43 | # Gitlab.project(3) |
44 | 44 | # Gitlab.project('gitlab') |
45 | 45 | # |
46 | # @param [Integer, String] id The ID or name of a project. | |
46 | # @param [Integer, String] id The ID or path of a project. | |
47 | 47 | # @return [Gitlab::ObjectifiedHash] |
48 | 48 | def project(id) |
49 | 49 | get("/projects/#{url_encode id}") |
55 | 55 | # Gitlab.project_events(42) |
56 | 56 | # Gitlab.project_events('gitlab') |
57 | 57 | # |
58 | # @param [Integer, String] project The ID or name of a project. | |
58 | # @param [Integer, String] project The ID or path of a project. | |
59 | 59 | # @param [Hash] options A customizable set of options. |
60 | 60 | # @option options [Integer] :page The page number. |
61 | 61 | # @option options [Integer] :per_page The number of results per page. |
75 | 75 | # @param [Hash] options A customizable set of options. |
76 | 76 | # @option options [String] :description The description of a project. |
77 | 77 | # @option options [String] :default_branch The default branch of a project. |
78 | # @option options [String] :path Repository name for new project. (Default is lowercase name with dashes) | |
78 | 79 | # @option options [String] :namespace_id The namespace in which to create a project. |
79 | 80 | # @option options [Boolean] :wiki_enabled The wiki integration for a project (0 = false, 1 = true). |
80 | 81 | # @option options [Boolean] :wall_enabled The wall functionality for a project (0 = false, 1 = true). |
94 | 95 | # @example |
95 | 96 | # Gitlab.delete_project(4) |
96 | 97 | # |
97 | # @param [Integer, String] id The ID or name of a project. | |
98 | # @param [Integer, String] id The ID or path of a project. | |
98 | 99 | # @return [Gitlab::ObjectifiedHash] Information about deleted project. |
99 | 100 | def delete_project(id) |
100 | delete("/projects/#{id}") | |
101 | delete("/projects/#{url_encode id}") | |
101 | 102 | end |
102 | 103 | |
103 | 104 | # Gets a list of project team members. |
106 | 107 | # Gitlab.team_members(42) |
107 | 108 | # Gitlab.team_members('gitlab') |
108 | 109 | # |
109 | # @param [Integer, String] project The ID or name of a project. | |
110 | # @param [Integer, String] project The ID or path of a project. | |
110 | 111 | # @param [Hash] options A customizable set of options. |
111 | 112 | # @option options [String] :query The search query. |
112 | 113 | # @option options [Integer] :page The page number. |
121 | 122 | # @example |
122 | 123 | # Gitlab.team_member('gitlab', 2) |
123 | 124 | # |
124 | # @param [Integer, String] project The ID or name of a project. | |
125 | # @param [Integer, String] project The ID or path of a project. | |
125 | 126 | # @param [Integer] id The ID of a project team member. |
126 | 127 | # @return [Gitlab::ObjectifiedHash] |
127 | 128 | def team_member(project, id) |
133 | 134 | # @example |
134 | 135 | # Gitlab.add_team_member('gitlab', 2, 40) |
135 | 136 | # |
136 | # @param [Integer, String] project The ID or name of a project. | |
137 | # @param [Integer, String] project The ID or path of a project. | |
137 | 138 | # @param [Integer] id The ID of a user. |
138 | 139 | # @param [Integer] access_level The access level to project. |
139 | 140 | # @param [Hash] options A customizable set of options. |
147 | 148 | # @example |
148 | 149 | # Gitlab.edit_team_member('gitlab', 3, 20) |
149 | 150 | # |
150 | # @param [Integer, String] project The ID or name of a project. | |
151 | # @param [Integer, String] project The ID or path of a project. | |
151 | 152 | # @param [Integer] id The ID of a user. |
152 | 153 | # @param [Integer] access_level The access level to project. |
153 | 154 | # @param [Hash] options A customizable set of options. |
161 | 162 | # @example |
162 | 163 | # Gitlab.remove_team_member('gitlab', 2) |
163 | 164 | # |
164 | # @param [Integer, String] project The ID or name of a project. | |
165 | # @param [Integer, String] project The ID or path of a project. | |
165 | 166 | # @param [Integer] id The ID of a user. |
166 | 167 | # @param [Hash] options A customizable set of options. |
167 | 168 | # @return [Gitlab::ObjectifiedHash] Information about removed team member. |
175 | 176 | # Gitlab.project_hooks(42) |
176 | 177 | # Gitlab.project_hooks('gitlab') |
177 | 178 | # |
178 | # @param [Integer, String] project The ID or name of a project. | |
179 | # @param [Integer, String] project The ID or path of a project. | |
179 | 180 | # @param [Hash] options A customizable set of options. |
180 | 181 | # @option options [Integer] :page The page number. |
181 | 182 | # @option options [Integer] :per_page The number of results per page. |
190 | 191 | # Gitlab.project_hook(42, 5) |
191 | 192 | # Gitlab.project_hook('gitlab', 5) |
192 | 193 | # |
193 | # @param [Integer, String] project The ID or name of a project. | |
194 | # @param [Integer, String] project The ID or path of a project. | |
194 | 195 | # @param [Integer] id The ID of a hook. |
195 | 196 | # @return [Gitlab::ObjectifiedHash] |
196 | 197 | def project_hook(project, id) |
202 | 203 | # @example |
203 | 204 | # Gitlab.add_project_hook(42, 'https://api.example.net/v1/webhooks/ci') |
204 | 205 | # |
205 | # @param [Integer, String] project The ID or name of a project. | |
206 | # @param [Integer, String] project The ID or path of a project. | |
206 | 207 | # @param [String] url The hook URL. |
207 | 208 | # @param [Hash] options A customizable set of options. |
208 | 209 | # @param option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true) |
220 | 221 | # @example |
221 | 222 | # Gitlab.edit_project_hook(42, 1, 'https://api.example.net/v1/webhooks/ci') |
222 | 223 | # |
223 | # @param [Integer, String] project The ID or name of a project. | |
224 | # @param [Integer, String] project The ID or path of a project. | |
224 | 225 | # @param [Integer] id The ID of the hook. |
225 | 226 | # @param [String] url The hook URL. |
226 | 227 | # @param [Hash] options A customizable set of options. |
239 | 240 | # @example |
240 | 241 | # Gitlab.delete_project_hook('gitlab', 4) |
241 | 242 | # |
242 | # @param [Integer, String] project The ID or name of a project. | |
243 | # @param [Integer, String] project The ID or path of a project. | |
243 | 244 | # @param [String] id The ID of the hook. |
244 | 245 | # @return [Gitlab::ObjectifiedHash] Information about deleted hook. |
245 | 246 | def delete_project_hook(project, id) |
255 | 256 | # @param [Integer] id The ID of a project. |
256 | 257 | # @return [Gitlab::ObjectifiedHash] |
257 | 258 | def push_rule(id) |
258 | get("/projects/#{id}/push_rule") | |
259 | get("/projects/#{url_encode id}/push_rule") | |
259 | 260 | end |
260 | 261 | |
261 | 262 | # Adds a project push rule. |
270 | 271 | # @param option [String] :commit_message_regex Commit message regex |
271 | 272 | # @return [Gitlab::ObjectifiedHash] Information about added push rule. |
272 | 273 | def add_push_rule(id, options={}) |
273 | post("/projects/#{id}/push_rule", body: options) | |
274 | post("/projects/#{url_encode id}/push_rule", body: options) | |
274 | 275 | end |
275 | 276 | |
276 | 277 | # Updates a project push rule. |
285 | 286 | # @param option [String] :commit_message_regex Commit message regex |
286 | 287 | # @return [Gitlab::ObjectifiedHash] Information about updated push rule. |
287 | 288 | def edit_push_rule(id, options={}) |
288 | put("/projects/#{id}/push_rule", body: options) | |
289 | put("/projects/#{url_encode id}/push_rule", body: options) | |
289 | 290 | end |
290 | 291 | |
291 | 292 | # Deletes a push rule from a project. |
297 | 298 | # @param [Integer] id The ID of a project. |
298 | 299 | # @return [Gitlab::ObjectifiedHash] Information about deleted push rule. |
299 | 300 | def delete_push_rule(id, options={}) |
300 | delete("/projects/#{id}/push_rule") | |
301 | delete("/projects/#{url_encode id}/push_rule") | |
301 | 302 | end |
302 | 303 | |
303 | 304 | # Mark this project as forked from the other |
305 | 306 | # @example |
306 | 307 | # Gitlab.make_forked(42, 24) |
307 | 308 | # |
308 | # @param [Integer, String] project The ID or name of a project. | |
309 | # @param [Integer, String] project The ID or path of a project. | |
309 | 310 | # @param [Integer] id The ID of the project it is forked from. |
310 | 311 | # @return [Gitlab::ObjectifiedHash] Information about the forked project. |
311 | 312 | def make_forked_from(project, id) |
317 | 318 | # @example |
318 | 319 | # Gitlab.remove_forked(42) |
319 | 320 | # |
320 | # @param [Integer, String] project The ID or name of a project. | |
321 | # @param [Integer, String] project The ID or path of a project. | |
321 | 322 | # @param [Integer] project The ID of the project it is forked from |
322 | 323 | # @return [Gitlab::ObjectifiedHash] Information about the forked project. |
323 | 324 | def remove_forked(project) |
329 | 330 | # @example |
330 | 331 | # Gitlab.deploy_keys(42) |
331 | 332 | # |
332 | # @param [Integer, String] project The ID or name of a project. | |
333 | # @param [Integer, String] project The ID or path of a project. | |
333 | 334 | # @param [Hash] options A customizable set of options. |
334 | 335 | # @option options [Integer] :page The page number. |
335 | 336 | # @option options [Integer] :per_page The number of results per page. |
343 | 344 | # @example |
344 | 345 | # Gitlab.deploy_key(42, 1) |
345 | 346 | # |
346 | # @param [Integer, String] project The ID or name of a project. | |
347 | # @param [Integer, String] project The ID or path of a project. | |
347 | 348 | # @param [Integer] id The ID of a deploy key. |
348 | 349 | # @return [Gitlab::ObjectifiedHash] |
349 | 350 | def deploy_key(project, id) |
355 | 356 | # @example |
356 | 357 | # Gitlab.create_deploy_key(42, 'My Key', 'Key contents') |
357 | 358 | # |
358 | # @param [Integer, String] project The ID or name of a project. | |
359 | # @param [Integer, String] project The ID or path of a project. | |
359 | 360 | # @param [String] title The title of a deploy key. |
360 | 361 | # @param [String] key The content of a deploy key. |
361 | 362 | # @return [Gitlab::ObjectifiedHash] Information about created deploy key. |
368 | 369 | # @example |
369 | 370 | # Gitlab.enable_deploy_key(42, 66) |
370 | 371 | # |
371 | # @param [Integer, String] project The ID or name of a project. | |
372 | # @param [Integer, String] project The ID or path of a project. | |
372 | 373 | # @param [Integer] key The ID of a deploy key. |
373 | 374 | # @return [Gitlab::ObjectifiedHash] Information about the enabled deploy key. |
374 | 375 | def enable_deploy_key(project, key) |
380 | 381 | # @example |
381 | 382 | # Gitlab.disable_deploy_key(42, 66) |
382 | 383 | # |
383 | # @param [Integer, String] project The ID or name of a project. | |
384 | # @param [Integer, String] project The ID or path of a project. | |
384 | 385 | # @param [Integer] key The ID of a deploy key. |
385 | 386 | # @return [Gitlab::ObjectifiedHash] Information about the disabled deploy key. |
386 | 387 | def disable_deploy_key(project, key) |
392 | 393 | # @example |
393 | 394 | # Gitlab.delete_deploy_key(42, 1) |
394 | 395 | # |
395 | # @param [Integer, String] project The ID or name of a project. | |
396 | # @param [Integer, String] project The ID or path of a project. | |
396 | 397 | # @param [Integer] id The ID of a deploy key. |
397 | 398 | # @return [Gitlab::ObjectifiedHash] Information about deleted deploy key. |
398 | 399 | def delete_deploy_key(project, id) |
405 | 406 | # Gitlab.create_fork(42) |
406 | 407 | # Gitlab.create_fork(42, { sudo: 'another_username' }) |
407 | 408 | # |
408 | # @param [Integer, String] project The ID or name of a project. | |
409 | # @param [Integer, String] project The ID or path of a project. | |
409 | 410 | # @param [Hash] options A customizable set of options. |
410 | 411 | # @option options [String] :sudo The username the project will be forked for |
411 | 412 | # @return [Gitlab::ObjectifiedHash] Information about the forked project. |
412 | 413 | def create_fork(id, options={}) |
413 | post("/projects/#{id}/fork", body: options) | |
414 | post("/projects/#{url_encode id}/fork", body: options) | |
414 | 415 | end |
415 | 416 | |
416 | 417 | # Updates an existing project. |
417 | 418 | # |
418 | 419 | # @example |
419 | 420 | # Gitlab.edit_project(42) |
420 | # Gitlab.edit_project(42, { name: 'project_name' }) | |
421 | # | |
422 | # @param [Integer, String] project The ID or name of a project. | |
423 | # @param [Hash] options A customizable set of options. | |
421 | # Gitlab.edit_project(42, { name: 'Project Name' }) | |
422 | # Gitlab.edit_project('project-name', { name: 'New Project Name', path: 'new-project-patth' }) | |
423 | # | |
424 | # @param [Integer, String] project The ID or path of a project. | |
425 | # @param [Hash] options A customizable set of options | |
424 | 426 | # @option options [String] :name The name of a project |
425 | # @option options [String] :path The name of a project | |
426 | # @option options [String] :description The name of a project | |
427 | # @option options [String] :path The project's repository name, also used in Gitlab's URLs | |
428 | # @option options [String] :description The description to show in Gitlab | |
429 | # (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) | |
430 | # | |
427 | 431 | # @return [Gitlab::ObjectifiedHash] Information about the edited project. |
428 | 432 | def edit_project(id, options={}) |
429 | put("/projects/#{id}", query: options) | |
433 | put("/projects/#{url_encode id}", body: options) | |
430 | 434 | end |
431 | 435 | |
432 | 436 | # Share project with group. |
434 | 438 | # @example |
435 | 439 | # Gitlab.share_project_with_group('gitlab', 2, 40) |
436 | 440 | # |
437 | # @param [Integer, String] project The ID or name of a project. | |
441 | # @param [Integer, String] project The ID or path of a project. | |
438 | 442 | # @param [Integer] id The ID of a group. |
439 | 443 | # @param [Integer] group_access The access level to project. |
440 | 444 | def share_project_with_group(project, id, group_access) |
443 | 447 | |
444 | 448 | # Stars a project. |
445 | 449 | # @see https://docs.gitlab.com/ce/api/projects.html#star-a-project |
446 | # | |
450 | # | |
447 | 451 | # @example |
448 | 452 | # Gitlab.star_project(42) |
449 | 453 | # Gitlab.star_project('gitlab-org/gitlab-ce') |
450 | # | |
451 | # @param [Integer, String] id The ID or name of a project. | |
454 | # | |
455 | # @param [Integer, String] id The ID or path of a project. | |
452 | 456 | # @return [Gitlab::ObjectifiedHash] Information about starred project. |
453 | 457 | def star_project(id) |
454 | post("/projects/#{id}/star") | |
458 | post("/projects/#{url_encode id}/star") | |
455 | 459 | end |
456 | 460 | |
457 | 461 | # Unstars a project. |
458 | 462 | # @see https://docs.gitlab.com/ce/api/projects.html#unstar-a-project |
459 | # | |
463 | # | |
460 | 464 | # @example |
461 | 465 | # Gitlab.unstar_project(42) |
462 | 466 | # Gitlab.unstar_project('gitlab-org/gitlab-ce') |
463 | # | |
464 | # @param [Integer, String] id The ID or name of a project. | |
467 | # | |
468 | # @param [Integer, String] id The ID or path of a project. | |
465 | 469 | # @return [Gitlab::ObjectifiedHash] Information about unstarred project. |
466 | 470 | def unstar_project(id) |
467 | delete("/projects/#{id}/star") | |
471 | delete("/projects/#{url_encode id}/star") | |
468 | 472 | end |
469 | 473 | end |
470 | 474 | end |
44 | 44 | # Gitlab.create_file(42, "path", "branch", "content", "commit message") |
45 | 45 | # |
46 | 46 | # @param [Integer, String] project The ID or name of a project. |
47 | # @param [String] full path to new file. | |
48 | # @param [String] the name of the branch. | |
49 | # @param [String] file content. | |
50 | # @param [String] commit message. | |
47 | # @param [String] path full path to new file. | |
48 | # @param [String] branch the name of the branch. | |
49 | # @param [String] content file content. | |
50 | # @param [String] commit_message ...commit message. | |
51 | # @param [Hash] options Optional additional details for commit | |
52 | # @option options [String] :author_name Commit author's name | |
53 | # @option options [String] :author_email Commit author's email address | |
51 | 54 | # @return [Gitlab::ObjectifiedHash] |
52 | def create_file(project, path, branch, content, commit_message) | |
53 | post("/projects/#{url_encode project}/repository/files", body: { | |
54 | file_path: path, | |
55 | branch_name: branch, | |
55 | def create_file(project, path, branch, content, commit_message, options = {}) | |
56 | post("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { | |
57 | branch: branch, | |
56 | 58 | commit_message: commit_message |
57 | }.merge(encoded_content_attributes(content))) | |
59 | }.merge(options).merge(encoded_content_attributes(content))) | |
58 | 60 | end |
59 | 61 | |
60 | 62 | # Edits an existing repository file. |
63 | 65 | # Gitlab.edit_file(42, "path", "branch", "content", "commit message") |
64 | 66 | # |
65 | 67 | # @param [Integer, String] project The ID or name of a project. |
66 | # @param [String] full path to new file. | |
67 | # @param [String] the name of the branch. | |
68 | # @param [String] file content. | |
69 | # @param [String] commit message. | |
68 | # @param [String] path full path of file to update. | |
69 | # @param [String] branch the name of the branch to commit changes to. | |
70 | # @param [String] content new file content. | |
71 | # @param [String] commit_message ...commit message. | |
72 | # @param [Hash] options Optional additional details for commit | |
73 | # @option options [String] :author_name Commit author's name | |
74 | # @option options [String] :author_email Commit author's email address | |
70 | 75 | # @return [Gitlab::ObjectifiedHash] |
71 | def edit_file(project, path, branch, content, commit_message) | |
72 | put("/projects/#{url_encode project}/repository/files", body: { | |
73 | file_path: path, | |
74 | branch_name: branch, | |
76 | def edit_file(project, path, branch, content, commit_message, options = {}) | |
77 | put("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { | |
78 | branch: branch, | |
75 | 79 | commit_message: commit_message |
76 | }.merge(encoded_content_attributes(content))) | |
80 | }.merge(options).merge(encoded_content_attributes(content))) | |
77 | 81 | end |
78 | 82 | |
79 | 83 | # Removes an existing repository file. |
82 | 86 | # Gitlab.remove_file(42, "path", "branch", "commit message") |
83 | 87 | # |
84 | 88 | # @param [Integer, String] project The ID or name of a project. |
85 | # @param [String] full path to new file. | |
86 | # @param [String] the name of the branch. | |
87 | # @param [String] commit message. | |
89 | # @param [String] path full path of file to delete. | |
90 | # @param [String] branch the name of the branch to commit the deletion to. | |
91 | # @param [String] commit_message ...a commit message ;) | |
92 | # @param [Hash] options Optional additional details for commit | |
93 | # @option options [String] :author_name Commit author's name | |
94 | # @option options [String] :author_email Commit author's email address | |
88 | 95 | # @return [Gitlab::ObjectifiedHash] |
89 | def remove_file(project, path, branch, commit_message) | |
90 | delete("/projects/#{url_encode project}/repository/files", body: { | |
91 | file_path: path, | |
92 | branch_name: branch, | |
96 | def remove_file(project, path, branch, commit_message, options = {}) | |
97 | delete("/projects/#{url_encode project}/repository/files/#{url_encode path}", body: { | |
98 | branch: branch, | |
93 | 99 | commit_message: commit_message |
94 | }) | |
100 | }.merge(options)) | |
95 | 101 | end |
96 | 102 | |
97 | 103 | private |
23 | 23 | # Gitlab.add_system_hook('https://api.example.net/v1/hook') |
24 | 24 | # |
25 | 25 | # @param [String] url The hook URL. |
26 | # @param [Hash] options Additional options, as allowed by Gitlab API, including but not limited to: | |
27 | # @option options [String] :token A secret token for Gitlab to send in the `X-Gitlab-Token` header for authentication. | |
28 | # @option options [boolean] :enable_ssl_verification `false` will cause Gitlab to ignore invalid/unsigned certificate errors (default is `true`) | |
26 | 29 | # @return [Gitlab::ObjectifiedHash] |
27 | def add_hook(url) | |
28 | post("/hooks", body: { url: url }) | |
30 | def add_hook(url, options = {}) | |
31 | post("/hooks", body: options.merge(url: url)) | |
29 | 32 | end |
30 | 33 | alias_method :add_system_hook, :add_hook |
31 | 34 |
0 | class Gitlab::Client | |
1 | # Defines methods related to todos | |
2 | # @see https://docs.gitlab.com/ce/api/todos.html | |
3 | module Todos | |
4 | # Gets a list of todos. | |
5 | # | |
6 | # @example | |
7 | # Gitlab.todos | |
8 | # Gitlab.todos({ action: 'assigned' }) | |
9 | # Gitlab.todos({ state: 'pending' }) | |
10 | # | |
11 | # @param [Hash] options A customizable set of options. | |
12 | # @option options [Integer] :action The action to be filtered. Can be `assigned`, `mentioned`, `build_failed`, `marked`, or `approval_required`. | |
13 | # @option options [Integer] :author_id The ID of an author | |
14 | # @option options [Integer] :project_id The ID of a project | |
15 | # @option options [Integer] :state The state of the todo. Can be either `pending` or `done` | |
16 | # @option options [Integer] :type The type of a todo. Can be either `Issue` or `MergeRequest` | |
17 | # @return [Array<Gitlab::ObjectifiedHash>] | |
18 | def todos(options={}) | |
19 | get("/todos", query: options) | |
20 | end | |
21 | ||
22 | # Marks a single pending todo for the current user as done. | |
23 | # | |
24 | # @example | |
25 | # Gitlab.mark_todo_as_done(42) | |
26 | # | |
27 | # @param [Integer] id The ID of the todo. | |
28 | # @return [Gitlab::ObjectifiedHash] | |
29 | def mark_todo_as_done(id) | |
30 | post("/todos/#{id}/mark_as_done") | |
31 | end | |
32 | ||
33 | # Marks all todos for the current user as done | |
34 | # | |
35 | # @example | |
36 | # Gitlab.mark_all_todos_as_done | |
37 | # | |
38 | # @return [void] This API call returns an empty response body. | |
39 | def mark_all_todos_as_done | |
40 | post("/todos/mark_as_done") | |
41 | end | |
42 | end | |
43 | end⏎ |
2 | 2 | class Client < API |
3 | 3 | Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f } |
4 | 4 | |
5 | include AwardEmojis | |
6 | include Boards | |
5 | 7 | include Branches |
6 | 8 | include Builds |
7 | 9 | include BuildVariables |
8 | 10 | include Commits |
11 | include Environments | |
9 | 12 | include Groups |
10 | 13 | include Issues |
11 | 14 | include Keys |
24 | 27 | include Snippets |
25 | 28 | include SystemHooks |
26 | 29 | include Tags |
30 | include Todos | |
27 | 31 | include Users |
28 | 32 | include Jobs |
29 | 33 |
0 | { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 } |
0 | [ { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 }, { "id" : 2, "label" : { "name" : "Ready", "color" : "#FF0000", "description" : null }, "position" : 2 }, { "id" : 3, "label" : { "name" : "Production", "color" : "#FF5F00", "description" : null }, "position" : 3 } ] |
0 | [ { "id" : 1, "lists" : [ { "id" : 1, "label" : { "name" : "Testing", "color" : "#F0AD4E", "description" : null }, "position" : 1 }, { "id" : 2, "label" : { "name" : "Ready", "color" : "#FF0000", "description" : null }, "position" : 2 }, { "id" : 3, "label" : { "name" : "Production", "color" : "#FF5F00", "description" : null }, "position" : 3 } ] } ] |
0 | { | |
1 | "id": 12, | |
2 | "name": "staging", | |
3 | "slug": "staging-cb247rv", | |
4 | "external_url": "https://staging.example.gitlab.com" | |
5 | }⏎ |
0 | [ | |
1 | { | |
2 | "id": 1, | |
3 | "name": "review/fix-foo", | |
4 | "slug": "review-fix-foo-dfjre3", | |
5 | "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com" | |
6 | }, | |
7 | { | |
8 | "id": 12, | |
9 | "name": "review/fix-bar", | |
10 | "slug": "review-fix-bar-dbwr18", | |
11 | "external_url": "https://review-fix-bar-dbwr18.example.gitlab.com" | |
12 | } | |
13 | ]⏎ |
0 | { | |
1 | "id": 4, | |
2 | "name": "blowfish", | |
3 | "user": { | |
4 | "name": "Administrator", | |
5 | "username": "root", | |
6 | "id": 1, | |
7 | "state": "active", | |
8 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
9 | "web_url": "http://gitlab.example.com/root" | |
10 | }, | |
11 | "created_at": "2016-06-15T10:09:34.206Z", | |
12 | "updated_at": "2016-06-15T10:09:34.206Z", | |
13 | "awardable_id": 80, | |
14 | "awardable_type": "Issue" | |
15 | }⏎ |
0 | [ | |
1 | { | |
2 | "id": 4, | |
3 | "name": "1234", | |
4 | "user": { | |
5 | "name": "Administrator", | |
6 | "username": "root", | |
7 | "id": 1, | |
8 | "state": "active", | |
9 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
10 | "web_url": "http://gitlab.example.com/root" | |
11 | }, | |
12 | "created_at": "2016-06-15T10:09:34.206Z", | |
13 | "updated_at": "2016-06-15T10:09:34.206Z", | |
14 | "awardable_id": 80, | |
15 | "awardable_type": "Issue" | |
16 | }, | |
17 | { | |
18 | "id": 1, | |
19 | "name": "microphone", | |
20 | "user": { | |
21 | "name": "User 4", | |
22 | "username": "user4", | |
23 | "id": 26, | |
24 | "state": "active", | |
25 | "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon", | |
26 | "web_url": "http://gitlab.example.com/user4" | |
27 | }, | |
28 | "created_at": "2016-06-15T10:09:34.177Z", | |
29 | "updated_at": "2016-06-15T10:09:34.177Z", | |
30 | "awardable_id": 80, | |
31 | "awardable_type": "Issue" | |
32 | } | |
33 | ]⏎ |
0 | {"name": "Backlog", "color": "#DD10AA"} | |
0 | {"name": "Backlog", "color": "#DD10AA", "subscribed": true} |
0 | {"name": "Backlog", "color": "#DD10AA", "subscribed": false} |
0 | { | |
1 | "id": 4, | |
2 | "name": "blowfish", | |
3 | "user": { | |
4 | "name": "Administrator", | |
5 | "username": "root", | |
6 | "id": 1, | |
7 | "state": "active", | |
8 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
9 | "web_url": "http://gitlab.example.com/root" | |
10 | }, | |
11 | "created_at": "2016-06-15T10:09:34.206Z", | |
12 | "updated_at": "2016-06-15T10:09:34.206Z", | |
13 | "awardable_id": 80, | |
14 | "awardable_type": "MergeRequest" | |
15 | }⏎ |
0 | [ | |
1 | { | |
2 | "id": 4, | |
3 | "name": "1234", | |
4 | "user": { | |
5 | "name": "Administrator", | |
6 | "username": "root", | |
7 | "id": 1, | |
8 | "state": "active", | |
9 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
10 | "web_url": "http://gitlab.example.com/root" | |
11 | }, | |
12 | "created_at": "2016-06-15T10:09:34.206Z", | |
13 | "updated_at": "2016-06-15T10:09:34.206Z", | |
14 | "awardable_id": 80, | |
15 | "awardable_type": "MergeRequest" | |
16 | }, | |
17 | { | |
18 | "id": 1, | |
19 | "name": "microphone", | |
20 | "user": { | |
21 | "name": "User 4", | |
22 | "username": "user4", | |
23 | "id": 26, | |
24 | "state": "active", | |
25 | "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon", | |
26 | "web_url": "http://gitlab.example.com/user4" | |
27 | }, | |
28 | "created_at": "2016-06-15T10:09:34.177Z", | |
29 | "updated_at": "2016-06-15T10:09:34.177Z", | |
30 | "awardable_id": 80, | |
31 | "awardable_type": "MergeRequest" | |
32 | } | |
33 | ]⏎ |
0 | { | |
1 | "id": 4, | |
2 | "name": "mood_bubble_lightning", | |
3 | "user": { | |
4 | "name": "User 4", | |
5 | "username": "user4", | |
6 | "id": 26, | |
7 | "state": "active", | |
8 | "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon", | |
9 | "web_url": "http://gitlab.example.com/user4" | |
10 | }, | |
11 | "created_at": "2016-06-15T10:09:34.197Z", | |
12 | "updated_at": "2016-06-15T10:09:34.197Z", | |
13 | "awardable_id": 1, | |
14 | "awardable_type": "Note" | |
15 | } |
0 | [ | |
1 | { | |
2 | "id": 2, | |
3 | "name": "mood_bubble_lightning", | |
4 | "user": { | |
5 | "name": "User 4", | |
6 | "username": "user4", | |
7 | "id": 26, | |
8 | "state": "active", | |
9 | "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon", | |
10 | "web_url": "http://gitlab.example.com/user4" | |
11 | }, | |
12 | "created_at": "2016-06-15T10:09:34.197Z", | |
13 | "updated_at": "2016-06-15T10:09:34.197Z", | |
14 | "awardable_id": 1, | |
15 | "awardable_type": "Note" | |
16 | } | |
17 | ]⏎ |
0 | { | |
1 | "id": 4, | |
2 | "name": "blowfish", | |
3 | "user": { | |
4 | "name": "Administrator", | |
5 | "username": "root", | |
6 | "id": 1, | |
7 | "state": "active", | |
8 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
9 | "web_url": "http://gitlab.example.com/root" | |
10 | }, | |
11 | "created_at": "2016-06-15T10:09:34.206Z", | |
12 | "updated_at": "2016-06-15T10:09:34.206Z", | |
13 | "awardable_id": 80, | |
14 | "awardable_type": "Snippet" | |
15 | }⏎ |
0 | [ | |
1 | { | |
2 | "id": 4, | |
3 | "name": "1234", | |
4 | "user": { | |
5 | "name": "Administrator", | |
6 | "username": "root", | |
7 | "id": 1, | |
8 | "state": "active", | |
9 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
10 | "web_url": "http://gitlab.example.com/root" | |
11 | }, | |
12 | "created_at": "2016-06-15T10:09:34.206Z", | |
13 | "updated_at": "2016-06-15T10:09:34.206Z", | |
14 | "awardable_id": 80, | |
15 | "awardable_type": "Snippet" | |
16 | }, | |
17 | { | |
18 | "id": 1, | |
19 | "name": "microphone", | |
20 | "user": { | |
21 | "name": "User 4", | |
22 | "username": "user4", | |
23 | "id": 26, | |
24 | "state": "active", | |
25 | "avatar_url": "http://www.gravatar.com/avatar/7e65550957227bd38fe2d7fbc6fd2f7b?s=80&d=identicon", | |
26 | "web_url": "http://gitlab.example.com/user4" | |
27 | }, | |
28 | "created_at": "2016-06-15T10:09:34.177Z", | |
29 | "updated_at": "2016-06-15T10:09:34.177Z", | |
30 | "awardable_id": 80, | |
31 | "awardable_type": "Snippet" | |
32 | } | |
33 | ]⏎ |
0 | { | |
1 | "id": 102, | |
2 | "project": { | |
3 | "id": 2, | |
4 | "name": "Gitlab Ce", | |
5 | "name_with_namespace": "Gitlab Org / Gitlab Ce", | |
6 | "path": "gitlab-ce", | |
7 | "path_with_namespace": "gitlab-org/gitlab-ce" | |
8 | }, | |
9 | "author": { | |
10 | "name": "Administrator", | |
11 | "username": "root", | |
12 | "id": 1, | |
13 | "state": "active", | |
14 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
15 | "web_url": "https://gitlab.example.com/root" | |
16 | }, | |
17 | "action_name": "marked", | |
18 | "target_type": "MergeRequest", | |
19 | "target": { | |
20 | "id": 34, | |
21 | "iid": 7, | |
22 | "project_id": 2, | |
23 | "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", | |
24 | "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.", | |
25 | "state": "opened", | |
26 | "created_at": "2016-06-17T07:49:24.419Z", | |
27 | "updated_at": "2016-06-17T07:52:43.484Z", | |
28 | "target_branch": "tutorials_git_tricks", | |
29 | "source_branch": "DNSBL_docs", | |
30 | "upvotes": 0, | |
31 | "downvotes": 0, | |
32 | "author": { | |
33 | "name": "Maxie Medhurst", | |
34 | "username": "craig_rutherford", | |
35 | "id": 12, | |
36 | "state": "active", | |
37 | "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", | |
38 | "web_url": "https://gitlab.example.com/craig_rutherford" | |
39 | }, | |
40 | "assignee": { | |
41 | "name": "Administrator", | |
42 | "username": "root", | |
43 | "id": 1, | |
44 | "state": "active", | |
45 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
46 | "web_url": "https://gitlab.example.com/root" | |
47 | }, | |
48 | "source_project_id": 2, | |
49 | "target_project_id": 2, | |
50 | "labels": [], | |
51 | "work_in_progress": false, | |
52 | "milestone": { | |
53 | "id": 32, | |
54 | "iid": 2, | |
55 | "project_id": 2, | |
56 | "title": "v1.0", | |
57 | "description": "Assumenda placeat ea voluptatem voluptate qui.", | |
58 | "state": "active", | |
59 | "created_at": "2016-06-17T07:47:34.163Z", | |
60 | "updated_at": "2016-06-17T07:47:34.163Z", | |
61 | "due_date": null | |
62 | }, | |
63 | "merge_when_pipeline_succeeds": false, | |
64 | "merge_status": "cannot_be_merged", | |
65 | "subscribed": true, | |
66 | "user_notes_count": 7 | |
67 | }, | |
68 | "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7", | |
69 | "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", | |
70 | "state": "done", | |
71 | "created_at": "2016-06-17T07:52:35.225Z" | |
72 | }⏎ |
0 | [ | |
1 | { | |
2 | "id": 102, | |
3 | "project": { | |
4 | "id": 2, | |
5 | "name": "Gitlab Ce", | |
6 | "name_with_namespace": "Gitlab Org / Gitlab Ce", | |
7 | "path": "gitlab-ce", | |
8 | "path_with_namespace": "gitlab-org/gitlab-ce" | |
9 | }, | |
10 | "author": { | |
11 | "name": "Administrator", | |
12 | "username": "root", | |
13 | "id": 1, | |
14 | "state": "active", | |
15 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
16 | "web_url": "https://gitlab.example.com/root" | |
17 | }, | |
18 | "action_name": "marked", | |
19 | "target_type": "MergeRequest", | |
20 | "target": { | |
21 | "id": 34, | |
22 | "iid": 7, | |
23 | "project_id": 2, | |
24 | "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", | |
25 | "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.", | |
26 | "state": "opened", | |
27 | "created_at": "2016-06-17T07:49:24.419Z", | |
28 | "updated_at": "2016-06-17T07:52:43.484Z", | |
29 | "target_branch": "tutorials_git_tricks", | |
30 | "source_branch": "DNSBL_docs", | |
31 | "upvotes": 0, | |
32 | "downvotes": 0, | |
33 | "author": { | |
34 | "name": "Maxie Medhurst", | |
35 | "username": "craig_rutherford", | |
36 | "id": 12, | |
37 | "state": "active", | |
38 | "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", | |
39 | "web_url": "https://gitlab.example.com/craig_rutherford" | |
40 | }, | |
41 | "assignee": { | |
42 | "name": "Administrator", | |
43 | "username": "root", | |
44 | "id": 1, | |
45 | "state": "active", | |
46 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
47 | "web_url": "https://gitlab.example.com/root" | |
48 | }, | |
49 | "source_project_id": 2, | |
50 | "target_project_id": 2, | |
51 | "labels": [], | |
52 | "work_in_progress": false, | |
53 | "milestone": { | |
54 | "id": 32, | |
55 | "iid": 2, | |
56 | "project_id": 2, | |
57 | "title": "v1.0", | |
58 | "description": "Assumenda placeat ea voluptatem voluptate qui.", | |
59 | "state": "active", | |
60 | "created_at": "2016-06-17T07:47:34.163Z", | |
61 | "updated_at": "2016-06-17T07:47:34.163Z", | |
62 | "due_date": null | |
63 | }, | |
64 | "merge_when_pipeline_succeeds": false, | |
65 | "merge_status": "cannot_be_merged", | |
66 | "subscribed": true, | |
67 | "user_notes_count": 7 | |
68 | }, | |
69 | "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7", | |
70 | "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", | |
71 | "state": "pending", | |
72 | "created_at": "2016-06-17T07:52:35.225Z" | |
73 | }, | |
74 | { | |
75 | "id": 98, | |
76 | "project": { | |
77 | "id": 2, | |
78 | "name": "Gitlab Ce", | |
79 | "name_with_namespace": "Gitlab Org / Gitlab Ce", | |
80 | "path": "gitlab-ce", | |
81 | "path_with_namespace": "gitlab-org/gitlab-ce" | |
82 | }, | |
83 | "author": { | |
84 | "name": "Maxie Medhurst", | |
85 | "username": "craig_rutherford", | |
86 | "id": 12, | |
87 | "state": "active", | |
88 | "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", | |
89 | "web_url": "https://gitlab.example.com/craig_rutherford" | |
90 | }, | |
91 | "action_name": "assigned", | |
92 | "target_type": "MergeRequest", | |
93 | "target": { | |
94 | "id": 34, | |
95 | "iid": 7, | |
96 | "project_id": 2, | |
97 | "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", | |
98 | "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.", | |
99 | "state": "opened", | |
100 | "created_at": "2016-06-17T07:49:24.419Z", | |
101 | "updated_at": "2016-06-17T07:52:43.484Z", | |
102 | "target_branch": "tutorials_git_tricks", | |
103 | "source_branch": "DNSBL_docs", | |
104 | "upvotes": 0, | |
105 | "downvotes": 0, | |
106 | "author": { | |
107 | "name": "Maxie Medhurst", | |
108 | "username": "craig_rutherford", | |
109 | "id": 12, | |
110 | "state": "active", | |
111 | "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", | |
112 | "web_url": "https://gitlab.example.com/craig_rutherford" | |
113 | }, | |
114 | "assignee": { | |
115 | "name": "Administrator", | |
116 | "username": "root", | |
117 | "id": 1, | |
118 | "state": "active", | |
119 | "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", | |
120 | "web_url": "https://gitlab.example.com/root" | |
121 | }, | |
122 | "source_project_id": 2, | |
123 | "target_project_id": 2, | |
124 | "labels": [], | |
125 | "work_in_progress": false, | |
126 | "milestone": { | |
127 | "id": 32, | |
128 | "iid": 2, | |
129 | "project_id": 2, | |
130 | "title": "v1.0", | |
131 | "description": "Assumenda placeat ea voluptatem voluptate qui.", | |
132 | "state": "active", | |
133 | "created_at": "2016-06-17T07:47:34.163Z", | |
134 | "updated_at": "2016-06-17T07:47:34.163Z", | |
135 | "due_date": null | |
136 | }, | |
137 | "merge_when_pipeline_succeeds": false, | |
138 | "merge_status": "cannot_be_merged", | |
139 | "subscribed": true, | |
140 | "user_notes_count": 7 | |
141 | }, | |
142 | "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7", | |
143 | "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", | |
144 | "state": "pending", | |
145 | "created_at": "2016-06-17T07:49:24.624Z" | |
146 | } | |
147 | ]⏎ |
0 | require 'spec_helper' | |
1 | ||
2 | describe Gitlab::Client do | |
3 | describe '.award_emojis' do | |
4 | context 'when issue award emojis' do | |
5 | before do | |
6 | stub_get("/projects/1/issues/80/award_emoji", "issue_award_emojis") | |
7 | @emojis = Gitlab.award_emojis(1, 80, 'issue') | |
8 | end | |
9 | ||
10 | it "should get the correct resources" do | |
11 | expect(a_get("/projects/1/issues/80/award_emoji")).to have_been_made | |
12 | end | |
13 | ||
14 | it "should return a paginated response of issue award emojis" do | |
15 | expect(@emojis).to be_a Gitlab::PaginatedResponse | |
16 | expect(@emojis.first.awardable_id).to eq(80) | |
17 | expect(@emojis.first.awardable_type).to eq("Issue") | |
18 | end | |
19 | end | |
20 | ||
21 | context 'when merge request award emojis' do | |
22 | before do | |
23 | stub_get("/projects/1/merge_requests/80/award_emoji", "merge_request_award_emojis") | |
24 | @emojis = Gitlab.award_emojis(1, 80, 'merge_request') | |
25 | end | |
26 | ||
27 | it "should get the correct resources" do | |
28 | expect(a_get("/projects/1/merge_requests/80/award_emoji")).to have_been_made | |
29 | end | |
30 | ||
31 | it "should return a paginated response of merge request award emojis" do | |
32 | expect(@emojis).to be_a Gitlab::PaginatedResponse | |
33 | expect(@emojis.first.awardable_id).to eq(80) | |
34 | expect(@emojis.first.awardable_type).to eq("MergeRequest") | |
35 | end | |
36 | end | |
37 | ||
38 | context 'when snippet award emojis' do | |
39 | before do | |
40 | stub_get("/projects/1/snippets/80/award_emoji", "snippet_award_emojis") | |
41 | @emojis = Gitlab.award_emojis(1, 80, 'snippet') | |
42 | end | |
43 | ||
44 | it "should get the correct resources" do | |
45 | expect(a_get("/projects/1/snippets/80/award_emoji")).to have_been_made | |
46 | end | |
47 | ||
48 | it "should return a paginated response of snippet award emojis" do | |
49 | expect(@emojis).to be_a Gitlab::PaginatedResponse | |
50 | expect(@emojis.first.awardable_id).to eq(80) | |
51 | expect(@emojis.first.awardable_type).to eq("Snippet") | |
52 | end | |
53 | end | |
54 | end | |
55 | ||
56 | describe '.note_award_emojis' do | |
57 | context 'when issue note award emojis' do | |
58 | before do | |
59 | stub_get("/projects/1/issues/80/notes/1/award_emoji", "note_award_emojis") | |
60 | @note_emojis = Gitlab.note_award_emojis(1, 80, 'issue', 1) | |
61 | end | |
62 | ||
63 | it "should get 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 "should return a paginated response of issue note award emojis" do | |
68 | expect(@note_emojis).to be_a Gitlab::PaginatedResponse | |
69 | expect(@note_emojis.first.awardable_id).to eq(1) | |
70 | expect(@note_emojis.first.awardable_type).to eq("Note") | |
71 | end | |
72 | end | |
73 | ||
74 | context 'when merge request note award emojis' do | |
75 | before do | |
76 | stub_get("/projects/1/merge_requests/80/notes/1/award_emoji", "note_award_emojis") | |
77 | @note_emojis = Gitlab.note_award_emojis(1, 80, 'merge_request', 1) | |
78 | end | |
79 | ||
80 | it "should get 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 "should return a paginated response of merge request note award emojis" do | |
85 | expect(@note_emojis).to be_a Gitlab::PaginatedResponse | |
86 | expect(@note_emojis.first.awardable_id).to eq(1) | |
87 | expect(@note_emojis.first.awardable_type).to eq("Note") | |
88 | end | |
89 | end | |
90 | ||
91 | context 'when snippet note award emojis' do | |
92 | before do | |
93 | stub_get("/projects/1/snippets/80/notes/1/award_emoji", "note_award_emojis") | |
94 | @note_emojis = Gitlab.note_award_emojis(1, 80, 'snippet', 1) | |
95 | end | |
96 | ||
97 | it "should get 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 "should return a paginated response of snippet note award emojis" do | |
102 | expect(@note_emojis).to be_a Gitlab::PaginatedResponse | |
103 | expect(@note_emojis.first.awardable_id).to eq(1) | |
104 | expect(@note_emojis.first.awardable_type).to eq("Note") | |
105 | end | |
106 | end | |
107 | end | |
108 | ||
109 | describe '.award_emoji' do | |
110 | context 'when issue award emoji' do | |
111 | before do | |
112 | stub_get("/projects/1/issues/80/award_emoji/4", "issue_award_emoji") | |
113 | @emoji = Gitlab.award_emoji(1, 80, 'issue', 4) | |
114 | end | |
115 | ||
116 | it "should get the correct resource" do | |
117 | expect(a_get("/projects/1/issues/80/award_emoji/4")).to have_been_made | |
118 | end | |
119 | ||
120 | it "should return information about an issue award emoji" do | |
121 | expect(@emoji.id).to eq(4) | |
122 | expect(@emoji.awardable_type).to eq("Issue") | |
123 | expect(@emoji.awardable_id).to eq(80) | |
124 | end | |
125 | end | |
126 | ||
127 | context 'when merge request award emoji' do | |
128 | before do | |
129 | stub_get("/projects/1/merge_requests/80/award_emoji/4", "merge_request_award_emoji") | |
130 | @emoji = Gitlab.award_emoji(1, 80, 'merge_request', 4) | |
131 | end | |
132 | ||
133 | it "should get 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 "should return information about a merge request award emoji" do | |
138 | expect(@emoji.id).to eq(4) | |
139 | expect(@emoji.awardable_type).to eq("MergeRequest") | |
140 | expect(@emoji.awardable_id).to eq(80) | |
141 | end | |
142 | end | |
143 | ||
144 | context 'when snippet award emoji' do | |
145 | before do | |
146 | stub_get("/projects/1/snippets/80/award_emoji/4", "snippet_award_emoji") | |
147 | @emoji = Gitlab.award_emoji(1, 80, 'snippet', 4) | |
148 | end | |
149 | ||
150 | it "should get the correct resource" do | |
151 | expect(a_get("/projects/1/snippets/80/award_emoji/4")).to have_been_made | |
152 | end | |
153 | ||
154 | it "should return information about a snippet award emoji" do | |
155 | expect(@emoji.id).to eq(4) | |
156 | expect(@emoji.awardable_type).to eq("Snippet") | |
157 | expect(@emoji.awardable_id).to eq(80) | |
158 | end | |
159 | end | |
160 | end | |
161 | ||
162 | describe '.note_award_emoji' do | |
163 | context 'when issue note award emoji' do | |
164 | before do | |
165 | stub_get("/projects/1/issues/80/notes/1/award_emoji/4", "note_award_emoji") | |
166 | @note_emoji = Gitlab.note_award_emoji(1, 80, 'issue', 1, 4) | |
167 | end | |
168 | ||
169 | it "should get 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 "should return information about an issue note award emoji" do | |
174 | expect(@note_emoji.id).to eq(4) | |
175 | expect(@note_emoji.awardable_type).to eq("Note") | |
176 | expect(@note_emoji.awardable_id).to eq(1) | |
177 | end | |
178 | end | |
179 | ||
180 | context 'when merge request note award emoji' do | |
181 | before do | |
182 | stub_get("/projects/1/merge_requests/80/notes/1/award_emoji/4", "note_award_emoji") | |
183 | @note_emoji = Gitlab.note_award_emoji(1, 80, 'merge_request', 1, 4) | |
184 | end | |
185 | ||
186 | it "should get 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 "should return information about a merge request note award emoji" do | |
191 | expect(@note_emoji.id).to eq(4) | |
192 | expect(@note_emoji.awardable_type).to eq("Note") | |
193 | expect(@note_emoji.awardable_id).to eq(1) | |
194 | end | |
195 | end | |
196 | ||
197 | context 'when snippet note award emoji' do | |
198 | before do | |
199 | stub_get("/projects/1/snippets/80/notes/1/award_emoji/4", "note_award_emoji") | |
200 | @note_emoji = Gitlab.note_award_emoji(1, 80, 'snippet', 1, 4) | |
201 | end | |
202 | ||
203 | it "should get 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 "should return information about a snippet note award emoji" do | |
208 | expect(@note_emoji.id).to eq(4) | |
209 | expect(@note_emoji.awardable_type).to eq("Note") | |
210 | expect(@note_emoji.awardable_id).to eq(1) | |
211 | end | |
212 | end | |
213 | end | |
214 | ||
215 | describe '.create_award_emoji' do | |
216 | context 'when issue award emoji' do | |
217 | 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 "should get 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 "should return correct information about the created issue award emoji" do | |
228 | expect(@emoji.name).to eq('blowfish') | |
229 | expect(@emoji.awardable_type).to eq('Issue') | |
230 | end | |
231 | end | |
232 | ||
233 | context 'when merge request award emoji' do | |
234 | 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 "should get 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 "should return correct information about the created merge request award emoji" do | |
245 | expect(@emoji.name).to eq('blowfish') | |
246 | expect(@emoji.awardable_type).to eq('MergeRequest') | |
247 | end | |
248 | end | |
249 | ||
250 | context 'when snippet award emoji' do | |
251 | 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 "should get 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 "should return correct information about the created snippet award emoji" do | |
262 | expect(@emoji.name).to eq('blowfish') | |
263 | expect(@emoji.awardable_type).to eq('Snippet') | |
264 | end | |
265 | end | |
266 | end | |
267 | ||
268 | describe '.create_note_award_emoji' do | |
269 | context 'when issue note award emoji' do | |
270 | 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 "should get 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 "should return correct information about the created issue note award emoji" do | |
281 | expect(@note_emoji.name).to eq('mood_bubble_lightning') | |
282 | expect(@note_emoji.awardable_type).to eq('Note') | |
283 | end | |
284 | end | |
285 | ||
286 | context 'when merge request note award emoji' do | |
287 | 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 "should get 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 "should return correct information about the created merge request note award emoji" do | |
298 | expect(@note_emoji.name).to eq('mood_bubble_lightning') | |
299 | expect(@note_emoji.awardable_type).to eq('Note') | |
300 | end | |
301 | end | |
302 | ||
303 | context 'when snippet note award emoji' do | |
304 | 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 "should get 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 "should return correct information about the created snippet note award emoji" do | |
315 | expect(@note_emoji.name).to eq('mood_bubble_lightning') | |
316 | expect(@note_emoji.awardable_type).to eq('Note') | |
317 | end | |
318 | end | |
319 | end | |
320 | ||
321 | describe '.delete_award_emoji' do | |
322 | context 'when issue award emoji' do | |
323 | 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 "should get the correct resource" do | |
329 | expect(a_delete("/projects/1/issues/80/award_emoji/4")).to have_been_made | |
330 | end | |
331 | end | |
332 | ||
333 | context 'when merge request award emoji' do | |
334 | 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 "should get the correct resource" do | |
340 | expect(a_delete("/projects/1/merge_requests/80/award_emoji/4")).to have_been_made | |
341 | end | |
342 | end | |
343 | ||
344 | context 'when snippet award emoji' do | |
345 | 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 "should get the correct resource" do | |
351 | expect(a_delete("/projects/1/snippets/80/award_emoji/4")).to have_been_made | |
352 | end | |
353 | end | |
354 | end | |
355 | ||
356 | describe '.delete_note_award_emoji' do | |
357 | context 'when issue note award emoji' do | |
358 | 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 "should get the correct resource" do | |
364 | expect(a_delete("/projects/1/issues/80/notes/1/award_emoji/4")).to have_been_made | |
365 | end | |
366 | end | |
367 | ||
368 | context 'when merge request note award emoji' do | |
369 | 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 "should get the correct resource" do | |
375 | expect(a_delete("/projects/1/merge_requests/80/notes/1/award_emoji/4")).to have_been_made | |
376 | end | |
377 | end | |
378 | ||
379 | context 'when snippet note award emoji' do | |
380 | 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 "should get the correct resource" do | |
386 | expect(a_delete("/projects/1/snippets/80/notes/1/award_emoji/4")).to have_been_made | |
387 | end | |
388 | end | |
389 | end | |
390 | end⏎ |
0 | require 'spec_helper' | |
1 | ||
2 | describe Gitlab::Client do | |
3 | describe ".boards" do | |
4 | before do | |
5 | stub_get("/projects/3/boards", "boards") | |
6 | @boards = Gitlab.boards(3) | |
7 | end | |
8 | ||
9 | it "should get the correct resource" do | |
10 | expect(a_get("/projects/3/boards")).to have_been_made | |
11 | end | |
12 | ||
13 | it "should return a paginated response of project's boards" do | |
14 | expect(@boards).to be_a Gitlab::PaginatedResponse | |
15 | end | |
16 | end | |
17 | ||
18 | describe ".board_lists" do | |
19 | before do | |
20 | stub_get("/projects/3/boards/1/lists", "board_lists") | |
21 | @board_lists = Gitlab.board_lists(3, 1) | |
22 | end | |
23 | ||
24 | it "should get the correct resource" do | |
25 | expect(a_get("/projects/3/boards/1/lists")).to have_been_made | |
26 | end | |
27 | ||
28 | it "should return a paginated response of board's lists" do | |
29 | expect(@board_lists).to be_a Gitlab::PaginatedResponse | |
30 | expect(@board_lists.first.id).to eq(1) | |
31 | end | |
32 | end | |
33 | ||
34 | describe ".board_list" do | |
35 | before do | |
36 | stub_get("/projects/3/boards/1/lists/1", "board_list") | |
37 | @board_list = Gitlab.board_list(3, 1, 1) | |
38 | end | |
39 | ||
40 | it "should get the correct resource" do | |
41 | expect(a_get("/projects/3/boards/1/lists/1")).to have_been_made | |
42 | end | |
43 | ||
44 | it "should return information about the list" do | |
45 | expect(@board_list.id).to eq(1) | |
46 | end | |
47 | end | |
48 | ||
49 | describe ".create_board_list" do | |
50 | before do | |
51 | stub_post("/projects/3/boards/1/lists", "board_list") | |
52 | @board_list = Gitlab.create_board_list(3, 1, 4) | |
53 | end | |
54 | ||
55 | it "should get the correct resource" do | |
56 | expect(a_post("/projects/3/boards/1/lists")).to have_been_made | |
57 | end | |
58 | ||
59 | it "should return information about a created board" do | |
60 | expect(@board_list.position).to eq(1) | |
61 | end | |
62 | end | |
63 | ||
64 | describe ".edit_board_list" do | |
65 | before do | |
66 | stub_put("/projects/3/boards/1/lists/1", "board_list") | |
67 | @board_list = Gitlab.edit_board_list(3, 1, 1, 3) | |
68 | end | |
69 | ||
70 | it "should get the correct resource" do | |
71 | expect(a_put("/projects/3/boards/1/lists/1")).to have_been_made | |
72 | end | |
73 | ||
74 | it "should return information about an edited board" do | |
75 | expect(@board_list.id).to eq(1) | |
76 | end | |
77 | end | |
78 | ||
79 | describe ".delete_board_list" do | |
80 | before do | |
81 | stub_delete("/projects/3/boards/1/lists/1", "board_list") | |
82 | @board_list = Gitlab.delete_board_list(3, 1, 1) | |
83 | end | |
84 | ||
85 | it "should get the correct resource" do | |
86 | expect(a_delete("/projects/3/boards/1/lists/1")).to have_been_made | |
87 | end | |
88 | ||
89 | it "should return information about the deleted board list" do | |
90 | expect(@board_list.id).to eq(1) | |
91 | end | |
92 | end | |
93 | end |
39 | 39 | describe ".protect_branch" do |
40 | 40 | before do |
41 | 41 | stub_put("/projects/3/repository/branches/api/protect", "branch") |
42 | @branch = Gitlab.protect_branch(3, "api") | |
43 | 42 | end |
44 | 43 | |
45 | it "should get the correct resource" do | |
46 | expect(a_put("/projects/3/repository/branches/api/protect")).to have_been_made | |
44 | context "without options" do | |
45 | before do | |
46 | @branch = Gitlab.protect_branch(3, "api") | |
47 | end | |
48 | ||
49 | it "should update the correct resource" do | |
50 | expect(a_put("/projects/3/repository/branches/api/protect")).to have_been_made | |
51 | end | |
52 | ||
53 | it "should return information about a protected repository branch" do | |
54 | expect(@branch.name).to eq("api") | |
55 | end | |
47 | 56 | end |
48 | 57 | |
49 | it "should return information about a protected repository branch" do | |
50 | expect(@branch.name).to eq("api") | |
58 | context "with options" do | |
59 | before do | |
60 | @branch = Gitlab.protect_branch(3, "api", developers_can_push: true) | |
61 | end | |
62 | ||
63 | it "should update the correct resource with the correct options" do | |
64 | expect( | |
65 | a_put("/projects/3/repository/branches/api/protect").with(body: { developers_can_push: 'true' }) | |
66 | ).to have_been_made | |
67 | end | |
51 | 68 | end |
52 | 69 | end |
53 | 70 |
147 | 147 | |
148 | 148 | let(:query) do |
149 | 149 | { |
150 | branch_name: 'dev', | |
150 | branch: 'dev', | |
151 | 151 | commit_message: 'refactors everything', |
152 | 152 | actions: actions, |
153 | 153 | author_email: 'joe@sample.org', |
156 | 156 | end |
157 | 157 | |
158 | 158 | before do |
159 | stub_post("/projects/6/repository/commits", 'project_commit_create').with(query: query) | |
159 | stub_post("/projects/6/repository/commits", 'project_commit_create').with(body: query) | |
160 | 160 | @commit = Gitlab.create_commit(6, 'dev', 'refactors everything', actions, {author_email: 'joe@sample.org', author_name: 'Joe Sample'}) |
161 | 161 | end |
162 | 162 |
0 | require 'spec_helper' | |
1 | ||
2 | describe Gitlab::Client do | |
3 | describe ".environments" do | |
4 | before do | |
5 | stub_get("/projects/3/environments", "environments") | |
6 | @environments = Gitlab.environments(3) | |
7 | end | |
8 | ||
9 | it "should get the correct resource" do | |
10 | expect(a_get("/projects/3/environments")).to have_been_made | |
11 | end | |
12 | ||
13 | it "should return a paginated response of project's environments" do | |
14 | expect(@environments).to be_a Gitlab::PaginatedResponse | |
15 | end | |
16 | end | |
17 | ||
18 | describe ".environment" do | |
19 | before do | |
20 | stub_get("/projects/3/environments/12", "environment") | |
21 | @environment = Gitlab.environment(3, 12) | |
22 | end | |
23 | ||
24 | it "should get the correct resource" do | |
25 | expect(a_get("/projects/3/environments/12")).to have_been_made | |
26 | end | |
27 | ||
28 | it "should return a single environment" do | |
29 | expect(@environment).to be_a Gitlab::ObjectifiedHash | |
30 | end | |
31 | ||
32 | it "should return information about an environment" do | |
33 | expect(@environment.id).to eq(12) | |
34 | expect(@environment.name).to eq("staging") | |
35 | end | |
36 | end | |
37 | ||
38 | describe ".create_environment" do | |
39 | context "without external_url" do | |
40 | before do | |
41 | stub_post("/projects/3/environments", "environment") | |
42 | @environment = Gitlab.create_environment(3, 'staging') | |
43 | end | |
44 | ||
45 | it "should get the correct resource" do | |
46 | expect(a_post("/projects/3/environments").with(body: { name: 'staging' })).to have_been_made | |
47 | end | |
48 | ||
49 | it "should return a single environment" do | |
50 | expect(@environment).to be_a Gitlab::ObjectifiedHash | |
51 | end | |
52 | ||
53 | it "should return information about an environment" do | |
54 | expect(@environment.name).to eq("staging") | |
55 | end | |
56 | end | |
57 | ||
58 | context "with external_url" do | |
59 | before do | |
60 | stub_post("/projects/3/environments", "environment") | |
61 | @environment = Gitlab.create_environment(3, 'staging', external_url: "https://staging.example.gitlab.com") | |
62 | end | |
63 | ||
64 | it "should get 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 | |
67 | end | |
68 | end | |
69 | end | |
70 | ||
71 | describe ".edit_environment" do | |
72 | 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 | }) | |
78 | end | |
79 | ||
80 | it "should get 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 | |
83 | end | |
84 | ||
85 | it "should return a single environment" do | |
86 | expect(@environment).to be_a Gitlab::ObjectifiedHash | |
87 | end | |
88 | ||
89 | it "should return information about an environment" do | |
90 | expect(@environment.name).to eq("staging") | |
91 | end | |
92 | end | |
93 | ||
94 | describe ".delete_environment" do | |
95 | before do | |
96 | stub_delete("/projects/3/environments/12", "environment") | |
97 | @environment = Gitlab.delete_environment(3, 12) | |
98 | end | |
99 | ||
100 | it "should get the correct resource" do | |
101 | expect(a_delete("/projects/3/environments/12")).to have_been_made | |
102 | end | |
103 | ||
104 | it "should return a single pipeline" do | |
105 | expect(@environment).to be_a Gitlab::ObjectifiedHash | |
106 | end | |
107 | ||
108 | it "should return information about a pipeline" do | |
109 | expect(@environment.name).to eq("staging") | |
110 | end | |
111 | end | |
112 | ||
113 | describe ".stop_environment" do | |
114 | before do | |
115 | stub_post("/projects/3/environments/12/stop", "environment") | |
116 | @environment = Gitlab.stop_environment(3, 12) | |
117 | end | |
118 | ||
119 | it "should get the correct resource" do | |
120 | expect(a_post("/projects/3/environments/12/stop")).to have_been_made | |
121 | end | |
122 | ||
123 | it "should return a single pipeline" do | |
124 | expect(@environment).to be_a Gitlab::ObjectifiedHash | |
125 | end | |
126 | ||
127 | it "should return information about a pipeline" do | |
128 | expect(@environment.name).to eq("staging") | |
129 | end | |
130 | end | |
131 | end |
58 | 58 | end |
59 | 59 | |
60 | 60 | describe ".delete_group" do |
61 | context "without description" do | |
62 | before do | |
63 | stub_delete("/groups/42", "group_delete") | |
64 | @group = Gitlab.delete_group(42) | |
65 | end | |
61 | before do | |
62 | stub_delete("/groups/42", "group_delete") | |
63 | @group = Gitlab.delete_group(42) | |
64 | end | |
66 | 65 | |
67 | it "should get the correct resource" do | |
68 | expect(a_delete("/groups/42")).to have_been_made | |
69 | end | |
66 | it "should get the correct resource" do | |
67 | expect(a_delete("/groups/42")).to have_been_made | |
68 | end | |
70 | 69 | |
71 | it "should return information about a deleted group" do | |
72 | expect(@group.name).to eq("Gitlab-Group") | |
73 | expect(@group.path).to eq("gitlab-group") | |
74 | end | |
70 | it "should return information about a deleted group" do | |
71 | expect(@group.name).to eq("Gitlab-Group") | |
72 | expect(@group.path).to eq("gitlab-group") | |
75 | 73 | end |
76 | 74 | end |
77 | 75 |
64 | 64 | expect(@label.color).to eq('#DD10AA') |
65 | 65 | end |
66 | 66 | end |
67 | ||
68 | describe ".subscribe_to_label" do | |
69 | before do | |
70 | stub_post("/projects/3/labels/Backlog/subscribe", "label") | |
71 | @label = Gitlab.subscribe_to_label(3, 'Backlog') | |
72 | end | |
73 | ||
74 | it "should get the correct resource" do | |
75 | expect(a_post("/projects/3/labels/Backlog/subscribe")).to have_been_made | |
76 | end | |
77 | ||
78 | it "should return information about the label subscribed to" do | |
79 | expect(@label.name).to eq('Backlog') | |
80 | expect(@label.subscribed).to eq(true) | |
81 | end | |
82 | end | |
83 | ||
84 | describe ".unsubscribe_from_label" do | |
85 | before do | |
86 | stub_post("/projects/3/labels/Backlog/unsubscribe", "label_unsubscribe") | |
87 | @label = Gitlab.unsubscribe_from_label(3, 'Backlog') | |
88 | end | |
89 | ||
90 | it "should get the correct resource" do | |
91 | expect(a_post("/projects/3/labels/Backlog/unsubscribe")).to have_been_made | |
92 | end | |
93 | ||
94 | it "should return information about the label subscribed to" do | |
95 | expect(@label.name).to eq('Backlog') | |
96 | expect(@label.subscribed).to eq(false) | |
97 | end | |
98 | end | |
67 | 99 | end |
201 | 201 | end |
202 | 202 | end |
203 | 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") | |
209 | @note = Gitlab.delete_note(3, 1201) | |
210 | end | |
211 | ||
212 | it "should get the correct resource" do | |
213 | expect(a_delete("/projects/3/notes/1201")).to have_been_made | |
214 | end | |
215 | ||
216 | it "should return 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") | |
224 | @note = Gitlab.delete_issue_note(3, 7, 1201) | |
225 | end | |
226 | ||
227 | it "should get the correct resource" do | |
228 | expect(a_delete("/projects/3/issues/7/notes/1201")).to have_been_made | |
229 | end | |
230 | ||
231 | it "should return 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") | |
239 | @note = Gitlab.delete_snippet_note(3, 7, 1201) | |
240 | end | |
241 | ||
242 | it "should get the correct resource" do | |
243 | expect(a_delete("/projects/3/snippets/7/notes/1201")).to have_been_made | |
244 | end | |
245 | ||
246 | it "should return 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") | |
254 | @note = Gitlab.delete_merge_request_note(3, 7, 1201) | |
255 | end | |
256 | ||
257 | it "should get the correct resource" do | |
258 | expect(a_delete("/projects/3/merge_requests/7/notes/1201")).to have_been_made | |
259 | end | |
260 | ||
261 | it "should return 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, body: "edited wall note content") | |
272 | end | |
273 | ||
274 | it "should get 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 "should return 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, body: "edited issue note content") | |
288 | end | |
289 | ||
290 | it "should get 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 "should return 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, body: "edited snippet note content") | |
304 | end | |
305 | ||
306 | it "should get 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 "should return 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, body: "edited merge request note content") | |
320 | end | |
321 | ||
322 | it "should get 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 "should return information about a modified request note" do | |
328 | expect(@note.id).to eq(1201) | |
329 | end | |
330 | end | |
331 | end | |
204 | 332 | end |
21 | 21 | |
22 | 22 | describe ".project_search" do |
23 | 23 | before do |
24 | stub_get("/projects/search/Gitlab", "project_search") | |
24 | stub_get("/projects?search=Gitlab", "project_search") | |
25 | 25 | @project_search = Gitlab.project_search("Gitlab") |
26 | 26 | end |
27 | 27 | |
28 | 28 | it "should get the correct resource" do |
29 | expect(a_get("/projects/search/Gitlab")).to have_been_made | |
29 | expect(a_get("/projects?search=Gitlab")).to have_been_made | |
30 | 30 | end |
31 | 31 | |
32 | 32 | it "should return a paginated response of projects found" do |
314 | 314 | end |
315 | 315 | |
316 | 316 | describe ".edit_project" do |
317 | before do | |
318 | stub_put("/projects/3", "project_edit").with(query: { name: "Gitlab-edit" }) | |
319 | @edited_project = Gitlab.edit_project(3, name: "Gitlab-edit") | |
320 | end | |
321 | ||
322 | it "should get the correct resource" do | |
323 | expect(a_put("/projects/3").with(query: { name: "Gitlab-edit" })).to have_been_made | |
324 | end | |
325 | ||
326 | it "should return information about an edited project" do | |
327 | expect(@edited_project.name).to eq("Gitlab-edit") | |
317 | context "using project ID" do | |
318 | before do | |
319 | stub_put("/projects/3", "project_edit").with(body: { name: "Gitlab-edit" }) | |
320 | @edited_project = Gitlab.edit_project(3, name: "Gitlab-edit") | |
321 | end | |
322 | ||
323 | it "should get the correct resource" do | |
324 | expect(a_put("/projects/3").with(body: { name: "Gitlab-edit" })).to have_been_made | |
325 | end | |
326 | ||
327 | it "should return information about an edited project" do | |
328 | expect(@edited_project.name).to eq("Gitlab-edit") | |
329 | end | |
330 | end | |
331 | ||
332 | context "using namespaced project path" do | |
333 | it "encodes the path properly" do | |
334 | stub = stub_put("/projects/namespace%2Fpath", "project_edit").with(body: { name: "Gitlab-edit" }) | |
335 | Gitlab.edit_project('namespace/path', name: "Gitlab-edit") | |
336 | expect(stub).to have_been_requested | |
337 | end | |
328 | 338 | end |
329 | 339 | end |
330 | 340 |
21 | 21 | @file = Gitlab.get_file(3, 'README.md', 'master') |
22 | 22 | end |
23 | 23 | |
24 | it "should create the correct resource" do | |
24 | it "should get the correct resource" do | |
25 | 25 | expect(a_get("/projects/3/repository/files/README%2Emd?ref=master")).to have_been_made |
26 | 26 | end |
27 | 27 | |
33 | 33 | end |
34 | 34 | |
35 | 35 | describe ".create_file" do |
36 | let!(:request_stub) { stub_post("/projects/3/repository/files", "repository_file") } | |
37 | let!(:file) { Gitlab.create_file(3, "path", "branch", "content", "commit message") } | |
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") } | |
38 | 39 | |
39 | 40 | it "should create the correct resource" do |
40 | expect(request_stub).to have_been_made | |
41 | expected_parameters = { | |
42 | author_name: "joe", | |
43 | branch: "branch", | |
44 | commit_message: "commit message" | |
45 | } | |
46 | expect(a_post(api_path).with(body: hash_including(expected_parameters))).to have_been_made | |
41 | 47 | end |
42 | 48 | |
43 | 49 | it "should return information about the new file" do |
47 | 53 | end |
48 | 54 | |
49 | 55 | describe ".edit_file" do |
50 | let!(:request_stub) { stub_put("/projects/3/repository/files", "repository_file") } | |
51 | let!(:file) { Gitlab.edit_file(3, "path", "branch", "content", "commit message") } | |
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") } | |
52 | 59 | |
53 | it "should create the correct resource" do | |
54 | expect(request_stub).to have_been_made | |
60 | it "should update the correct resource" do | |
61 | expected_parameters = { | |
62 | author_name: "joe", | |
63 | branch: "branch", | |
64 | commit_message: "commit message" | |
65 | } | |
66 | expect(a_put(api_path).with(body: hash_including(expected_parameters))).to have_been_made | |
55 | 67 | end |
56 | 68 | |
57 | 69 | it "should return information about the new file" do |
61 | 73 | end |
62 | 74 | |
63 | 75 | describe ".remove_file" do |
64 | let!(:request_stub) { stub_delete("/projects/3/repository/files", "repository_file") } | |
65 | let!(:file) { Gitlab.remove_file(3, "path", "branch", "commit message") } | |
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") } | |
66 | 79 | |
67 | it "should create the correct resource" do | |
68 | expect(request_stub).to have_been_made | |
80 | it "should update the correct resource" do | |
81 | expected_parameters = { | |
82 | author_name: "joe", | |
83 | branch: "branch", | |
84 | commit_message: "commit message" | |
85 | } | |
86 | expect(a_delete(api_path).with(body: hash_including(expected_parameters))).to have_been_made | |
69 | 87 | end |
70 | 88 | |
71 | 89 | it "should return information about the new file" do |
24 | 24 | describe ".add_hook" do |
25 | 25 | before do |
26 | 26 | stub_post("/hooks", "system_hook") |
27 | @hook = Gitlab.add_hook("http://example.com/hook") | |
27 | @hook = Gitlab.add_hook("http://example.com/hook", token: 'secret-token') | |
28 | 28 | end |
29 | 29 | |
30 | 30 | it "should get the correct resource" do |
31 | expect(a_post("/hooks")).to have_been_made | |
31 | expect(a_post("/hooks").with(body: hash_including(token: 'secret-token'))).to have_been_made | |
32 | 32 | end |
33 | 33 | |
34 | 34 | it "should return information about a added system hook" do |
0 | require 'spec_helper' | |
1 | ||
2 | describe Gitlab::Client do | |
3 | describe '.todos' do | |
4 | before do | |
5 | stub_get("/todos", "todos") | |
6 | @todos = Gitlab.todos | |
7 | end | |
8 | ||
9 | it "should get the correct resources" do | |
10 | expect(a_get("/todos")).to have_been_made | |
11 | end | |
12 | ||
13 | it "should return a paginated response of user's todos" do | |
14 | expect(@todos).to be_a Gitlab::PaginatedResponse | |
15 | end | |
16 | end | |
17 | ||
18 | describe '.mark_todo_as_done' do | |
19 | before do | |
20 | stub_post("/todos/102/mark_as_done", "todo") | |
21 | @todo = Gitlab.mark_todo_as_done(102) | |
22 | end | |
23 | ||
24 | it "should get the correct resource" do | |
25 | expect(a_post("/todos/102/mark_as_done")).to have_been_made | |
26 | end | |
27 | ||
28 | it "should return information about the todo marked as done" do | |
29 | expect(@todo.id).to eq(102) | |
30 | expect(@todo.state).to eq('done') | |
31 | end | |
32 | end | |
33 | ||
34 | describe '.mark_all_todos_as_done' do | |
35 | before do | |
36 | stub_post("/todos/mark_as_done", "todos") | |
37 | @todos = Gitlab.mark_all_todos_as_done | |
38 | end | |
39 | ||
40 | it "should get the correct resources" do | |
41 | expect(a_post("/todos/mark_as_done")).to have_been_made | |
42 | end | |
43 | end | |
44 | end⏎ |