Commit graph

102 commits

Author SHA1 Message Date
Sebastian Ziebell f0e417091c Merge branch 'master' into fixes/api
Conflicts:
	spec/requests/api/projects_spec.rb
2013-02-20 14:30:11 +01:00
Matt Humphrey dddf6eab2d Removed unnecessary paramter hash. Also tidied up hash format in hook creation spec 2013-02-20 11:45:54 +00:00
Sebastian Ziebell eefb27f5ae Merge branch 'master' into fixes/api
Conflicts:
	spec/requests/api/projects_spec.rb
2013-02-20 12:43:32 +01:00
Matt Humphrey 33c513274d Fix RESTfulness of project hook deletions by API 2013-02-20 11:35:36 +00:00
Sebastian Ziebell 1b97a2eee8 API: fixes return codes, documentation updated with status codes, tests added
The users API updated with return codes, e.g. if required parameters are missing
a `400 Bad Request` error is returned instead of `404`. Fixes return codes of functions,
e.g. deletion of a ssh key is an idempotent function now.
The API documentation is updated to reflect the current status of the API. Descriptions
are more detailed and complete, infos to return values are added to all functions.
2013-02-20 12:23:56 +01:00
Dmitriy Zaporozhets b7ac654b88 Merge pull request #2988 from Asquera/error_project_limit
API: creating last project before limit returns 404
2013-02-20 02:47:30 -08:00
Dmitriy Zaporozhets 25e4c512d4 Merge pull request #3011 from Asquera/fix_access_to_nonvisible_hook
API: fixes visibility of project hook
2013-02-20 02:45:07 -08:00
Andrew8xx8 1644117a1a Issue uses StateMachine now 2013-02-18 14:43:50 +04:00
Andrew8xx8 0b512af803 Milestone uses StateMachine now 2013-02-18 14:43:50 +04:00
Andrew8xx8 29f70acc98 Merge Request uses StateMachine now 2013-02-18 14:43:50 +04:00
Sebastian Ziebell e9d3b96595 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.
2013-02-16 14:42:49 +01:00
Sebastian Ziebell 5417fbfecd Test to check 404 error when project id not found 2013-02-14 21:00:05 +01:00
Sebastian Ziebell c305eb31aa API: tests that check status codes for project branches and hooks
Status code 422 (Unprocessable Entity) returned if invalid url is given when creating
or updating a project hook.
2013-02-14 16:55:33 +01:00
Sebastian Ziebell 6df02adc7a API: status code 403 returned if new project would exceed limit
When the project limit is reached the user is not allowed to create new ones.
Instead of error code 404 the status code 403 (Forbidden) is returned with error
message via API.
2013-02-14 15:51:56 +01:00
Sebastian Ziebell 1a01fc0c96 API: tests to show incorrect behavior when reaching project limit
When reaching the project limit the API returns an error code 404 on the last possible
project. The project itself is created and is available in the database (seems valid).
A similar behavior can be observed when reaching the project limit via web client, but
in this case the user is notified that the maximum number of projects is reached. The project
itself is still created and can be accessed.

Tests are added to check the behavior when reaching the project limit or one tries
to exceed it via the API.
2013-02-14 11:13:25 +01:00
Sebastian Ziebell 6fc3263e15 API: extracted helper method to provide 400 bad request error with description
Extracted a method for 400 error (Bad request) and adjusted code accordingly. The name of
the missing attribute is used to show which one was missing from the request. It is used to
give an appropriate message in the json response.
2013-02-13 15:48:52 +01:00
Sebastian Ziebell 54ab9bb6df API: return status code 400 if filepath of raw file blob not given 2013-02-13 14:47:59 +01:00
Sebastian Ziebell fd01f3aacd API: fixes a few return codes for project snippets
When using project snippets via API the functions now provide status codes for
different situations other then only returning 404 error. If required parameters are missing,
e.g. `title` when creating a project snippet a 400 (Bad request) error is returned. The snippet
delete function now is idempotent and returns a 200 (Ok) regardless if the snippet with the
given id is available or not. Changing return codes of these functions has the advantage that
the 404 error is used only for resources, which are not available.

