diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-28 18:09:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-28 18:09:59 +0300 |
commit | e0529f76a36026dc4bd51fbec1e5c52e7f3866e1 (patch) | |
tree | ac809b949e3257d89cac17c3409aadddd0a740cb /spec/migrations/20230418215853_add_assignee_widget_to_incidents_spec.rb | |
parent | 72cb3bee798655c2d370dfedf3c04665aaa43aa3 (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.rb | 47 |
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 |