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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-28 18:09:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-28 18:09:59 +0300
commite0529f76a36026dc4bd51fbec1e5c52e7f3866e1 (patch)
treeac809b949e3257d89cac17c3409aadddd0a740cb /spec/migrations/20230418215853_add_assignee_widget_to_incidents_spec.rb
parent72cb3bee798655c2d370dfedf3c04665aaa43aa3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations/20230418215853_add_assignee_widget_to_incidents_spec.rb')
-rw-r--r--spec/migrations/20230418215853_add_assignee_widget_to_incidents_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/migrations/20230418215853_add_assignee_widget_to_incidents_spec.rb b/spec/migrations/20230418215853_add_assignee_widget_to_incidents_spec.rb
new file mode 100644
index 00000000000..d809d0e6a54
--- /dev/null
+++ b/spec/migrations/20230418215853_add_assignee_widget_to_incidents_spec.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe AddAssigneeWidgetToIncidents, :migration, feature_category: :team_planning do
+ let(:migration) { described_class.new }
+ let(:work_item_definitions) { table(:work_item_widget_definitions) }
+ let(:work_item_types) { table(:work_item_types) }
+
+ let(:widget_name) { 'Assignees' }
+ let(:work_item_type) { 'Incident' }
+
+ describe '#up' do
+ it 'creates widget definition' do
+ type = work_item_types.find_by_name_and_namespace_id(work_item_type, nil)
+ work_item_definitions.where(work_item_type_id: type, name: widget_name).delete_all if type
+
+ expect { migrate! }.to change { work_item_definitions.count }.by(1)
+
+ type = work_item_types.find_by_name_and_namespace_id(work_item_type, nil)
+
+ expect(work_item_definitions.where(work_item_type_id: type, name: widget_name).count).to eq 1
+ end
+
+ it 'logs a warning if the type is missing' do
+ allow(described_class::WorkItemType).to receive(:find_by_name_and_namespace_id).and_call_original
+ allow(described_class::WorkItemType).to receive(:find_by_name_and_namespace_id)
+ .with(work_item_type, nil).and_return(nil)
+
+ expect(Gitlab::AppLogger).to receive(:warn).with(AddAssigneeWidgetToIncidents::FAILURE_MSG)
+ migrate!
+ end
+ end
+
+ describe '#down' do
+ it 'removes definitions for widget' do
+ migrate!
+
+ expect { migration.down }.to change { work_item_definitions.count }.by(-1)
+
+ type = work_item_types.find_by_name_and_namespace_id(work_item_type, nil)
+
+ expect(work_item_definitions.where(work_item_type_id: type, name: widget_name).count).to eq 0
+ end
+ end
+end