Tests added to check these status codes when handling project snippets.
2013-02-13 12:09:16 +01:00
Sebastian Ziebell 375caeefcf Merge branch 'master' into fixes/api 2013-02-13 10:31:06 +01:00
Sebastian Ziebell ae40e855ef API: test checks a 400 code is returned if snippet title not given 2013-02-13 10:29:42 +01:00
Sebastian Ziebell 82bd0904ff API: test checks a 404 error is returned if snippet id not found 2013-02-13 10:25:13 +01:00
Sebastian Ziebell 7cc4339f71 API: changed status codes for project hooks functions
Different status codes in the API lib are returned on hook creation, update or deletion.
If a required parameter is not given (e.g. `url` in `/projects/:id/hooks/:hook_id`) status
code 400 (Bad request) is returned. On hook deletion a 200 status code is returned, regardless if
the hook is present or not. This makes the DELETE function an idempotent operation. Appropriate tests
are added to check these status codes.
2013-02-12 17:44:42 +01:00
Sebastian Ziebell 56b3223945 Fixes test that checks status code of hook creation 2013-02-08 18:19:59 +01:00
Sebastian Ziebell 40e7846f3e Status code 404 returned when retrieving non existent branch (issue #2922)
Accessing a repository branch that does not exist returns a 404 error instead
of 200 now. Added a test.
2013-02-08 17:04:08 +01:00
Sebastian Ziebell 9544f90389 Adding a project hook returns status code 400 if url is not given
When adding a project hook a url must be specified or a 400 error code is returned

* Specs added to check status code on handling project hooks
* refactored code, extracted a method
2013-02-08 16:48:05 +01:00
Sebastian Ziebell 818caf0b5d API: refined status code handling when adding or updating a project member
When a user is added to a project that is already a member of, a status code 201 is now returned to
signal an idempotent operation. If something fails then instead of returning error code 404 different
more specific error codes are returned. Status code 400 (Bad request) is returned when a required
attribute, e.g. `access_level` is not given or 422 if there is a semantic error, e.g. should
the `access_level` have an unsupported value.

Specs are added to check these status codes.
2013-02-08 14:33:29 +01:00
Sebastian Ziebell 8045a81bcf Merge branch 'master' into fixes/api 2013-02-08 10:32:42 +01:00
Sebastian Ziebell 5d8a99f104 Test to check a user must be part of the team to see project.
A user must be part of the team to see a protected project. A test is given
to check that a 404 error is returned if the user can not see the project.
2013-02-06 17:11:01 +01:00
Sebastian Ziebell bb24275f8d Status code 400 is returned if body is missing on note creation.
If a note is created with a POST request via API (`/projects/:id/notes`) status
code 400 is returned instead of 404. The resource itself exists but the request
is incomplete. Specs added to check different status codes when accessing, creating
and updating notes.
2013-02-06 17:11:00 +01:00
Sebastian Ziebell b9d40d2524 Tests added to check status codes when handling milestone via API
A few more tests added to check status code when creating or updating milestones.
2013-02-06 17:11:00 +01:00
Sebastian Ziebell 41e93bbfe2 Test added to check creation of note to a non-existent MR via API 2013-02-06 17:05:55 +01:00
Sebastian Ziebell f978a71f41 Creating MR comment without a note returns status code 400 (Bad request)
Creating a comment to an existing merge request via API without providing a note
returns a status code 400 now, suggesting a bad request. The reason for this
is the resource itself (MR) exists but the required property is not set.
2013-02-06 17:02:30 +01:00
Sebastian Ziebell 413952ff94 Creating or updating a MR returns more informative status codes.
Using the API library to create or update a merge request at the moment a 404 error is returned.
This is fine when the merge request in question does not exist, but does not provide good
information that for example a required attribute is missing.
A status code of 400 (Bad request) is returned when creating or updating a merge request
when either `source_branch` or `target_branch` is missing. A status code of 409 is returned
when `source_branch` and `target_branch` are the same. Tests are added for these cases.
2013-02-06 16:57:00 +01:00
Christian Simon 6dba727cb2 Add test for duplicate group paths 2013-02-01 18:58:53 +01:00
Christian Simon fc0c692870 Add docs/tests for groups api 2013-02-01 14:59:22 +01:00
Felix Gilcher ce6436b98a Don't crash when removing a user that's not project member
The attempt to revoke project access for a user that was not member of the
project results in a 500 Internal Server error where it actually should
result in a 200 OK since after the operation, the user is not member of
the project. This turns the operation into an idempotent call that can
be repeated with no ill effects.

Updated the spec and changed the code accordingly. However, the result differs
slightly, as we can't return the users project access level if the user was not
member. I'm not aware if anybody relies on the result of this call.

Fixes #2832
2013-02-01 13:53:35 +00:00
Dmitriy Zaporozhets 5857a7a9ce Merge pull request #2839 from m4tthumphrey/protected-branches-api
Added methods to protect and unprotect branches in from the API
2013-01-31 10:44:20 -08:00
Dmitriy Zaporozhets fd1b9fdc12 Merge branch 'extend_user_api' of https://github.com/bladealslayer/gitlabhq into bladealslayer-extend_user_api
Conflicts:
	spec/requests/api/users_spec.rb
2013-01-31 13:00:50 +02:00
Matt Humphrey 2c7554e897 Added methods to protect and unprotect branches 2013-01-31 09:26:03 +00:00
Dmitriy Zaporozhets 9da7b2e8d8 add specs for api -> merge request notes 2013-01-31 08:42:11 +02:00
Marin Jankovski 296cdd591f Add optional signup. 2013-01-18 11:57:31 +01:00
Dmitriy Zaporozhets afbdbb0c95 Rspec fixes 2013-01-04 18:50:31 +02:00
Dmitriy Zaporozhets ccf0686b01 Fix api specs. Use id instead path 2013-01-02 19:46:06 +02:00
Dmitriy Zaporozhets d431e43392 Fix few bugs and tests after refactoring ownership logic 2013-01-02 19:32:34 +02:00
Dmitriy Zaporozhets fa8f834374 Fix import rake task and tests 2012-12-23 00:15:48 +02:00
Valeriy Sizov 77d632890b refactoring gfm_autocomplete 2012-12-20 20:52:12 +02:00
Boyan Tabakov e954438a1d Extended users API to support updating and deleting users.
Also added tests.
2012-12-18 21:24:31 +02:00
Nihad Abbasov 270a43370a API: get a single wall note 2012-12-01 02:20:45 -08:00
Nihad Abbasov ee6187bd55 API: ability to create a wall note 2012-11-29 15:52:56 -08:00
Nihad Abbasov c946bf886c API: create new notes 2012-11-29 12:11:00 -08:00