annotate test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb @ 1474:c4436fec34bf bug_494

Close obsolete branch bug_494
author Chris Cannam
date Sat, 10 Nov 2012 13:57:53 +0000
parents cbb26bc654de
children 433d4f72a19b
rev   line source
Chris@0 1
Chris@119 2 require File.expand_path('../../../../../../test_helper', __FILE__)
Chris@0 3
Chris@441 4 class FilesystemAdapterTest < ActiveSupport::TestCase
Chris@909 5 REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
Chris@441 6
Chris@441 7 if File.directory?(REPOSITORY_PATH)
Chris@0 8 def setup
Chris@0 9 @adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH)
Chris@0 10 end
Chris@441 11
Chris@0 12 def test_entries
Chris@441 13 assert_equal 3, @adapter.entries.size
Chris@441 14 assert_equal ["dir", "japanese", "test"], @adapter.entries.collect(&:name)
Chris@441 15 assert_equal ["dir", "japanese", "test"], @adapter.entries(nil).collect(&:name)
Chris@441 16 assert_equal ["dir", "japanese", "test"], @adapter.entries("/").collect(&:name)
Chris@0 17 ["dir", "/dir", "/dir/", "dir/"].each do |path|
Chris@0 18 assert_equal ["subdir", "dirfile"], @adapter.entries(path).collect(&:name)
Chris@0 19 end
Chris@0 20 # If y try to use "..", the path is ignored
Chris@0 21 ["/../","dir/../", "..", "../", "/..", "dir/.."].each do |path|
Chris@441 22 assert_equal ["dir", "japanese", "test"], @adapter.entries(path).collect(&:name),
Chris@441 23 ".. must be ignored in path argument"
Chris@0 24 end
Chris@0 25 end
Chris@441 26
Chris@0 27 def test_cat
Chris@0 28 assert_equal "TEST CAT\n", @adapter.cat("test")
Chris@0 29 assert_equal "TEST CAT\n", @adapter.cat("/test")
Chris@0 30 # Revision number is ignored
Chris@0 31 assert_equal "TEST CAT\n", @adapter.cat("/test", 1)
Chris@0 32 end
Chris@441 33
Chris@441 34 def test_path_encoding_default_utf8
Chris@441 35 adpt1 = Redmine::Scm::Adapters::FilesystemAdapter.new(
Chris@441 36 REPOSITORY_PATH
Chris@441 37 )
Chris@441 38 assert_equal "UTF-8", adpt1.path_encoding
Chris@441 39 adpt2 = Redmine::Scm::Adapters::FilesystemAdapter.new(
Chris@441 40 REPOSITORY_PATH,
Chris@441 41 nil,
Chris@441 42 nil,
Chris@441 43 nil,
Chris@441 44 ""
Chris@441 45 )
Chris@441 46 assert_equal "UTF-8", adpt2.path_encoding
Chris@441 47 end
Chris@0 48 else
Chris@0 49 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
Chris@0 50 def test_fake; assert true end
Chris@0 51 end
Chris@0 52 end