Commit 23c76715 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

let test adding repo for real

parent c902d83b
...@@ -3,7 +3,7 @@ require 'fileutils' ...@@ -3,7 +3,7 @@ require 'fileutils'
require_relative 'gitlab_config' require_relative 'gitlab_config'
class GitlabProjects class GitlabProjects
attr_accessor :project_name attr_reader :project_name, :full_path
def initialize def initialize
@command = ARGV.shift @command = ARGV.shift
...@@ -25,12 +25,12 @@ class GitlabProjects ...@@ -25,12 +25,12 @@ class GitlabProjects
protected protected
def add_project def add_project
FileUtils.mkdir_p(@full_path, mode: 0770) FileUtils.mkdir_p(full_path, mode: 0770)
cmd = "cd #{@full_path} && git init --bare && ln -s #{@hook_path} #{@full_path}/hooks/post-receive" cmd = "cd #{full_path} && git init --bare && ln -s #{@hook_path} #{full_path}/hooks/post-receive"
system(cmd) system(cmd)
end end
def rm_project def rm_project
FileUtils.rm_rf(@full_path) FileUtils.rm_rf(full_path)
end end
end end
...@@ -17,10 +17,21 @@ describe GitlabProjects do ...@@ -17,10 +17,21 @@ describe GitlabProjects do
before do before do
argv('add-project', 'gitlab-ci.git') argv('add-project', 'gitlab-ci.git')
@gl_projects = GitlabProjects.new @gl_projects = GitlabProjects.new
@gl_projects.stub(full_path: tmp_repo_path)
end
after do
FileUtils.rm_rf(tmp_repo_path)
end
it "should create a directory" do
@gl_projects.stub(system: true)
@gl_projects.send :add_project
File.exists?(tmp_repo_path).should be_true
end end
it "should receive valid cmd" do it "should receive valid cmd" do
valid_cmd = "cd /home/git/repositories/gitlab-ci.git && git init --bare && ln -s /home/git/gitlab-shell/hooks/post-receive /home/git/repositories/gitlab-ci.git/hooks/post-receive" valid_cmd = "cd #{tmp_repo_path} && git init --bare && ln -s /home/git/gitlab-shell/hooks/post-receive #{tmp_repo_path}/hooks/post-receive"
@gl_projects.should_receive(:system).with(valid_cmd) @gl_projects.should_receive(:system).with(valid_cmd)
@gl_projects.send :add_project @gl_projects.send :add_project
end end
...@@ -31,4 +42,8 @@ describe GitlabProjects do ...@@ -31,4 +42,8 @@ describe GitlabProjects do
ARGV[i] = arg ARGV[i] = arg
end end
end end
def tmp_repo_path
File.join(ROOT_PATH, 'tmp', 'gitlab-ci.git')
end
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