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:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-03-29 14:57:21 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2018-04-04 20:49:48 +0300
commite40c0085ef300aca38076af3ea2f227761084038 (patch)
tree46f24452583fe738e4e1117d8a7d149de078397d /spec/requests/api/project_import_spec.rb
parent11a9fbe65b22c334bc47edf0a23b89619766553d (diff)
Store override params as import data on projects
This means import data doesn't necessarily have to have an import_url anymore. The `ProjectImportData` could just contain the override data in it's serialized data attribute. The import data is automatically cleaned up after it is finished by the state machine.
Diffstat (limited to 'spec/requests/api/project_import_spec.rb')
-rw-r--r--spec/requests/api/project_import_spec.rb30
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb
index 987f6e26971..cf0c2aa903a 100644
--- a/spec/requests/api/project_import_spec.rb
+++ b/spec/requests/api/project_import_spec.rb
@@ -40,7 +40,7 @@ describe API::ProjectImport do
expect(response).to have_gitlab_http_status(201)
end
- it 'schedules an import at the user namespace level' do
+ it 'does not shedule an import for a nampespace that does not exist' do
expect_any_instance_of(Project).not_to receive(:import_schedule)
expect(::Projects::CreateService).not_to receive(:new)
@@ -71,6 +71,34 @@ describe API::ProjectImport do
expect(json_response['error']).to eq('file is invalid')
end
+ it 'allows overriding project params' do
+ stub_import(namespace)
+ override_params = { 'description' => 'Hello world' }
+
+ post api('/projects/import', user),
+ path: 'test-import',
+ file: fixture_file_upload(file),
+ namespace: namespace.id,
+ override_params: override_params
+ import_project = Project.find(json_response['id'])
+
+ expect(import_project.import_data.data['override_params']).to eq(override_params)
+ end
+
+ it 'does store params that are not allowed' do
+ stub_import(namespace)
+ override_params = { 'not_allowed' => 'Hello world' }
+
+ post api('/projects/import', user),
+ path: 'test-import',
+ file: fixture_file_upload(file),
+ namespace: namespace.id,
+ override_params: override_params
+ import_project = Project.find(json_response['id'])
+
+ expect(import_project.import_data.data['override_params']).to be_empty
+ end
+
def stub_import(namespace)
expect_any_instance_of(Project).to receive(:import_schedule)
expect(::Projects::CreateService).to receive(:new).with(user, hash_including(namespace_id: namespace.id)).and_call_original