Commit 5ec1db07 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'georgekoltsov/fix-epics-pipeline' into 'master'

Fix user reference transformation in EpicsPipeline

See merge request gitlab-org/gitlab!58913
parents cd656246 3df6c529
---
title: Fix user reference transformation in EpicsPipeline
merge_request: 58913
author:
type: fixed
......@@ -11,8 +11,7 @@ module EE
query: EE::BulkImports::Groups::Graphql::GetEpicsQuery
transformer ::BulkImports::Common::Transformers::ProhibitedAttributesTransformer
transformer ::BulkImports::Common::Transformers::UserReferenceTransformer,
reference: :author
transformer ::BulkImports::Common::Transformers::UserReferenceTransformer, reference: 'author'
transformer EE::BulkImports::Groups::Transformers::EpicAttributesTransformer
def transform(_, data)
......
......@@ -125,7 +125,7 @@ RSpec.describe EE::BulkImports::Groups::Pipelines::EpicsPipeline, :clean_gitlab_
expect(described_class.transformers)
.to contain_exactly(
{ klass: BulkImports::Common::Transformers::ProhibitedAttributesTransformer, options: nil },
{ klass: BulkImports::Common::Transformers::UserReferenceTransformer, options: { reference: :author } },
{ klass: BulkImports::Common::Transformers::UserReferenceTransformer, options: { reference: 'author' } },
{ klass: EE::BulkImports::Groups::Transformers::EpicAttributesTransformer, options: nil }
)
end
......
......@@ -12,7 +12,7 @@ module BulkImports
DEFAULT_REFERENCE = 'user'
def initialize(options = {})
@reference = options[:reference] || DEFAULT_REFERENCE
@reference = options[:reference].to_s.presence || DEFAULT_REFERENCE
@suffixed_reference = "#{@reference}_id"
end
......
......@@ -52,19 +52,26 @@ RSpec.describe BulkImports::Common::Transformers::UserReferenceTransformer do
end
context 'when custom reference is provided' do
it 'updates provided reference' do
hash = {
'author' => {
'public_email' => user.email
shared_examples 'updates provided reference' do |reference|
let(:hash) do
{
'author' => {
'public_email' => user.email
}
}
}
end
transformer = described_class.new(reference: 'author')
result = transformer.transform(context, hash)
it 'updates provided reference' do
transformer = described_class.new(reference: reference)
result = transformer.transform(context, hash)
expect(result['author']).to be_nil
expect(result['author_id']).to eq(user.id)
expect(result['author']).to be_nil
expect(result['author_id']).to eq(user.id)
end
end
include_examples 'updates provided reference', 'author'
include_examples 'updates provided reference', :author
end
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