Commit 150e4d45 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '215327-job-failed-ee-spec-lib-ee-api-entities-vulnerability_spec-rb-17' into 'master'

Fix a flaky spec that would assume records order

Closes #215327

See merge request gitlab-org/gitlab!30390
parents 20b52057 edf4b5dd
......@@ -86,6 +86,12 @@ FactoryBot.modify do
import_type { 'github' }
end
trait :with_vulnerability do
after(:create) do |project|
create(:vulnerability, :detected, project: project)
end
end
trait :with_vulnerabilities do
after(:create) do |project|
create_list(:vulnerability, 2, :detected, project: project)
......
......@@ -3,16 +3,14 @@
require 'spec_helper'
describe ::EE::API::Entities::Vulnerability do
before do
create_list(:vulnerabilities_finding, 2, vulnerability: vulnerability)
end
let_it_be(:project) { create(:project, :with_vulnerabilities) }
let_it_be(:project) { create(:project, :with_vulnerability) }
let(:vulnerability) { project.vulnerabilities.first }
let(:entity) { described_class.new(vulnerability)}
subject { described_class.new(vulnerability).as_json }
subject { entity.as_json }
before do
create(:vulnerabilities_finding, vulnerability: vulnerability)
end
it 'contains vulnerability properties' do
expect(subject[:id]).to eq(vulnerability.id)
......
......@@ -244,7 +244,7 @@ describe Vulnerability do
end
describe '#finding' do
let_it_be(:project) { create(:project, :with_vulnerabilities) }
let_it_be(:project) { create(:project, :with_vulnerability) }
let_it_be(:vulnerability) { project.vulnerabilities.first }
let_it_be(:finding1) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) }
let_it_be(:finding2) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) }
......@@ -257,7 +257,7 @@ describe Vulnerability do
end
describe '#finding_scanner_name' do
let_it_be(:project) { create(:project, :with_vulnerabilities) }
let_it_be(:project) { create(:project, :with_vulnerability) }
let_it_be(:vulnerability) { project.vulnerabilities.first }
let_it_be(:finding) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) }
......@@ -267,7 +267,7 @@ describe Vulnerability do
end
describe '#project_default_branch' do
let_it_be(:project) { create(:project, :repository, :with_vulnerabilities) }
let_it_be(:project) { create(:project, :repository, :with_vulnerability) }
let_it_be(:vulnerability) { project.vulnerabilities.first }
subject { vulnerability.project_default_branch }
......@@ -276,7 +276,7 @@ describe Vulnerability do
end
describe '#resolved_on_default_branch' do
let_it_be(:project) { create(:project, :repository, :with_vulnerabilities) }
let_it_be(:project) { create(:project, :repository, :with_vulnerability) }
let_it_be(:pipeline_with_vulnerability) { create(:ci_pipeline, :success, project: project, sha: project.commit.id) }
let_it_be(:vulnerability) { project.vulnerabilities.first }
let_it_be(:finding1) { create(:vulnerabilities_occurrence, vulnerability: vulnerability, pipelines: [pipeline_with_vulnerability]) }
......
......@@ -10,7 +10,7 @@ describe API::VulnerabilityExports do
end
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :with_vulnerabilities) }
let_it_be(:project) { create(:project, :with_vulnerability) }
let(:project_vulnerability_exports_path) { "/projects/#{project.id}/vulnerability_exports" }
let(:project_vulnerability_export_path) { "#{project_vulnerability_exports_path}/#{vulnerability_export.id}" }
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe VulnerabilityExports::ExportWorker, type: :worker do
describe '#perform' do
let_it_be(:project) { create(:project, :with_vulnerabilities) }
let_it_be(:project) { create(:project, :with_vulnerability) }
let!(:vulnerability_export) { create(:vulnerability_export, :created, :csv, project: project) }
let(:worker) { described_class.new }
......
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