diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-10-25 02:13:24 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-10-25 02:13:24 +0800 |
commit | 600da9ee0bb823e4b14fd45d6ff0e5f0b61b9737 (patch) | |
tree | f91eeeee22da72eed5bdf5b87ca27bdc95b136a0 /lib/api/todos.rb | |
parent | 40ff7579e9ba025610dfada9703386b4dc657d6d (diff) | |
parent | cb38290ababe43aca0c635fb87d3a38c4c5debcd (diff) | |
download | gitlab-ce-19737-read-only-auditor.tar.gz |
Merge remote-tracking branch 'upstream/master' into 19737-read-only-auditor19737-read-only-auditor
* upstream/master: (1277 commits)
Grapify the labels API
Fix typo in project settings that prevents users from enabling container registry.
Fix old monitoring links to point to the new location
Added path parameter to Commits API
fixes build with cache:clear issue
Merge branch 'security-fix-leaking-namespace-name' into 'security'
Fix authored vote from notes
Grapify builds API
Add changelog item for groups 404 on relative url
Add relative url support to routing contrainers
Update project member controller to match recent master logic
Add parentheses around return redirect_to method
Trigger change even in select2 test helper to produce production-like behaviour
Refactor js that disable form submit if no members selected
Improve create project member test at project_members_controller_spec
Move changelog item to 8.14
Refactor create member tests from group_members_controller_spec
Refactor groups/projects members controller
Gracefully handle adding of no users to projects and groups
Revert "Change "Group#web_url" to return "/groups/twitter" rather than "/twitter"."
...
Diffstat (limited to 'lib/api/todos.rb')
-rw-r--r-- | lib/api/todos.rb | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/lib/api/todos.rb b/lib/api/todos.rb index 19df13d8aac..832b04a3bb1 100644 --- a/lib/api/todos.rb +++ b/lib/api/todos.rb @@ -8,18 +8,19 @@ module API 'issues' => ->(id) { find_project_issue(id) } } + params do + requires :id, type: String, desc: 'The ID of a project' + end resource :projects do ISSUABLE_TYPES.each do |type, finder| type_id_str = "#{type.singularize}_id".to_sym - # Create a todo on an issuable - # - # Parameters: - # id (required) - The ID of a project - # issuable_id (required) - The ID of an issuable - # Example Request: - # POST /projects/:id/issues/:issuable_id/todo - # POST /projects/:id/merge_requests/:issuable_id/todo + desc 'Create a todo on an issuable' do + success Entities::Todo + end + params do + requires type_id_str, type: Integer, desc: 'The ID of an issuable' + end post ":id/#{type}/:#{type_id_str}/todo" do issuable = instance_exec(params[type_id_str], &finder) todo = TodoService.new.mark_todo(issuable, current_user).first @@ -40,25 +41,21 @@ module API end end - # Get a todo list - # - # Example Request: - # GET /todos - # + desc 'Get a todo list' do + success Entities::Todo + end get do todos = find_todos present paginate(todos), with: Entities::Todo, current_user: current_user end - # Mark a todo as done - # - # Parameters: - # id: (required) - The ID of the todo being marked as done - # - # Example Request: - # DELETE /todos/:id - # + desc 'Mark a todo as done' do + success Entities::Todo + end + params do + requires :id, type: Integer, desc: 'The ID of the todo being marked as done' + end delete ':id' do todo = current_user.todos.find(params[:id]) TodoService.new.mark_todos_as_done([todo], current_user) @@ -66,11 +63,7 @@ module API present todo.reload, with: Entities::Todo, current_user: current_user end - # Mark all todos as done - # - # Example Request: - # DELETE /todos - # + desc 'Mark all todos as done' delete do todos = find_todos TodoService.new.mark_todos_as_done(todos, current_user) |