2016-11-25 16:10:37 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Import::OTRS::Priority do
|
|
|
|
|
|
|
|
def creates_with(zammad_structure)
|
|
|
|
expect(import_object).to receive(:new).with(zammad_structure).and_call_original
|
|
|
|
expect_any_instance_of(import_object).to receive(:save)
|
|
|
|
expect_any_instance_of(described_class).to receive(:reset_primary_key_sequence)
|
|
|
|
start_import_test
|
|
|
|
end
|
|
|
|
|
|
|
|
def updates_with(zammad_structure)
|
|
|
|
expect(import_object).to receive(:find_by).and_return(existing_object)
|
2017-09-11 11:16:08 +00:00
|
|
|
expect(existing_object).to receive(:update!).with(zammad_structure)
|
2016-11-25 16:10:37 +00:00
|
|
|
expect(import_object).not_to receive(:new)
|
|
|
|
start_import_test
|
|
|
|
end
|
|
|
|
|
|
|
|
def load_priority_json(file)
|
|
|
|
json_fixture("import/otrs/priority/#{file}")
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:import_object) { Ticket::Priority }
|
|
|
|
let(:existing_object) { instance_double(import_object) }
|
|
|
|
let(:start_import_test) { described_class.new(object_structure) }
|
|
|
|
|
|
|
|
context 'default' do
|
|
|
|
|
|
|
|
let(:object_structure) { load_priority_json('default') }
|
2017-10-01 12:25:52 +00:00
|
|
|
let(:zammad_structure) do
|
2016-11-25 16:10:37 +00:00
|
|
|
{
|
|
|
|
created_by_id: '1',
|
|
|
|
updated_by_id: '1',
|
2018-12-19 17:31:51 +00:00
|
|
|
active: true,
|
|
|
|
updated_at: '2014-04-28 10:53:18',
|
|
|
|
created_at: '2014-04-28 10:53:18',
|
2020-03-24 17:54:45 +00:00
|
|
|
ui_color: 'high-priority',
|
|
|
|
ui_icon: 'important',
|
2018-12-19 17:31:51 +00:00
|
|
|
name: '4 high',
|
|
|
|
id: '4'
|
2016-11-25 16:10:37 +00:00
|
|
|
}
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-11-25 16:10:37 +00:00
|
|
|
|
|
|
|
it 'creates' do
|
|
|
|
creates_with(zammad_structure)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates' do
|
|
|
|
updates_with(zammad_structure)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|