Mercurial > hg > soundsoftware-site
comparison test/unit/repository_filesystem_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 RepositoryFilesystemTest < ActiveSupport::TestCase | 20 class RepositoryFilesystemTest < ActiveSupport::TestCase |
21 fixtures :projects | 21 fixtures :projects |
22 | 22 |
23 include Redmine::I18n | |
24 | |
23 REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s | 25 REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s |
24 | 26 |
25 def setup | 27 def setup |
26 @project = Project.find(3) | 28 @project = Project.find(3) |
27 Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem') | 29 Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem') |
30 :url => REPOSITORY_PATH | 32 :url => REPOSITORY_PATH |
31 ) | 33 ) |
32 assert @repository | 34 assert @repository |
33 end | 35 end |
34 | 36 |
37 def test_blank_root_directory_error_message | |
38 set_language_if_valid 'en' | |
39 repo = Repository::Filesystem.new( | |
40 :project => @project, | |
41 :identifier => 'test' | |
42 ) | |
43 assert !repo.save | |
44 assert_include "Root directory can't be blank", | |
45 repo.errors.full_messages | |
46 end | |
47 | |
48 def test_blank_root_directory_error_message_fr | |
49 set_language_if_valid 'fr' | |
50 str = "R\xc3\xa9pertoire racine doit \xc3\xaatre renseign\xc3\xa9(e)" | |
51 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding) | |
52 repo = Repository::Filesystem.new( | |
53 :project => @project, | |
54 :url => "", | |
55 :identifier => 'test', | |
56 :path_encoding => '' | |
57 ) | |
58 assert !repo.save | |
59 assert_include str, repo.errors.full_messages | |
60 end | |
61 | |
35 if File.directory?(REPOSITORY_PATH) | 62 if File.directory?(REPOSITORY_PATH) |
36 def test_fetch_changesets | 63 def test_fetch_changesets |
37 assert_equal 0, @repository.changesets.count | 64 assert_equal 0, @repository.changesets.count |
38 assert_equal 0, @repository.changes.count | 65 assert_equal 0, @repository.filechanges.count |
39 @repository.fetch_changesets | 66 @repository.fetch_changesets |
40 @project.reload | 67 @project.reload |
41 assert_equal 0, @repository.changesets.count | 68 assert_equal 0, @repository.changesets.count |
42 assert_equal 0, @repository.changes.count | 69 assert_equal 0, @repository.filechanges.count |
43 end | 70 end |
44 | 71 |
45 def test_entries | 72 def test_entries |
46 assert_equal 3, @repository.entries("", 2).size | 73 entries = @repository.entries("", 2) |
74 assert_kind_of Redmine::Scm::Adapters::Entries, entries | |
75 assert_equal 3, entries.size | |
76 end | |
77 | |
78 def test_entries_in_directory | |
47 assert_equal 2, @repository.entries("dir", 3).size | 79 assert_equal 2, @repository.entries("dir", 3).size |
48 end | 80 end |
49 | 81 |
50 def test_cat | 82 def test_cat |
51 assert_equal "TEST CAT\n", @repository.scm.cat("test") | 83 assert_equal "TEST CAT\n", @repository.scm.cat("test") |