Commit 636c81c0 authored by Victor Zagorodny's avatar Victor Zagorodny

Simplify API tests

parent e77bd057
...@@ -33,16 +33,16 @@ describe API::Vulnerabilities do ...@@ -33,16 +33,16 @@ describe API::Vulnerabilities do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response.map { |v| v['id'] }).to contain_exactly(project.vulnerabilities.second.id) expect(json_response.map { |v| v['id'] }).to contain_exactly(project.vulnerabilities.second.id)
end end
end
it_behaves_like 'forbids access to vulnerability-like endpoint in expected cases' context 'when "first-class vulnerabilities" feature is disabled' do
before do
stub_feature_flags(first_class_vulnerabilities: false)
end
context 'when "first-class vulnerabilities" feature is disabled' do it_behaves_like 'getting list of vulnerability findings'
before do
stub_feature_flags(first_class_vulnerabilities: false)
end end
it_behaves_like 'getting list of vulnerability findings'
end end
it_behaves_like 'forbids access to vulnerability-like endpoint in expected cases'
end end
end end
...@@ -10,16 +10,23 @@ describe API::VulnerabilityFindings do ...@@ -10,16 +10,23 @@ describe API::VulnerabilityFindings do
let(:project_vulnerabilities_path) { "/projects/#{project.id}/vulnerability_findings" } let(:project_vulnerabilities_path) { "/projects/#{project.id}/vulnerability_findings" }
it_behaves_like 'getting list of vulnerability findings' it_behaves_like 'getting list of vulnerability findings'
it_behaves_like 'forbids access to vulnerability-like endpoint in expected cases'
context 'when "first-class vulnerabilities" feature is disabled' do context 'with an authorized user with proper permissions' do
before do before do
stub_feature_flags(first_class_vulnerabilities: false) project.add_developer(user)
end end
it 'responds with "not found"' do context 'when "first-class vulnerabilities" feature is disabled' do
get api(project_vulnerabilities_path, user) before do
stub_feature_flags(first_class_vulnerabilities: false)
end
expect(response).to have_gitlab_http_status(404) it 'responds with "not found"' do
get api(project_vulnerabilities_path, user)
expect(response).to have_gitlab_http_status(404)
end
end end
end end
end end
......
...@@ -217,6 +217,4 @@ shared_examples 'getting list of vulnerability findings' do ...@@ -217,6 +217,4 @@ shared_examples 'getting list of vulnerability findings' do
end end
end end
end end
it_behaves_like 'forbids access to vulnerability-like endpoint in expected cases'
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