comparison test/unit/.svn/text-base/repository_subversion_test.rb.svn-base @ 441:cbce1fd3b1b7 redmine-1.2

Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author Chris Cannam
date Mon, 06 Jun 2011 14:24:13 +0100
parents 051f544170fe
children
comparison
equal deleted inserted replaced
245:051f544170fe 441:cbce1fd3b1b7
1 # redMine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2007 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 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(3) 24 @project = Project.find(3)
25 assert @repository = Repository::Subversion.create(:project => @project, 25 @repository = Repository::Subversion.create(:project => @project,
26 :url => "file://#{self.class.repository_path('subversion')}") 26 :url => self.class.subversion_repository_url)
27 assert @repository
27 end 28 end
28 29
29 if repository_configured?('subversion') 30 if repository_configured?('subversion')
30 def test_fetch_changesets_from_scratch 31 def test_fetch_changesets_from_scratch
31 @repository.fetch_changesets 32 @repository.fetch_changesets
32 @repository.reload 33 @repository.reload
33 34
34 assert_equal 11, @repository.changesets.count 35 assert_equal 11, @repository.changesets.count
35 assert_equal 20, @repository.changes.count 36 assert_equal 20, @repository.changes.count
36 assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments 37 assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
37 end 38 end
38 39
39 def test_fetch_changesets_incremental 40 def test_fetch_changesets_incremental
40 @repository.fetch_changesets 41 @repository.fetch_changesets
41 # Remove changesets with revision > 5 42 # Remove changesets with revision > 5
42 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5} 43 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
43 @repository.reload 44 @repository.reload
44 assert_equal 5, @repository.changesets.count 45 assert_equal 5, @repository.changesets.count
45 46
46 @repository.fetch_changesets 47 @repository.fetch_changesets
47 assert_equal 11, @repository.changesets.count 48 assert_equal 11, @repository.changesets.count
48 end 49 end
49 50
50 def test_latest_changesets 51 def test_latest_changesets
51 @repository.fetch_changesets 52 @repository.fetch_changesets
52 53
53 # with limit 54 # with limit
54 changesets = @repository.latest_changesets('', nil, 2) 55 changesets = @repository.latest_changesets('', nil, 2)
55 assert_equal 2, changesets.size 56 assert_equal 2, changesets.size
56 assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets 57 assert_equal @repository.latest_changesets('', nil).slice(0,2), changesets
57 58
58 # with path 59 # with path
59 changesets = @repository.latest_changesets('subversion_test/folder', nil) 60 changesets = @repository.latest_changesets('subversion_test/folder', nil)
60 assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision) 61 assert_equal ["10", "9", "7", "6", "5", "2"], changesets.collect(&:revision)
61 62
62 # with path and revision 63 # with path and revision
63 changesets = @repository.latest_changesets('subversion_test/folder', 8) 64 changesets = @repository.latest_changesets('subversion_test/folder', 8)
64 assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision) 65 assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision)
65 end 66 end
66 67
67 def test_directory_listing_with_square_brackets_in_path 68 def test_directory_listing_with_square_brackets_in_path
68 @repository.fetch_changesets 69 @repository.fetch_changesets
69 @repository.reload 70 @repository.reload
70 71
71 entries = @repository.entries('subversion_test/[folder_with_brackets]') 72 entries = @repository.entries('subversion_test/[folder_with_brackets]')
72 assert_not_nil entries, 'Expect to find entries in folder_with_brackets' 73 assert_not_nil entries, 'Expect to find entries in folder_with_brackets'
73 assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets' 74 assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets'
74 assert_equal 'README.txt', entries.first.name 75 assert_equal 'README.txt', entries.first.name
75 end 76 end
76 77
77 def test_directory_listing_with_square_brackets_in_base 78 def test_directory_listing_with_square_brackets_in_base
78 @project = Project.find(3) 79 @project = Project.find(3)
79 @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]") 80 @repository = Repository::Subversion.create(
81 :project => @project,
82 :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]")
80 83
81 @repository.fetch_changesets 84 @repository.fetch_changesets
82 @repository.reload 85 @repository.reload
83 86
84 assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision' 87 assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision'
141 def test_log_encoding_ignore_setting 144 def test_log_encoding_ignore_setting
142 with_settings :commit_logs_encoding => 'windows-1252' do 145 with_settings :commit_logs_encoding => 'windows-1252' do
143 s1 = "\xC2\x80" 146 s1 = "\xC2\x80"
144 s2 = "\xc3\x82\xc2\x80" 147 s2 = "\xc3\x82\xc2\x80"
145 if s1.respond_to?(:force_encoding) 148 if s1.respond_to?(:force_encoding)
146 s3 = s1 149 s1.force_encoding('ISO-8859-1')
147 s4 = s2 150 s2.force_encoding('UTF-8')
148 s1.force_encoding('ASCII-8BIT') 151 assert_equal s1.encode('UTF-8'), s2
149 s2.force_encoding('ASCII-8BIT')
150 s3.force_encoding('ISO-8859-1')
151 s4.force_encoding('UTF-8')
152 assert_equal s3.encode('UTF-8'), s4
153 end 152 end
154 c = Changeset.new(:repository => @repository, 153 c = Changeset.new(:repository => @repository,
155 :comments=>s2, 154 :comments => s2,
156 :revision=>'123', 155 :revision => '123',
157 :committed_on => Time.now) 156 :committed_on => Time.now)
158 assert c.save 157 assert c.save
159 assert_equal s2, c.comments 158 assert_equal s2, c.comments
160 end 159 end
161 end 160 end