summaryrefslogtreecommitdiff
path: root/spec/migrations/20220211214605_update_integrations_trigger_type_new_on_insert_null_safe_spec.rb
blob: 8a6a542bc5ec7fb55df771b0e4b0a9689cd2df39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require 'spec_helper'

require_migration!

RSpec.describe UpdateIntegrationsTriggerTypeNewOnInsertNullSafe, :migration, feature_category: :integrations do
  let(:integrations) { table(:integrations) }

  before do
    migrate!
  end

  it 'leaves defined values alone' do
    record = integrations.create!(type: 'XService', type_new: 'Integrations::Y')

    expect(integrations.find(record.id)).to have_attributes(type: 'XService', type_new: 'Integrations::Y')
  end

  it 'keeps type_new synchronized with type' do
    record = integrations.create!(type: 'AbcService', type_new: nil)

    expect(integrations.find(record.id)).to have_attributes(
      type: 'AbcService',
      type_new: 'Integrations::Abc'
    )
  end

  it 'keeps type synchronized with type_new' do
    record = integrations.create!(type: nil, type_new: 'Integrations::Abc')

    expect(integrations.find(record.id)).to have_attributes(
      type: 'AbcService',
      type_new: 'Integrations::Abc'
    )
  end
end