diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/migrations/add_triggers_to_integrations_type_new_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/migrations/add_triggers_to_integrations_type_new_spec.rb')
-rw-r--r-- | spec/migrations/add_triggers_to_integrations_type_new_spec.rb | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/spec/migrations/add_triggers_to_integrations_type_new_spec.rb b/spec/migrations/add_triggers_to_integrations_type_new_spec.rb new file mode 100644 index 00000000000..07845715a52 --- /dev/null +++ b/spec/migrations/add_triggers_to_integrations_type_new_spec.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +require 'spec_helper' + +require_migration! + +RSpec.describe AddTriggersToIntegrationsTypeNew do + let(:migration) { described_class.new } + let(:integrations) { table(:integrations) } + + describe '#up' do + before do + migrate! + end + + describe 'INSERT trigger' do + it 'sets `type_new` to the transformed `type` class name' do + Gitlab::Integrations::StiType.namespaced_integrations.each do |type| + integration = integrations.create!(type: "#{type}Service") + + expect(integration.reload).to have_attributes( + type: "#{type}Service", + type_new: "Integrations::#{type}" + ) + end + end + + it 'ignores types that are not namespaced' do + # We don't actually have any integrations without namespaces, + # but we can abuse one of the integration base classes. + integration = integrations.create!(type: 'BaseIssueTracker') + + expect(integration.reload).to have_attributes( + type: 'BaseIssueTracker', + type_new: nil + ) + end + + it 'ignores types that are unknown' do + integration = integrations.create!(type: 'FooBar') + + expect(integration.reload).to have_attributes( + type: 'FooBar', + type_new: nil + ) + end + end + end + + describe '#down' do + before do + migration.up + migration.down + end + + it 'drops the INSERT trigger' do + integration = integrations.create!(type: 'JiraService') + + expect(integration.reload).to have_attributes( + type: 'JiraService', + type_new: nil + ) + end + end +end |