Mercurial > hg > soundsoftware-site
comparison test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | af80e5618e9b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 | |
2 require File.dirname(__FILE__) + '/../../../../../test_helper' | |
3 | |
4 | |
5 class FilesystemAdapterTest < ActiveSupport::TestCase | |
6 | |
7 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository' | |
8 | |
9 if File.directory?(REPOSITORY_PATH) | |
10 def setup | |
11 @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH) | |
12 end | |
13 | |
14 def test_entries | |
15 assert_equal 2, @adapter.entries.size | |
16 assert_equal ["dir", "test"], @adapter.entries.collect(&:name) | |
17 assert_equal ["dir", "test"], @adapter.entries(nil).collect(&:name) | |
18 assert_equal ["dir", "test"], @adapter.entries("/").collect(&:name) | |
19 ["dir", "/dir", "/dir/", "dir/"].each do |path| | |
20 assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name) | |
21 end | |
22 # If y try to use "..", the path is ignored | |
23 ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path| | |
24 assert_equal ["dir", "test"], @adapter.entries(path).collect(&:name), ".. must be ignored in path argument" | |
25 end | |
26 end | |
27 | |
28 def test_cat | |
29 assert_equal "TEST CAT\n", @adapter.cat("test") | |
30 assert_equal "TEST CAT\n", @adapter.cat("/test") | |
31 # Revision number is ignored | |
32 assert_equal "TEST CAT\n", @adapter.cat("/test", 1) | |
33 end | |
34 | |
35 else | |
36 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS." | |
37 def test_fake; assert true end | |
38 end | |
39 | |
40 end | |
41 | |
42 |