From bbd1bfd1558c32a4210a554e5e6fcc35d58e4052 Mon Sep 17 00:00:00 2001 From: livedata Date: Fri, 15 Feb 2013 15:37:06 +0100 Subject: fixed API access to the project --- lib/api/entities.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index c1873d87b55..2cd8aa6c265 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -20,7 +20,7 @@ module Gitlab class Project < Grape::Entity expose :id, :name, :description, :default_branch expose :owner, using: Entities::UserBasic - expose :private_flag, as: :private + expose :public, as: :private expose :path, :path_with_namespace expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :created_at expose :namespace -- cgit v1.2.1 From b7297285369171c95b006e49d6da7bc84b969fc8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 16 Feb 2013 14:42:22 +0200 Subject: uppercase Gitlab version and revision constants. check api return gitlab version now --- lib/api/internal.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/api') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 3e5e3a478ba..5d74a761c05 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -40,7 +40,9 @@ module Gitlab get "/check" do { - api_version: '3' + api_version: Gitlab::API.version, + gitlab_version: Gitlab::VERSION, + gitlab_rev: Gitlab::REVISION, } end end -- cgit v1.2.1 From e9d3b9659525c23a1d8c3b755c792040a5b41148 Mon Sep 17 00:00:00 2001 From: Sebastian Ziebell Date: Sat, 16 Feb 2013 14:42:49 +0100 Subject: API: fixes visibility of project hook When a user is not authorized to see the list of hooks for a project, he is still able to access the hooks separately. For example if access to `GET /projects/:id/hooks` fails and returns a `403 Unauthorized` error it is still possible to access a hook directly via `GET /projects/:id/hooks/:hook_id`. Fixes access, also added tests to check access and status codes of hooks. --- lib/api/projects.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/api') diff --git a/lib/api/projects.rb b/lib/api/projects.rb index d416121a78a..921aa237f26 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -155,6 +155,7 @@ module Gitlab # Example Request: # GET /projects/:id/hooks/:hook_id get ":id/hooks/:hook_id" do + authorize! :admin_project, user_project @hook = user_project.hooks.find(params[:hook_id]) present @hook, with: Entities::Hook end -- cgit v1.2.1 From 29f70acc987abe0b188ef187c70f179088d79589 Mon Sep 17 00:00:00 2001 From: Andrew8xx8 Date: Mon, 18 Feb 2013 13:07:49 +0400 Subject: Merge Request uses StateMachine now --- lib/api/entities.rb | 2 +- lib/api/merge_requests.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 2cd8aa6c265..8d965b6066e 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -81,7 +81,7 @@ module Gitlab end class MergeRequest < Grape::Entity - expose :id, :target_branch, :source_branch, :project_id, :title, :closed, :merged + expose :id, :target_branch, :source_branch, :project_id, :title, :state expose :author, :assignee, using: Entities::UserBasic end diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 470cd1e1c2d..7f763eb49d5 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -73,12 +73,12 @@ module Gitlab # target_branch - The target branch # assignee_id - Assignee user ID # title - Title of MR - # closed - Status of MR. true - closed + # state_event - Status of MR. (close|reopen|merge) # Example: # PUT /projects/:id/merge_request/:merge_request_id # put ":id/merge_request/:merge_request_id" do - attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :closed] + attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :state_event] merge_request = user_project.merge_requests.find(params[:merge_request_id]) authorize! :modify_merge_request, merge_request -- cgit v1.2.1 From 0b512af803d007852bcba40c75203e0e45dda177 Mon Sep 17 00:00:00 2001 From: Andrew8xx8 Date: Mon, 18 Feb 2013 13:10:09 +0400 Subject: Milestone uses StateMachine now --- lib/api/milestones.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api') diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb index 6aca9d01b09..eaf0d37c18b 100644 --- a/lib/api/milestones.rb +++ b/lib/api/milestones.rb @@ -59,14 +59,14 @@ module Gitlab # title (optional) - The title of a milestone # description (optional) - The description of a milestone # due_date (optional) - The due date of a milestone - # closed (optional) - The status of the milestone + # state (optional) - The status of the milestone (close|activate) # Example Request: # PUT /projects/:id/milestones/:milestone_id put ":id/milestones/:milestone_id" do authorize! :admin_milestone, user_project @milestone = user_project.milestones.find(params[:milestone_id]) - attrs = attributes_for_keys [:title, :description, :due_date, :closed] + attrs = attributes_for_keys [:title, :description, :due_date, :state_event] if @milestone.update_attributes attrs present @milestone, with: Entities::Milestone else -- cgit v1.2.1 From 1644117a1ac45bd7d250e7bced929a00a3befe5e Mon Sep 17 00:00:00 2001 From: Andrew8xx8 Date: Mon, 18 Feb 2013 13:10:58 +0400 Subject: Issue uses StateMachine now --- lib/api/entities.rb | 7 +++---- lib/api/issues.rb | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8d965b6066e..b5dd033bc5d 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -35,12 +35,11 @@ module Gitlab class Group < Grape::Entity expose :id, :name, :path, :owner_id end - + class GroupDetail < Group expose :projects, using: Entities::Project end - class RepoObject < Grape::Entity expose :name, :commit expose :protected do |repo, options| @@ -63,7 +62,7 @@ module Gitlab class Milestone < Grape::Entity expose :id expose (:project_id) {|milestone| milestone.project.id} - expose :title, :description, :due_date, :closed, :updated_at, :created_at + expose :title, :description, :due_date, :state, :updated_at, :created_at end class Issue < Grape::Entity @@ -73,7 +72,7 @@ module Gitlab expose :label_list, as: :labels expose :milestone, using: Entities::Milestone expose :assignee, :author, using: Entities::UserBasic - expose :closed, :updated_at, :created_at + expose :state, :updated_at, :created_at end class SSHKey < Grape::Entity diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 4d832fbe593..70bbf47e72c 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -69,14 +69,14 @@ module Gitlab # assignee_id (optional) - The ID of a user to assign issue # milestone_id (optional) - The ID of a milestone to assign issue # labels (optional) - The labels of an issue - # closed (optional) - The state of an issue (0 = false, 1 = true) + # state (optional) - The state of an issue (close|reopen) # Example Request: # PUT /projects/:id/issues/:issue_id put ":id/issues/:issue_id" do @issue = user_project.issues.find(params[:issue_id]) authorize! :modify_issue, @issue - attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id, :closed] + attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id, :state_event] attrs[:label_list] = params[:labels] if params[:labels].present? IssueObserver.current_user = current_user if @issue.update_attributes attrs -- cgit v1.2.1 From 67465dc5ef885fef236b6a4e2de5e008e8e149b1 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 19 Feb 2013 11:45:49 +0200 Subject: Fix private flag for project --- lib/api/entities.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index b5dd033bc5d..1cae1d337fe 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -20,7 +20,7 @@ module Gitlab class Project < Grape::Entity expose :id, :name, :description, :default_branch expose :owner, using: Entities::UserBasic - expose :public, as: :private + expose :public expose :path, :path_with_namespace expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :created_at expose :namespace -- cgit v1.2.1