Commit a421ebba authored by Victor Zagorodny's avatar Victor Zagorodny Committed by James Lopez

Respond with 304 Not Modified if Vulnerability is already dismissed

parent f977d2d6
...@@ -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