summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2017-08-28 17:13:22 +0200
committerRobert Schilling <rschilling@student.tugraz.at>2017-08-29 10:12:10 +0200
commitee4820a5268d02fb7ed142511d1a194f06629a1e (patch)
treedfca250f557830c030c21941bf8ab7ca8d5e829c
parent8bd9fb4cc4f8689a23c68e1b7f893ee59907069f (diff)
downloadgitlab-ce-ee4820a5268d02fb7ed142511d1a194f06629a1e.tar.gz
Add a spec when ressource is not modified
-rw-r--r--lib/api/projects.rb6
-rw-r--r--spec/requests/api/projects_spec.rb2
-rw-r--r--spec/support/shared_examples/requests/api/status_shared_examples.rb22
3 files changed, 22 insertions, 8 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 78e25b6da03..78d900984ac 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -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'
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 46550243d06..4490e50702b 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -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
diff --git a/spec/support/shared_examples/requests/api/status_shared_examples.rb b/spec/support/shared_examples/requests/api/status_shared_examples.rb
index 1bffd1e49db..7d7f66adeab 100644
--- a/spec/support/shared_examples/requests/api/status_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/status_shared_examples.rb
@@ -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