##// END OF EJS Templates
scm: bazaar: add test to override human_attribute_name of "path to repository"...
Toshi MARUYAMA -
r8840:9f581b9eebe2
parent child
Show More
@@ -1,119 +1,147
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 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 RepositoryBazaarTest < ActiveSupport::TestCase
21 21 fixtures :projects
22 22
23 include Redmine::I18n
24
23 25 REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository/trunk').to_s
24 26 REPOSITORY_PATH.gsub!(/\/+/, '/')
25 27 NUM_REV = 4
26 28
27 29 def setup
28 30 @project = Project.find(3)
29 31 @repository = Repository::Bazaar.create(
30 32 :project => @project, :url => "file:///#{REPOSITORY_PATH}",
31 33 :log_encoding => 'UTF-8')
32 34 assert @repository
33 35 end
34 36
37 def test_blank_path_to_repository_error_message
38 set_language_if_valid 'en'
39 repo = Repository::Bazaar.new(
40 :project => @project,
41 :identifier => 'test',
42 :log_encoding => 'UTF-8'
43 )
44 assert !repo.save
45 assert_include "Path to repository can't be blank",
46 repo.errors.full_messages
47 end
48
49 def test_blank_path_to_repository_error_message_fr
50 set_language_if_valid 'fr'
51 str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)"
52 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
53 repo = Repository::Bazaar.new(
54 :project => @project,
55 :url => "",
56 :identifier => 'test',
57 :log_encoding => 'UTF-8'
58 )
59 assert !repo.save
60 assert_include str, repo.errors.full_messages
61 end
62
35 63 if File.directory?(REPOSITORY_PATH)
36 64 def test_fetch_changesets_from_scratch
37 65 assert_equal 0, @repository.changesets.count
38 66 @repository.fetch_changesets
39 67 @project.reload
40 68
41 69 assert_equal NUM_REV, @repository.changesets.count
42 70 assert_equal 9, @repository.changes.count
43 71 assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
44 72 end
45 73
46 74 def test_fetch_changesets_incremental
47 75 assert_equal 0, @repository.changesets.count
48 76 @repository.fetch_changesets
49 77 @project.reload
50 78 assert_equal NUM_REV, @repository.changesets.count
51 79 # Remove changesets with revision > 5
52 80 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
53 81 @project.reload
54 82 assert_equal 2, @repository.changesets.count
55 83
56 84 @repository.fetch_changesets
57 85 @project.reload
58 86 assert_equal NUM_REV, @repository.changesets.count
59 87 end
60 88
61 89 def test_entries
62 90 entries = @repository.entries
63 91 assert_equal 2, entries.size
64 92
65 93 assert_equal 'dir', entries[0].kind
66 94 assert_equal 'directory', entries[0].name
67 95
68 96 assert_equal 'file', entries[1].kind
69 97 assert_equal 'doc-mkdir.txt', entries[1].name
70 98 end
71 99
72 100 def test_entries_in_subdirectory
73 101 entries = @repository.entries('directory')
74 102 assert_equal 3, entries.size
75 103
76 104 assert_equal 'file', entries.last.kind
77 105 assert_equal 'edit.png', entries.last.name
78 106 end
79 107
80 108 def test_previous
81 109 assert_equal 0, @repository.changesets.count
82 110 @repository.fetch_changesets
83 111 @project.reload
84 112 assert_equal NUM_REV, @repository.changesets.count
85 113 changeset = @repository.find_changeset_by_name('3')
86 114 assert_equal @repository.find_changeset_by_name('2'), changeset.previous
87 115 end
88 116
89 117 def test_previous_nil
90 118 assert_equal 0, @repository.changesets.count
91 119 @repository.fetch_changesets
92 120 @project.reload
93 121 assert_equal NUM_REV, @repository.changesets.count
94 122 changeset = @repository.find_changeset_by_name('1')
95 123 assert_nil changeset.previous
96 124 end
97 125
98 126 def test_next
99 127 assert_equal 0, @repository.changesets.count
100 128 @repository.fetch_changesets
101 129 @project.reload
102 130 assert_equal NUM_REV, @repository.changesets.count
103 131 changeset = @repository.find_changeset_by_name('2')
104 132 assert_equal @repository.find_changeset_by_name('3'), changeset.next
105 133 end
106 134
107 135 def test_next_nil
108 136 assert_equal 0, @repository.changesets.count
109 137 @repository.fetch_changesets
110 138 @project.reload
111 139 assert_equal NUM_REV, @repository.changesets.count
112 140 changeset = @repository.find_changeset_by_name('4')
113 141 assert_nil changeset.next
114 142 end
115 143 else
116 144 puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
117 145 def test_fake; assert true end
118 146 end
119 147 end
General Comments 0
You need to be logged in to leave comments. Login now