Commit 0b2c43decb49b449f02379b474c6c68859356554
- Diff rendering mode:
- inline
- side by side
spec/models/git_backend_spec.rb
(7 / 27)
|   | |||
| 12 | 12 | FileUtils.mkdir_p(@repository.full_repository_path, :mode => 0755) | |
| 13 | 13 | end | |
| 14 | 14 | ||
| 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 | |||
| 33 | 15 | it "creates a bare git repository" do | |
| 34 | 16 | path = @repository.full_repository_path | |
| 35 | 17 | FileUtils.should_receive(:mkdir_p).with(path, :mode => 0750).and_return(true) | |
| 36 | 18 | 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 | |||
| 40 | 20 | GitBackend.should_receive(:execute_command).with( | |
| 41 | 21 | %Q{GIT_DIR="#{path}" git-update-server-info} | |
| 42 | 22 | ).and_return(true) | |
| … | … | ||
| 28 | 28 | source_path = @repository.full_repository_path | |
| 29 | 29 | target_path = repositories(:johans).full_repository_path | |
| 30 | 30 | 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 | |||
| 34 | 32 | GitBackend.should_receive(:execute_command).with( | |
| 35 | 33 | %Q{GIT_DIR="#{target_path}" git-update-server-info} | |
| 36 | 34 | ).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 | |||
| 39 | 40 | GitBackend.clone(target_path, source_path) | |
| 40 | # File.exist?(File.join(target_path, "hooks")).should == false | ||
| 41 | 41 | end | |
| 42 | 42 | ||
| 43 | 43 | it "deletes a git repository" do |

