blob: 66649eebf703ffee6327b5444cd28e1445363ae5 (
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
|
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe RemoveWebHooksWebHookLogsWebHookIdFk, feature_category: :integrations do
let(:web_hooks) { table(:web_hooks) }
let(:logs) { table(:web_hook_logs) }
let!(:hook) { web_hooks.create! }
let!(:log_a) { logs.create!(web_hook_id: hook.id, response_body: 'msg-a') }
let!(:log_b) { logs.create!(web_hook_id: hook.id, response_body: 'msg-b') }
describe '#up' do
it 'allows us to delete web-hooks and leave web-hook logs intact' do
migrate!
expect { hook.delete }.not_to change(logs, :count)
expect(logs.pluck(:response_body)).to match_array %w[msg-a msg-b]
end
end
describe '#down' do
it 'ensures referential integrity of hook logs' do
migrate!
schema_migrate_down!
expect { hook.delete }.to change(logs, :count).by(-2)
end
end
end
|