Fixed bug #890 - Imported states from OTRS are not correctly mapped to Zammad states.

This commit is contained in:
Thorsten Eckel 2017-05-16 18:11:36 +02:00
parent e4de5bb988
commit 54d4a87ead
2 changed files with 82 additions and 0 deletions

View file

@ -64,6 +64,7 @@ module Import
def update_ticket_attributes
update_ticket_state
update_ticket_pending_time
reseed_dependent_objects
end
def update_ticket_state
@ -124,6 +125,17 @@ module Import
force: true # otherwise _id as a name is not permitted
)
end
def reseed_dependent_objects
Overview.reseed
Trigger.reseed
Macro.reseed
# we don't have to re-seed the ObjectManager
# Attributes since they contain the already
# imported DynamicFields which will be lost
ObjectManager::Attribute.seed
end
end
end
end

View file

@ -108,4 +108,74 @@ RSpec.describe Import::OTRS::StateFactory do
expect(state.default_create).to be false
expect(state.default_follow_up).to be false
end
context 'changing Ticket::State IDs' do
let(:state_backend_param) {
states = %w(new open merged pending_reminder pending_auto_close_p pending_auto_close_n pending_auto_close_p closed_successful closed_unsuccessful closed_successful removed)
state_backend_param = []
states.each do |state|
state_backend_param.push(load_state_json(state))
end
state_backend_param
}
it 'updates Overviews' do
name = 'My pending reached Tickets'
overview = Overview.find_by(name: name)
expect do
described_class.import(state_backend_param)
overview = Overview.find_by(name: name)
end.to change {
overview.id
}.and change {
overview.condition['ticket.state_id'][:value]
}
end
it 'updates Macros' do
name = 'Close & Tag as Spam'
macro = Macro.find_by(name: name)
expect do
described_class.import(state_backend_param)
macro = Macro.find_by(name: name)
end.to change {
macro.id
}.and change {
macro.perform['ticket.state_id'][:value]
}
end
it 'updates Triggers' do
name = 'auto reply (on new tickets)'
trigger = Trigger.find_by(name: name)
expect do
described_class.import(state_backend_param)
trigger = Trigger.find_by(name: name)
end.to change {
trigger.id
}.and change {
trigger.condition['ticket.state_id'][:value]
}
end
it 'updates ObjectManager::Attributes' do
attribute = ObjectManager::Attribute.get(
object: 'Ticket',
name: 'pending_time',
)
expect do
described_class.import(state_backend_param)
attribute = ObjectManager::Attribute.get(
object: 'Ticket',
name: 'pending_time',
)
end.to change {
attribute.data_option[:required_if][:state_id]
}
end
end
end