Skip to content

Commit

Permalink
Fixes #5054 - OTRS import: After an OTRS import some statuses have a …
Browse files Browse the repository at this point in the history
…wrong ignore_escalation setting in Zammad.
  • Loading branch information
dominikklein committed Feb 16, 2024
1 parent d0375fa commit b7cde8a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
15 changes: 11 additions & 4 deletions lib/import/otrs/state.rb
Expand Up @@ -60,11 +60,14 @@ def create(state)
end

def map(state)
mapped_state_type_id = state_type_id(state)

{
created_by_id: 1,
updated_by_id: 1,
active: active?(state),
state_type_id: state_type_id(state)
created_by_id: 1,
updated_by_id: 1,
active: active?(state),
state_type_id: mapped_state_type_id,
ignore_escalation: ignore_escalation?(mapped_state_type_id)
}
.merge(from_mapping(state))
end
Expand All @@ -74,6 +77,10 @@ def state_type_id(state)
::Ticket::StateType.lookup(name: state['TypeName']).id
end

def ignore_escalation?(state_type_id)
::Ticket::StateType.names_in_category(:work_on).exclude?(::Ticket::StateType.lookup(id: state_type_id).name)
end

def map_type(state)
return if state['TypeName'] != 'pending auto'

Expand Down
46 changes: 36 additions & 10 deletions spec/lib/import/otrs/state_spec.rb
Expand Up @@ -30,19 +30,45 @@ def load_state_json(file)
let(:start_import_test) { described_class.new(object_structure) }

context 'closed' do

let(:object_structure) { load_state_json('default') }
let(:zammad_structure) do
{
created_by_id: 1,
updated_by_id: 1,
active: '1',
state_type_id: 5,
updated_at: '2014-04-28 10:53:18',
created_at: '2014-04-28 10:53:18',
name: 'closed successful',
id: '2',
note: 'Ticket is closed successful.'
created_by_id: 1,
updated_by_id: 1,
active: '1',
state_type_id: 5,
updated_at: '2014-04-28 10:53:18',
created_at: '2014-04-28 10:53:18',
name: 'closed successful',
id: '2',
note: 'Ticket is closed successful.',
ignore_escalation: true
}
end

it 'creates' do
creates_with(zammad_structure)
end

it 'updates' do
updates_with(zammad_structure)
end
end

context 'open' do
let(:object_structure) { load_state_json('open') }
let(:zammad_structure) do
{
created_by_id: 1,
updated_by_id: 1,
active: '1',
state_type_id: 2,
updated_at: '2014-04-28 10:53:18',
created_at: '2014-04-28 10:53:18',
name: 'open',
id: '4',
note: 'Open tickets.',
ignore_escalation: false
}
end

Expand Down

0 comments on commit b7cde8a

Please sign in to comment.