From 5a6e824c3ad4b34eac57fe8b4becdcc8ba5f5677 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 3 Feb 2017 14:16:11 +0100 Subject: [PATCH] Working on issue #689 - User root@localhost gets imported but should not. --- lib/import/otrs/user_factory.rb | 8 ++++++++ spec/import/otrs/user_factory_spec.rb | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/import/otrs/user_factory.rb b/lib/import/otrs/user_factory.rb index ea49ccc77..ce3430876 100644 --- a/lib/import/otrs/user_factory.rb +++ b/lib/import/otrs/user_factory.rb @@ -2,6 +2,14 @@ module Import module OTRS module UserFactory extend Import::Factory + + # rubocop:disable Style/ModuleFunction + extend self + + # skip root@localhost since we have our own \o/ + def skip?(record, *_args) + record['UserID'].to_i == 1 + end end end end diff --git a/spec/import/otrs/user_factory_spec.rb b/spec/import/otrs/user_factory_spec.rb index b88035417..4f38bf84a 100644 --- a/spec/import/otrs/user_factory_spec.rb +++ b/spec/import/otrs/user_factory_spec.rb @@ -3,4 +3,12 @@ require 'import/factory_examples' RSpec.describe Import::OTRS::UserFactory do it_behaves_like 'Import::Factory' + + it 'skips root@localhost' do + + root_data = json_fixture('import/otrs/user/default') + expect(Import::OTRS::User).to_not receive(:new) + + described_class.import([root_data]) + end end