Mercurial > hg > soundsoftware-site
comparison test/unit/repository_cvs_test.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | cbce1fd3b1b7 |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
19 require 'pp' | 19 require 'pp' |
20 class RepositoryCvsTest < ActiveSupport::TestCase | 20 class RepositoryCvsTest < ActiveSupport::TestCase |
21 fixtures :projects | 21 fixtures :projects |
22 | 22 |
23 # No '..' in the repository path | 23 REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s |
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository' | |
25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | 24 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
26 # CVS module | 25 # CVS module |
27 MODULE_NAME = 'test' | 26 MODULE_NAME = 'test' |
28 CHANGESETS_NUM = 7 | 27 CHANGESETS_NUM = 7 |
29 | 28 |
38 | 37 |
39 if File.directory?(REPOSITORY_PATH) | 38 if File.directory?(REPOSITORY_PATH) |
40 def test_fetch_changesets_from_scratch | 39 def test_fetch_changesets_from_scratch |
41 assert_equal 0, @repository.changesets.count | 40 assert_equal 0, @repository.changesets.count |
42 @repository.fetch_changesets | 41 @repository.fetch_changesets |
43 @repository.reload | 42 @project.reload |
44 | 43 |
45 assert_equal CHANGESETS_NUM, @repository.changesets.count | 44 assert_equal CHANGESETS_NUM, @repository.changesets.count |
46 assert_equal 16, @repository.changes.count | 45 assert_equal 16, @repository.changes.count |
47 assert_not_nil @repository.changesets.find_by_comments('Two files changed') | 46 assert_not_nil @repository.changesets.find_by_comments('Two files changed') |
48 | 47 |
81 end | 80 end |
82 | 81 |
83 def test_deleted_files_should_not_be_listed | 82 def test_deleted_files_should_not_be_listed |
84 assert_equal 0, @repository.changesets.count | 83 assert_equal 0, @repository.changesets.count |
85 @repository.fetch_changesets | 84 @repository.fetch_changesets |
86 @repository.reload | 85 @project.reload |
87 assert_equal CHANGESETS_NUM, @repository.changesets.count | 86 assert_equal CHANGESETS_NUM, @repository.changesets.count |
88 | 87 |
89 entries = @repository.entries('sources') | 88 entries = @repository.entries('sources') |
90 assert entries.detect {|e| e.name == 'watchers_controller.rb'} | 89 assert entries.detect {|e| e.name == 'watchers_controller.rb'} |
91 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} | 90 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} |
92 end | 91 end |
93 | 92 |
94 def test_entries_rev3 | 93 def test_entries_rev3 |
94 assert_equal 0, @repository.changesets.count | |
95 @repository.fetch_changesets | 95 @repository.fetch_changesets |
96 @repository.reload | 96 @project.reload |
97 assert_equal CHANGESETS_NUM, @repository.changesets.count | |
97 entries = @repository.entries('', '3') | 98 entries = @repository.entries('', '3') |
98 assert_equal 3, entries.size | 99 assert_equal 3, entries.size |
99 assert_equal entries[2].name, "README" | 100 assert_equal entries[2].name, "README" |
100 assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22) | 101 assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22) |
101 assert_equal entries[2].lastrev.identifier, '3' | 102 assert_equal entries[2].lastrev.identifier, '3' |
102 assert_equal entries[2].lastrev.revision, '3' | 103 assert_equal entries[2].lastrev.revision, '3' |
103 assert_equal entries[2].lastrev.author, 'LANG' | 104 assert_equal entries[2].lastrev.author, 'LANG' |
104 end | 105 end |
105 | 106 |
106 def test_entries_invalid_path | 107 def test_entries_invalid_path |
108 assert_equal 0, @repository.changesets.count | |
107 @repository.fetch_changesets | 109 @repository.fetch_changesets |
108 @repository.reload | 110 @project.reload |
111 assert_equal CHANGESETS_NUM, @repository.changesets.count | |
109 assert_nil @repository.entries('missing') | 112 assert_nil @repository.entries('missing') |
110 assert_nil @repository.entries('missing', '3') | 113 assert_nil @repository.entries('missing', '3') |
111 end | 114 end |
112 | 115 |
113 def test_entries_invalid_revision | 116 def test_entries_invalid_revision |
117 assert_equal 0, @repository.changesets.count | |
114 @repository.fetch_changesets | 118 @repository.fetch_changesets |
115 @repository.reload | 119 @project.reload |
120 assert_equal CHANGESETS_NUM, @repository.changesets.count | |
116 assert_nil @repository.entries('', '123') | 121 assert_nil @repository.entries('', '123') |
117 end | 122 end |
118 | 123 |
119 def test_cat | 124 def test_cat |
125 assert_equal 0, @repository.changesets.count | |
120 @repository.fetch_changesets | 126 @repository.fetch_changesets |
121 @repository.reload | 127 @project.reload |
128 assert_equal CHANGESETS_NUM, @repository.changesets.count | |
122 buf = @repository.cat('README') | 129 buf = @repository.cat('README') |
123 assert buf | 130 assert buf |
124 lines = buf.split("\n") | 131 lines = buf.split("\n") |
125 assert_equal 3, lines.length | 132 assert_equal 3, lines.length |
126 buf = lines[1].gsub(/\r$/, "") | 133 buf = lines[1].gsub(/\r$/, "") |
140 # invalid revision | 147 # invalid revision |
141 assert @repository.cat('README', '123').blank? | 148 assert @repository.cat('README', '123').blank? |
142 end | 149 end |
143 | 150 |
144 def test_annotate | 151 def test_annotate |
152 assert_equal 0, @repository.changesets.count | |
145 @repository.fetch_changesets | 153 @repository.fetch_changesets |
146 @repository.reload | 154 @project.reload |
155 assert_equal CHANGESETS_NUM, @repository.changesets.count | |
147 ann = @repository.annotate('README') | 156 ann = @repository.annotate('README') |
148 assert ann | 157 assert ann |
149 assert_equal 3, ann.revisions.length | 158 assert_equal 3, ann.revisions.length |
150 assert_equal '1.2', ann.revisions[1].revision | 159 assert_equal '1.2', ann.revisions[1].revision |
151 assert_equal 'LANG', ann.revisions[1].author | 160 assert_equal 'LANG', ann.revisions[1].author |