comparison test/unit/repository_darcs_test.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42
comparison
equal deleted inserted replaced
929:5f33065ddc4b 1115:433d4f72a19b
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang 2 # Copyright (C) 2006-2012 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.
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 class RepositoryDarcsTest < ActiveSupport::TestCase 20 class RepositoryDarcsTest < ActiveSupport::TestCase
21 fixtures :projects 21 fixtures :projects
22 22
23 include Redmine::I18n
24
23 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s 25 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
24 NUM_REV = 6 26 NUM_REV = 6
25 27
26 def setup 28 def setup
27 @project = Project.find(3) 29 @project = Project.find(3)
31 :log_encoding => 'UTF-8' 33 :log_encoding => 'UTF-8'
32 ) 34 )
33 assert @repository 35 assert @repository
34 end 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 if File.directory?(REPOSITORY_PATH) 64 if File.directory?(REPOSITORY_PATH)
37 def test_fetch_changesets_from_scratch 65 def test_fetch_changesets_from_scratch
38 assert_equal 0, @repository.changesets.count 66 assert_equal 0, @repository.changesets.count
39 @repository.fetch_changesets 67 @repository.fetch_changesets
40 @project.reload 68 @project.reload
41 69
42 assert_equal NUM_REV, @repository.changesets.count 70 assert_equal NUM_REV, @repository.changesets.count
43 assert_equal 13, @repository.changes.count 71 assert_equal 13, @repository.filechanges.count
44 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments 72 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
45 end 73 end
46 74
47 def test_fetch_changesets_incremental 75 def test_fetch_changesets_incremental
48 assert_equal 0, @repository.changesets.count 76 assert_equal 0, @repository.changesets.count
56 assert_equal 3, @repository.changesets.count 84 assert_equal 3, @repository.changesets.count
57 85
58 @repository.fetch_changesets 86 @repository.fetch_changesets
59 @project.reload 87 @project.reload
60 assert_equal NUM_REV, @repository.changesets.count 88 assert_equal NUM_REV, @repository.changesets.count
89 end
90
91 def test_entries
92 entries = @repository.entries
93 assert_kind_of Redmine::Scm::Adapters::Entries, entries
61 end 94 end
62 95
63 def test_entries_invalid_revision 96 def test_entries_invalid_revision
64 assert_equal 0, @repository.changesets.count 97 assert_equal 0, @repository.changesets.count
65 @repository.fetch_changesets 98 @repository.fetch_changesets