To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 5d / 5da0b4c4bee024389ce63f0775bf42e759cc86ef.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (2 KB)
| 1 |
|
|---|---|
| 2 |
require File.expand_path('../../../../../../test_helper', __FILE__)
|
| 3 |
|
| 4 |
class FilesystemAdapterTest < ActiveSupport::TestCase |
| 5 |
REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
|
| 6 |
|
| 7 |
if File.directory?(REPOSITORY_PATH) |
| 8 |
def setup |
| 9 |
@adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH) |
| 10 |
end |
| 11 |
|
| 12 |
def test_entries |
| 13 |
assert_equal 3, @adapter.entries.size |
| 14 |
assert_equal ["dir", "japanese", "test"], @adapter.entries.collect(&:name) |
| 15 |
assert_equal ["dir", "japanese", "test"], @adapter.entries(nil).collect(&:name) |
| 16 |
assert_equal ["dir", "japanese", "test"], @adapter.entries("/").collect(&:name)
|
| 17 |
["dir", "/dir", "/dir/", "dir/"].each do |path| |
| 18 |
assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name) |
| 19 |
end |
| 20 |
# If y try to use "..", the path is ignored |
| 21 |
["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path| |
| 22 |
assert_equal ["dir", "japanese", "test"], @adapter.entries(path).collect(&:name), |
| 23 |
".. must be ignored in path argument" |
| 24 |
end |
| 25 |
end |
| 26 |
|
| 27 |
def test_cat |
| 28 |
assert_equal "TEST CAT\n", @adapter.cat("test")
|
| 29 |
assert_equal "TEST CAT\n", @adapter.cat("/test")
|
| 30 |
# Revision number is ignored |
| 31 |
assert_equal "TEST CAT\n", @adapter.cat("/test", 1)
|
| 32 |
end |
| 33 |
|
| 34 |
def test_path_encoding_default_utf8 |
| 35 |
adpt1 = Redmine::Scm::Adapters::FilesystemAdapter.new( |
| 36 |
REPOSITORY_PATH |
| 37 |
) |
| 38 |
assert_equal "UTF-8", adpt1.path_encoding |
| 39 |
adpt2 = Redmine::Scm::Adapters::FilesystemAdapter.new( |
| 40 |
REPOSITORY_PATH, |
| 41 |
nil, |
| 42 |
nil, |
| 43 |
nil, |
| 44 |
"" |
| 45 |
) |
| 46 |
assert_equal "UTF-8", adpt2.path_encoding |
| 47 |
end |
| 48 |
else |
| 49 |
puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS." |
| 50 |
def test_fake; assert true end |
| 51 |
end |
| 52 |
end |