summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-31 21:10:12 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-31 21:10:12 +0000
commit8bb9ee876910bf5a14e116ace9ec95791486a78a (patch)
tree7e2ad1f15f11dcbb5b45b2a581b7d720c272885d /spec/migrations
parent04338021ada9669bcf8d6cf2d35b0debf50e8cc1 (diff)
downloadgitlab-ce-8bb9ee876910bf5a14e116ace9ec95791486a78a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/migrate_incident_issues_to_incident_type_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/migrations/migrate_incident_issues_to_incident_type_spec.rb b/spec/migrations/migrate_incident_issues_to_incident_type_spec.rb
new file mode 100644
index 00000000000..dc38695c7fe
--- /dev/null
+++ b/spec/migrations/migrate_incident_issues_to_incident_type_spec.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20200723040950_migrate_incident_issues_to_incident_type.rb')
+
+RSpec.describe MigrateIncidentIssuesToIncidentType do
+ let(:migration) { described_class.new }
+
+ let(:projects) { table(:projects) }
+ let(:namespaces) { table(:namespaces) }
+ let(:labels) { table(:labels) }
+ let(:issues) { table(:issues) }
+ let(:label_links) { table(:label_links) }
+ let(:label_props) { IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES }
+
+ let(:namespace) { namespaces.create!(name: 'foo', path: 'foo') }
+ let!(:project) { projects.create!(namespace_id: namespace.id) }
+ let(:label) { labels.create!(project_id: project.id, **label_props) }
+ let!(:incident_issue) { issues.create!(project_id: project.id) }
+ let!(:other_issue) { issues.create!(project_id: project.id) }
+
+ # Issue issue_type enum
+ let(:issue_type) { 0 }
+ let(:incident_type) { 1 }
+
+ before do
+ label_links.create!(target_id: incident_issue.id, label_id: label.id, target_type: 'Issue')
+ end
+
+ describe '#up' do
+ it 'updates the incident issue type' do
+ expect { migrate! }
+ .to change { incident_issue.reload.issue_type }
+ .from(issue_type)
+ .to(incident_type)
+
+ expect(other_issue.reload.issue_type).to eql(issue_type)
+ end
+ end
+
+ describe '#down' do
+ let!(:incident_issue) { issues.create!(project_id: project.id, issue_type: issue_type) }
+
+ it 'updates the incident issue type' do
+ migration.up
+
+ expect { migration.down }
+ .to change { incident_issue.reload.issue_type }
+ .from(incident_type)
+ .to(issue_type)
+
+ expect(other_issue.reload.issue_type).to eql(issue_type)
+ end
+ end
+end