annotate .svn/pristine/5d/5da0b4c4bee024389ce63f0775bf42e759cc86ef.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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