Fixes #2694 - Zendesk import doesn't consider all tickets.
This commit is contained in:
parent
f1f93b773e
commit
f1eee78381
6 changed files with 35 additions and 4 deletions
|
@ -0,0 +1,20 @@
|
|||
class Sequencer
|
||||
class Unit
|
||||
module Import
|
||||
module Zendesk
|
||||
module Mixin
|
||||
module IncrementalExport
|
||||
|
||||
def self.included(base)
|
||||
base.uses :client
|
||||
end
|
||||
|
||||
def resource_collection
|
||||
"::ZendeskAPI::#{resource_klass}".constantize.incremental_export(client, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,6 +3,7 @@ class Sequencer
|
|||
module Import
|
||||
module Zendesk
|
||||
class Organizations < Sequencer::Unit::Import::Zendesk::SubSequence::Object
|
||||
include ::Sequencer::Unit::Import::Zendesk::Mixin::IncrementalExport
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class Sequencer
|
|||
|
||||
def self.included(base)
|
||||
base.extend(ClassMethods)
|
||||
|
||||
base.uses :dry_run, :import_job
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ class Sequencer
|
|||
module Import
|
||||
module Zendesk
|
||||
class Tickets < Sequencer::Unit::Import::Zendesk::SubSequence::Object
|
||||
include ::Sequencer::Unit::Import::Zendesk::Mixin::IncrementalExport
|
||||
|
||||
uses :user_map, :organization_map, :group_map, :ticket_field_map
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ class Sequencer
|
|||
module Import
|
||||
module Zendesk
|
||||
class Users < Sequencer::Unit::Import::Zendesk::SubSequence::Object
|
||||
include ::Sequencer::Unit::Import::Zendesk::Mixin::IncrementalExport
|
||||
|
||||
uses :organization_map, :group_map, :user_group_map
|
||||
|
||||
|
|
|
@ -2,6 +2,13 @@ RSpec.shared_examples 'Sequencer::Unit::Import::Zendesk::SubSequence::Base' do
|
|||
describe 'error handling' do
|
||||
before do
|
||||
allow(params[:client]).to receive(collection_name).and_return(client_collection)
|
||||
|
||||
# if method 'incremental_export' is defined in class add additional receive via incremental_export
|
||||
# for Users, Tickets and Organizations we are using Mixin 'IncrementalExport' to get the correct resource_collection method
|
||||
if "ZendeskAPI/#{collection_name}".classify.safe_constantize.respond_to?(:incremental_export)
|
||||
allow("ZendeskAPI/#{collection_name}".classify.safe_constantize).to receive(:incremental_export).and_return(client_collection)
|
||||
end
|
||||
|
||||
allow(client_collection).to receive(:all!).and_raise(api_error)
|
||||
end
|
||||
|
||||
|
@ -10,10 +17,10 @@ RSpec.shared_examples 'Sequencer::Unit::Import::Zendesk::SubSequence::Base' do
|
|||
dry_run: false,
|
||||
import_job: instance_double(ImportJob),
|
||||
client: double('ZendeskAPI'),
|
||||
group_map: {}, # required by Tickets
|
||||
organization_map: {}, # required by Tickets
|
||||
ticket_field_map: {}, # required by Tickets
|
||||
user_map: {}, # required by Tickets
|
||||
group_map: {}, # required by Tickets
|
||||
organization_map: {}, # required by Tickets
|
||||
ticket_field_map: {}, # required by Tickets
|
||||
user_map: {}, # required by Tickets
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue