summaryrefslogtreecommitdiff
path: root/spec/controllers/import
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-08-08 15:05:58 +0200
committerJames Lopez <james@jameslopez.es>2016-09-20 10:14:39 +0200
commit0c65112da79e177da3574458c3bb5befc349fd30 (patch)
treef3715fa7342143d1fd7bd53278c3ecf279e87c49 /spec/controllers/import
parent95b9421ad3b2678da6e0af0131eafd52cdd0b2a5 (diff)
downloadgitlab-ce-0c65112da79e177da3574458c3bb5befc349fd30.tar.gz
modify github import JS and controller so we can now specify a namespace and/or name for a project.
- Fixed and added specs. - Added different namespace options depending on user privilages - Updated docs.
Diffstat (limited to 'spec/controllers/import')
-rw-r--r--spec/controllers/import/github_controller_spec.rb46
1 files changed, 34 insertions, 12 deletions
diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb
index ebfbf54182b..4f96567192d 100644
--- a/spec/controllers/import/github_controller_spec.rb
+++ b/spec/controllers/import/github_controller_spec.rb
@@ -124,8 +124,8 @@ describe Import::GithubController do
context "when the GitHub user and GitLab user's usernames match" do
it "takes the current user's namespace" do
expect(Gitlab::GithubImport::ProjectCreator).
- to receive(:new).with(github_repo, user.namespace, user, access_params).
- and_return(double(execute: true))
+ to receive(:new).with(github_repo, github_repo.name, user.namespace, user, access_params).
+ and_return(double(execute: true))
post :create, format: :js
end
@@ -136,8 +136,8 @@ describe Import::GithubController do
it "takes the current user's namespace" do
expect(Gitlab::GithubImport::ProjectCreator).
- to receive(:new).with(github_repo, user.namespace, user, access_params).
- and_return(double(execute: true))
+ to receive(:new).with(github_repo, github_repo.name, user.namespace, user, access_params).
+ and_return(double(execute: true))
post :create, format: :js
end
@@ -158,8 +158,8 @@ describe Import::GithubController do
context "when the namespace is owned by the GitLab user" do
it "takes the existing namespace" do
expect(Gitlab::GithubImport::ProjectCreator).
- to receive(:new).with(github_repo, existing_namespace, user, access_params).
- and_return(double(execute: true))
+ to receive(:new).with(github_repo, github_repo.name, existing_namespace, user, access_params).
+ and_return(double(execute: true))
post :create, format: :js
end
@@ -171,9 +171,10 @@ describe Import::GithubController do
existing_namespace.save
end
- it "doesn't create a project" do
+ it "creates a project using user's namespace" do
expect(Gitlab::GithubImport::ProjectCreator).
- not_to receive(:new)
+ to receive(:new).with(github_repo, github_repo.name, user.namespace, user, access_params).
+ and_return(double(execute: true))
post :create, format: :js
end
@@ -186,15 +187,15 @@ describe Import::GithubController do
expect(Gitlab::GithubImport::ProjectCreator).
to receive(:new).and_return(double(execute: true))
- expect { post :create, format: :js }.to change(Namespace, :count).by(1)
+ expect { post :create, target_namespace: github_repo.name, format: :js }.to change(Namespace, :count).by(1)
end
it "takes the new namespace" do
expect(Gitlab::GithubImport::ProjectCreator).
- to receive(:new).with(github_repo, an_instance_of(Group), user, access_params).
+ to receive(:new).with(github_repo, github_repo.name, an_instance_of(Group), user, access_params).
and_return(double(execute: true))
- post :create, format: :js
+ post :create, target_namespace: github_repo.name, format: :js
end
end
@@ -212,13 +213,34 @@ describe Import::GithubController do
it "takes the current user's namespace" do
expect(Gitlab::GithubImport::ProjectCreator).
- to receive(:new).with(github_repo, user.namespace, user, access_params).
+ to receive(:new).with(github_repo, github_repo.name, user.namespace, user, access_params).
and_return(double(execute: true))
post :create, format: :js
end
end
end
+
+ context 'user has chosen a namespace and name for the project' do
+ let(:test_namespace) { create(:namespace, name: 'test_namespace', owner: user) }
+ let(:test_name) { 'test_name' }
+
+ it 'takes the selected namespace and name' do
+ expect(Gitlab::GithubImport::ProjectCreator).
+ to receive(:new).with(github_repo, test_name, test_namespace, user, access_params).
+ and_return(double(execute: true))
+
+ post :create, { target_namespace: test_namespace.name, new_name: test_name, format: :js }
+ end
+
+ it 'takes the selected name and default namespace' do
+ expect(Gitlab::GithubImport::ProjectCreator).
+ to receive(:new).with(github_repo, test_name, user.namespace, user, access_params).
+ and_return(double(execute: true))
+
+ post :create, { new_name: test_name, format: :js }
+ end
+ end
end
end
end