comparison .svn/pristine/b0/b080561727eb14f1a6a2cf717727d6923d2488b6.svn-base @ 1494:e248c7af89ec redmine-2.4

Update to Redmine SVN revision 12979 on 2.4-stable branch
author Chris Cannam
date Mon, 17 Mar 2014 08:54:02 +0000
parents
children
comparison
equal deleted inserted replaced
1464:261b3d9a4903 1494:e248c7af89ec
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.expand_path('../../../../../../test_helper', __FILE__)
19 begin
20 require 'mocha/setup'
21
22 class CvsAdapterTest < ActiveSupport::TestCase
23 REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
24 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
25 MODULE_NAME = 'test'
26
27 if File.directory?(REPOSITORY_PATH)
28 def setup
29 @adapter = Redmine::Scm::Adapters::CvsAdapter.new(MODULE_NAME, REPOSITORY_PATH)
30 end
31
32 def test_scm_version
33 to_test = { "\nConcurrent Versions System (CVS) 1.12.13 (client/server)\n" => [1,12,13],
34 "\r\n1.12.12\r\n1.12.11" => [1,12,12],
35 "1.12.11\r\n1.12.10\r\n" => [1,12,11]}
36 to_test.each do |s, v|
37 test_scm_version_for(s, v)
38 end
39 end
40
41 def test_revisions_all
42 cnt = 0
43 @adapter.revisions('', nil, nil, :log_encoding => 'UTF-8') do |revision|
44 cnt += 1
45 end
46 assert_equal 16, cnt
47 end
48
49 def test_revisions_from_rev3
50 rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22)
51 cnt = 0
52 @adapter.revisions('', rev3_committed_on, nil, :log_encoding => 'UTF-8') do |revision|
53 cnt += 1
54 end
55 assert_equal 4, cnt
56 end
57
58 def test_entries_rev3
59 rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22)
60 entries = @adapter.entries('sources', rev3_committed_on)
61 assert_equal 2, entries.size
62 assert_equal entries[0].name, "watchers_controller.rb"
63 assert_equal entries[0].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22)
64 end
65
66 def test_path_encoding_default_utf8
67 adpt1 = Redmine::Scm::Adapters::CvsAdapter.new(
68 MODULE_NAME,
69 REPOSITORY_PATH
70 )
71 assert_equal "UTF-8", adpt1.path_encoding
72 adpt2 = Redmine::Scm::Adapters::CvsAdapter.new(
73 MODULE_NAME,
74 REPOSITORY_PATH,
75 nil,
76 nil,
77 ""
78 )
79 assert_equal "UTF-8", adpt2.path_encoding
80 end
81
82 def test_root_url_path
83 to_test = {
84 ':pserver:cvs_user:cvs_password@123.456.789.123:9876/repo' => '/repo',
85 ':pserver:cvs_user:cvs_password@123.456.789.123/repo' => '/repo',
86 ':pserver:cvs_user:cvs_password@cvs_server:/repo' => '/repo',
87 ':pserver:cvs_user:cvs_password@cvs_server:9876/repo' => '/repo',
88 ':pserver:cvs_user:cvs_password@cvs_server/repo' => '/repo',
89 ':pserver:cvs_user:cvs_password@cvs_server/path/repo' => '/path/repo',
90 ':ext:cvsservername:/path' => '/path'
91 }
92
93 to_test.each do |string, expected|
94 assert_equal expected, Redmine::Scm::Adapters::CvsAdapter.new('foo', string).send(:root_url_path), "#{string} failed"
95 end
96 end
97
98 private
99
100 def test_scm_version_for(scm_command_version, version)
101 @adapter.class.expects(:scm_version_from_command_line).returns(scm_command_version)
102 assert_equal version, @adapter.class.scm_command_version
103 end
104 else
105 puts "Cvs test repository NOT FOUND. Skipping unit tests !!!"
106 def test_fake; assert true end
107 end
108 end
109
110 rescue LoadError
111 class CvsMochaFake < ActiveSupport::TestCase
112 def test_fake; assert(false, "Requires mocha to run those tests") end
113 end
114 end
115