Commit 2d544d54 authored by James Lopez's avatar James Lopez

spec and fix for fogbugz lonely user problem

parent 3d484861
......@@ -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) { Gitlab::FogbugzImport::Client.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