init project

This commit is contained in:
Jasder
2020-03-09 00:40:16 +08:00
commit 2937b2a94d
6549 changed files with 7215173 additions and 0 deletions

View File

@@ -0,0 +1 @@
{"name":"api","commit":{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","parents":[{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616"}],"tree":"f8c4b21c036339f92fcc5482aa28a41250553b27","message":"API: expose issues project id","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-07-25T04:22:21-07:00","committed_date":"2012-07-25T04:22:21-07:00"},"protected": true}

View File

@@ -0,0 +1 @@
[{"name":"api","commit":{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","parents":[{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616"}],"tree":"f8c4b21c036339f92fcc5482aa28a41250553b27","message":"API: expose issues project id","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-07-25T04:22:21-07:00","committed_date":"2012-07-25T04:22:21-07:00"}},{"name":"dashboard-feed","commit":{"id":"f8f6ff065eccc6ede4d35ed87a09bb962b84ca25","parents":[{"id":"2cf8010792c3075824ee27d0f037aeb178cbbf7e"}],"tree":"e17f2157143d550891d4669c10b7446e4739bc6d","message":"add projects atom feed","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-05-31T23:42:02-07:00","committed_date":"2012-05-31T23:42:02-07:00"}},{"name":"master","commit":{"id":"2cf8010792c3075824ee27d0f037aeb178cbbf7e","parents":[{"id":"af226ae9c9af406c8a0e0bbdf364563495c2f432"},{"id":"e851cb07762aa464aae10e8b4b28de87c1a6f925"}],"tree":"6c6845838039f01723d91f395a1d2fa1dcc82522","message":"Merge pull request #868 from SaitoWu/bugfix/encoding\n\nBugfix/encoding","author":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"committer":{"name":"Dmitriy Zaporozhets","email":"dmitriy.zaporozhets@gmail.com"},"authored_date":"2012-05-30T00:24:43-07:00","committed_date":"2012-05-30T00:24:43-07:00"}},{"name":"preview_notes","commit":{"id":"3749e0d99ac6bfbc65889b1b7a5310e14e7fe89a","parents":[{"id":"2483181f2c3d4ea7d2c68147b19bc07fc3937b0c"}],"tree":"f8c56161b0d6561568f088df9961362eb1ece88b","message":"pass project_id to notes preview path","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-08-09T23:46:27-07:00","committed_date":"2012-08-09T23:46:27-07:00"}},{"name":"refactoring","commit":{"id":"7c7761099cae83f59fe5780340e100be890847b2","parents":[{"id":"058d80b3363dd4fc4417ca4f60f76119188a2470"}],"tree":"d7d4a94c700dc0e84ee943019213d2358a49c413","message":"fix deprecation warnings","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-05-29T07:16:28-07:00","committed_date":"2012-05-29T07:16:28-07:00"}}]

View File

@@ -0,0 +1 @@
{"note":"Cool Merge Request!","author":{"id":1,"username":"jsmith","email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-07-11T01:32:18Z"}}

View File

@@ -0,0 +1 @@
{"name":"api","commit":{ "id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","message":"API: expose issues project id","parent_ids":["949b1df930bedace1dbd755aaa4a82e8c451a616"],"authored_date":"2012-07-25T04:22:21-07:00","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","committed_date":"2012-07-25T04:22:21-07:00","committer_name":"Nihad Abbasov","committer_email":"narkoz.2008@gmail.com"},"protected": false}

View File

@@ -0,0 +1 @@
{"id":2,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}

View File

@@ -0,0 +1 @@
{"message": "409 Already exists"}

60
lib/gitlab-cli/spec/fixtures/group.json vendored Normal file
View File

@@ -0,0 +1,60 @@
{"id": 10, "name": "GitLab-Group", "path": "gitlab-group", "owner_id": 6, "projects": [
{
"id": 9,
"name": "mojito",
"description": null,
"default_branch": "master",
"owner": {
"id": 6,
"username": "jose",
"email": "jose@abc.com",
"name": "Jose Jose",
"blocked": false,
"created_at": "2013-02-06T06:54:06Z"
},
"path": "mojito",
"path_with_namespace": "gitlab-group/mojito",
"issues_enabled": true,
"merge_requests_enabled": true,
"wall_enabled": true,
"wiki_enabled": true,
"created_at": "2013-02-06T16:59:15Z",
"namespace": {
"created_at": "2013-02-06T16:58:22Z",
"id": 10,
"name": "GitLab-Group",
"owner_id": 6,
"path": "gitlab-group",
"updated_at": "2013-02-06T16:58:22Z"
}
},
{
"id": 10,
"name": "gitlabhq",
"description": null,
"default_branch": null,
"owner": {
"id": 6,
"username": "randx",
"email": "randx@github.com",
"name": "Dmitry Z",
"blocked": false,
"created_at": "2013-02-06T06:54:06Z"
},
"path": "gitlabhq",
"path_with_namespace": "gitlab-group/gitlabhq",
"issues_enabled": true,
"merge_requests_enabled": true,
"wall_enabled": true,
"wiki_enabled": true,
"created_at": "2013-02-06T17:02:31Z",
"namespace": {
"created_at": "2013-02-06T16:58:22Z",
"id": 10,
"name": "GitLab-Group",
"owner_id": 6,
"path": "gitlab-group",
"updated_at": "2013-02-06T16:58:22Z"
}
}
]}

View File

@@ -0,0 +1 @@
{"id":3,"name":"Gitlab-Group","path":"gitlab-group","owner_id":1}

View File

