2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2017-03-27 09:25:45 +00:00
|
|
|
require 'lib/import/import_factory_examples'
|
2016-11-25 16:10:37 +00:00
|
|
|
|
|
|
|
RSpec.shared_examples 'Import::BaseFactory' do
|
|
|
|
it_behaves_like 'Import factory'
|
|
|
|
|
|
|
|
it 'responds to pre_import_hook' do
|
|
|
|
expect(described_class).to respond_to('pre_import_hook')
|
|
|
|
end
|
2020-02-18 19:51:31 +00:00
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
it 'responds to post_import_hook' do
|
|
|
|
expect(described_class).to respond_to('post_import_hook')
|
|
|
|
end
|
2020-02-18 19:51:31 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
it 'responds to backend_class' do
|
|
|
|
expect(described_class).to respond_to('backend_class')
|
|
|
|
end
|
2020-02-18 19:51:31 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
it 'responds to skip?' do
|
|
|
|
expect(described_class).to respond_to('skip?')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
RSpec.shared_examples 'Import::BaseFactory extender' do
|
|
|
|
it 'calls new on determined backend object' do
|
2021-07-16 13:29:38 +00:00
|
|
|
record = double
|
2020-10-22 13:57:01 +00:00
|
|
|
allow(described_class).to receive(:backend_class).and_return(Class)
|
|
|
|
allow(Class).to receive(:new)
|
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
described_class.import([record])
|
2020-10-22 13:57:01 +00:00
|
|
|
expect(Class).to have_received(:new).with(record, any_args)
|
2016-11-25 16:10:37 +00:00
|
|
|
end
|
|
|
|
end
|