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:
authorValery Sizov <valery@gitlab.com>2015-02-03 00:52:44 +0300
committerValery Sizov <valery@gitlab.com>2015-02-05 23:50:34 +0300
commit7ddba92a394b5e5fd67eda50b6ee25b38e53e7b9 (patch)
tree6881815924e2f0b07506e81f4ae6f9b9506c4035
parent5194214e3a2f97accf0c8119b4cb39fd4fcef5db (diff)
Gitlab integration: added tests
-rw-r--r--lib/gitlab/gitlab_import/project_creator.rb2
-rw-r--r--spec/lib/gitlab/gitlab_import/project_creator.rb25
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/gitlab/gitlab_import/project_creator.rb b/lib/gitlab/gitlab_import/project_creator.rb
index affd828e816..6424d56f8f1 100644
--- a/lib/gitlab/gitlab_import/project_creator.rb
+++ b/lib/gitlab/gitlab_import/project_creator.rb
@@ -19,7 +19,7 @@ module Gitlab
visibility_level: repo["visibility_level"],
import_type: "gitlab",
import_source: repo["path_with_namespace"],
- import_url: repo["http_url_to_repo"]#.sub("://", "://oauth2@#{current_user.gitlab_access_token}")
+ import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{current_user.gitlab_access_token}@")
)
if @project.save!
diff --git a/spec/lib/gitlab/gitlab_import/project_creator.rb b/spec/lib/gitlab/gitlab_import/project_creator.rb
new file mode 100644
index 00000000000..51f3534ed60
--- /dev/null
+++ b/spec/lib/gitlab/gitlab_import/project_creator.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe Gitlab::GitlabImport::ProjectCreator do
+ let(:user) { create(:user, gitlab_access_token: "asdffg") }
+ let(:repo) {{
+ name: 'vim',
+ path: 'vim',
+ visibility_level: Gitlab::VisibilityLevel::PRIVATE,
+ path_with_namespace: 'asd/vim',
+ http_url_to_repo: "https://gitlab.com/asd/vim.git",
+ owner: {name: "john"}}.with_indifferent_access
+ }
+ let(:namespace){ create(:namespace) }
+
+ it 'creates project' do
+ Project.any_instance.stub(:add_import_job)
+
+ project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user)
+ project_creator.execute
+ project = Project.last
+
+ project.import_url.should == "https://oauth2:asdffg@gitlab.com/asd/vim.git"
+ project.visibility_level.should == Gitlab::VisibilityLevel::PRIVATE
+ end
+end