Commit 0b2c43decb49b449f02379b474c6c68859356554

Refactored GitBackend

Signed-off-by: David A. Cuadrado <krawek@gmail.com>
  
1212 FileUtils.mkdir_p(@repository.full_repository_path, :mode => 0755)
1313 end
1414
15 def push_something
16 path = File.join(Dir.tmpdir, "gitorious.test")
17 FileUtils.mkpath(path)
18
19 Dir.chdir(path) do
20 File.open("something", "w") do |file|
21 file << "dummy #{rand}\n"
22 end
23
24 git = Grit::Git.new(File.join(path, ".git"))
25 git.init({}, "--shared")
26 git.add({}, "something")
27 git.commit({:m => true}, "message")
28 git.push({:all => true}, @repository.full_repository_path)
29 end
30 end
31
32
3315 it "creates a bare git repository" do
3416 path = @repository.full_repository_path
3517 FileUtils.should_receive(:mkdir_p).with(path, :mode => 0750).and_return(true)
3618 FileUtils.should_receive(:touch).with(File.join(path, "git-daemon-export-ok"))
37# GitBackend.should_receive(:execute_command).with(
38# %Q{chmod +x #{File.join(path, "hooks/post-update")}}
39# ).and_return(true)
19
4020 GitBackend.should_receive(:execute_command).with(
4121 %Q{GIT_DIR="#{path}" git-update-server-info}
4222 ).and_return(true)
2828 source_path = @repository.full_repository_path
2929 target_path = repositories(:johans).full_repository_path
3030 FileUtils.should_receive(:touch).with(File.join(target_path, "git-daemon-export-ok"))
31# GitBackend.should_receive(:execute_command).with(
32# %Q{chmod +x #{File.join(target_path, "hooks/post-update")}}
33# ).and_return(true)
31
3432 GitBackend.should_receive(:execute_command).with(
3533 %Q{GIT_DIR="#{target_path}" git-update-server-info}
3634 ).and_return(true)
37
38 push_something
35
36 git = mock("Grit::Git instance")
37 Grit::Git.should_receive(:new).and_return(git)
38 git.should_receive(:clone)
39
3940 GitBackend.clone(target_path, source_path)
40# File.exist?(File.join(target_path, "hooks")).should == false
4141 end
4242
4343 it "deletes a git repository" do