Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb')
-rw-r--r--spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb b/spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb
new file mode 100644
index 00000000000..92ece81ffc8
--- /dev/null
+++ b/spec/migrations/cleanup_vulnerability_state_transitions_with_same_from_state_to_state_spec.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe CleanupVulnerabilityStateTransitionsWithSameFromStateToState, :migration do
+ let_it_be(:namespace) { table(:namespaces).create!(name: 'namespace', type: 'Group', path: 'namespace') }
+ let_it_be(:user) { table(:users).create!(email: 'author@example.com', username: 'author', projects_limit: 10) }
+ let_it_be(:project) do
+ table(:projects).create!(
+ path: 'project',
+ namespace_id: namespace.id,
+ project_namespace_id: namespace.id
+ )
+ end
+
+ let_it_be(:vulnerability) do
+ table(:vulnerabilities).create!(
+ project_id: project.id,
+ author_id: user.id,
+ title: 'test',
+ severity: 7,
+ confidence: 7,
+ report_type: 0
+ )
+ end
+
+ let_it_be(:state_transitions) { table(:vulnerability_state_transitions) }
+
+ let!(:state_transition_with_no_state_change) do
+ state_transitions.create!(
+ vulnerability_id: vulnerability.id,
+ from_state: 2,
+ to_state: 2
+ )
+ end
+
+ let!(:state_transition_with_state_change) do
+ state_transitions.create!(
+ vulnerability_id: vulnerability.id,
+ from_state: 1,
+ to_state: 2
+ )
+ end
+
+ it 'deletes state transitions with no state change' do
+ expect { migrate! }.to change(state_transitions, :count).from(2).to(1)
+ end
+end