Commit d624ab80 authored by Illya Klymov's avatar Illya Klymov

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

Update controller and serializer entity for actually importing groups

See merge request gitlab-org/gitlab!49697
parents c9f1648c 336ebb41
...@@ -57,7 +57,7 @@ class Import::BulkImportsController < ApplicationController ...@@ -57,7 +57,7 @@ class Import::BulkImportsController < ApplicationController
end end
def create_params def create_params
params.permit(:bulk_import, [*bulk_import_params]) params.permit(bulk_import: bulk_import_params)[:bulk_import]
end end
def bulk_import_params def bulk_import_params
...@@ -127,7 +127,7 @@ class Import::BulkImportsController < ApplicationController ...@@ -127,7 +127,7 @@ class Import::BulkImportsController < ApplicationController
def credentials def credentials
{ {
url: session[url_key], url: session[url_key],
access_token: [access_token_key] access_token: session[access_token_key]
} }
end end
end end
...@@ -12,4 +12,8 @@ class Import::BulkImportEntity < Grape::Entity ...@@ -12,4 +12,8 @@ class Import::BulkImportEntity < Grape::Entity
expose :full_path do |entity| expose :full_path do |entity|
entity['full_path'] entity['full_path']
end end
expose :web_url do |entity|
entity['web_url']
end
end end
...@@ -57,8 +57,8 @@ RSpec.describe Import::BulkImportsController do ...@@ -57,8 +57,8 @@ RSpec.describe Import::BulkImportsController do
let(:client_response) do let(:client_response) do
double( double(
parsed_response: [ parsed_response: [
{ 'id' => 1, 'full_name' => 'group1', 'full_path' => 'full/path/group1' }, { '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' } { 'id' => 2, 'full_name' => 'group2', 'full_path' => 'full/path/group2', 'web_url' => 'http://demo.host/full/path/group1' }
] ]
) )
end end
...@@ -132,12 +132,27 @@ RSpec.describe Import::BulkImportsController do ...@@ -132,12 +132,27 @@ RSpec.describe Import::BulkImportsController do
end end
describe 'POST create' do 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 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) expect(service).to receive(:execute)
end end
post :create post :create, params: { bulk_import: bulk_import_params }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
......
...@@ -7,14 +7,15 @@ RSpec.describe Import::BulkImportEntity do ...@@ -7,14 +7,15 @@ RSpec.describe Import::BulkImportEntity do
{ {
'id' => 1, 'id' => 1,
'full_name' => 'test', 'full_name' => 'test',
'full_path' => 'full/path/test', 'full_path' => 'full/path/tes',
'web_url' => 'http://web.url/path',
'foo' => 'bar' 'foo' => 'bar'
} }
end end
subject { described_class.represent(importable_data).as_json } 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 it "exposes #{attribute}" do
expect(subject[attribute.to_sym]).to eq(importable_data[attribute]) expect(subject[attribute.to_sym]).to eq(importable_data[attribute])
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