Commit f5f62194 authored by James Lopez's avatar James Lopez

Merge branch '10242-respond-304-if-already-dismissed' into 'master'

Respond with 304 Not Modified if Vulnerability is already dismissed

See merge request gitlab-org/gitlab!18677
parents f977d2d6 a421ebba
...@@ -44,6 +44,8 @@ module API ...@@ -44,6 +44,8 @@ module API
post ':id/dismiss' do post ':id/dismiss' do
if Feature.enabled?(:first_class_vulnerabilities) if Feature.enabled?(:first_class_vulnerabilities)
vulnerability = find_and_authorize_vulnerability!(:dismiss_vulnerability) vulnerability = find_and_authorize_vulnerability!(:dismiss_vulnerability)
break not_modified! if vulnerability.closed?
vulnerability = ::Vulnerabilities::DismissService.new(current_user, vulnerability).execute vulnerability = ::Vulnerabilities::DismissService.new(current_user, vulnerability).execute
render_vulnerability(vulnerability) render_vulnerability(vulnerability)
else else
......
...@@ -111,6 +111,16 @@ describe API::Vulnerabilities do ...@@ -111,6 +111,16 @@ describe API::Vulnerabilities do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(403)
end end
end end
context 'if a vulnerability is already dismissed' do
let(:vulnerability) { create(:vulnerability, :closed, project: project) }
it 'responds with 304 Not Modified' do
subject
expect(response).to have_gitlab_http_status(304)
end
end
end end
context 'when user does not have permissions to create a dismissal feedback' do context 'when user does not have permissions to create a dismissal feedback' 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