##// END OF EJS Templates
Fixed failing subversion test....
Jean-Philippe Lang -
r4501:29fddddaf1b2
parent child
Show More
@@ -1,146 +1,137
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
19
20 class RepositorySubversionTest < ActiveSupport::TestCase
20 class RepositorySubversionTest < ActiveSupport::TestCase
21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
22
22
23 def setup
23 def setup
24 @project = Project.find(1)
24 @project = Project.find(1)
25 assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}")
25 assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}")
26 end
26 end
27
27
28 if repository_configured?('subversion')
28 if repository_configured?('subversion')
29 def test_fetch_changesets_from_scratch
29 def test_fetch_changesets_from_scratch
30 @repository.fetch_changesets
30 @repository.fetch_changesets
31 @repository.reload
31 @repository.reload
32
32
33 assert_equal 11, @repository.changesets.count
33 assert_equal 11, @repository.changesets.count
34 assert_equal 20, @repository.changes.count
34 assert_equal 20, @repository.changes.count
35 assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
35 assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
36 end
36 end
37
37
38 def test_fetch_changesets_incremental
38 def test_fetch_changesets_incremental
39 @repository.fetch_changesets
39 @repository.fetch_changesets
40 # Remove changesets with revision > 5
40 # Remove changesets with revision > 5
41 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
41 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
42 @repository.reload
42 @repository.reload
43 assert_equal 5, @repository.changesets.count
43 assert_equal 5, @repository.changesets.count
44
44
45 @repository.fetch_changesets
45 @repository.fetch_changesets
46 assert_equal 11, @repository.changesets.count
46 assert_equal 11, @repository.changesets.count
47 end
47 end
48
48
49 def test_latest_changesets
49 def test_latest_changesets
50 @repository.fetch_changesets
50 @repository.fetch_changesets
51
51
52 # with limit
52 # with limit
53 changesets = @repository.latest_changesets('', nil, 2)
53 changesets = @repository.latest_changesets('', nil, 2)
54 assert_equal 2, changesets.size
54 assert_equal 2, changesets.size
55 assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets
55 assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets
56
56
57 # with path
57 # with path
58 changesets = @repository.latest_changesets('subversion_test/folder', nil)
58 changesets = @repository.latest_changesets('subversion_test/folder', nil)
59 assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision)
59 assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision)
60
60
61 # with path and revision
61 # with path and revision
62 changesets = @repository.latest_changesets('subversion_test/folder', 8)
62 changesets = @repository.latest_changesets('subversion_test/folder', 8)
63 assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision)
63 assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision)
64 end
64 end
65
65
66 def test_directory_listing_with_square_brackets_in_path
66 def test_directory_listing_with_square_brackets_in_path
67 @repository.fetch_changesets
67 @repository.fetch_changesets
68 @repository.reload
68 @repository.reload
69
69
70 entries = @repository.entries('subversion_test/[folder_with_brackets]')
70 entries = @repository.entries('subversion_test/[folder_with_brackets]')
71 assert_not_nil entries, 'Expect to find entries in folder_with_brackets'
71 assert_not_nil entries, 'Expect to find entries in folder_with_brackets'
72 assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets'
72 assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets'
73 assert_equal 'README.txt', entries.first.name
73 assert_equal 'README.txt', entries.first.name
74 end
74 end
75
75
76 def test_directory_listing_with_square_brackets_in_base
76 def test_directory_listing_with_square_brackets_in_base
77 @project = Project.find(1)
77 @project = Project.find(1)
78 @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]")
78 @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]")
79
79
80 @repository.fetch_changesets
80 @repository.fetch_changesets
81 @repository.reload
81 @repository.reload
82
82
83 assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision'
83 assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision'
84 assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add'
84 assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add'
85
85
86 entries = @repository.entries('')
86 entries = @repository.entries('')
87 assert_not_nil entries, 'Expect to find entries'
87 assert_not_nil entries, 'Expect to find entries'
88 assert_equal 1, entries.size, 'Expect a single entry'
88 assert_equal 1, entries.size, 'Expect a single entry'
89 assert_equal 'README.txt', entries.first.name
89 assert_equal 'README.txt', entries.first.name
90 end
90 end
91
91
92 def test_identifier
92 def test_identifier
93 @repository.fetch_changesets
93 @repository.fetch_changesets
94 @repository.reload
94 @repository.reload
95 c = @repository.changesets.find_by_revision('1')
95 c = @repository.changesets.find_by_revision('1')
96 assert_equal c.revision, c.identifier
96 assert_equal c.revision, c.identifier
97 end
97 end
98
98
99 def test_identifier_nine_digit
99 def test_identifier_nine_digit
100 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
100 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
101 :revision => '123456789', :comments => 'test')
101 :revision => '123456789', :comments => 'test')
102 assert_equal c.identifier, c.revision
102 assert_equal c.identifier, c.revision
103 end
103 end
104
104
105 def test_format_identifier
105 def test_format_identifier
106 @repository.fetch_changesets
106 @repository.fetch_changesets
107 @repository.reload
107 @repository.reload
108 c = @repository.changesets.find_by_revision('1')
108 c = @repository.changesets.find_by_revision('1')
109 assert_equal c.format_identifier, c.revision
109 assert_equal c.format_identifier, c.revision
110 end
110 end
111
111
112 def test_format_identifier_nine_digit
112 def test_format_identifier_nine_digit
113 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
113 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
114 :revision => '123456789', :comments => 'test')
114 :revision => '123456789', :comments => 'test')
115 assert_equal c.format_identifier, c.revision
115 assert_equal c.format_identifier, c.revision
116 end
116 end
117
117
118 def test_activities
118 def test_activities
119 @repository.fetch_changesets
119 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
120 @repository.reload
120 :revision => '1', :comments => 'test')
121 f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1))
121
122 f.scope = ['changesets']
122 assert c.event_title.include?('1:'), c.event_title
123 events = f.events
123 assert_equal c.event_url[:rev], '1'
124 assert_kind_of Array, events
125 eve = events[-9]
126 assert eve.event_title.include?('1:')
127 assert_equal eve.event_url[:rev], '1'
128 end
124 end
129
125
130 def test_activities_nine_digit
126 def test_activities_nine_digit
131 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
127 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
132 :revision => '123456789', :comments => 'test')
128 :revision => '123456789', :comments => 'test')
133 assert( c.save )
129
134 f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1))
130 assert c.event_title.include?('123456789:')
135 f.scope = ['changesets']
131 assert_equal c.event_url[:rev], '123456789'
136 events = f.events
137 assert_kind_of Array, events
138 eve = events[-11]
139 assert eve.event_title.include?('123456789:')
140 assert_equal eve.event_url[:rev], '123456789'
141 end
132 end
142 else
133 else
143 puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
134 puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
144 def test_fake; assert true end
135 def test_fake; assert true end
145 end
136 end
146 end
137 end
General Comments 0
You need to be logged in to leave comments. Login now