##// END OF EJS Templates
scm: darcs: add test to override human_attribute_name of "path to repository"...
Toshi MARUYAMA -
r8839:b73d5d7ecc17
parent child
Show More
@@ -1,96 +1,124
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 RepositoryDarcsTest < ActiveSupport::TestCase
21 21 fixtures :projects
22 22
23 include Redmine::I18n
24
23 25 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
24 26 NUM_REV = 6
25 27
26 28 def setup
27 29 @project = Project.find(3)
28 30 @repository = Repository::Darcs.create(
29 31 :project => @project,
30 32 :url => REPOSITORY_PATH,
31 33 :log_encoding => 'UTF-8'
32 34 )
33 35 assert @repository
34 36 end
35 37
38 def test_blank_path_to_repository_error_message
39 set_language_if_valid 'en'
40 repo = Repository::Darcs.new(
41 :project => @project,
42 :identifier => 'test',
43 :log_encoding => 'UTF-8'
44 )
45 assert !repo.save
46 assert_include "Path to repository can't be blank",
47 repo.errors.full_messages
48 end
49
50 def test_blank_path_to_repository_error_message_fr
51 set_language_if_valid 'fr'
52 str = "Chemin du d\xc3\xa9p\xc3\xb4t doit \xc3\xaatre renseign\xc3\xa9(e)"
53 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
54 repo = Repository::Darcs.new(
55 :project => @project,
56 :url => "",
57 :identifier => 'test',
58 :log_encoding => 'UTF-8'
59 )
60 assert !repo.save
61 assert_include str, repo.errors.full_messages
62 end
63
36 64 if File.directory?(REPOSITORY_PATH)
37 65 def test_fetch_changesets_from_scratch
38 66 assert_equal 0, @repository.changesets.count
39 67 @repository.fetch_changesets
40 68 @project.reload
41 69
42 70 assert_equal NUM_REV, @repository.changesets.count
43 71 assert_equal 13, @repository.changes.count
44 72 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
45 73 end
46 74
47 75 def test_fetch_changesets_incremental
48 76 assert_equal 0, @repository.changesets.count
49 77 @repository.fetch_changesets
50 78 @project.reload
51 79 assert_equal NUM_REV, @repository.changesets.count
52 80
53 81 # Remove changesets with revision > 3
54 82 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
55 83 @project.reload
56 84 assert_equal 3, @repository.changesets.count
57 85
58 86 @repository.fetch_changesets
59 87 @project.reload
60 88 assert_equal NUM_REV, @repository.changesets.count
61 89 end
62 90
63 91 def test_entries_invalid_revision
64 92 assert_equal 0, @repository.changesets.count
65 93 @repository.fetch_changesets
66 94 @project.reload
67 95 assert_equal NUM_REV, @repository.changesets.count
68 96 assert_nil @repository.entries('', '123')
69 97 end
70 98
71 99 def test_deleted_files_should_not_be_listed
72 100 assert_equal 0, @repository.changesets.count
73 101 @repository.fetch_changesets
74 102 @project.reload
75 103 assert_equal NUM_REV, @repository.changesets.count
76 104 entries = @repository.entries('sources')
77 105 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
78 106 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
79 107 end
80 108
81 109 def test_cat
82 110 if @repository.scm.supports_cat?
83 111 assert_equal 0, @repository.changesets.count
84 112 @repository.fetch_changesets
85 113 @project.reload
86 114 assert_equal NUM_REV, @repository.changesets.count
87 115 cat = @repository.cat("sources/welcome_controller.rb", 2)
88 116 assert_not_nil cat
89 117 assert cat.include?('class WelcomeController < ApplicationController')
90 118 end
91 119 end
92 120 else
93 121 puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
94 122 def test_fake; assert true end
95 123 end
96 124 end
General Comments 0
You need to be logged in to leave comments. Login now