@@ -1,57 +1,84 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class RepositoryFilesystemTest < ActiveSupport::TestCase |
|
20 | class RepositoryFilesystemTest < ActiveSupport::TestCase | |
21 | fixtures :projects |
|
21 | fixtures :projects | |
22 |
|
22 | |||
|
23 | include Redmine::I18n | |||
|
24 | ||||
23 | REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s |
|
25 | REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s | |
24 |
|
26 | |||
25 | def setup |
|
27 | def setup | |
26 | @project = Project.find(3) |
|
28 | @project = Project.find(3) | |
27 | Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem') |
|
29 | Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem') | |
28 | @repository = Repository::Filesystem.create( |
|
30 | @repository = Repository::Filesystem.create( | |
29 | :project => @project, |
|
31 | :project => @project, | |
30 | :url => REPOSITORY_PATH |
|
32 | :url => REPOSITORY_PATH | |
31 | ) |
|
33 | ) | |
32 | assert @repository |
|
34 | assert @repository | |
33 | end |
|
35 | end | |
34 |
|
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 | ||||
35 | if File.directory?(REPOSITORY_PATH) |
|
62 | if File.directory?(REPOSITORY_PATH) | |
36 | def test_fetch_changesets |
|
63 | def test_fetch_changesets | |
37 | assert_equal 0, @repository.changesets.count |
|
64 | assert_equal 0, @repository.changesets.count | |
38 | assert_equal 0, @repository.changes.count |
|
65 | assert_equal 0, @repository.changes.count | |
39 | @repository.fetch_changesets |
|
66 | @repository.fetch_changesets | |
40 | @project.reload |
|
67 | @project.reload | |
41 | assert_equal 0, @repository.changesets.count |
|
68 | assert_equal 0, @repository.changesets.count | |
42 | assert_equal 0, @repository.changes.count |
|
69 | assert_equal 0, @repository.changes.count | |
43 | end |
|
70 | end | |
44 |
|
71 | |||
45 | def test_entries |
|
72 | def test_entries | |
46 | assert_equal 3, @repository.entries("", 2).size |
|
73 | assert_equal 3, @repository.entries("", 2).size | |
47 | assert_equal 2, @repository.entries("dir", 3).size |
|
74 | assert_equal 2, @repository.entries("dir", 3).size | |
48 | end |
|
75 | end | |
49 |
|
76 | |||
50 | def test_cat |
|
77 | def test_cat | |
51 | assert_equal "TEST CAT\n", @repository.scm.cat("test") |
|
78 | assert_equal "TEST CAT\n", @repository.scm.cat("test") | |
52 | end |
|
79 | end | |
53 | else |
|
80 | else | |
54 | puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS." |
|
81 | puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS." | |
55 | def test_fake; assert true end |
|
82 | def test_fake; assert true end | |
56 | end |
|
83 | end | |
57 | end |
|
84 | end |
General Comments 0
You need to be logged in to leave comments.
Login now