Skip to content
Snippets Groups Projects
Commit d78771f6 authored by Illya Klymov's avatar Illya Klymov :rocket:
Browse files

Merge branch '249160-group-migration-import-one-group-frontend' into 'master'

Update controller and serializer entity for actually importing groups

See merge request !49697
parents 942be4c5 b6123526
No related branches found
No related tags found
No related merge requests found
Pipeline #229633728 passed with warnings
......@@ -57,7 +57,7 @@ def configure_params
end
def create_params
params.permit(:bulk_import, [*bulk_import_params])
params.permit(bulk_import: bulk_import_params)[:bulk_import]
end
def bulk_import_params
......@@ -127,7 +127,7 @@ def clear_session_data
def credentials
{
url: session[url_key],
access_token: [access_token_key]
access_token: session[access_token_key]
}
end
end
......@@ -12,4 +12,8 @@ class Import::BulkImportEntity < Grape::Entity
expose :full_path do |entity|
entity['full_path']
end
expose :web_url do |entity|
entity['web_url']
end
end
......@@ -57,8 +57,8 @@
let(:client_response) do
double(
parsed_response: [
{ 'id' => 1, 'full_name' => 'group1', 'full_path' => 'full/path/group1' },
{ 'id' => 2, 'full_name' => 'group2', 'full_path' => 'full/path/group2' }
{ 'id' => 1, 'full_name' => 'group1', 'full_path' => 'full/path/group1', 'web_url' => 'http://demo.host/full/path/group1' },
{ 'id' => 2, 'full_name' => 'group2', 'full_path' => 'full/path/group2', 'web_url' => 'http://demo.host/full/path/group1' }
]
)
end
......@@ -132,12 +132,27 @@
end
describe 'POST create' do
let(:instance_url) { "http://fake-intance" }
let(:pat) { "fake-pat" }
before do
session[:bulk_import_gitlab_access_token] = pat
session[:bulk_import_gitlab_url] = instance_url
end
it 'executes BulkImportService' do
expect_next_instance_of(BulkImportService) do |service|
bulk_import_params = [{ "source_type" => "group_entity",
"source_full_path" => "full_path",
"destination_name" =>
"destination_name",
"destination_namespace" => "root" }]
expect_next_instance_of(
BulkImportService, user, bulk_import_params, { url: instance_url, access_token: pat }) do |service|
expect(service).to receive(:execute)
end
post :create
post :create, params: { bulk_import: bulk_import_params }
expect(response).to have_gitlab_http_status(:ok)
end
......
......@@ -7,14 +7,15 @@
{
'id' => 1,
'full_name' => 'test',
'full_path' => 'full/path/test',
'full_path' => 'full/path/tes',
'web_url' => 'http://web.url/path',
'foo' => 'bar'
}
end
subject { described_class.represent(importable_data).as_json }
%w[id full_name full_path].each do |attribute|
%w[id full_name full_path web_url].each do |attribute|
it "exposes #{attribute}" do
expect(subject[attribute.to_sym]).to eq(importable_data[attribute])
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment