Commit a9200d93 authored by Robert Schilling's avatar Robert Schilling

Ensure that issues and merge requests are found

parent fa300909
......@@ -680,6 +680,7 @@ Example response:
"subscribed": true
}
```
## Unsubscribe from a merge request
Unsubscribes the authenticated user from a merge request to not receive
......
......@@ -239,8 +239,8 @@ module API
# issue_id (required) - The ID of a project issue
# Example Request:
# POST /projects/:id/issues/:issue_id/subscription
post ":id/issues/:issue_id/subscription" do
issue = user_project.issues.find_by(id: params[:issue_id])
post ':id/issues/:issue_id/subscription' do
issue = user_project.issues.find(params[:issue_id])
if issue.subscribed?(current_user)
not_modified!
......@@ -257,8 +257,8 @@ module API
# issue_id (required) - The ID of a project issue
# Example Request:
# DELETE /projects/:id/issues/:issue_id/subscription
delete ":id/issues/:issue_id/subscription" do
issue = user_project.issues.find_by(id: params[:issue_id])
delete ':id/issues/:issue_id/subscription' do
issue = user_project.issues.find(params[:issue_id])
if issue.subscribed?(current_user)
issue.unsubscribe(current_user)
......
......@@ -594,20 +594,20 @@ describe API::API, api: true do
describe 'DELETE :id/issues/:issue_id/subscription' do
it 'unsubscribes from an issue' do
post api("/projects/#{project.id}/issues/#{issue.id}/subscription", user)
delete api("/projects/#{project.id}/issues/#{issue.id}/subscription", user)
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}/subscription", user2)
delete 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)
delete api("/projects/#{project.id}/issues/123/subscription", user)
expect(response.status).to eq(404)
end
......
......@@ -529,6 +529,12 @@ describe API::API, api: true do
expect(response.status).to eq(304)
end
it 'returns 404 if the merge request is not found' do
post api("/projects/#{project.id}/merge_requests/123/subscription", user)
expect(response.status).to eq(404)
end
end
describe 'DELETE :id/merge_requests/:merge_request_id/subscription' do
......@@ -544,6 +550,12 @@ describe API::API, api: true do
expect(response.status).to eq(304)
end
it 'returns 404 if the merge request is not found' do
post api("/projects/#{project.id}/merge_requests/123/subscription", user)
expect(response.status).to eq(404)
end
end
def mr_with_later_created_and_updated_at_time
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment