Commit 3e649dd1 authored by Robert Schilling's avatar Robert Schilling Committed by Sean McGivern

Add a spec when ressource is not modified

parent ca9676ec
......@@ -377,8 +377,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
......@@ -422,8 +421,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'
......
......@@ -1601,6 +1601,7 @@ describe API::Projects do
end
it_behaves_like '412 response' do
let(:success_status) { 202 }
let(:request) { api("/projects/#{project.id}", user) }
end
......@@ -1636,6 +1637,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,11 +43,25 @@ end
shared_examples_for '412 response' do
let(:params) { nil }
before do
delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => '1990-01-12T00:00:48-0600' }
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
it 'returns 412' do
expect(response).to have_gitlab_http_status(412)
end
end
it 'returns 412' do
expect(response).to have_gitlab_http_status(412)
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