##// END OF EJS Templates
scm: cvs: change project id of unit app test from 1 to 3....
Toshi MARUYAMA -
r4668:f922fa765fb2
parent child
Show More
@@ -1,66 +1,66
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 require 'pp'
19 require 'pp'
20 class RepositoryCvsTest < ActiveSupport::TestCase
20 class RepositoryCvsTest < ActiveSupport::TestCase
21 fixtures :projects
21 fixtures :projects
22
22
23 # No '..' in the repository path
23 # No '..' in the repository path
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
26 # CVS module
26 # CVS module
27 MODULE_NAME = 'test'
27 MODULE_NAME = 'test'
28
28
29 def setup
29 def setup
30 @project = Project.find(1)
30 @project = Project.find(3)
31 assert @repository = Repository::Cvs.create(:project => @project,
31 assert @repository = Repository::Cvs.create(:project => @project,
32 :root_url => REPOSITORY_PATH,
32 :root_url => REPOSITORY_PATH,
33 :url => MODULE_NAME)
33 :url => MODULE_NAME)
34 end
34 end
35
35
36 if File.directory?(REPOSITORY_PATH)
36 if File.directory?(REPOSITORY_PATH)
37 def test_fetch_changesets_from_scratch
37 def test_fetch_changesets_from_scratch
38 @repository.fetch_changesets
38 @repository.fetch_changesets
39 @repository.reload
39 @repository.reload
40
40
41 assert_equal 5, @repository.changesets.count
41 assert_equal 5, @repository.changesets.count
42 assert_equal 14, @repository.changes.count
42 assert_equal 14, @repository.changes.count
43 assert_not_nil @repository.changesets.find_by_comments('Two files changed')
43 assert_not_nil @repository.changesets.find_by_comments('Two files changed')
44 end
44 end
45
45
46 def test_fetch_changesets_incremental
46 def test_fetch_changesets_incremental
47 @repository.fetch_changesets
47 @repository.fetch_changesets
48 # Remove the 3 latest changesets
48 # Remove the 3 latest changesets
49 @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy)
49 @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy)
50 @repository.reload
50 @repository.reload
51 assert_equal 2, @repository.changesets.count
51 assert_equal 2, @repository.changesets.count
52
52
53 @repository.fetch_changesets
53 @repository.fetch_changesets
54 assert_equal 5, @repository.changesets.count
54 assert_equal 5, @repository.changesets.count
55 end
55 end
56
56
57 def test_deleted_files_should_not_be_listed
57 def test_deleted_files_should_not_be_listed
58 entries = @repository.entries('sources')
58 entries = @repository.entries('sources')
59 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
59 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
60 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
60 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
61 end
61 end
62 else
62 else
63 puts "CVS test repository NOT FOUND. Skipping unit tests !!!"
63 puts "CVS test repository NOT FOUND. Skipping unit tests !!!"
64 def test_fake; assert true end
64 def test_fake; assert true end
65 end
65 end
66 end
66 end
General Comments 0
You need to be logged in to leave comments. Login now