1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Import::BulkImports::SourceUsersMapper, feature_category: :importers do
let_it_be(:portable) { create(:group) }
let_it_be(:bulk_import) { create(:bulk_import, :with_configuration) }
let_it_be(:entity) do
create(
:bulk_import_entity,
group: portable,
bulk_import: bulk_import,
source_full_path: 'source/full/path',
destination_slug: 'My-Destination-Group',
destination_namespace: portable.full_path
)
end
let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) }
let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) }
let_it_be(:import_source_user_1) do
create(:import_source_user,
namespace: portable,
import_type: Import::SOURCE_DIRECT_TRANSFER,
source_hostname: bulk_import.configuration.url,
source_user_identifier: 101
)
end
let_it_be(:import_source_user_2) do
create(:import_source_user,
:completed,
namespace: portable,
import_type: Import::SOURCE_DIRECT_TRANSFER,
source_hostname: bulk_import.configuration.url,
source_user_identifier: 102
)
end
subject(:mapper) { described_class.new(context: context) }
describe '#map' do
it 'returns placeholder user id' do
expect(mapper.map['101']).to eq(import_source_user_1.placeholder_user_id)
end
context 'when import source user have been reassigned to a real user' do
it 'returns real user user id' do
expect(mapper.map['102']).to eq(import_source_user_2.reassign_to_user_id)
end
end
end
describe '#include?' do
it 'always returns true' do
expect(mapper.include?('any_identifier')).to eq(true)
end
end
end
|