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 / .svn / pristine / 87 / 87a01faa16db9719fa9af9f610ef19a85f7c0bc6.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (3.1 KB)

1 1296:038ba2d95de8 Chris
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
18
require File.expand_path('../../test_helper', __FILE__)
19
20
class RepositoryFilesystemTest < ActiveSupport::TestCase
21
  fixtures :projects
22
23
  include Redmine::I18n
24
25
  REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
26
27
  def setup
28
    @project = Project.find(3)
29
    Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
30
    @repository = Repository::Filesystem.create(
31
                               :project => @project,
32
                               :url     => REPOSITORY_PATH
33
                                 )
34
    assert @repository
35
  end
36
37
  def test_blank_root_directory_error_message
38
    set_language_if_valid 'en'
39
    repo = Repository::Filesystem.new(
40
                          :project      => @project,
41
                          :identifier   => 'test'
42
                        )
43
    assert !repo.save
44
    assert_include "Root directory can't be blank",
45
                   repo.errors.full_messages
46
  end
47
48
  def test_blank_root_directory_error_message_fr
49
    set_language_if_valid 'fr'
50
    str = "R\xc3\xa9pertoire racine doit \xc3\xaatre renseign\xc3\xa9(e)"
51
    str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
52
    repo = Repository::Filesystem.new(
53
                          :project      => @project,
54
                          :url          => "",
55
                          :identifier   => 'test',
56
                          :path_encoding => ''
57
                        )
58
    assert !repo.save
59
    assert_include str, repo.errors.full_messages
60
  end
61
62
  if File.directory?(REPOSITORY_PATH)
63
    def test_fetch_changesets
64
      assert_equal 0, @repository.changesets.count
65
      assert_equal 0, @repository.filechanges.count
66
      @repository.fetch_changesets
67
      @project.reload
68
      assert_equal 0, @repository.changesets.count
69
      assert_equal 0, @repository.filechanges.count
70
    end
71
72
    def test_entries
73
      entries = @repository.entries("", 2)
74
      assert_kind_of Redmine::Scm::Adapters::Entries, entries
75
      assert_equal 3, entries.size
76
    end
77
78
    def test_entries_in_directory
79
      assert_equal 2, @repository.entries("dir", 3).size
80
    end
81
82
    def test_cat
83
      assert_equal "TEST CAT\n", @repository.scm.cat("test")
84
    end
85
  else
86
    puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
87
    def test_fake; assert true end
88
  end
89
end