##// END OF EJS Templates
Fixed failing subversion test....
Jean-Philippe Lang -
r4501:29fddddaf1b2
parent child
Show More
@@ -1,146 +1,137
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class RepositorySubversionTest < ActiveSupport::TestCase
21 21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
22 22
23 23 def setup
24 24 @project = Project.find(1)
25 25 assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}")
26 26 end
27 27
28 28 if repository_configured?('subversion')
29 29 def test_fetch_changesets_from_scratch
30 30 @repository.fetch_changesets
31 31 @repository.reload
32 32
33 33 assert_equal 11, @repository.changesets.count
34 34 assert_equal 20, @repository.changes.count
35 35 assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
36 36 end
37 37
38 38 def test_fetch_changesets_incremental
39 39 @repository.fetch_changesets
40 40 # Remove changesets with revision > 5
41 41 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
42 42 @repository.reload
43 43 assert_equal 5, @repository.changesets.count
44 44
45 45 @repository.fetch_changesets
46 46 assert_equal 11, @repository.changesets.count
47 47 end
48 48
49 49 def test_latest_changesets
50 50 @repository.fetch_changesets
51 51
52 52 # with limit
53 53 changesets = @repository.latest_changesets('', nil, 2)
54 54 assert_equal 2, changesets.size
55 55 assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets
56 56
57 57 # with path
58 58 changesets = @repository.latest_changesets('subversion_test/folder', nil)
59 59 assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision)
60 60
61 61 # with path and revision
62 62 changesets = @repository.latest_changesets('subversion_test/folder', 8)
63 63 assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision)
64 64 end
65 65
66 66 def test_directory_listing_with_square_brackets_in_path
67 67 @repository.fetch_changesets
68 68 @repository.reload
69 69
70 70 entries = @repository.entries('subversion_test/[folder_with_brackets]')
71 71 assert_not_nil entries, 'Expect to find entries in folder_with_brackets'
72 72 assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets'
73 73 assert_equal 'README.txt', entries.first.name
74 74 end
75 75
76 76 def test_directory_listing_with_square_brackets_in_base
77 77 @project = Project.find(1)
78 78 @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]")
79 79
80 80 @repository.fetch_changesets
81 81 @repository.reload
82 82
83 83 assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision'
84 84 assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add'
85 85
86 86 entries = @repository.entries('')
87 87 assert_not_nil entries, 'Expect to find entries'
88 88 assert_equal 1, entries.size, 'Expect a single entry'
89 89 assert_equal 'README.txt', entries.first.name
90 90 end
91 91
92 92 def test_identifier
93 93 @repository.fetch_changesets
94 94 @repository.reload
95 95 c = @repository.changesets.find_by_revision('1')
96 96 assert_equal c.revision, c.identifier
97 97 end
98 98
99 99 def test_identifier_nine_digit
100 100 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
101 101 :revision => '123456789', :comments => 'test')
102 102 assert_equal c.identifier, c.revision
103 103 end
104 104
105 105 def test_format_identifier
106 106 @repository.fetch_changesets
107 107 @repository.reload
108 108 c = @repository.changesets.find_by_revision('1')
109 109 assert_equal c.format_identifier, c.revision
110 110 end
111 111
112 112 def test_format_identifier_nine_digit
113 113 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
114 114 :revision => '123456789', :comments => 'test')
115 115 assert_equal c.format_identifier, c.revision
116 116 end
117 117
118 118 def test_activities
119 @repository.fetch_changesets
120 @repository.reload
121 f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1))
122 f.scope = ['changesets']
123 events = f.events
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'
119 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
120 :revision => '1', :comments => 'test')
121
122 assert c.event_title.include?('1:'), c.event_title
123 assert_equal c.event_url[:rev], '1'
128 124 end
129 125
130 126 def test_activities_nine_digit
131 127 c = Changeset.new(:repository => @repository, :committed_on => Time.now,
132 128 :revision => '123456789', :comments => 'test')
133 assert( c.save )
134 f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1))
135 f.scope = ['changesets']
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'
129
130 assert c.event_title.include?('123456789:')
131 assert_equal c.event_url[:rev], '123456789'
141 132 end
142 133 else
143 134 puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
144 135 def test_fake; assert true end
145 136 end
146 137 end
General Comments 0
You need to be logged in to leave comments. Login now