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