Commit 258aa3c05106ac14a545cfa08a8276989da6a529
- Diff rendering mode:
- inline
- side by side
|   | |||
| 63 | 63 | end | |
| 64 | 64 | ||
| 65 | 65 | it "archives the source tree" do | |
| 66 | @git.should_receive(:commit).and_return(true) | ||
| 67 | @git.should_receive(:archive_tar_gz).and_return("the data") | ||
| 66 | 68 | do_get | |
| 67 | 69 | response.should be_success | |
| 68 | 70 |
spec/models/repository_spec.rb
(29 / 26)
|   | |||
| 15 | 15 | }.merge(opts)) | |
| 16 | 16 | end | |
| 17 | 17 | ||
| 18 | def push_something | ||
| 19 | path = File.join(Dir.tmpdir, "gitorious.test") | ||
| 20 | FileUtils.mkpath(path) | ||
| 21 | |||
| 22 | Dir.chdir(path) do | ||
| 23 | File.open("something", "w") do |file| | ||
| 24 | file << "dummy #{rand}\n" | ||
| 25 | end | ||
| 26 | |||
| 27 | git = Grit::Git.new(File.join(path, ".git")) | ||
| 28 | git.init({}, "--shared") | ||
| 29 | git.add({}, "something") | ||
| 30 | git.commit({:m => true}, "message") | ||
| 31 | git.push({:all => true}, @repository.full_repository_path) | ||
| 32 | end | ||
| 33 | end | ||
| 34 | |||
| 35 | 18 | it "should have valid associations" do | |
| 36 | 19 | @repository.should have_valid_associations | |
| 37 | 20 | end | |
| … | … | ||
| 107 | 107 | target = @repository | |
| 108 | 108 | target_path = @repository.full_repository_path | |
| 109 | 109 | ||
| 110 | Repository.git_backend.should_receive(:clone).with(target.full_repository_path, | ||
| 110 | git_backend = mock("Git backend") | ||
| 111 | Repository.should_receive(:git_backend).and_return(git_backend) | ||
| 112 | git_backend.should_receive(:clone).with(target.full_repository_path, | ||
| 111 | 113 | source.full_repository_path).and_return(true) | |
| 114 | Repository.should_receive(:create_hooks).and_return(true) | ||
| 112 | 115 | ||
| 113 | push_something | ||
| 114 | Repository.clone_git_repository(target.gitdir, source.gitdir) | ||
| 116 | Repository.clone_git_repository(target.gitdir, source.gitdir).should be_true | ||
| 117 | end | ||
| 118 | |||
| 119 | it "should create the hooks" do | ||
| 120 | hooks = "/path/to/hooks" | ||
| 121 | path = "/path/to/repository" | ||
| 122 | base_path = "#{RAILS_ROOT}/data/hooks" | ||
| 115 | 123 | ||
| 116 | Dir.chdir(target_path) do | ||
| 117 | hooks = File.join(target_path, "hooks") | ||
| 118 | File.exist?(hooks).should == true | ||
| 119 | File.symlink?(hooks).should == true | ||
| 120 | File.symlink?(File.expand_path(File.readlink(hooks))).should == true | ||
| 121 | end | ||
| 124 | File.should_receive(:join).ordered.with(GitoriousConfig["repository_base_path"], ".hooks").and_return(hooks) | ||
| 125 | |||
| 126 | Dir.should_receive(:chdir).ordered.with(path).and_yield(nil) | ||
| 127 | |||
| 128 | File.should_receive(:symlink?).ordered.with(hooks).and_return(false) | ||
| 129 | File.should_receive(:exist?).ordered.with(hooks).and_return(false) | ||
| 130 | FileUtils.should_receive(:ln_s).ordered.with(base_path, hooks) | ||
| 131 | |||
| 132 | local_hooks = "/path/to/local/hooks" | ||
| 133 | File.should_receive(:join).ordered.with(path, "hooks").and_return(local_hooks) | ||
| 134 | |||
| 135 | File.should_receive(:exist?).ordered.with(local_hooks).and_return(true) | ||
| 136 | |||
| 137 | File.should_receive(:join).with(path, "description").ordered | ||
| 138 | |||
| 139 | File.should_receive(:open).ordered.and_return(true) | ||
| 140 | |||
| 141 | Repository.create_hooks(path).should be_true | ||
| 122 | 142 | end | |
| 123 | 143 | ||
| 124 | 144 | it "deletes a repository" do |

