Commit 64106865 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix/fogbugz-import' into 'master'

spec and fix for fogbugz lonely user problem

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/14766

I encountered this issue while manually testing all import types for
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3066

This is really due to a horrible API

```
{ 'people' => { 'person' => array_of_people_or_single_person_as_hash } }
```

See merge request !3457
parents a4f55888 c2d5cc91
......@@ -26,7 +26,7 @@ module Gitlab
def user_map
users = {}
res = @api.command(:listPeople)
res['people']['person'].each do |user|
[res['people']['person']].flatten.each do |user|
users[user['ixPerson']] = { name: user['sFullName'], email: user['sEmail'] }
end
users
......
require 'spec_helper'
describe Gitlab::FogbugzImport::Client, lib: true do
let(:client) { described_class.new(uri: '', token: '') }
let(:one_user) { { 'people' => { 'person' => { "ixPerson" => "2", "sFullName" => "James" } } } }
let(:two_users) { { 'people' => { 'person' => [one_user, { "ixPerson" => "3" }] } } }
it 'retrieves user_map with one user' do
stub_api(one_user)
expect(client.user_map.count).to eq(1)
end
it 'retrieves user_map with two users' do
stub_api(two_users)
expect(client.user_map.count).to eq(2)
end
def stub_api(users)
allow_any_instance_of(::Fogbugz::Interface).to receive(:command).with(:listPeople).and_return(users)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment