Commit ee4820a5 authored by Robert Schilling's avatar Robert Schilling

Add a spec when ressource is not modified

parent 8bd9fb4c
......@@ -365,8 +365,7 @@ module API
authorize! :remove_fork_project, user_project
if user_project.forked?
status 204
user_project.forked_project_link.destroy
destroy_conditionally!(user_project.forked_project_link)
else
not_modified!
end
......@@ -410,8 +409,7 @@ module API
link = user_project.project_group_links.find_by(group_id: params[:group_id])
not_found!('Group Link') unless link
status 204
link.destroy
destroy_conditionally!(link)
end
desc 'Upload a file'
......
......@@ -1541,6 +1541,7 @@ describe API::Projects do
end
it_behaves_like '412 response' do
let(:success_status) { 202 }
let(:request) { api("/projects/#{project.id}", user) }
end
......@@ -1576,6 +1577,7 @@ describe API::Projects do
end
it_behaves_like '412 response' do
let(:success_status) { 202 }
let(:request) { api("/projects/#{project.id}", admin) }
end
end
......
......@@ -43,6 +43,9 @@ end
shared_examples_for '412 response' do
let(:params) { nil }
let(:success_status) { 204 }
context 'for a modified ressource' do
before do
delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => '1990-01-12T00:00:48-0600' }
end
......@@ -50,4 +53,15 @@ shared_examples_for '412 response' do
it 'returns 412' do
expect(response).to have_gitlab_http_status(412)
end
end
context 'for an unmodified ressource' do
before do
delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => Time.now }
end
it 'returns accepted' do
expect(response).to have_gitlab_http_status(success_status)
end
end
end
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