comparison test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb @ 523:0b6c82dead28 luisf

Merge from branch "cannam"
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 25 Jul 2011 14:23:37 +0100
parents cbce1fd3b1b7
children cbb26bc654de
comparison
equal deleted inserted replaced
318:f7c525dc7585 523:0b6c82dead28
1 1
2 require File.dirname(__FILE__) + '/../../../../../test_helper' 2 require File.expand_path('../../../../../../test_helper', __FILE__)
3
4 3
5 class FilesystemAdapterTest < ActiveSupport::TestCase 4 class FilesystemAdapterTest < ActiveSupport::TestCase
6 5
7 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository' 6 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository'
8 7
9 if File.directory?(REPOSITORY_PATH) 8 if File.directory?(REPOSITORY_PATH)
10 def setup 9 def setup
11 @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH) 10 @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH)
12 end 11 end
13 12
14 def test_entries 13 def test_entries
15 assert_equal 2, @adapter.entries.size 14 assert_equal 3, @adapter.entries.size
16 assert_equal ["dir", "test"], @adapter.entries.collect(&:name) 15 assert_equal ["dir", "japanese", "test"], @adapter.entries.collect(&:name)
17 assert_equal ["dir", "test"], @adapter.entries(nil).collect(&:name) 16 assert_equal ["dir", "japanese", "test"], @adapter.entries(nil).collect(&:name)
18 assert_equal ["dir", "test"], @adapter.entries("/").collect(&:name) 17 assert_equal ["dir", "japanese", "test"], @adapter.entries("/").collect(&:name)
19 ["dir", "/dir", "/dir/", "dir/"].each do |path| 18 ["dir", "/dir", "/dir/", "dir/"].each do |path|
20 assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name) 19 assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name)
21 end 20 end
22 # If y try to use "..", the path is ignored 21 # If y try to use "..", the path is ignored
23 ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path| 22 ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path|
24 assert_equal ["dir", "test"], @adapter.entries(path).collect(&:name), ".. must be ignored in path argument" 23 assert_equal ["dir", "japanese", "test"], @adapter.entries(path).collect(&:name),
24 ".. must be ignored in path argument"
25 end 25 end
26 end 26 end
27 27
28 def test_cat 28 def test_cat
29 assert_equal "TEST CAT\n", @adapter.cat("test") 29 assert_equal "TEST CAT\n", @adapter.cat("test")
30 assert_equal "TEST CAT\n", @adapter.cat("/test") 30 assert_equal "TEST CAT\n", @adapter.cat("/test")
31 # Revision number is ignored 31 # Revision number is ignored
32 assert_equal "TEST CAT\n", @adapter.cat("/test", 1) 32 assert_equal "TEST CAT\n", @adapter.cat("/test", 1)
33 end 33 end
34 34
35 def test_path_encoding_default_utf8
36 adpt1 = Redmine::Scm::Adapters::FilesystemAdapter.new(
37 REPOSITORY_PATH
38 )
39 assert_equal "UTF-8", adpt1.path_encoding
40 adpt2 = Redmine::Scm::Adapters::FilesystemAdapter.new(
41 REPOSITORY_PATH,
42 nil,
43 nil,
44 nil,
45 ""
46 )
47 assert_equal "UTF-8", adpt2.path_encoding
48 end
35 else 49 else
36 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS." 50 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
37 def test_fake; assert true end 51 def test_fake; assert true end
38 end 52 end
39
40 end 53 end
41
42