Chris@0
|
1 # redMine - project management software
|
Chris@0
|
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
|
Chris@0
|
3 #
|
Chris@0
|
4 # This program is free software; you can redistribute it and/or
|
Chris@0
|
5 # modify it under the terms of the GNU General Public License
|
Chris@0
|
6 # as published by the Free Software Foundation; either version 2
|
Chris@0
|
7 # of the License, or (at your option) any later version.
|
Chris@0
|
8 #
|
Chris@0
|
9 # This program is distributed in the hope that it will be useful,
|
Chris@0
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
12 # GNU General Public License for more details.
|
Chris@0
|
13 #
|
Chris@0
|
14 # You should have received a copy of the GNU General Public License
|
Chris@0
|
15 # along with this program; if not, write to the Free Software
|
Chris@0
|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@0
|
17
|
Chris@0
|
18 require File.dirname(__FILE__) + '/../test_helper'
|
Chris@0
|
19
|
Chris@0
|
20 class RepositorySubversionTest < ActiveSupport::TestCase
|
Chris@0
|
21 fixtures :projects, :repositories
|
Chris@0
|
22
|
Chris@0
|
23 def setup
|
Chris@0
|
24 @project = Project.find(1)
|
Chris@0
|
25 assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}")
|
Chris@0
|
26 end
|
Chris@0
|
27
|
Chris@0
|
28 if repository_configured?('subversion')
|
Chris@0
|
29 def test_fetch_changesets_from_scratch
|
Chris@0
|
30 @repository.fetch_changesets
|
Chris@0
|
31 @repository.reload
|
Chris@0
|
32
|
Chris@0
|
33 assert_equal 11, @repository.changesets.count
|
Chris@0
|
34 assert_equal 20, @repository.changes.count
|
Chris@0
|
35 assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
|
Chris@0
|
36 end
|
Chris@0
|
37
|
Chris@0
|
38 def test_fetch_changesets_incremental
|
Chris@0
|
39 @repository.fetch_changesets
|
Chris@0
|
40 # Remove changesets with revision > 5
|
Chris@0
|
41 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
|
Chris@0
|
42 @repository.reload
|
Chris@0
|
43 assert_equal 5, @repository.changesets.count
|
Chris@0
|
44
|
Chris@0
|
45 @repository.fetch_changesets
|
Chris@0
|
46 assert_equal 11, @repository.changesets.count
|
Chris@0
|
47 end
|
Chris@0
|
48
|
Chris@0
|
49 def test_latest_changesets
|
Chris@0
|
50 @repository.fetch_changesets
|
Chris@0
|
51
|
Chris@0
|
52 # with limit
|
Chris@0
|
53 changesets = @repository.latest_changesets('', nil, 2)
|
Chris@0
|
54 assert_equal 2, changesets.size
|
Chris@0
|
55 assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets
|
Chris@0
|
56
|
Chris@0
|
57 # with path
|
Chris@0
|
58 changesets = @repository.latest_changesets('subversion_test/folder', nil)
|
Chris@0
|
59 assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision)
|
Chris@0
|
60
|
Chris@0
|
61 # with path and revision
|
Chris@0
|
62 changesets = @repository.latest_changesets('subversion_test/folder', 8)
|
Chris@0
|
63 assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision)
|
Chris@0
|
64 end
|
Chris@0
|
65
|
Chris@0
|
66 def test_directory_listing_with_square_brackets_in_path
|
Chris@0
|
67 @repository.fetch_changesets
|
Chris@0
|
68 @repository.reload
|
Chris@0
|
69
|
Chris@0
|
70 entries = @repository.entries('subversion_test/[folder_with_brackets]')
|
Chris@0
|
71 assert_not_nil entries, 'Expect to find entries in folder_with_brackets'
|
Chris@0
|
72 assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets'
|
Chris@0
|
73 assert_equal 'README.txt', entries.first.name
|
Chris@0
|
74 end
|
Chris@0
|
75
|
Chris@0
|
76 def test_directory_listing_with_square_brackets_in_base
|
Chris@0
|
77 @project = Project.find(1)
|
Chris@0
|
78 @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]")
|
Chris@0
|
79
|
Chris@0
|
80 @repository.fetch_changesets
|
Chris@0
|
81 @repository.reload
|
Chris@0
|
82
|
Chris@0
|
83 assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision'
|
Chris@0
|
84 assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add'
|
Chris@0
|
85
|
Chris@0
|
86 entries = @repository.entries('')
|
Chris@0
|
87 assert_not_nil entries, 'Expect to find entries'
|
Chris@0
|
88 assert_equal 1, entries.size, 'Expect a single entry'
|
Chris@0
|
89 assert_equal 'README.txt', entries.first.name
|
Chris@0
|
90 end
|
Chris@0
|
91 else
|
Chris@0
|
92 puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
|
Chris@0
|
93 def test_fake; assert true end
|
Chris@0
|
94 end
|
Chris@0
|
95 end
|