diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/migrations/populate_dismissal_information_for_vulnerabilities_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/migrations/populate_dismissal_information_for_vulnerabilities_spec.rb')
-rw-r--r-- | spec/migrations/populate_dismissal_information_for_vulnerabilities_spec.rb | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/spec/migrations/populate_dismissal_information_for_vulnerabilities_spec.rb b/spec/migrations/populate_dismissal_information_for_vulnerabilities_spec.rb deleted file mode 100644 index 66fd5eb5ae5..00000000000 --- a/spec/migrations/populate_dismissal_information_for_vulnerabilities_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -require_migration! - -RSpec.describe PopulateDismissalInformationForVulnerabilities, feature_category: :vulnerability_management do - let(:users) { table(:users) } - let(:namespaces) { table(:namespaces) } - let(:projects) { table(:projects) } - let(:vulnerabilities) { table(:vulnerabilities) } - - let(:existing_dismissed_at) { Time.now } - let(:states) { { detected: 1, dismissed: 2, resolved: 3, confirmed: 4 } } - let!(:namespace) { namespaces.create!(name: "foo", path: "bar") } - let!(:user_1) { users.create!(name: 'John Doe', email: 'john_doe+1@example.com', projects_limit: 5) } - let!(:user_2) { users.create!(name: 'John Doe', email: 'john_doe+2@example.com', projects_limit: 5) } - let!(:project) { projects.create!(namespace_id: namespace.id) } - let!(:vulnerability_params) do - { - project_id: project.id, - author_id: user_1.id, - title: 'Vulnerability', - severity: 5, - confidence: 5, - report_type: 5 - } - end - - let!(:detected_vulnerability) { vulnerabilities.create!(**vulnerability_params, state: states[:detected]) } - let!(:resolved_vulnerability) { vulnerabilities.create!(**vulnerability_params, state: states[:resolved]) } - let!(:confirmed_vulnerability) { vulnerabilities.create!(**vulnerability_params, state: states[:confirmed]) } - - let!(:dismissed_vulnerability_1) { vulnerabilities.create!(**vulnerability_params, state: states[:dismissed], updated_by_id: user_2.id) } - let!(:dismissed_vulnerability_2) { vulnerabilities.create!(**vulnerability_params, state: states[:dismissed], last_edited_by_id: user_2.id) } - let!(:dismissed_vulnerability_3) { vulnerabilities.create!(**vulnerability_params, state: states[:dismissed], dismissed_at: existing_dismissed_at, author_id: user_2.id) } - let!(:dismissed_vulnerability_4) { vulnerabilities.create!(**vulnerability_params, state: states[:dismissed], dismissed_by_id: user_1.id, author_id: user_2.id) } - let!(:dismissed_vulnerability_5) { vulnerabilities.create!(**vulnerability_params, state: states[:dismissed], dismissed_at: existing_dismissed_at, dismissed_by_id: user_1.id, updated_by_id: user_2.id) } - - around do |example| - freeze_time { example.run } - end - - it 'updates the dismissal information for vulnerabilities' do - expect { migrate! }.to change { dismissed_vulnerability_1.reload.dismissed_at }.from(nil).to(dismissed_vulnerability_1.updated_at) - .and change { dismissed_vulnerability_1.reload.dismissed_by_id }.from(nil).to(user_2.id) - .and change { dismissed_vulnerability_2.reload.dismissed_at }.from(nil).to(dismissed_vulnerability_2.updated_at) - .and change { dismissed_vulnerability_2.reload.dismissed_by_id }.from(nil).to(user_2.id) - .and change { dismissed_vulnerability_3.reload.dismissed_by_id }.from(nil).to(user_2.id) - .and change { dismissed_vulnerability_4.reload.dismissed_at }.from(nil).to(dismissed_vulnerability_4.updated_at) - .and not_change { dismissed_vulnerability_3.reload.dismissed_at }.from(existing_dismissed_at) - .and not_change { dismissed_vulnerability_4.reload.dismissed_by_id }.from(user_1.id) - .and not_change { dismissed_vulnerability_5.reload.dismissed_at }.from(existing_dismissed_at) - .and not_change { dismissed_vulnerability_5.reload.dismissed_by_id }.from(user_1.id) - .and not_change { detected_vulnerability.reload.dismissed_at }.from(nil) - .and not_change { detected_vulnerability.reload.dismissed_by_id }.from(nil) - .and not_change { resolved_vulnerability.reload.dismissed_at }.from(nil) - .and not_change { resolved_vulnerability.reload.dismissed_by_id }.from(nil) - .and not_change { confirmed_vulnerability.reload.dismissed_at }.from(nil) - .and not_change { confirmed_vulnerability.reload.dismissed_by_id }.from(nil) - end -end |