diff options
author | Angelo Lakra <alakra@comverge.com> | 2013-09-26 14:44:55 -0600 |
---|---|---|
committer | Angelo Lakra <angelo.lakra@gmail.com> | 2013-10-08 00:43:14 -0600 |
commit | fc49034fb454a88626e4e705520c2eb686c6594f (patch) | |
tree | d214bcd4a82eb37d61a5fa603d16bef7675137c9 /lib/api/projects.rb | |
parent | 19c7b21fdd7ce37567ba1149bc15e220a4b91944 (diff) | |
download | gitlab-ci-fc49034fb454a88626e4e705520c2eb686c6594f.tar.gz |
Adding POST /projects (for creation) and several rspec unit stubs for
projects api
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 7f8b51e..b66e65e 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -14,6 +14,31 @@ module API project = Project.find(params[:id]) present project, with: Entities::Project end + + post do + required_attributes! [:name, :gitlab_id, :gitlab_url, :ssh_url_to_repo] + + # TODO: Check if this has automatic filtering of attributes + # via the Grape API + + filtered_params = { + :name => params[:name], + :gitlab_id => params[:gitlab_id], + :gitlab_url => params[:gitlab_url], + :scripts => params[:scripts] || 'ls -al', + :default_ref => params[:default_ref] || 'master', + :ssh_url_to_repo => params[:ssh_url_to_repo] + } + + project = Project.new(filtered_params) + + if project.save + present project, :with => Entities::Project + else + errors = project.errors.full_messages.join(", ") + render_api_error!(errors, 400) + end + end end end end |