Commit edf4b5dd authored by Rémy Coutable's avatar Rémy Coutable

Fix a flaky spec that would assume records order

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent be07e235
......@@ -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)
......
......@@ -168,7 +168,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) }
......@@ -181,7 +181,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) }
......@@ -191,7 +191,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 }
......@@ -200,7 +200,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