Package list ruby-gitlab / upstream/4.2.0
New upstream version 4.2.0 Sophie Brun 4 years ago
44 changed file(s) with 1960 addition(s) and 197 deletion(s). Raw diff Collapse all Expand all
00 ## Change Log
11
22 ### 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)
320
421 ### 4.1.0 (26/05/2017)
522 - 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
3535 # @example
3636 # Gitlab.protect_branch(3, 'api')
3737 # 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`)
3841 #
3942 # @param [Integer, String] project The ID or name of a project.
4043 # @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)
4450 end
4551 alias_method :repo_protect_branch, :protect_branch
4652
5258 #
5359 # @param [Integer, String] project The ID or name of a project.
5460 # @param [String] branch The name of the branch.
55 # @return [Gitlab::ObjectifiedHash]
61 # @return [Gitlab::ObjectifiedHash] Details about the branch
5662 def unprotect_branch(project, branch)
5763 put("/projects/#{url_encode project}/repository/branches/#{branch}/unprotect")
5864 end
6773 # @param [Integer, String] project The ID or name of a project.
6874 # @param [String] branch The name of the new branch.
6975 # @param [String] ref Create branch from commit sha or existing branch
70 # @return [Gitlab::ObjectifiedHash]
76 # @return [Gitlab::ObjectifiedHash] Details about the branch
7177 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 })
7379 end
7480 alias_method :repo_create_branch, :create_branch
7581
8187 #
8288 # @param [Integer, String] project The ID or name of a project.
8389 # @param [String] branch The name of the branch to delete
84 # @return [Gitlab::ObjectifiedHash]
8590 def delete_branch(project, branch)
8691 delete("/projects/#{url_encode project}/repository/branches/#{branch}")
8792 end
9393 # @option options [String] :stage Filter by stage
9494 # @option options [String] :name Filter by status name, eg. jenkins
9595 # @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)
9898 end
9999 alias_method :repo_commit_status, :commit_status
100100
112112 # @option options [String] :ref The ref (branch or tag) to which the status refers
113113 # @option options [String] :name Filter by status name, eg. jenkins
114114 # @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))
117117 end
118118 alias_method :repo_update_commit_status, :update_commit_status
119119
135135 # @return [Gitlab::ObjectifiedHash] hash of commit related data
136136 def create_commit(project, branch, message, actions, options={})
137137 payload = {
138 branch_name: branch,
138 branch: branch,
139139 commit_message: message,
140140 actions: actions,
141141 }.merge(options)
142 post("/projects/#{url_encode project}/repository/commits", query: payload)
142 post("/projects/#{url_encode project}/repository/commits", body: payload)
143143 end
144144 end
145145 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
1818 # Gitlab.create_label(42, "Backlog", '#DD10AA')
1919 #
2020 # @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.
2326 # @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))
2629 end
2730
2831 # Updates a label.
3639 # @param [Hash] options A customizable set of options.
3740 # @option options [String] :new_name The new name of a label.
3841 # @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.
3944 # @return [Gitlab::ObjectifiedHash] Information about updated label.
4045 def edit_label(project, name, options={})
4146 put("/projects/#{url_encode project}/labels", body: options.merge(name: name))
5257 def delete_label(project, name)
5358 delete("/projects/#{url_encode project}/labels", body: { name: name })
5459 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
5584 end
5685 end
8181 put("/projects/#{url_encode project}/merge_requests/#{id}/merge", body: options)
8282 end
8383
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
14384 # Gets the changes of a merge request.
14485 #
14586 # @example
5555 def merge_request_notes(project, merge_request, options={})
5656 get("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", query: options)
5757 end
58 alias_method :merge_request_comments, :merge_request_notes
5859
5960 # Gets a single wall note.
6061 #
156157 def create_merge_request_note(project, merge_request, body)
157158 post("/projects/#{url_encode project}/merge_requests/#{merge_request}/notes", body: { body: body })
158159 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
159265 end
160266 end
3333 # @option options [String] :sort Return requests sorted in asc or desc order
3434 # @return [Array<Gitlab::ObjectifiedHash>]
3535 def project_search(query, options={})
36 get("/projects/search/#{query}", query: options)
36 get("/projects", query: options.merge(search:query))
3737 end
3838 alias_method :search_projects, :project_search
3939
4343 # Gitlab.project(3)
4444 # Gitlab.project('gitlab')
4545 #
46 # @param [Integer, String] id The ID or name of a project.
46 # @param [Integer, String] id The ID or path of a project.
4747 # @return [Gitlab::ObjectifiedHash]
4848 def project(id)
4949 get("/projects/#{url_encode id}")
5555 # Gitlab.project_events(42)
5656 # Gitlab.project_events('gitlab')
5757 #
58 # @param [Integer, String] project The ID or name of a project.
58 # @param [Integer, String] project The ID or path of a project.
5959 # @param [Hash] options A customizable set of options.
6060 # @option options [Integer] :page The page number.
6161 # @option options [Integer] :per_page The number of results per page.
7575 # @param [Hash] options A customizable set of options.
7676 # @option options [String] :description The description of a project.
7777 # @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)
7879 # @option options [String] :namespace_id The namespace in which to create a project.
7980 # @option options [Boolean] :wiki_enabled The wiki integration for a project (0 = false, 1 = true).
8081 # @option options [Boolean] :wall_enabled The wall functionality for a project (0 = false, 1 = true).
9495 # @example
9596 # Gitlab.delete_project(4)
9697 #
97 # @param [Integer, String] id The ID or name of a project.
98 # @param [Integer, String] id The ID or path of a project.
9899 # @return [Gitlab::ObjectifiedHash] Information about deleted project.
99100 def delete_project(id)
100 delete("/projects/#{id}")
101 delete("/projects/#{url_encode id}")
101102 end
102103
103104 # Gets a list of project team members.
106107 # Gitlab.team_members(42)
107108 # Gitlab.team_members('gitlab')
108109 #
109 # @param [Integer, String] project The ID or name of a project.
110 # @param [Integer, String] project The ID or path of a project.
110111 # @param [Hash] options A customizable set of options.
111112 # @option options [String] :query The search query.
112113 # @option options [Integer] :page The page number.
121122 # @example
122123 # Gitlab.team_member('gitlab', 2)
123124 #
124 # @param [Integer, String] project The ID or name of a project.
125 # @param [Integer, String] project The ID or path of a project.
125126 # @param [Integer] id The ID of a project team member.
126127 # @return [Gitlab::ObjectifiedHash]
127128 def team_member(project, id)
133134 # @example
134135 # Gitlab.add_team_member('gitlab', 2, 40)
135136 #
136 # @param [Integer, String] project The ID or name of a project.
137 # @param [Integer, String] project The ID or path of a project.
137138 # @param [Integer] id The ID of a user.
138139 # @param [Integer] access_level The access level to project.
139140 # @param [Hash] options A customizable set of options.
147148 # @example
148149 # Gitlab.edit_team_member('gitlab', 3, 20)
149150 #
150 # @param [Integer, String] project The ID or name of a project.
151 # @param [Integer, String] project The ID or path of a project.
151152 # @param [Integer] id The ID of a user.
152153 # @param [Integer] access_level The access level to project.
153154 # @param [Hash] options A customizable set of options.
161162 # @example
162163 # Gitlab.remove_team_member('gitlab', 2)
163164 #
164 # @param [Integer, String] project The ID or name of a project.
165 # @param [Integer, String] project The ID or path of a project.
165166 # @param [Integer] id The ID of a user.
166167 # @param [Hash] options A customizable set of options.
167168 # @return [Gitlab::ObjectifiedHash] Information about removed team member.
175176 # Gitlab.project_hooks(42)
176177 # Gitlab.project_hooks('gitlab')
177178 #
178 # @param [Integer, String] project The ID or name of a project.
179 # @param [Integer, String] project The ID or path of a project.
179180 # @param [Hash] options A customizable set of options.
180181 # @option options [Integer] :page The page number.
181182 # @option options [Integer] :per_page The number of results per page.
190191 # Gitlab.project_hook(42, 5)
191192 # Gitlab.project_hook('gitlab', 5)
192193 #
193 # @param [Integer, String] project The ID or name of a project.
194 # @param [Integer, String] project The ID or path of a project.
194195 # @param [Integer] id The ID of a hook.
195196 # @return [Gitlab::ObjectifiedHash]
196197 def project_hook(project, id)
202203 # @example
203204 # Gitlab.add_project_hook(42, 'https://api.example.net/v1/webhooks/ci')
204205 #
205 # @param [Integer, String] project The ID or name of a project.
206 # @param [Integer, String] project The ID or path of a project.
206207 # @param [String] url The hook URL.
207208 # @param [Hash] options A customizable set of options.
208209 # @param option [Boolean] :push_events Trigger hook on push events (0 = false, 1 = true)
220221 # @example
221222 # Gitlab.edit_project_hook(42, 1, 'https://api.example.net/v1/webhooks/ci')
222223 #
223 # @param [Integer, String] project The ID or name of a project.
224 # @param [Integer, String] project The ID or path of a project.
224225 # @param [Integer] id The ID of the hook.
225226 # @param [String] url The hook URL.
226227 # @param [Hash] options A customizable set of options.
239240 # @example
240241 # Gitlab.delete_project_hook('gitlab', 4)
241242 #
242 # @param [Integer, String] project The ID or name of a project.
243 # @param [Integer, String] project The ID or path of a project.
243244 # @param [String] id The ID of the hook.
244245 # @return [Gitlab::ObjectifiedHash] Information about deleted hook.
245246 def delete_project_hook(project, id)
255256 # @param [Integer] id The ID of a project.
256257 # @return [Gitlab::ObjectifiedHash]
257258 def push_rule(id)
258 get("/projects/#{id}/push_rule")
259 get("/projects/#{url_encode id}/push_rule")
259260 end
260261
261262 # Adds a project push rule.
270271 # @param option [String] :commit_message_regex Commit message regex
271272 # @return [Gitlab::ObjectifiedHash] Information about added push rule.
272273 def add_push_rule(id, options={})
273 post("/projects/#{id}/push_rule", body: options)
274 post("/projects/#{url_encode id}/push_rule", body: options)
274275 end
275276
276277 # Updates a project push rule.
285286 # @param option [String] :commit_message_regex Commit message regex
286287 # @return [Gitlab::ObjectifiedHash] Information about updated push rule.
287288 def edit_push_rule(id, options={})
288 put("/projects/#{id}/push_rule", body: options)
289 put("/projects/#{url_encode id}/push_rule", body: options)
289290 end
290291
291292 # Deletes a push rule from a project.
297298 # @param [Integer] id The ID of a project.
298299 # @return [Gitlab::ObjectifiedHash] Information about deleted push rule.
299300 def delete_push_rule(id, options={})
300 delete("/projects/#{id}/push_rule")
301 delete("/projects/#{url_encode id}/push_rule")
301302 end
302303
303304 # Mark this project as forked from the other
305306 # @example
306307 # Gitlab.make_forked(42, 24)
307308 #
308 # @param [Integer, String] project The ID or name of a project.
309 # @param [Integer, String] project The ID or path of a project.
309310 # @param [Integer] id The ID of the project it is forked from.
310311 # @return [Gitlab::ObjectifiedHash] Information about the forked project.
311312 def make_forked_from(project, id)
317318 # @example
318319 # Gitlab.remove_forked(42)
319320 #
320 # @param [Integer, String] project The ID or name of a project.
321 # @param [Integer, String] project The ID or path of a project.
321322 # @param [Integer] project The ID of the project it is forked from
322323 # @return [Gitlab::ObjectifiedHash] Information about the forked project.
323324 def remove_forked(project)
329330 # @example
330331 # Gitlab.deploy_keys(42)
331332 #
332 # @param [Integer, String] project The ID or name of a project.
333 # @param [Integer, String] project The ID or path of a project.
333334 # @param [Hash] options A customizable set of options.
334335 # @option options [Integer] :page The page number.
335336 # @option options [Integer] :per_page The number of results per page.
343344 # @example
344345 # Gitlab.deploy_key(42, 1)
345346 #
346 # @param [Integer, String] project The ID or name of a project.
347 # @param [Integer, String] project The ID or path of a project.
347348 # @param [Integer] id The ID of a deploy key.
348349 # @return [Gitlab::ObjectifiedHash]
349350 def deploy_key(project, id)
355356 # @example
356357 # Gitlab.create_deploy_key(42, 'My Key', 'Key contents')
357358 #
358 # @param [Integer, String] project The ID or name of a project.
359 # @param [Integer, String] project The ID or path of a project.
359360 # @param [String] title The title of a deploy key.
360361 # @param [String] key The content of a deploy key.
361362 # @return [Gitlab::ObjectifiedHash] Information about created deploy key.
368369 # @example
369370 # Gitlab.enable_deploy_key(42, 66)
370371 #
371 # @param [Integer, String] project The ID or name of a project.
372 # @param [Integer, String] project The ID or path of a project.
372373 # @param [Integer] key The ID of a deploy key.
373374 # @return [Gitlab::ObjectifiedHash] Information about the enabled deploy key.
374375 def enable_deploy_key(project, key)
380381 # @example
381382 # Gitlab.disable_deploy_key(42, 66)
382383 #
383 # @param [Integer, String] project The ID or name of a project.
384 # @param [Integer, String] project The ID or path of a project.
384385 # @param [Integer] key The ID of a deploy key.
385386 # @return [Gitlab::ObjectifiedHash] Information about the disabled deploy key.
386387 def disable_deploy_key(project, key)
392393 # @example
393394 # Gitlab.delete_deploy_key(42, 1)
394395 #
395 # @param [Integer, String] project The ID or name of a project.
396 # @param [Integer, String] project The ID or path of a project.
396397 # @param [Integer] id The ID of a deploy key.
397398 # @return [Gitlab::ObjectifiedHash] Information about deleted deploy key.
398399 def delete_deploy_key(project, id)
405406 # Gitlab.create_fork(42)
406407 # Gitlab.create_fork(42, { sudo: 'another_username' })
407408 #
408 # @param [Integer, String] project The ID or name of a project.
409 # @param [Integer, String] project The ID or path of a project.
409410 # @param [Hash] options A customizable set of options.
410411 # @option options [String] :sudo The username the project will be forked for
411412 # @return [Gitlab::ObjectifiedHash] Information about the forked project.
412413 def create_fork(id, options={})
413 post("/projects/#{id}/fork", body: options)
414 post("/projects/#{url_encode id}/fork", body: options)
414415 end
415416
416417 # Updates an existing project.
417418 #
418419 # @example
419420 # 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
424426 # @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 #
427431 # @return [Gitlab::ObjectifiedHash] Information about the edited project.
428432 def edit_project(id, options={})
429 put("/projects/#{id}", query: options)
433 put("/projects/#{url_encode id}", body: options)
430434 end
431435
432436 # Share project with group.
434438 # @example
435439 # Gitlab.share_project_with_group('gitlab', 2, 40)
436440 #
437 # @param [Integer, String] project The ID or name of a project.
441 # @param [Integer, String] project The ID or path of a project.
438442 # @param [Integer] id The ID of a group.
439443 # @param [Integer] group_access The access level to project.
440444 def share_project_with_group(project, id, group_access)
443447
444448 # Stars a project.
445449 # @see https://docs.gitlab.com/ce/api/projects.html#star-a-project
446 #
450 #
447451 # @example
448452 # Gitlab.star_project(42)
449453 # 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.
452456 # @return [Gitlab::ObjectifiedHash] Information about starred project.
453457 def star_project(id)
454 post("/projects/#{id}/star")
458 post("/projects/#{url_encode id}/star")
455459 end
456460
457461 # Unstars a project.
458462 # @see https://docs.gitlab.com/ce/api/projects.html#unstar-a-project
459 #
463 #
460464 # @example
461465 # Gitlab.unstar_project(42)
462466 # 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.
465469 # @return [Gitlab::ObjectifiedHash] Information about unstarred project.
466470 def unstar_project(id)
467 delete("/projects/#{id}/star")
471 delete("/projects/#{url_encode id}/star")
468472 end
469473 end
470474 end
4444 # Gitlab.create_file(42, "path", "branch", "content", "commit message")
4545 #
4646 # @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
5154 # @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,
5658 commit_message: commit_message
57 }.merge(encoded_content_attributes(content)))
59 }.merge(options).merge(encoded_content_attributes(content)))
5860 end
5961
6062 # Edits an existing repository file.
6365 # Gitlab.edit_file(42, "path", "branch", "content", "commit message")
6466 #
6567 # @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
7075 # @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,
7579 commit_message: commit_message
76 }.merge(encoded_content_attributes(content)))
80 }.merge(options).merge(encoded_content_attributes(content)))
7781 end
7882
7983 # Removes an existing repository file.
8286 # Gitlab.remove_file(42, "path", "branch", "commit message")
8387 #
8488 # @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
8895 # @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,
9399 commit_message: commit_message
94 })
100 }.merge(options))
95101 end
96102
97103 private
2323 # Gitlab.add_system_hook('https://api.example.net/v1/hook')
2424 #
2525 # @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`)
2629 # @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))
2932 end
3033 alias_method :add_system_hook, :add_hook
3134
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
22 class Client < API
33 Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
44
5 include AwardEmojis
6 include Boards
57 include Branches
68 include Builds
79 include BuildVariables
810 include Commits
11 include Environments
912 include Groups
1013 include Issues
1114 include Keys
2427 include Snippets
2528 include SystemHooks
2629 include Tags
30 include Todos
2731 include Users
2832 include Jobs
2933
00 module Gitlab
1 VERSION = "4.1.0"
1 VERSION = "4.2.0"
22 end
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
3939 describe ".protect_branch" do
4040 before do
4141 stub_put("/projects/3/repository/branches/api/protect", "branch")
42 @branch = Gitlab.protect_branch(3, "api")
4342 end
4443
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
4756 end
4857
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
5168 end
5269 end
5370
147147
148148 let(:query) do
149149 {
150 branch_name: 'dev',
150 branch: 'dev',
151151 commit_message: 'refactors everything',
152152 actions: actions,
153153 author_email: 'joe@sample.org',
156156 end
157157
158158 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)
160160 @commit = Gitlab.create_commit(6, 'dev', 'refactors everything', actions, {author_email: 'joe@sample.org', author_name: 'Joe Sample'})
161161 end
162162
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
5858 end
5959
6060 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
6665
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
7069
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")
7573 end
7674 end
7775
6464 expect(@label.color).to eq('#DD10AA')
6565 end
6666 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
6799 end
201201 end
202202 end
203203 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
204332 end
2121
2222 describe ".project_search" do
2323 before do
24 stub_get("/projects/search/Gitlab", "project_search")
24 stub_get("/projects?search=Gitlab", "project_search")
2525 @project_search = Gitlab.project_search("Gitlab")
2626 end
2727
2828 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
3030 end
3131
3232 it "should return a paginated response of projects found" do
314314 end
315315
316316 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
328338 end
329339 end
330340
2121 @file = Gitlab.get_file(3, 'README.md', 'master')
2222 end
2323
24 it "should create the correct resource" do
24 it "should get the correct resource" do
2525 expect(a_get("/projects/3/repository/files/README%2Emd?ref=master")).to have_been_made
2626 end
2727
3333 end
3434
3535 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") }
3839
3940 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
4147 end
4248
4349 it "should return information about the new file" do
4753 end
4854
4955 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") }
5259
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
5567 end
5668
5769 it "should return information about the new file" do
6173 end
6274
6375 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") }
6679
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
6987 end
7088
7189 it "should return information about the new file" do
2424 describe ".add_hook" do
2525 before do
2626 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')
2828 end
2929
3030 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
3232 end
3333
3434 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