To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / test / unit / lib / redmine / scm / adapters / filesystem_adapter_test.rb @ 441:cbce1fd3b1b7

History | View | Annotate | Download (2.02 KB)

1 0:513646585e45 Chris
2 119:8661b858af72 Chris
require File.expand_path('../../../../../../test_helper', __FILE__)
3 0:513646585e45 Chris
4 441:cbce1fd3b1b7 Chris
class FilesystemAdapterTest < ActiveSupport::TestCase
5 0:513646585e45 Chris
6 441:cbce1fd3b1b7 Chris
  REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository'
7
8
  if File.directory?(REPOSITORY_PATH)
9 0:513646585e45 Chris
    def setup
10
      @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH)
11
    end
12 441:cbce1fd3b1b7 Chris
13 0:513646585e45 Chris
    def test_entries
14 441:cbce1fd3b1b7 Chris
      assert_equal 3, @adapter.entries.size
15
      assert_equal ["dir", "japanese", "test"], @adapter.entries.collect(&:name)
16
      assert_equal ["dir", "japanese", "test"], @adapter.entries(nil).collect(&:name)
17
      assert_equal ["dir", "japanese", "test"], @adapter.entries("/").collect(&:name)
18 0:513646585e45 Chris
      ["dir", "/dir", "/dir/", "dir/"].each do |path|
19
        assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name)
20
      end
21
      # If y try to use "..", the path is ignored
22
      ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path|
23 441:cbce1fd3b1b7 Chris
        assert_equal ["dir", "japanese", "test"], @adapter.entries(path).collect(&:name),
24
             ".. must be ignored in path argument"
25 0:513646585e45 Chris
      end
26
    end
27 441:cbce1fd3b1b7 Chris
28 0:513646585e45 Chris
    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 441:cbce1fd3b1b7 Chris
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
49 0:513646585e45 Chris
  else
50
    puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
51
    def test_fake; assert true end
52
  end
53
end