Fixed issue #526 - Import throws error if run a second time.
This commit is contained in:
parent
51985bc67e
commit
0e7a84facf
3 changed files with 12 additions and 3 deletions
|
@ -48,7 +48,7 @@ module Import
|
|||
|
||||
# only update roles if different (reduce sql statements)
|
||||
if @local_customer.role_ids == customer[:role_ids]
|
||||
user.delete(:role_ids)
|
||||
customer.delete(:role_ids)
|
||||
end
|
||||
|
||||
log "update User.find_by(login: #{customer[:login]})"
|
||||
|
|
|
@ -13,7 +13,10 @@ RSpec.describe Import::OTRS::CustomerUser do
|
|||
def updates_with(zammad_structure)
|
||||
expect_organization_lookup
|
||||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
expect(existing_object).to receive(:role_ids).and_return([]).at_least(:once)
|
||||
# we delete the :role_ids from the zammad_structure to make sure that
|
||||
# a) role_ids call returns the initial role_ids
|
||||
# b) and update_attributes gets called without them
|
||||
expect(existing_object).to receive(:role_ids).and_return(zammad_structure.delete(:role_ids)).at_least(:once)
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
|
|
|
@ -12,12 +12,18 @@ RSpec.describe Import::OTRS::User do
|
|||
|
||||
def updates_with(zammad_structure)
|
||||
expect(import_object).to receive(:find_by).and_return(existing_object)
|
||||
expect(existing_object).to receive(:role_ids).and_return([])
|
||||
# we delete the :role_ids from the zammad_structure to make sure that
|
||||
# a) role_ids call returns the initial role_ids
|
||||
# b) and update_attributes gets called without them
|
||||
expect(existing_object).to receive(:role_ids).and_return(zammad_structure.delete(:role_ids))
|
||||
expect(existing_object).to receive(:update_attributes).with(zammad_structure)
|
||||
expect(import_object).not_to receive(:new)
|
||||
start_import_test
|
||||
end
|
||||
|
||||
def role_delete_expecations(role_ids)
|
||||
end
|
||||
|
||||
def load_user_json(file)
|
||||
json_fixture("import/otrs/user/#{file}")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue