Fixes #2694 - Zendesk import doesn't consider all tickets.

This commit is contained in:
Denny Bresch 2019-08-08 10:25:37 +02:00 committed by Thorsten Eckel
parent f1f93b773e
commit f1eee78381
6 changed files with 35 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -13,6 +13,7 @@ class Sequencer
def self.included(base)
base.extend(ClassMethods)
base.uses :dry_run, :import_job
end

View file

@ -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

View file

@ -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

View file

@ -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