diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2016-04-12 14:46:59 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2016-04-13 13:52:13 +0200 |
commit | fa3009095fbb995550a20e5d0cbc994f4290fbea (patch) | |
tree | 99dc2ad7c4f3f7afa9a980622df786d24866774b /spec/requests/api | |
parent | f875189b3962bde6e4b7b8c4ffdd18af83cbc922 (diff) | |
download | gitlab-ce-fa3009095fbb995550a20e5d0cbc994f4290fbea.tar.gz |
Make subscription API more RESTful
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/issues_spec.rb | 26 | ||||
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 14 |
2 files changed, 26 insertions, 14 deletions
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 437caf466b0..8361a1649e0 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -571,33 +571,45 @@ describe API::API, api: true do end end - describe 'POST :id/issues/:issue_id/subscribe' do + describe 'POST :id/issues/:issue_id/subscription' do it 'subscribes to an issue' do - post api("/projects/#{project.id}/issues/#{issue.id}/subscribe", user2) + post api("/projects/#{project.id}/issues/#{issue.id}/subscription", user2) expect(response.status).to eq(201) expect(json_response['subscribed']).to eq(true) end it 'returns 304 if already subscribed' do - post api("/projects/#{project.id}/issues/#{issue.id}/subscribe", user) + post api("/projects/#{project.id}/issues/#{issue.id}/subscription", user) expect(response.status).to eq(304) end + + it 'returns 404 if the issue is not found' do + post api("/projects/#{project.id}/issues/123/subscription", user) + + expect(response.status).to eq(404) + end end - describe 'POST :id/issues/:issue_id/unsubscribe' do + describe 'DELETE :id/issues/:issue_id/subscription' do it 'unsubscribes from an issue' do - post api("/projects/#{project.id}/issues/#{issue.id}/unsubscribe", user) + post api("/projects/#{project.id}/issues/#{issue.id}/subscription", user) - expect(response.status).to eq(201) + expect(response.status).to eq(200) expect(json_response['subscribed']).to eq(false) end it 'returns 304 if not subscribed' do - post api("/projects/#{project.id}/issues/#{issue.id}/unsubscribe", user2) + post api("/projects/#{project.id}/issues/#{issue.id}/subscription", user2) expect(response.status).to eq(304) end + + it 'returns 404 if the issue is not found' do + post api("/projects/#{project.id}/issues/123/subscription", user) + + expect(response.status).to eq(404) + end end end diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index b71c72a3829..c247fcf9c96 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -516,31 +516,31 @@ describe API::API, api: true do end end - describe 'POST :id/merge_requests/:merge_request_id/subscribe' do + describe 'POST :id/merge_requests/:merge_request_id/subscription' do it 'subscribes to a merge request' do - post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscribe", admin) + post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", admin) expect(response.status).to eq(201) expect(json_response['subscribed']).to eq(true) end it 'returns 304 if already subscribed' do - post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscribe", user) + post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", user) expect(response.status).to eq(304) end end - describe 'POST :id/merge_requests/:merge_request_id/unsubscribe' do + describe 'DELETE :id/merge_requests/:merge_request_id/subscription' do it 'unsubscribes from a merge request' do - post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/unsubscribe", user) + delete api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", user) - expect(response.status).to eq(201) + expect(response.status).to eq(200) expect(json_response['subscribed']).to eq(false) end it 'returns 304 if not subscribed' do - post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/unsubscribe", admin) + delete api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", admin) expect(response.status).to eq(304) end |