@@ -0,0 +1 @@
{"id":2,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-09-04T18:15:30Z","access_level":10}

View File

@@ -0,0 +1 @@
{"created_at":"2013-09-04T18:18:15Z","group_access":10,"group_id":3,"id":2,"notification_level":3,"updated_at":"2013-09-04T18:18:15Z","user_id":2}

View File

@@ -0,0 +1 @@
[{"id":1,"username":"eraymond","email":"eraymond@local.host","name":"Edward Raymond","state":"active","created_at":"2013-08-30T16:16:22Z","access_level":50},{"id":1,"username":"jsmith","email":"jsmith@local.host","name":"John Smith","state":"active","created_at":"2013-08-30T16:16:22Z","access_level":50}]

View File

@@ -0,0 +1,2 @@
[{"id": 3,"name": "ThreeGroup","path": "threegroup","owner_id": 1},{"id": 5,"name": "Five-Group","path": "five-group","owner_id": 2},{"id": 8,"name": "Eight Group","path": "eight-group","owner_id": 6}
]

View File

@@ -0,0 +1 @@
{"id":33,"project_id":3,"title":"Beatae possimus nostrum nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.","description":null,"labels":[],"milestone":null,"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}

View File

@@ -0,0 +1 @@
[{"id":1,"project_id":1,"title":"Culpa eius recusandae suscipit autem distinctio dolorum.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":6,"project_id":2,"title":"Ut in dolorum omnis sed sit aliquam.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":12,"project_id":3,"title":"Veniam et tempore quidem eum reprehenderit cupiditate non aut velit eaque.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":21,"project_id":1,"title":"Vitae ea aliquam et quo eligendi sapiente voluptatum labore hic nihil culpa.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":26,"project_id":2,"title":"Quo enim est nihil atque placeat voluptas neque eos voluptas.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":32,"project_id":3,"title":"Deserunt tenetur impedit est beatae voluptas voluptas quaerat quisquam.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}]

1
lib/gitlab-cli/spec/fixtures/key.json vendored Normal file
View File

@@ -0,0 +1 @@
{"id":1,"title":"narkoz@helium","key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkUsh42Nh1yefGd1jbSELn5XsY8p5Oxmau0/1HqHnjuYOaj5X+kHccFDwtmtg9Ox8ua/+WptNsiE8IUwsD3zKgEjajgwq3gMeeFdxfXwM+tEvHOOMV9meRrgRWGYCToPbT6sR7/YMAYa7cPqWSpx/oZhYfz4XtoMv3ZZT1fZMmx3MY3HwXwW8j+obJyN2K4LN0TFi9RPgWWYn0DCyb9OccmABimt3i74WoJ/OT8r6/7swce8+OSe0Q2wBhyTtvxg2vtUcoek8Af+EZaUMBwSEzEsocOCzwQvjF5XUk5o7dJ8nP8W3RE60JWX57t16eQm7lBmumLYfszpn2isd6W7a1 narkoz@helium"}

View File

@@ -0,0 +1 @@
[{"id":1,"title":"narkoz@helium","key":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkUsh42Nh1yefGd1jbSELn5XsY8p5Oxmau0/1HqHnjuYOaj5X+kHccFDwtmtg9Ox8ua/+WptNsiE8IUwsD3zKgEjajgwq3gMeeFdxfXwM+tEvHOOMV9meRrgRWGYCToPbT6sR7/YMAYa7cPqWSpx/oZhYfz4XtoMv3ZZT1fZMmx3MY3HwXwW8j+obJyN2K4LN0TFi9RPgWWYn0DCyb9OccmABimt3i74WoJ/OT8r6/7swce8+OSe0Q2wBhyTtvxg2vtUcoek8Af+EZaUMBwSEzEsocOCzwQvjF5XUk5o7dJ8nP8W3RE60JWX57t16eQm7lBmumLYfszpn2isd6W7a1 narkoz@helium"}]

View File

@@ -0,0 +1 @@
{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}

View File

@@ -0,0 +1 @@
[{"note":"this is the 1st comment on the 2merge merge request","author":{"id":11,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}},{"note":"another discussion point on the 2merge request","author":{"id":12,"username":"admin","email":"admin@example.com","name":"A User","state":"active","created_at":"2014-03-06T08:17:35.000Z"}}]

View File

@@ -0,0 +1 @@
[{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}]

View File

@@ -0,0 +1 @@
{"id":1,"project_id":3,"title":"3.0","description":"","due_date":"2012-10-22","closed":false,"updated_at":"2012-09-17T10:15:31Z","created_at":"2012-09-17T10:15:31Z"}

View File

@@ -0,0 +1 @@
[{"id":1,"project_id":3,"title":"3.0","description":"","due_date":"2012-10-22","closed":false,"updated_at":"2012-09-17T10:15:31Z","created_at":"2012-09-17T10:15:31Z"}]

View File

@@ -0,0 +1 @@
{"id":1201,"body":"The solution is rather tricky","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"created_at":"2012-11-27T19:16:44Z"}

View File

@@ -0,0 +1 @@
[{"id":1201,"body":"The solution is rather tricky","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"created_at":"2012-11-27T19:16:44Z"},{"id":1207,"body":"I know, right?","author":{"id":1,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"created_at":"2012-11-27T19:58:21Z"}]

View File

@@ -0,0 +1 @@
{"id":3,"code":"gitlab","name":"Gitlab","description":null,"path":"gitlab","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"public":false,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:58Z"}

View File

@@ -0,0 +1,13 @@
{
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
"short_id": "6104942438c",
"title": "Sanitize for network graph",
"author_name": "randx",
"author_email": "dmitriy.zaporozhets@gmail.com",
"created_at": "2012-09-20T09:06:12+03:00",
"committed_date": "2012-09-20T09:06:12+03:00",
"authored_date": "2012-09-20T09:06:12+03:00",
"parent_ids": [
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
]
}

View File

@@ -0,0 +1,10 @@
{
"diff": "--- a/doc/update/5.4-to-6.0.md\n+++ b/doc/update/5.4-to-6.0.md\n@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files",
"new_path": "doc/update/5.4-to-6.0.md",
"old_path": "doc/update/5.4-to-6.0.md",
"a_mode": null,
"b_mode": "100644",
"new_file": false,
"renamed_file": false,
"deleted_file": false
}

View File

@@ -0,0 +1 @@
[{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","short_id":"f7dd067490f","title":"API: expose issues project id","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-25T04:22:21-07:00"},{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616","short_id":"949b1df930b","title":"API: update docs","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-25T02:35:41-07:00"},{"id":"1b95c8bff351f6718ec31ac1de1e48c57bc95d44","short_id":"1b95c8bff35","title":"API: ability to get project by id","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-25T02:18:30-07:00"},{"id":"92d98f5a0c28bffd7b070cda190b07ab72667d58","short_id":"92d98f5a0c2","title":"Merge pull request #1118 from patthoyts/pt/ldap-missing-password","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-25T01:51:06-07:00"},{"id":"60d3e94874964a626f105d3598e1c122addcf43e","short_id":"60d3e948749","title":"Merge pull request #1122 from patthoyts/pt/missing-log","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-25T01:50:34-07:00"},{"id":"b683a71aa1230f17f9df47661c77dfeae27027de","short_id":"b683a71aa12","title":"Merge pull request #1135 from NARKOZ/api","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-25T01:48:00-07:00"},{"id":"fbb41100db35cf2def2c8b4d896b7015d56bd15b","short_id":"fbb41100db3","title":"update help section with issues API docs","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-24T05:52:43-07:00"},{"id":"eca823c1c7cef45cc18c6ab36d2327650c85bfc3","short_id":"eca823c1c7c","title":"Merge branch 'master' into api","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-24T05:46:36-07:00"},{"id":"024e0348904179a8dea81c01e27a5f014cf57499","short_id":"024e0348904","title":"update API docs","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-24T05:25:01-07:00"},{"id":"7b33d8cbcab3b0ee5789ec607455ab62130db69f","short_id":"7b33d8cbcab","title":"add issues API","author_name":"Nihad Abbasov","author_email":"narkoz.2008@gmail.com","created_at":"2012-07-24T05:19:51-07:00"},{"id":"6035ad7e1fe519d0c6a42731790183889e3ba31d","short_id":"6035ad7e1fe","title":"Create the githost.log file if necessary.","author_name":"Pat Thoyts","author_email":"patthoyts@users.sourceforge.net","created_at":"2012-07-21T07:32:04-07:00"},{"id":"a2d244ec062f3348f6cd1c5218c6097402c5f562","short_id":"a2d244ec062","title":"Handle LDAP missing credentials error with a flash message.","author_name":"Pat Thoyts","author_email":"patthoyts@users.sourceforge.net","created_at":"2012-07-21T01:04:05-07:00"},{"id":"8b7e404b5b6944e9c92cc270b2e5d0005781d49d","short_id":"8b7e404b5b6","title":"Up to 2.7.0","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:53:55-07:00"},{"id":"11721b0dbe82c35789be3e4fa8e14663934b2ff5","short_id":"11721b0dbe8","title":"Help section for system hooks completed","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:47:57-07:00"},{"id":"9c8a1e651716212cf50a623d98e03b8dbdb2c64a","short_id":"9c8a1e65171","title":"Fix system hook example","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:32:42-07:00"},{"id":"4261acda90ff4c61326d80cba026ae76e8551f8f","short_id":"4261acda90f","title":"move SSH keys tab closer to begining","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:27:09-07:00"},{"id":"a69fc5dd23bd502fd36892a80eec21a4c53891f8","short_id":"a69fc5dd23b","title":"Endless event loading for dsahboard","author_name":"randx","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-21T00:23:05-07:00"},{"id":"860fa1163a5fbdfec2bb01ff2d584351554dee29","short_id":"860fa1163a5","title":"Merge pull request #1117 from patthoyts/pt/user-form","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-20T14:23:49-07:00"},{"id":"787e5e94acf5e20280416c9fda105ef5b77576b3","short_id":"787e5e94acf","title":"Fix english on the edit user form.","author_name":"Pat Thoyts","author_email":"patthoyts@users.sourceforge.net","created_at":"2012-07-20T14:18:42-07:00"},{"id":"9267cb04b0b3fdf127899c4b7e636dc27fac06d3","short_id":"9267cb04b0b","title":"Merge branch 'refactoring_controllers' of dev.gitlabhq.com:gitlabhq","author_name":"Dmitriy Zaporozhets","author_email":"dmitriy.zaporozhets@gmail.com","created_at":"2012-07-20T07:24:56-07:00"}]

View File

@@ -0,0 +1,8 @@
{
"created_at": "2013-10-05T15:05:26Z",
"fingerprint": "5c:b5:e6:b0:f5:31:65:3f:a6:b5:59:86:32:cc:15:e1",
"id": 2,
"key": "ssh-rsa ...",
"updated_at": "2013-10-05T15:05:26Z",
"user_id": null
}

View File

@@ -0,0 +1 @@
[{"title":null,"project_id":2,"action_name":"opened","target_id":null,"target_type":null,"author_id":1,"data":{"before":"ac0c1aa3898d6dea54d7868ea6f9c45fd5e30c59","after":"66350dbb62a221bc619b665aef3e1e7d3b306747","ref":"refs/heads/master","user_id":1,"user_name":"Administrator","project_id":2,"repository":{"name":"gitlab-ci","url":"git@demo.gitlab.com:gitlab/gitlab-ci.git","description":"Continuous integration server for gitlabhq | Coordinator","homepage":"http://demo.gitlab.com/gitlab/gitlab-ci"},"commits":[{"id":"8cf469b039931bab37bbf025e6b69287ea3cfb0e","message":"Modify screenshot\n\nSigned-off-by: Dmitriy Zaporozhets \u003Cdummy@gmail.com\u003E","timestamp":"2014-05-20T10:34:27+00:00","url":"http://demo.gitlab.com/gitlab/gitlab-ci/commit/8cf469b039931bab37bbf025e6b69287ea3cfb0e","author":{"name":"Dummy","email":"dummy@gmail.com"}},{"id":"66350dbb62a221bc619b665aef3e1e7d3b306747","message":"Edit some code\n\nSigned-off-by: Dmitriy Zaporozhets \u003Cdummy@gmail.com\u003E","timestamp":"2014-05-20T10:35:15+00:00","url":"http://demo.gitlab.com/gitlab/gitlab-ci/commit/66350dbb62a221bc619b665aef3e1e7d3b306747","author":{"name":"Dummy","email":"dummy@gmail.com"}}],"total_commits_count":2},"target_title":null,"created_at":"2014-05-20T10:35:26.240Z"},{"title":null,"project_id":2,"action_name":"opened","target_id":2,"target_type":"MergeRequest","author_id":1,"data":null,"target_title":" Morbi et cursus leo. Sed eget vestibulum sapien","created_at":"2014-05-20T10:24:11.917Z"}]

View File

@@ -0,0 +1 @@
{"id":1,"code":"brute","name":"Brute","description":null,"path":"brute","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Owner","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"private":true,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:56Z"}

View File

@@ -0,0 +1 @@
{"created_at":"2013-07-03T13:51:48Z","forked_from_project_id":24,"forked_to_project_id":42,"id":1,"updated_at":"2013-07-03T13:51:48Z"}

View File

@@ -0,0 +1 @@
{"id":1,"url":"https://api.example.net/v1/webhooks/ci"}

View File

@@ -0,0 +1 @@
[{"id":1,"url":"https://api.example.net/v1/webhooks/ci"}]

View File

@@ -0,0 +1 @@
[{"id":36,"project_id":3,"title":"Eos ut modi et laudantium quasi porro voluptas sed.","description":null,"labels":[],"milestone":null,"assignee":{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":35,"project_id":3,"title":"Ducimus illo in iure voluptatem dolores labore.","description":null,"labels":[],"milestone":null,"assignee":{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":34,"project_id":3,"title":"Rem tempora voluptatum atque eum sit nihil neque.","description":null,"labels":[],"milestone":null,"assignee":{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":33,"project_id":3,"title":"Beatae possimus nostrum nihil reiciendis laboriosam nihil delectus alias accusantium dolor unde.","description":null,"labels":[],"milestone":null,"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":32,"project_id":3,"title":"Deserunt tenetur impedit est beatae voluptas voluptas quaerat quisquam.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":16,"project_id":3,"title":"Numquam earum aut laudantium reprehenderit voluptatem aut.","description":null,"labels":[],"milestone":null,"assignee":{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":15,"project_id":3,"title":"Qui veritatis voluptas fuga voluptate voluptas cupiditate.","description":null,"labels":[],"milestone":null,"assignee":{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":14,"project_id":3,"title":"In assumenda et ipsa qui debitis voluptatem incidunt.","description":null,"labels":[],"milestone":null,"assignee":{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":13,"project_id":3,"title":"Illo eveniet consequatur enim iste provident facilis rerum voluptatem et architecto aut.","description":null,"labels":[],"milestone":null,"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"author":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":12,"project_id":3,"title":"Veniam et tempore quidem eum reprehenderit cupiditate non aut velit eaque.","description":null,"labels":[],"milestone":null,"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}]

View File

@@ -0,0 +1,6 @@
{
"id": 2,
"title": "Key Title",
"key": "ssh-rsa ...",
"created_at": "2013-09-22T18:34:32Z"
}

View File

@@ -0,0 +1,6 @@
[{
"id": 2,
"title": "Key Title",
"key": "ssh-rsa ...",
"created_at": "2013-09-22T18:34:32Z"
}]

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
[{"id":1,"code":"brute","name":"Brute","description":null,"path":"brute","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"private":true,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:56Z"},{"id":2,"code":"mozart","name":"Mozart","description":null,"path":"mozart","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"private":true,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:57Z"},{"id":3,"code":"gitlab","name":"Gitlab","description":null,"path":"gitlab","default_branch":null,"owner":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"private":true,"issues_enabled":true,"merge_requests_enabled":true,"wall_enabled":true,"wiki_enabled":true,"created_at":"2012-09-17T09:41:58Z"}]

View File

@@ -0,0 +1 @@
{"name":"api","commit":{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","parents":[{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616"}],"tree":"f8c4b21c036339f92fcc5482aa28a41250553b27","message":"API: expose issues project id","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-07-25T04:22:21-07:00","committed_date":"2012-07-25T04:22:21-07:00"},"protected":true}

View File

@@ -0,0 +1 @@
{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z","private_token":"qEsq1pt6HJPaNciie3MG"}

View File

@@ -0,0 +1 @@
{"id":1,"title":"Rails Console ActionMailer","file_name":"mailer_test.rb","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"expires_at":"2012-09-24T00:00:00Z","updated_at":"2012-09-17T09:51:42Z","created_at":"2012-09-17T09:51:42Z"}

View File

@@ -0,0 +1 @@
[{"id":1,"title":"Rails Console ActionMailer","file_name":"mailer_test.rb","author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"expires_at":"2012-09-24T00:00:00Z","updated_at":"2012-09-17T09:51:42Z","created_at":"2012-09-17T09:51:42Z"}]

View File

@@ -0,0 +1 @@
{"id": 3, "url": "http://example.com/hook", "created_at": "2013-10-02T10:15:31Z"}

View File

@@ -0,0 +1 @@
{ "event_name": "project_create", "name": "Ruby", "path": "ruby", "project_id": 1, "owner_name": "Someone", "owner_email": "example@gitlabhq.com" }

View File

@@ -0,0 +1 @@
[{"id": 3, "url": "http://example.com/hook", "created_at": "2013-10-02T10:15:31Z"}]

1
lib/gitlab-cli/spec/fixtures/tag.json vendored Normal file
View File

@@ -0,0 +1 @@
{"name": "v1.0.0","commit": {"id": "2695effb5807a22ff3d138d593fd856244e155e7","parents": [],"message": "Initial commit","authored_date": "2012-05-28T04:42:42-07:00","author_name": "John Smith","author email": "john@example.com","committer_name": "Jack Smith","committed_date": "2012-05-28T04:42:42-07:00","committer_email": "jack@example.com"},"protected": false}

View File

@@ -0,0 +1 @@
{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z","access_level":40}

View File

@@ -0,0 +1 @@
[{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z","access_level":40},{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":20},{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":6,"email":"faye.watsica@rohanwalter.com","name":"Ambrose Hansen","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":40},{"id":7,"email":"maida@walshtorp.name","name":"Alana Hahn","blocked":false,"created_at":"2012-09-17T09:42:03Z","access_level":20}]

View File

@@ -0,0 +1 @@
{"name":"api","commit":{"id":"f7dd067490fe57505f7226c3b54d3127d2f7fd46","parents":[{"id":"949b1df930bedace1dbd755aaa4a82e8c451a616"}],"tree":"f8c4b21c036339f92fcc5482aa28a41250553b27","message":"API: expose issues project id","author":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"committer":{"name":"Nihad Abbasov","email":"narkoz.2008@gmail.com"},"authored_date":"2012-07-25T04:22:21-07:00","committed_date":"2012-07-25T04:22:21-07:00"},"protected":false}

View File

@@ -0,0 +1 @@
{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"A different new feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}

View File

@@ -0,0 +1 @@
{"id":1,"email":"john@example.com","name":"John Smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"}

View File

@@ -0,0 +1 @@
[{"id":1,"email":"john@example.com","name":"John Smith","bio":null,"skype":"","linkedin":"","twitter":"john","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:41:56Z"},{"id":2,"email":"jack@example.com","name":"Jack Smith","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":3,"email":"wilma@mayerblanda.ca","name":"Beatrice Jewess","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":4,"email":"nicole@mertz.com","name":"Felipe Davis","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":5,"email":"aliza_stark@schmeler.info","name":"Michale Von","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":6,"email":"faye.watsica@rohanwalter.com","name":"Ambrose Hansen","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"},{"id":7,"email":"maida@walshtorp.name","name":"Alana Hahn","bio":null,"skype":"","linkedin":"","twitter":"","dark_scheme":false,"theme_id":1,"blocked":false,"created_at":"2012-09-17T09:42:03Z"}]

View File

@@ -0,0 +1,80 @@
require 'spec_helper'
describe Gitlab::CLI do
describe ".run" do
context "when command is version" do
it "should show gem version" do
output = capture_output { Gitlab::CLI.run('-v') }
expect(output).to eq("Gitlab Ruby Gem #{Gitlab::VERSION}\n")
end
end
context "when command is info" do
it "should show environment info" do
output = capture_output { Gitlab::CLI.run('info') }
expect(output).to include("Gitlab endpoint is")
expect(output).to include("Gitlab private token is")
expect(output).to include("Ruby Version is")
expect(output).to include("Gitlab Ruby Gem")
end
end
context "when command is help" do
it "should show available actions" do
output = capture_output { Gitlab::CLI.run('help') }
expect(output).to include('Available commands')
expect(output).to include('MergeRequests')
expect(output).to include('team_members')
end
end
context "when command is user" do
before do
stub_get("/user", "user")
@output = capture_output { Gitlab::CLI.run('user') }
end
it "should show executed command" do
expect(@output).to include('Gitlab.user')
end
it "should show user data" do
expect(@output).to include('name')
expect(@output).to include('John Smith')
end
end
end
describe ".start" do
context "when command with excluded fields" do
before do
stub_get("/user", "user")
args = ['user', '--except=id,email,name']
@output = capture_output { Gitlab::CLI.start(args) }
end
it "should show user data with excluded fields" do
expect(@output).to_not include('John Smith')
expect(@output).to include('bio')
expect(@output).to include('created_at')
end
end
context "when command with required fields" do
before do
stub_get("/user", "user")
args = ['user', '--only=id,email,name']
@output = capture_output { Gitlab::CLI.start(args) }
end
it "should show user data with required fields" do
expect(@output).to include('id')
expect(@output).to include('name')
expect(@output).to include('email')
expect(@output).to include('John Smith')
expect(@output).to_not include('bio')
expect(@output).to_not include('created_at')
end
end
end
end

View File

@@ -0,0 +1,103 @@
require 'spec_helper'
describe Gitlab::Client do
it { should respond_to :repo_branches }
it { should respond_to :repo_branch }
it { should respond_to :repo_protect_branch }
it { should respond_to :repo_unprotect_branch }
describe ".branches" do
before do
stub_get("/projects/3/repository/branches", "branches")
@branches = Gitlab.branches(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3/repository/branches")).to have_been_made
end
it "should return an array of repository branches" do
expect(@branches).to be_an Array
expect(@branches.first.name).to eq("api")
end
end
describe ".branch" do
before do
stub_get("/projects/3/repository/branches/api", "branch")
@branch = Gitlab.branch(3, "api")
end
it "should get the correct resource" do
expect(a_get("/projects/3/repository/branches/api")).to have_been_made
end
it "should return information about a repository branch" do
expect(@branch.name).to eq("api")
end
end
describe ".protect_branch" do
before do
stub_put("/projects/3/repository/branches/api/protect", "protect_branch")
@branch = Gitlab.protect_branch(3, "api")
end
it "should get the correct resource" do
expect(a_put("/projects/3/repository/branches/api/protect")).to have_been_made
end
it "should return information about a protected repository branch" do
expect(@branch.name).to eq("api")
expect(@branch.protected).to eq(true)
end
end
describe ".unprotect_branch" do
before do
stub_put("/projects/3/repository/branches/api/unprotect", "unprotect_branch")
@branch = Gitlab.unprotect_branch(3, "api")
end
it "should get the correct resource" do
expect(a_put("/projects/3/repository/branches/api/unprotect")).to have_been_made
end
it "should return information about an unprotected repository branch" do
expect(@branch.name).to eq("api")
expect(@branch.protected).to eq(false)
end
end
describe ".create_branch" do
context "with branch name" do
before do
stub_post("/projects/3/repository/branches", "create_branch")
@branch = Gitlab.create_branch(3, "api","master")
end
it "should get the correct resource" do
expect(a_post("/projects/3/repository/branches")).to have_been_made
end
it "should return information about a new repository branch" do
expect(@branch.name).to eq("api")
end
end
context "with commit hash" do
before do
stub_post("/projects/3/repository/branches", "create_branch")
@branch = Gitlab.create_branch(3, "api","949b1df930bedace1dbd755aaa4a82e8c451a616")
end
it "should get the correct resource" do
expect(a_post("/projects/3/repository/branches")).to have_been_made
end
it "should return information about a new repository branch" do
expect(@branch.name).to eq("api")
end
end
end
end

View File

@@ -0,0 +1,111 @@
require 'spec_helper'
describe Gitlab::Client do
describe ".groups" do
before do
stub_get("/groups", "groups")
stub_get("/groups/3", "group")
@group = Gitlab.group(3)
@groups = Gitlab.groups
end
it "should get the correct resource" do
expect(a_get("/groups")).to have_been_made
expect(a_get("/groups/3")).to have_been_made
end
it "should return an array of Groups" do
expect(@groups).to be_an Array
expect(@groups.first.path).to eq("threegroup")
end
end
describe ".create_group" do
before do
stub_post("/groups", "group_create")
@group = Gitlab.create_group('GitLab-Group', 'gitlab-path')
end
it "should get the correct resource" do
expect(a_post("/groups").
with(:body => {:path => 'gitlab-path', :name => 'GitLab-Group'})).to have_been_made
end
it "should return information about a created group" do
expect(@group.name).to eq("Gitlab-Group")
expect(@group.path).to eq("gitlab-group")
end
end
describe ".transfer_project_to_group" do
before do
stub_post("/projects", "project")
@project = Gitlab.create_project('Gitlab')
stub_post("/groups", "group_create")
@group = Gitlab.create_group('GitLab-Group', 'gitlab-path')
stub_post("/groups/#{@group.id}/projects/#{@project.id}", "group_create")
@group_transfer = Gitlab.transfer_project_to_group(@group.id,@project.id)
end
it "should post to the correct resource" do
expect(a_post("/groups/#{@group.id}/projects/#{@project.id}").with(:body => {:id => @group.id.to_s, :project_id => @project.id.to_s})).to have_been_made
end
it "should return information about the group" do
expect(@group_transfer.name).to eq(@group.name)
expect(@group_transfer.path).to eq(@group.path)
expect(@group_transfer.id).to eq(@group.id)
end
end
describe ".group_members" do
before do
stub_get("/groups/3/members", "group_members")
@members = Gitlab.group_members(3)
end
it "should get the correct resource" do
expect(a_get("/groups/3/members")).to have_been_made
end
it "should return information about a group members" do
expect(@members).to be_an Array
expect(@members.size).to eq(2)
expect(@members[1].name).to eq("John Smith")
end
end
describe ".add_group_member" do
before do
stub_post("/groups/3/members", "group_member")
@member = Gitlab.add_group_member(3, 1, 40)
end
it "should get the correct resource" do
expect(a_post("/groups/3/members").
with(:body => {:user_id => '1', :access_level => '40'})).to have_been_made
end
it "should return information about an added member" do
expect(@member.name).to eq("John Smith")
end
end
describe ".remove_group_member" do
before do
stub_delete("/groups/3/members/1", "group_member_delete")
@group = Gitlab.remove_group_member(3, 1)
end
it "should get the correct resource" do
expect(a_delete("/groups/3/members/1")).to have_been_made
end
it "should return information about the group the member was removed from" do
expect(@group.group_id).to eq(3)
end
end
end

View File

@@ -0,0 +1,122 @@
require 'spec_helper'
describe Gitlab::Client do
describe ".issues" do
context "with project ID passed" do
before do
stub_get("/projects/3/issues", "project_issues")
@issues = Gitlab.issues(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3/issues")).to have_been_made
end
it "should return an array of project's issues" do
expect(@issues).to be_an Array
expect(@issues.first.project_id).to eq(3)
end
end
context "without project ID passed" do
before do
stub_get("/issues", "issues")
@issues = Gitlab.issues
end
it "should get the correct resource" do
expect(a_get("/issues")).to have_been_made
end
it "should return an array of user's issues" do
expect(@issues).to be_an Array
expect(@issues.first.closed).to be_falsey
expect(@issues.first.author.name).to eq("John Smith")
end
end
end
describe ".issue" do
before do
stub_get("/projects/3/issues/33", "issue")
@issue = Gitlab.issue(3, 33)
end
it "should get the correct resource" do
expect(a_get("/projects/3/issues/33")).to have_been_made
end
it "should return information about an issue" do
expect(@issue.project_id).to eq(3)
expect(@issue.assignee.name).to eq("Jack Smith")
end
end
describe ".create_issue" do
before do
stub_post("/projects/3/issues", "issue")
@issue = Gitlab.create_issue(3, 'title')
end
it "should get the correct resource" do
expect(a_post("/projects/3/issues").
with(:body => {:title => 'title'})).to have_been_made
end
it "should return information about a created issue" do
expect(@issue.project_id).to eq(3)
expect(@issue.assignee.name).to eq("Jack Smith")
end
end
describe ".edit_issue" do
before do
stub_put("/projects/3/issues/33", "issue")
@issue = Gitlab.edit_issue(3, 33, :title => 'title')
end
it "should get the correct resource" do
expect(a_put("/projects/3/issues/33").
with(:body => {:title => 'title'})).to have_been_made
end
it "should return information about an edited issue" do
expect(@issue.project_id).to eq(3)
expect(@issue.assignee.name).to eq("Jack Smith")
end
end
describe ".close_issue" do
before do
stub_put("/projects/3/issues/33", "issue")
@issue = Gitlab.close_issue(3, 33)
end
it "should get the correct resource" do
expect(a_put("/projects/3/issues/33").
with(:body => {:state_event => 'close'})).to have_been_made
end
it "should return information about an closed issue" do
expect(@issue.project_id).to eq(3)
expect(@issue.assignee.name).to eq("Jack Smith")
end
end
describe ".reopen_issue" do
before do
stub_put("/projects/3/issues/33", "issue")
@issue = Gitlab.reopen_issue(3, 33)
end
it "should get the correct resource" do
expect(a_put("/projects/3/issues/33").
with(:body => {:state_event => 'reopen'})).to have_been_made
end
it "should return information about an reopened issue" do
expect(@issue.project_id).to eq(3)
expect(@issue.assignee.name).to eq("Jack Smith")
end
end
end

View File

@@ -0,0 +1,124 @@
require 'spec_helper'
describe Gitlab::Client do
describe ".merge_requests" do
before do
stub_get("/projects/3/merge_requests", "merge_requests")
@merge_requests = Gitlab.merge_requests(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3/merge_requests")).to have_been_made
end
it "should return an array of project's merge requests" do
expect(@merge_requests).to be_an Array
expect(@merge_requests.first.project_id).to eq(3)
end
end
describe ".merge_request" do
before do
stub_get("/projects/3/merge_request/1", "merge_request")
@merge_request = Gitlab.merge_request(3, 1)
end
it "should get the correct resource" do
expect(a_get("/projects/3/merge_request/1")).to have_been_made
end
it "should return information about a merge request" do
expect(@merge_request.project_id).to eq(3)
expect(@merge_request.assignee.name).to eq("Jack Smith")
end
end
describe ".create_merge_request" do
before do
stub_post("/projects/3/merge_requests", "create_merge_request")
end
it "should fail if it doesn't have a source_branch" do
expect {
Gitlab.create_merge_request(3, 'New merge request', :target_branch => 'master')
}.to raise_error Gitlab::Error::MissingAttributes
end
it "should fail if it doesn't have a target_branch" do
expect {
Gitlab.create_merge_request(3, 'New merge request', :source_branch => 'dev')
}.to raise_error Gitlab::Error::MissingAttributes
end
it "should return information about a merge request" do
@merge_request = Gitlab.create_merge_request(3, 'New feature',
:source_branch => 'api',
:target_branch => 'master'
)
expect(@merge_request.project_id).to eq(3)
expect(@merge_request.assignee.name).to eq("Jack Smith")
expect(@merge_request.title).to eq('New feature')
end
end
describe ".update_merge_request" do
before do
stub_put("/projects/3/merge_request/2", "update_merge_request")
@merge_request = Gitlab.update_merge_request(3, 2,
:assignee_id => '1',
:target_branch => 'master',
:title => 'A different new feature'
)
end
it "should return information about a merge request" do
expect(@merge_request.project_id).to eq(3)
expect(@merge_request.assignee.name).to eq("Jack Smith")
expect(@merge_request.title).to eq('A different new feature')
end
end
describe ".merge_request_comments" do
before do
stub_get("/projects/3/merge_request/2/comments", "merge_request_comments")
@merge_request = Gitlab.merge_request_comments(3, 2)
end
it "should return merge request's comments" do
expect(@merge_request).to be_an Array
expect(@merge_request.length).to eq(2)
expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request")
expect(@merge_request[0].author.id).to eq(11)
expect(@merge_request[1].note).to eq("another discussion point on the 2merge request")
expect(@merge_request[1].author.id).to eq(12)
end
end
describe ".merge_request_comments" do
before do
stub_get("/projects/3/merge_request/2/comments", "merge_request_comments")
@merge_request = Gitlab.merge_request_comments(3, 2)
end
it "should return merge request's comments" do
expect(@merge_request).to be_an Array
expect(@merge_request.length).to eq(2)
expect(@merge_request[0].note).to eq("this is the 1st comment on the 2merge merge request")
expect(@merge_request[0].author.id).to eq(11)
expect(@merge_request[1].note).to eq("another discussion point on the 2merge request")
expect(@merge_request[1].author.id).to eq(12)
end
end
describe ".create_merge_request_comment" do
before do
stub_post("/projects/3/merge_request/2/comments", "comment_merge_request")
end
it "should return information about a merge request" do
@merge_request = Gitlab.create_merge_request_comment(3, 2, 'Cool Merge Request!')
expect(@merge_request.note).to eq('Cool Merge Request!')
@merge_request.author.id == 1
end
end
end

View File

@@ -0,0 +1,66 @@
require 'spec_helper'
describe Gitlab::Client do
describe ".milestones" do
before do
stub_get("/projects/3/milestones", "milestones")
@milestones = Gitlab.milestones(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3/milestones")).to have_been_made
end
it "should return an array of project's milestones" do
expect(@milestones).to be_an Array
expect(@milestones.first.project_id).to eq(3)
end
end
describe ".milestone" do
before do
stub_get("/projects/3/milestones/1", "milestone")
@milestone = Gitlab.milestone(3, 1)
end
it "should get the correct resource" do
expect(a_get("/projects/3/milestones/1")).to have_been_made
end
it "should return information about a milestone" do
expect(@milestone.project_id).to eq(3)
end
end
describe ".create_milestone" do
before do
stub_post("/projects/3/milestones", "milestone")
@milestone = Gitlab.create_milestone(3, 'title')
end
it "should get the correct resource" do
expect(a_post("/projects/3/milestones").
with(:body => {:title => 'title'})).to have_been_made
end
it "should return information about a created milestone" do
expect(@milestone.project_id).to eq(3)
end
end
describe ".edit_milestone" do
before do
stub_put("/projects/3/milestones/33", "milestone")
@milestone = Gitlab.edit_milestone(3, 33, :title => 'title')
end
it "should get the correct resource" do
expect(a_put("/projects/3/milestones/33").
with(:body => {:title => 'title'})).to have_been_made
end
it "should return information about an edited milestone" do
expect(@milestone.project_id).to eq(3)
end
end
end

View File

@@ -0,0 +1,156 @@
require 'spec_helper'
describe Gitlab::Client do
describe "notes" do
context "when wall notes" do
before do
stub_get("/projects/3/notes", "notes")
@notes = Gitlab.notes(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3/notes")).to have_been_made
end
it "should return an array of notes" do
expect(@notes).to be_an Array
expect(@notes.first.author.name).to eq("John Smith")
end
end
context "when issue notes" do
before do
stub_get("/projects/3/issues/7/notes", "notes")
@notes = Gitlab.issue_notes(3, 7)
end
it "should get the correct resource" do
expect(a_get("/projects/3/issues/7/notes")).to have_been_made
end
it "should return an array of notes" do
expect(@notes).to be_an Array
expect(@notes.first.author.name).to eq("John Smith")
end
end
context "when snippet notes" do
before do
stub_get("/projects/3/snippets/7/notes", "notes")
@notes = Gitlab.snippet_notes(3, 7)
end
it "should get the correct resource" do
expect(a_get("/projects/3/snippets/7/notes")).to have_been_made
end
it "should return an array of notes" do
expect(@notes).to be_an Array
expect(@notes.first.author.name).to eq("John Smith")
end
end
end
describe "note" do
context "when wall note" do
before do
stub_get("/projects/3/notes/1201", "note")
@note = Gitlab.note(3, 1201)
end
it "should get the correct resource" do
expect(a_get("/projects/3/notes/1201")).to have_been_made
end
it "should return information about a note" do
expect(@note.body).to eq("The solution is rather tricky")
expect(@note.author.name).to eq("John Smith")
end
end
context "when issue note" do
before do
stub_get("/projects/3/issues/7/notes/1201", "note")
@note = Gitlab.issue_note(3, 7, 1201)
end
it "should get the correct resource" do
expect(a_get("/projects/3/issues/7/notes/1201")).to have_been_made
end
it "should return information about a note" do
expect(@note.body).to eq("The solution is rather tricky")
expect(@note.author.name).to eq("John Smith")
end
end
context "when snippet note" do
before do
stub_get("/projects/3/snippets/7/notes/1201", "note")
@note = Gitlab.snippet_note(3, 7, 1201)
end
it "should get the correct resource" do
expect(a_get("/projects/3/snippets/7/notes/1201")).to have_been_made
end
it "should return information about a note" do
expect(@note.body).to eq("The solution is rather tricky")
expect(@note.author.name).to eq("John Smith")
end
end
end
describe "create note" do
context "when wall note" do
before do
stub_post("/projects/3/notes", "note")
@note = Gitlab.create_note(3, "The solution is rather tricky")
end
it "should get the correct resource" do
expect(a_post("/projects/3/notes").
with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
end
it "should return information about a created note" do
expect(@note.body).to eq("The solution is rather tricky")
expect(@note.author.name).to eq("John Smith")
end
end
context "when issue note" do
before do
stub_post("/projects/3/issues/7/notes", "note")
@note = Gitlab.create_issue_note(3, 7, "The solution is rather tricky")
end
it "should get the correct resource" do
expect(a_post("/projects/3/issues/7/notes").
with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
end
it "should return information about a created note" do
expect(@note.body).to eq("The solution is rather tricky")
expect(@note.author.name).to eq("John Smith")
end
end
context "when snippet note" do
before do
stub_post("/projects/3/snippets/7/notes", "note")
@note = Gitlab.create_snippet_note(3, 7, "The solution is rather tricky")
end
it "should get the correct resource" do
expect(a_post("/projects/3/snippets/7/notes").
with(:body => {:body => 'The solution is rather tricky'})).to have_been_made
end
it "should return information about a created note" do
expect(@note.body).to eq("The solution is rather tricky")
expect(@note.author.name).to eq("John Smith")
end
end
end
end

View File

@@ -0,0 +1,357 @@
require 'spec_helper'
describe Gitlab::Client do
describe ".projects" do
before do
stub_get("/projects", "projects")
@projects = Gitlab.projects
end
it "should get the correct resource" do
expect(a_get("/projects")).to have_been_made
end
it "should return an array of projects" do
expect(@projects).to be_an Array
expect(@projects.first.name).to eq("Brute")
expect(@projects.first.owner.name).to eq("John Smith")
end
end
describe ".project" do
before do
stub_get("/projects/3", "project")
@project = Gitlab.project(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3")).to have_been_made
end
it "should return information about a project" do
expect(@project.name).to eq("Gitlab")
expect(@project.owner.name).to eq("John Smith")
end
end
describe ".project_events" do
before do
stub_get("/projects/2/events", "project_events")
@events = Gitlab.project_events(2)
end
it "should get the correct resource" do
expect(a_get("/projects/2/events")).to have_been_made
end
it "should return an array of events" do
expect(@events).to be_an Array
expect(@events.size).to eq(2)
end
it "should return the action name of the event" do
expect(@events.first.action_name).to eq("opened")
end
end
describe ".create_project" do
before do
stub_post("/projects", "project")
@project = Gitlab.create_project('Gitlab')
end
it "should get the correct resource" do
expect(a_post("/projects")).to have_been_made
end
it "should return information about a created project" do
expect(@project.name).to eq("Gitlab")
expect(@project.owner.name).to eq("John Smith")
end
end
describe ".create_project for user" do
before do
stub_post("/users", "user")
@owner = Gitlab.create_user("john@example.com", "pass", {name: 'John Owner'})
stub_post("/projects/user/#{@owner.id}", "project_for_user")
@project = Gitlab.create_project('Brute', {:user_id => @owner.id})
end
it "should return information about a created project" do
expect(@project.name).to eq("Brute")
expect(@project.owner.name).to eq("John Owner")
end
end
describe ".delete_project" do
before do
stub_delete("/projects/Gitlab", "project")
@project = Gitlab.delete_project('Gitlab')
end
it "should get the correct resource" do
expect(a_delete("/projects/Gitlab")).to have_been_made
end
it "should return information about a deleted project" do
expect(@project.name).to eq("Gitlab")
expect(@project.owner.name).to eq("John Smith")
end
end
describe ".team_members" do
before do
stub_get("/projects/3/members", "team_members")
@team_members = Gitlab.team_members(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3/members")).to have_been_made
end
it "should return an array of team members" do
expect(@team_members).to be_an Array
expect(@team_members.first.name).to eq("John Smith")
end
end
describe ".team_member" do
before do
stub_get("/projects/3/members/1", "team_member")
@team_member = Gitlab.team_member(3, 1)
end
it "should get the correct resource" do
expect(a_get("/projects/3/members/1")).to have_been_made
end
it "should return information about a team member" do
expect(@team_member.name).to eq("John Smith")
end
end
describe ".add_team_member" do
before do
stub_post("/projects/3/members", "team_member")
@team_member = Gitlab.add_team_member(3, 1, 40)
end
it "should get the correct resource" do
expect(a_post("/projects/3/members").
with(:body => {:user_id => '1', :access_level => '40'})).to have_been_made
end
it "should return information about an added team member" do
expect(@team_member.name).to eq("John Smith")
end
end
describe ".edit_team_member" do
before do
stub_put("/projects/3/members/1", "team_member")
@team_member = Gitlab.edit_team_member(3, 1, 40)
end
it "should get the correct resource" do
expect(a_put("/projects/3/members/1").
with(:body => {:access_level => '40'})).to have_been_made
end
it "should return information about an edited team member" do
expect(@team_member.name).to eq("John Smith")
end
end
describe ".remove_team_member" do
before do
stub_delete("/projects/3/members/1", "team_member")
@team_member = Gitlab.remove_team_member(3, 1)
end
it "should get the correct resource" do
expect(a_delete("/projects/3/members/1")).to have_been_made
end
it "should return information about a removed team member" do
expect(@team_member.name).to eq("John Smith")
end
end
describe ".project_hooks" do
before do
stub_get("/projects/1/hooks", "project_hooks")
@hooks = Gitlab.project_hooks(1)
end
it "should get the correct resource" do
expect(a_get("/projects/1/hooks")).to have_been_made
end
it "should return an array of hooks" do
expect(@hooks).to be_an Array
expect(@hooks.first.url).to eq("https://api.example.net/v1/webhooks/ci")
end
end
describe ".project_hook" do
before do
stub_get("/projects/1/hooks/1", "project_hook")
@hook = Gitlab.project_hook(1, 1)
end
it "should get the correct resource" do
expect(a_get("/projects/1/hooks/1")).to have_been_made
end
it "should return information about a hook" do
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
end
end
describe ".add_project_hook" do
context "without specified events" do
before do
stub_post("/projects/1/hooks", "project_hook")
@hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci")
end
it "should get the correct resource" do
body = {:url => "https://api.example.net/v1/webhooks/ci"}
expect(a_post("/projects/1/hooks").with(:body => body)).to have_been_made
end
it "should return information about an added hook" do
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
end
end
context "with specified events" do
before do
stub_post("/projects/1/hooks", "project_hook")
@hook = Gitlab.add_project_hook(1, "https://api.example.net/v1/webhooks/ci", push_events: true, merge_requests_events: true)
end
it "should get the correct resource" do
body = {:url => "https://api.example.net/v1/webhooks/ci", push_events: "true", merge_requests_events: "true"}
expect(a_post("/projects/1/hooks").with(:body => body)).to have_been_made
end
it "should return information about an added hook" do
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
end
end
end
describe ".edit_project_hook" do
before do
stub_put("/projects/1/hooks/1", "project_hook")
@hook = Gitlab.edit_project_hook(1, 1, "https://api.example.net/v1/webhooks/ci")
end
it "should get the correct resource" do
body = {:url => "https://api.example.net/v1/webhooks/ci"}
expect(a_put("/projects/1/hooks/1").with(:body => body)).to have_been_made
end
it "should return information about an edited hook" do
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
end
end
describe ".delete_project_hook" do
before do
stub_delete("/projects/1/hooks/1", "project_hook")
@hook = Gitlab.delete_project_hook(1, 1)
end
it "should get the correct resource" do
expect(a_delete("/projects/1/hooks/1")).to have_been_made
end
it "should return information about a deleted hook" do
expect(@hook.url).to eq("https://api.example.net/v1/webhooks/ci")
end
end
describe ".make_forked_from" do
before do
stub_post("/projects/42/fork/24", "project_fork_link")
@forked_project_link = Gitlab.make_forked_from(42, 24)
end
it "should get the correct resource" do
expect(a_post("/projects/42/fork/24")).to have_been_made
end
it "should return information about a forked project" do
expect(@forked_project_link.forked_from_project_id).to eq(24)
expect(@forked_project_link.forked_to_project_id).to eq(42)
end
end
describe ".remove_forked" do
before do
stub_delete("/projects/42/fork", "project_fork_link")
@forked_project_link = Gitlab.remove_forked(42)
end
it "should be sent to correct resource" do
expect(a_delete("/projects/42/fork")).to have_been_made
end
it "should return information about an unforked project" do
expect(@forked_project_link.forked_to_project_id).to eq(42)
end
end
describe ".deploy_keys" do
before do
stub_get("/projects/42/keys", "project_keys")
@deploy_keys = Gitlab.deploy_keys(42)
end
it "should get the correct resource" do
expect(a_get("/projects/42/keys")).to have_been_made
end
it "should return project deploy keys" do
expect(@deploy_keys).to be_an Array
expect(@deploy_keys.first.id).to eq 2
expect(@deploy_keys.first.title).to eq "Key Title"
expect(@deploy_keys.first.key).to match(/ssh-rsa/)
end
end
describe ".deploy_key" do
before do
stub_get("/projects/42/keys/2", "project_key")
@deploy_key = Gitlab.deploy_key(42, 2)
end
it "should get the correct resource" do
expect(a_get("/projects/42/keys/2")).to have_been_made
end
it "should return project deploy key" do
expect(@deploy_key.id).to eq 2
expect(@deploy_key.title).to eq "Key Title"
expect(@deploy_key.key).to match(/ssh-rsa/)
end
end
describe ".delete_deploy_key" do
before do
stub_delete("/projects/42/keys/2", "project_delete_key")
@deploy_key = Gitlab.delete_deploy_key(42, 2)
end
it "should get the correct resource" do
expect(a_delete("/projects/42/keys/2")).to have_been_made
end
it "should return information about a deleted key" do
expect(@deploy_key.id).to eq(2)
end
end
end

View File

@@ -0,0 +1,92 @@
require 'spec_helper'
describe Gitlab::Client do
it { should respond_to :repo_tags }
it { should respond_to :repo_create_tag }
it { should respond_to :repo_branches }
it { should respond_to :repo_branch }
it { should respond_to :repo_commits }
it { should respond_to :repo_commit }
it { should respond_to :repo_commit_diff }
describe ".tags" do
before do
stub_get("/projects/3/repository/tags", "project_tags")
@tags = Gitlab.tags(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3/repository/tags")).to have_been_made
end
it "should return an array of repository tags" do
expect(@tags).to be_an Array
expect(@tags.first.name).to eq("v2.8.2")
end
end
describe ".create_tag" do
before do
stub_post("/projects/3/repository/tags", "tag")
@tag = Gitlab.create_tag(3, 'v1.0.0', '2695effb5807a22ff3d138d593fd856244e155e7')
end
it "should get the correct resource" do
expect(a_post("/projects/3/repository/tags")).to have_been_made
end
it "should return information about a new repository tag" do
expect(@tag.name).to eq("v1.0.0")
end
end
describe ".commits" do
before do
stub_get("/projects/3/repository/commits", "project_commits").
with(:query => {:ref_name => "api"})
@commits = Gitlab.commits(3, :ref_name => "api")
end
it "should get the correct resource" do
expect(a_get("/projects/3/repository/commits").
with(:query => {:ref_name => "api"})).to have_been_made
end
it "should return an array of repository commits" do
expect(@commits).to be_an Array
expect(@commits.first.id).to eq("f7dd067490fe57505f7226c3b54d3127d2f7fd46")
end
end
describe ".commit" do
before do
stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6", "project_commit")
@commit = Gitlab.commit(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
end
it "should get the correct resource" do
expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6"))
.to have_been_made
end
it "should return a repository commit" do
expect(@commit.id).to eq("6104942438c14ec7bd21c6cd5bd995272b3faff6")
end
end
describe ".commit_diff" do
before do
stub_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff", "project_commit_diff")
@diff = Gitlab.commit_diff(3, '6104942438c14ec7bd21c6cd5bd995272b3faff6')
end
it "should get the correct resource" do
expect(a_get("/projects/3/repository/commits/6104942438c14ec7bd21c6cd5bd995272b3faff6/diff"))
.to have_been_made
end
it "should return a diff of a commit" do
expect(@diff.new_path).to eq("doc/update/5.4-to-6.0.md")
end
end
end

View File

@@ -0,0 +1,85 @@
require 'spec_helper'
describe Gitlab::Client do
describe ".snippets" do
before do
stub_get("/projects/3/snippets", "snippets")
@snippets = Gitlab.snippets(3)
end
it "should get the correct resource" do
expect(a_get("/projects/3/snippets")).to have_been_made
end
it "should return an array of project's snippets" do
expect(@snippets).to be_an Array
expect(@snippets.first.file_name).to eq("mailer_test.rb")
end
end
describe ".snippet" do
before do
stub_get("/projects/3/snippets/1", "snippet")
@snippet = Gitlab.snippet(3, 1)
end
it "should get the correct resource" do
expect(a_get("/projects/3/snippets/1")).to have_been_made
end
it "should return information about a snippet" do
expect(@snippet.file_name).to eq("mailer_test.rb")
expect(@snippet.author.name).to eq("John Smith")
end
end
describe ".create_snippet" do
before do
stub_post("/projects/3/snippets", "snippet")
@snippet = Gitlab.create_snippet(3, {:title => 'API', :file_name => 'api.rb', :code => 'code'})
end
it "should get the correct resource" do
body = {:title => 'API', :file_name => 'api.rb', :code => 'code'}
expect(a_post("/projects/3/snippets").with(:body => body)).to have_been_made
end
it "should return information about a new snippet" do
expect(@snippet.file_name).to eq("mailer_test.rb")
expect(@snippet.author.name).to eq("John Smith")
end
end
describe ".edit_snippet" do
before do
stub_put("/projects/3/snippets/1", "snippet")
@snippet = Gitlab.edit_snippet(3, 1, :file_name => 'mailer_test.rb')
end
it "should get the correct resource" do
expect(a_put("/projects/3/snippets/1").
with(:body => {:file_name => 'mailer_test.rb'})).to have_been_made
end
it "should return information about an edited snippet" do
expect(@snippet.file_name).to eq("mailer_test.rb")
expect(@snippet.author.name).to eq("John Smith")
end
end
describe ".delete_snippet" do
before do
stub_delete("/projects/3/snippets/1", "snippet")
@snippet = Gitlab.delete_snippet(3, 1)
end
it "should get the correct resource" do
expect(a_delete("/projects/3/snippets/1")).to have_been_made
end
it "should return information about a deleted snippet" do
expect(@snippet.file_name).to eq("mailer_test.rb")
expect(@snippet.author.name).to eq("John Smith")
end
end
end

View File

@@ -0,0 +1,69 @@
require 'spec_helper'
describe Gitlab::Client do
it { should respond_to :system_hooks }
it { should respond_to :add_system_hook }
it { should respond_to :system_hook }
it { should respond_to :delete_system_hook }
describe ".hooks" do
before do
stub_get("/hooks", "system_hooks")
@hooks = Gitlab.hooks
end
it "should get the correct resource" do
expect(a_get("/hooks")).to have_been_made
end
it "should return an array of system hooks" do
expect(@hooks).to be_an Array
expect(@hooks.first.url).to eq("http://example.com/hook")
end
end
describe ".add_hook" do
before do
stub_post("/hooks", "system_hook")
@hook = Gitlab.add_hook("http://example.com/hook")
end
it "should get the correct resource" do
expect(a_post("/hooks")).to have_been_made
end
it "should return information about a added system hook" do
expect(@hook.url).to eq("http://example.com/hook")
end
end
describe ".hook" do
before do
stub_get("/hooks/3", "system_hook_test")
@hook = Gitlab.hook(3)
end
it "should get the correct resource" do
expect(a_get("/hooks/3")).to have_been_made
end
it "should return information about a added system hook" do
expect(@hook.event_name).to eq("project_create")
expect(@hook.project_id).to eq(1)
end
end
describe ".delete_hook" do
before do
stub_delete("/hooks/3", "system_hook")
@hook = Gitlab.delete_hook(3)
end
it "should get the correct resource" do
expect(a_delete("/hooks/3")).to have_been_made
end
it "should return information about a deleted system hook" do
expect(@hook.url).to eq("http://example.com/hook")
end
end
end

View File

@@ -0,0 +1,192 @@
require 'spec_helper'
describe Gitlab::Client do
describe ".users" do
before do
stub_get("/users", "users")
@users = Gitlab.users
end
it "should get the correct resource" do
expect(a_get("/users")).to have_been_made
end
it "should return an array of users" do
expect(@users).to be_an Array
expect(@users.first.email).to eq("john@example.com")
end
end
describe ".user" do
context "with user ID passed" do
before do
stub_get("/users/1", "user")
@user = Gitlab.user(1)
end
it "should get the correct resource" do
expect(a_get("/users/1")).to have_been_made
end
it "should return information about a user" do
expect(@user.email).to eq("john@example.com")
end
end
context "without user ID passed" do
before do
stub_get("/user", "user")
@user = Gitlab.user
end
it "should get the correct resource" do
expect(a_get("/user")).to have_been_made
end
it "should return information about an authorized user" do
expect(@user.email).to eq("john@example.com")
end
end
end
describe ".create_user" do
context "when successful request" do
before do
stub_post("/users", "user")
@user = Gitlab.create_user("email", "pass")
end
it "should get the correct resource" do
body = {:email => "email", :password => "pass", :name => "email"}
expect(a_post("/users").with(:body => body)).to have_been_made
end
it "should return information about a created user" do
expect(@user.email).to eq("john@example.com")
end
end
context "when bad request" do
it "should throw an exception" do
stub_post("/users", "error_already_exists", 409)
expect {
Gitlab.create_user("email", "pass")
}.to raise_error(Gitlab::Error::Conflict, "Server responded with code 409, message: 409 Already exists. Request URI: #{Gitlab.endpoint}/users")
end
end
end
describe ".edit_user" do
before do
@options = { :name => "Roberto" }
stub_put("/users/1", "user").with(:body => @options)
@user = Gitlab.edit_user(1, @options)
end
it "should get the correct resource" do
expect(a_put("/users/1").with(:body => @options)).to have_been_made
end
end
describe ".session" do
after do
Gitlab.endpoint = 'https://api.example.com'
Gitlab.private_token = 'secret'
end
before do
stub_request(:post, "#{Gitlab.endpoint}/session").
to_return(:body => load_fixture('session'), :status => 200)
@session = Gitlab.session("email", "pass")
end
context "when endpoint is not set" do
it "should raise Error::MissingCredentials" do
Gitlab.endpoint = nil
expect {
Gitlab.session("email", "pass")
}.to raise_error(Gitlab::Error::MissingCredentials, 'Please set an endpoint to API')
end
end
context "when private_token is not set" do
it "should not raise Error::MissingCredentials" do
Gitlab.private_token = nil
expect { Gitlab.session("email", "pass") }.to_not raise_error
end
end
context "when endpoint is set" do
it "should get the correct resource" do
expect(a_request(:post, "#{Gitlab.endpoint}/session")).to have_been_made
end
it "should return information about a created session" do
expect(@session.email).to eq("john@example.com")
expect(@session.private_token).to eq("qEsq1pt6HJPaNciie3MG")
end
end
end
describe ".ssh_keys" do
before do
stub_get("/user/keys", "keys")
@keys = Gitlab.ssh_keys
end
it "should get the correct resource" do
expect(a_get("/user/keys")).to have_been_made
end
it "should return an array of SSH keys" do
expect(@keys).to be_an Array
expect(@keys.first.title).to eq("narkoz@helium")
end
end
describe ".ssh_key" do
before do
stub_get("/user/keys/1", "key")
@key = Gitlab.ssh_key(1)
end
it "should get the correct resource" do
expect(a_get("/user/keys/1")).to have_been_made
end
it "should return information about an SSH key" do
expect(@key.title).to eq("narkoz@helium")
end
end
describe ".create_ssh_key" do
before do
stub_post("/user/keys", "key")
@key = Gitlab.create_ssh_key("title", "body")
end
it "should get the correct resource" do
body = {:title => "title", :key => "body"}
expect(a_post("/user/keys").with(:body => body)).to have_been_made
end
it "should return information about a created SSH key" do
expect(@key.title).to eq("narkoz@helium")
end
end
describe ".delete_ssh_key" do
before do
stub_delete("/user/keys/1", "key")
@key = Gitlab.delete_ssh_key(1)
end
it "should get the correct resource" do
expect(a_delete("/user/keys/1")).to have_been_made
end
it "should return information about a deleted SSH key" do
expect(@key.title).to eq("narkoz@helium")
end
end
end

View File

@@ -0,0 +1,23 @@
require 'spec_helper'
describe Gitlab::ObjectifiedHash do
before do
@hash = {a: 1, b: 2}
@oh = Gitlab::ObjectifiedHash.new @hash
end
it "should objectify hash" do
expect(@oh.a).to eq(@hash[:a])
expect(@oh.b).to eq(@hash[:b])
end
describe "#to_hash" do
it "should return an original hash" do
expect(@oh.to_hash).to eq(@hash)
end
it "should have an alias #to_h" do
expect(@oh.respond_to?(:to_h)).to be_truthy
end
end
end

View File

@@ -0,0 +1,48 @@
require 'spec_helper'
describe Gitlab::Request do
it { should respond_to :get }
it { should respond_to :post }
it { should respond_to :put }
it { should respond_to :delete }
describe ".default_options" do
it "should have default values" do
default_options = Gitlab::Request.default_options
expect(default_options).to be_a Hash
expect(default_options[:parser]).to be_a Proc
expect(default_options[:format]).to eq(:json)
expect(default_options[:headers]).to eq({'Accept' => 'application/json'})
expect(default_options[:default_params]).to be_nil
end
end
describe ".parse" do
it "should return ObjectifiedHash" do
body = JSON.unparse({a: 1, b: 2})
expect(Gitlab::Request.parse(body)).to be_an Gitlab::ObjectifiedHash
end
end
describe "#set_request_defaults" do
context "when endpoint is not set" do
it "should raise Error::MissingCredentials" do
expect {
Gitlab::Request.new.set_request_defaults(nil, 1234000)
}.to raise_error(Gitlab::Error::MissingCredentials, 'Please set an endpoint to API')
end
end
context "when endpoint is set" do
it "should set base_uri" do
Gitlab::Request.new.set_request_defaults('http://rabbit-hole.example.org', 1234000)
expect(Gitlab::Request.base_uri).to eq("http://rabbit-hole.example.org")
end
it "should set default_params" do
Gitlab::Request.new.set_request_defaults('http://rabbit-hole.example.org', 1234000, 'sudoer')
expect(Gitlab::Request.default_params).to eq({:sudo => 'sudoer'})
end
end
end
end

View File

@@ -0,0 +1,65 @@
require 'spec_helper'
describe Gitlab do
after { Gitlab.reset }
describe ".client" do
it "should be a Gitlab::Client" do
expect(Gitlab.client).to be_a Gitlab::Client
end
end
describe ".actions" do
it "should return an array of client methods" do
actions = Gitlab.actions
expect(actions).to be_an Array
expect(actions.first).to be_a Symbol
expect(actions.sort.first).to match(/add_/)
end
end
describe ".endpoint=" do
it "should set endpoint" do
Gitlab.endpoint = 'https://api.example.com'
expect(Gitlab.endpoint).to eq('https://api.example.com')
end
end
describe ".private_token=" do
it "should set private_token" do
Gitlab.private_token = 'secret'
expect(Gitlab.private_token).to eq('secret')
end
end
describe ".sudo=" do
it "should set sudo" do
Gitlab.sudo = 'user'
expect(Gitlab.sudo).to eq('user')
end
end
describe ".user_agent" do
it "should return default user_agent" do
expect(Gitlab.user_agent).to eq(Gitlab::Configuration::DEFAULT_USER_AGENT)
end
end
describe ".user_agent=" do
it "should set user_agent" do
Gitlab.user_agent = 'Custom User Agent'
expect(Gitlab.user_agent).to eq('Custom User Agent')
end
end
describe ".configure" do
Gitlab::Configuration::VALID_OPTIONS_KEYS.each do |key|
it "should set #{key}" do
Gitlab.configure do |config|
config.send("#{key}=", key)
expect(Gitlab.send(key)).to eq(key)
end
end
end
end
end

View File

@@ -0,0 +1,74 @@
require 'rspec'
require 'webmock/rspec'
require File.expand_path('../../lib/gitlab', __FILE__)
require File.expand_path('../../lib/gitlab/cli', __FILE__)
def capture_output
out = StringIO.new
$stdout = out
$stderr = out
yield
$stdout = STDOUT
$stderr = STDERR
out.string
end
def load_fixture(name)
File.new(File.dirname(__FILE__) + "/fixtures/#{name}.json")
end
RSpec.configure do |config|
config.before(:all) do
Gitlab.endpoint = 'https://api.example.com'
Gitlab.private_token = 'secret'
end
end
# GET
def stub_get(path, fixture)
stub_request(:get, "#{Gitlab.endpoint}#{path}").
with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token}).
to_return(:body => load_fixture(fixture))
end
def a_get(path)
a_request(:get, "#{Gitlab.endpoint}#{path}").
with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token})
end
# POST
def stub_post(path, fixture, status_code=200)
stub_request(:post, "#{Gitlab.endpoint}#{path}").
with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token}).
to_return(:body => load_fixture(fixture), :status => status_code)
end
def a_post(path)
a_request(:post, "#{Gitlab.endpoint}#{path}").
with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token})
end
# PUT
def stub_put(path, fixture)
stub_request(:put, "#{Gitlab.endpoint}#{path}").
with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token}).
to_return(:body => load_fixture(fixture))
end
def a_put(path)
a_request(:put, "#{Gitlab.endpoint}#{path}").
with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token})
end
# DELETE
def stub_delete(path, fixture)
stub_request(:delete, "#{Gitlab.endpoint}#{path}").
with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token}).
to_return(:body => load_fixture(fixture))
end
def a_delete(path)
a_request(:delete, "#{Gitlab.endpoint}#{path}").
with(:headers => {'PRIVATE-TOKEN' => Gitlab.private_token})
end