##// END OF EJS Templates
Rails3: scm: filesystem: replace @repository.reload to @project.reload of test_fetch_changesets at unit model test...
Toshi MARUYAMA -
r7044:3b6c6a67803b
parent child
Show More
@@ -1,55 +1,57
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 REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
23 REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
24
24
25 def setup
25 def setup
26 @project = Project.find(3)
26 @project = Project.find(3)
27 Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
27 Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
28 @repository = Repository::Filesystem.create(
28 @repository = Repository::Filesystem.create(
29 :project => @project,
29 :project => @project,
30 :url => REPOSITORY_PATH
30 :url => REPOSITORY_PATH
31 )
31 )
32 assert @repository
32 assert @repository
33 end
33 end
34
34
35 if File.directory?(REPOSITORY_PATH)
35 if File.directory?(REPOSITORY_PATH)
36 def test_fetch_changesets
36 def test_fetch_changesets
37 assert_equal 0, @repository.changesets.count
38 assert_equal 0, @repository.changes.count
37 @repository.fetch_changesets
39 @repository.fetch_changesets
38 @repository.reload
40 @project.reload
39 assert_equal 0, @repository.changesets.count
41 assert_equal 0, @repository.changesets.count
40 assert_equal 0, @repository.changes.count
42 assert_equal 0, @repository.changes.count
41 end
43 end
42
44
43 def test_entries
45 def test_entries
44 assert_equal 3, @repository.entries("", 2).size
46 assert_equal 3, @repository.entries("", 2).size
45 assert_equal 2, @repository.entries("dir", 3).size
47 assert_equal 2, @repository.entries("dir", 3).size
46 end
48 end
47
49
48 def test_cat
50 def test_cat
49 assert_equal "TEST CAT\n", @repository.scm.cat("test")
51 assert_equal "TEST CAT\n", @repository.scm.cat("test")
50 end
52 end
51 else
53 else
52 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
54 puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
53 def test_fake; assert true end
55 def test_fake; assert true end
54 end
56 end
55 end
57 end
General Comments 0
You need to be logged in to leave comments. Login now