2011-05-08 09:09:25 +04:00
|
|
|
# Redmine - project management software
|
|
|
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
2008-06-08 19:40:24 +04:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-05-08 09:09:25 +04:00
|
|
|
#
|
2008-06-08 19:40:24 +04:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2011-05-08 09:09:25 +04:00
|
|
|
#
|
2008-06-08 19:40:24 +04:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2010-12-13 02:24:34 +03:00
|
|
|
require File.expand_path('../../test_helper', __FILE__)
|
2008-06-08 19:40:24 +04:00
|
|
|
|
2009-09-13 21:14:35 +04:00
|
|
|
class RepositoryFilesystemTest < ActiveSupport::TestCase
|
2008-06-08 19:40:24 +04:00
|
|
|
fixtures :projects
|
2011-03-22 08:47:24 +03:00
|
|
|
|
2012-02-24 17:04:06 +04:00
|
|
|
include Redmine::I18n
|
|
|
|
|
2011-06-10 15:11:58 +04:00
|
|
|
REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
|
2011-03-22 08:47:24 +03:00
|
|
|
|
2008-06-08 19:40:24 +04:00
|
|
|
def setup
|
2011-03-22 08:48:06 +03:00
|
|
|
@project = Project.find(3)
|
2008-06-08 19:40:24 +04:00
|
|
|
Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
|
2011-05-21 05:10:47 +04:00
|
|
|
@repository = Repository::Filesystem.create(
|
|
|
|
:project => @project,
|
|
|
|
:url => REPOSITORY_PATH
|
|
|
|
)
|
|
|
|
assert @repository
|
2008-06-08 19:40:24 +04:00
|
|
|
end
|
2011-03-22 08:47:24 +03:00
|
|
|
|
2012-02-24 17:04:06 +04:00
|
|
|
def test_blank_root_directory_error_message
|
|
|
|
set_language_if_valid 'en'
|
|
|
|
repo = Repository::Filesystem.new(
|
|
|
|
:project => @project,
|
|
|
|
:identifier => 'test'
|
|
|
|
)
|
|
|
|
assert !repo.save
|
|
|
|
assert_include "Root directory can't be blank",
|
|
|
|
repo.errors.full_messages
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_blank_root_directory_error_message_fr
|
|
|
|
set_language_if_valid 'fr'
|
|
|
|
str = "R\xc3\xa9pertoire racine doit \xc3\xaatre renseign\xc3\xa9(e)"
|
|
|
|
str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
|
|
|
|
repo = Repository::Filesystem.new(
|
|
|
|
:project => @project,
|
|
|
|
:url => "",
|
|
|
|
:identifier => 'test',
|
|
|
|
:path_encoding => ''
|
|
|
|
)
|
|
|
|
assert !repo.save
|
|
|
|
assert_include str, repo.errors.full_messages
|
|
|
|
end
|
|
|
|
|
2011-05-08 09:09:25 +04:00
|
|
|
if File.directory?(REPOSITORY_PATH)
|
2008-06-08 19:40:24 +04:00
|
|
|
def test_fetch_changesets
|
2011-09-12 14:03:09 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
|
|
|
assert_equal 0, @repository.changes.count
|
2008-06-08 19:40:24 +04:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:03:09 +04:00
|
|
|
@project.reload
|
2008-06-08 19:40:24 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
|
|
|
assert_equal 0, @repository.changes.count
|
|
|
|
end
|
2011-03-22 08:47:24 +03:00
|
|
|
|
2008-06-08 19:40:24 +04:00
|
|
|
def test_entries
|
2011-03-22 18:30:19 +03:00
|
|
|
assert_equal 3, @repository.entries("", 2).size
|
2008-06-08 19:40:24 +04:00
|
|
|
assert_equal 2, @repository.entries("dir", 3).size
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_cat
|
|
|
|
assert_equal "TEST CAT\n", @repository.scm.cat("test")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
|
|
|
|
def test_fake; assert true end
|
|
|
|
end
|
|
|
|
end
|