Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/cleanup/destroyable_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def print_data

stdout.puts '********'
stdout.puts 'Integration:'
if integration.nil?
if integration.blank?
stdout.puts 'No associated integration'
else
stdout.puts integration.attributes.to_yaml
Expand All @@ -46,7 +46,7 @@ def print_data

stdout.puts '*******'
stdout.puts 'These are the IAA orders that will be affected: \n'
if iaa_orders.nil?
if iaa_orders.blank?
stdout.puts 'No IAA orders will be affected'
else
stdout.puts 'These are the IAA orders that will be affected: \n'
Expand Down Expand Up @@ -79,11 +79,11 @@ def destroy_records
private

def integration_usages
integration&.integration_usages
integration&.integration_usages || []
end

def iaa_orders
integration&.iaa_orders
integration&.iaa_orders || []
end

def in_person_enrollments
Expand Down
10 changes: 10 additions & 0 deletions spec/lib/cleanup/destroyable_records_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@
expect(iaa_order.integrations.include? integration).to be false
end

describe 'integration without usages or iaa_orders' do
let!(:empty_integration) { create(:integration) }
let!(:service_provider) { empty_integration.service_provider }

it 'destroys the integration' do
deleted_int = Agreements::Integration.find_by(id: empty_integration.id)
expect(deleted_int).to be nil
end
end

it 'does not delete unrelated objects' do
iu2.reload
iaa_order.reload
Expand Down