summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-03-30 21:24:50 +0000
committerJames Lopez <james@jameslopez.es>2017-04-03 12:45:00 +0200
commit398f16b6579891572baae09e9f1b8ac386c858b2 (patch)
treea2e45d7c092bad79110b901ccdb934ea67da90a0
parente719c46b3f6520099bf66a9479c93fbf6a30c35a (diff)
downloadgitlab-ce-398f16b6579891572baae09e9f1b8ac386c858b2.tar.gz
Merge branch '30289-allow-users-to-import-github-projects-to-subgroups' into 'master'
Allow users to import GitHub projects to subgroups Closes #30289 and #30148 See merge request !10344
-rw-r--r--app/controllers/import/base_controller.rb2
-rw-r--r--changelogs/unreleased/30289-allow-users-to-import-github-projects-to-subgroups.yml4
-rw-r--r--spec/support/controllers/githubish_import_controller_shared_examples.rb14
3 files changed, 19 insertions, 1 deletions
diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb
index 256c41e6145..eeee027ef2d 100644
--- a/app/controllers/import/base_controller.rb
+++ b/app/controllers/import/base_controller.rb
@@ -11,7 +11,7 @@ class Import::BaseController < ApplicationController
namespace.add_owner(current_user)
namespace
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
- Namespace.find_by_path_or_name(name)
+ Namespace.find_by_full_path(name)
end
end
end
diff --git a/changelogs/unreleased/30289-allow-users-to-import-github-projects-to-subgroups.yml b/changelogs/unreleased/30289-allow-users-to-import-github-projects-to-subgroups.yml
new file mode 100644
index 00000000000..a33382a85e3
--- /dev/null
+++ b/changelogs/unreleased/30289-allow-users-to-import-github-projects-to-subgroups.yml
@@ -0,0 +1,4 @@
+---
+title: Allow users to import GitHub projects to subgroups
+merge_request:
+author:
diff --git a/spec/support/controllers/githubish_import_controller_shared_examples.rb b/spec/support/controllers/githubish_import_controller_shared_examples.rb
index d0fd2d52004..51f1015f43c 100644
--- a/spec/support/controllers/githubish_import_controller_shared_examples.rb
+++ b/spec/support/controllers/githubish_import_controller_shared_examples.rb
@@ -228,5 +228,19 @@ shared_examples 'a GitHub-ish import controller: POST create' do
post :create, { new_name: test_name, format: :js }
end
end
+
+ context 'user has chosen a nested namespace and name for the project' do
+ let(:parent_namespace) { create(:namespace, name: 'foo', owner: user) }
+ let(:nested_namespace) { create(:namespace, name: 'bar', parent: parent_namespace, owner: user) }
+ let(:test_name) { 'test_name' }
+
+ it 'takes the selected namespace and name' do
+ expect(Gitlab::GithubImport::ProjectCreator).
+ to receive(:new).with(provider_repo, test_name, nested_namespace, user, access_params, type: provider).
+ and_return(double(execute: true))
+
+ post :create, { target_namespace: nested_namespace.full_path, new_name: test_name, format: :js }
+ end
+ end
end
end