Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/bulk_imports/users_mapper_spec.rb')
-rw-r--r--spec/lib/bulk_imports/users_mapper_spec.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/lib/bulk_imports/users_mapper_spec.rb b/spec/lib/bulk_imports/users_mapper_spec.rb
index e6357319d05..dc2beb42080 100644
--- a/spec/lib/bulk_imports/users_mapper_spec.rb
+++ b/spec/lib/bulk_imports/users_mapper_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe BulkImports::UsersMapper do
+RSpec.describe BulkImports::UsersMapper, feature_category: :importers do
let_it_be(:user) { create(:user) }
let_it_be(:import) { create(:bulk_import, user: user) }
let_it_be(:entity) { create(:bulk_import_entity, bulk_import: import) }
@@ -34,6 +34,22 @@ RSpec.describe BulkImports::UsersMapper do
end
end
+ describe '#map_usernames' do
+ context 'when value for specified key exists' do
+ it 'returns a map of source & destination usernames from redis' do
+ allow(Gitlab::Cache::Import::Caching).to receive(:values_from_hash).and_return({ "source_username" => "destination_username" })
+
+ expect(subject.map_usernames).to eq({ "source_username" => "destination_username" })
+ end
+ end
+
+ context 'when value for specified key does not exist' do
+ it 'returns nil' do
+ expect(subject.map_usernames[:non_existent_key]).to be_nil
+ end
+ end
+ end
+
describe '#default_user_id' do
it 'returns current user id' do
expect(subject.default_user_id).to eq(user.id)
@@ -65,4 +81,12 @@ RSpec.describe BulkImports::UsersMapper do
subject.cache_source_user_id(1, 2)
end
end
+
+ describe '#cache_source_username' do
+ it 'caches provided source & destination usernames in redis' do
+ expect(Gitlab::Cache::Import::Caching).to receive(:hash_add).with("bulk_imports/#{import.id}/#{entity.id}/source_usernames", 'source', 'destination')
+
+ subject.cache_source_username('source', 'destination')
+ end
+ end
end