diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/lib/gitlab/background_migration/populate_dismissed_state_for_vulnerabilities_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/lib/gitlab/background_migration/populate_dismissed_state_for_vulnerabilities_spec.rb')
-rw-r--r-- | spec/lib/gitlab/background_migration/populate_dismissed_state_for_vulnerabilities_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/lib/gitlab/background_migration/populate_dismissed_state_for_vulnerabilities_spec.rb b/spec/lib/gitlab/background_migration/populate_dismissed_state_for_vulnerabilities_spec.rb new file mode 100644 index 00000000000..bc55f240a58 --- /dev/null +++ b/spec/lib/gitlab/background_migration/populate_dismissed_state_for_vulnerabilities_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Gitlab::BackgroundMigration::PopulateDismissedStateForVulnerabilities, schema: 2020_11_30_103926 do + let(:users) { table(:users) } + let(:namespaces) { table(:namespaces) } + let(:projects) { table(:projects) } + let(:vulnerabilities) { table(:vulnerabilities) } + + let!(:namespace) { namespaces.create!(name: "foo", path: "bar") } + let!(:user) { users.create!(name: 'John Doe', email: 'test@example.com', projects_limit: 5) } + let!(:project) { projects.create!(namespace_id: namespace.id) } + let!(:vulnerability_params) do + { + project_id: project.id, + author_id: user.id, + title: 'Vulnerability', + severity: 5, + confidence: 5, + report_type: 5 + } + end + + let!(:vulnerability_1) { vulnerabilities.create!(vulnerability_params.merge(state: 1)) } + let!(:vulnerability_2) { vulnerabilities.create!(vulnerability_params.merge(state: 3)) } + + describe '#perform' do + it 'changes state of vulnerability to dismissed' do + subject.perform(vulnerability_1.id, vulnerability_2.id) + + expect(vulnerability_1.reload.state).to eq(2) + expect(vulnerability_2.reload.state).to eq(2) + end + + it 'populates missing dismissal information' do + expect_next_instance_of(::Gitlab::BackgroundMigration::PopulateMissingVulnerabilityDismissalInformation) do |migration| + expect(migration).to receive(:perform).with(vulnerability_1.id, vulnerability_2.id) + end + + subject.perform(vulnerability_1.id, vulnerability_2.id) + end + end +end |