Commit 5b392445 authored by Chad Woolley's avatar Chad Woolley Committed by Markus Koller

Fix typo and method call arguments in wiki destroy endpoint

In this commit we fix a typo (`reponse` vs. `response`) and
also the method call `response_api_error!` that was lacking
one argument.
parent c4bfd1a1
---
title: Fix bug in wiki page destroy API endpoint when an error is raised
merge_request: 56285
author:
type: fixed
......@@ -111,7 +111,7 @@ module API
if response.success?
no_content!
else
render_api_error!(reponse.message)
unprocessable_entity!(response.message)
end
end
......
......@@ -14,6 +14,7 @@ require 'spec_helper'
RSpec.describe API::Wikis do
include WorkhorseHelpers
include AfterNextHelpers
let(:user) { create(:user) }
let(:group) { create(:group).tap { |g| g.add_owner(user) } }
......@@ -578,6 +579,20 @@ RSpec.describe API::Wikis do
include_examples 'wiki API 404 Wiki Page Not Found'
end
end
context 'when there is an error deleting the page' do
it 'returns 422' do
project.add_maintainer(user)
allow_next(WikiPages::DestroyService, current_user: user, container: project)
.to receive(:execute).and_return(ServiceResponse.error(message: 'foo'))
delete(api(url, user))
expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['message']).to eq 'foo'
end
end
end
context 'when wiki belongs to a group project' do
......
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