##// END OF EJS Templates
Merged r9390 from trunk....
Merged r9390 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9400 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r8896:9c264a7e66cb
r9266:8fefb7c05bb9
Show More
repository_cvs_test.rb
240 lines | 8.9 KiB | text/x-ruby | RubyLexer
/ test / unit / repository_cvs_test.rb
Toshi MARUYAMA
scm: cvs: remove trailing white-spaces from unit model test....
r5582 # Redmine - project management software
# Copyright (C) 2006-2011 Jean-Philippe Lang
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
scm: cvs: remove trailing white-spaces from unit model test....
r5582 #
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
scm: cvs: remove trailing white-spaces from unit model test....
r5582 #
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 require 'pp'
Eric Davis
Upgraded to Rails 2.3.4 (#3597)...
r2773 class RepositoryCvsTest < ActiveSupport::TestCase
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 fixtures :projects
Toshi MARUYAMA
scm: cvs: code clean up unit model test....
r5319
Toshi MARUYAMA
scm: cvs: add test to override human_attribute_name...
r8848 include Redmine::I18n
Toshi MARUYAMA
scm: cvs: replace RAILS_ROOT to Rails.root in unit model test....
r5940 REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
Jean-Philippe Lang
Fixes platform determination under JRuby (#1804)....
r1752 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 # CVS module
Toshi MARUYAMA
scm: cvs: update test repository....
r5331 MODULE_NAME = 'test'
CHANGESETS_NUM = 7
Toshi MARUYAMA
scm: cvs: code clean up unit model test....
r5319
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 def setup
Toshi MARUYAMA
scm: cvs: change project id of unit app test from 1 to 3....
r4668 @project = Project.find(3)
Toshi MARUYAMA
scm: cvs: remove trailing white-spaces from unit model test....
r5582 @repository = Repository::Cvs.create(:project => @project,
Toshi MARUYAMA
scm: add feature of per project repository log encoding setting (#1735)....
r4862 :root_url => REPOSITORY_PATH,
Toshi MARUYAMA
scm: cvs: remove trailing white-spaces from unit model test....
r5582 :url => MODULE_NAME,
Toshi MARUYAMA
scm: add feature of per project repository log encoding setting (#1735)....
r4862 :log_encoding => 'UTF-8')
assert @repository
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 end
Toshi MARUYAMA
scm: cvs: code clean up unit model test....
r5319
Toshi MARUYAMA
scm: cvs: add test to override human_attribute_name...
r8848 def test_blank_module_error_message
set_language_if_valid 'en'
repo = Repository::Cvs.new(
:project => @project,
:identifier => 'test',
:log_encoding => 'UTF-8',
:root_url => REPOSITORY_PATH
)
assert !repo.save
assert_include "Module can't be blank",
repo.errors.full_messages
end
def test_blank_module_error_message_fr
set_language_if_valid 'fr'
str = "Module doit \xc3\xaatre renseign\xc3\xa9(e)"
str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
repo = Repository::Cvs.new(
:project => @project,
:identifier => 'test',
:log_encoding => 'UTF-8',
:path_encoding => '',
:url => '',
:root_url => REPOSITORY_PATH
)
assert !repo.save
assert_include str, repo.errors.full_messages
end
def test_blank_cvsroot_error_message
set_language_if_valid 'en'
repo = Repository::Cvs.new(
:project => @project,
:identifier => 'test',
:log_encoding => 'UTF-8',
:url => MODULE_NAME
)
assert !repo.save
assert_include "CVSROOT can't be blank",
repo.errors.full_messages
end
def test_blank_cvsroot_error_message_fr
set_language_if_valid 'fr'
str = "CVSROOT doit \xc3\xaatre renseign\xc3\xa9(e)"
str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
repo = Repository::Cvs.new(
:project => @project,
:identifier => 'test',
:log_encoding => 'UTF-8',
:path_encoding => '',
:url => MODULE_NAME,
:root_url => ''
)
assert !repo.save
assert_include str, repo.errors.full_messages
end
Toshi MARUYAMA
scm: cvs: remove trailing white-spaces from unit model test....
r5582 if File.directory?(REPOSITORY_PATH)
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 def test_fetch_changesets_from_scratch
Toshi MARUYAMA
scm: cvs: add fetch_changesets at all unit app test methods....
r4671 assert_equal 0, @repository.changesets.count
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 @repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_fetch_changesets_from_scratch at unit model test...
r7011 @project.reload
Toshi MARUYAMA
scm: cvs: code clean up unit model test....
r5319
Toshi MARUYAMA
scm: cvs: update test repository....
r5331 assert_equal CHANGESETS_NUM, @repository.changesets.count
assert_equal 16, @repository.changes.count
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 assert_not_nil @repository.changesets.find_by_comments('Two files changed')
Toshi MARUYAMA
scm: cvs: generate pseudo scmid for auto issue close text (#6706)....
r4682
r2 = @repository.changesets.find_by_revision('2')
assert_equal 'v1-20071213-162510', r2.scmid
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 end
Toshi MARUYAMA
scm: cvs: code clean up unit model test....
r5319
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 def test_fetch_changesets_incremental
Toshi MARUYAMA
scm: cvs: add fetch_changesets at all unit app test methods....
r4671 assert_equal 0, @repository.changesets.count
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 @repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_fetch_changesets_incremental at unit model test...
r8896 @project.reload
assert_equal CHANGESETS_NUM, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: change temporary revision number from "_N" to "tmpN" (#996, #3761, #6706)....
r4681 # Remove changesets with revision > 3
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_fetch_changesets_incremental at unit model test...
r8896 @project.reload
Toshi MARUYAMA
scm: cvs: change temporary revision number from "_N" to "tmpN" (#996, #3761, #6706)....
r4681 assert_equal 3, @repository.changesets.count
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_fetch_changesets_incremental at unit model test...
r8896 assert_equal %w|3 2 1|, @repository.changesets.all.collect(&:revision)
Toshi MARUYAMA
scm: cvs: change temporary revision number from "_N" to "tmpN" (#996, #3761, #6706)....
r4681
rev3_commit = @repository.changesets.find(:first, :order => 'committed_on DESC')
assert_equal '3', rev3_commit.revision
# 2007-12-14 01:27:22 +0900
rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22)
Toshi MARUYAMA
scm: cvs: generate pseudo scmid for auto issue close text (#6706)....
r4682 assert_equal 'HEAD-20071213-162722', rev3_commit.scmid
Toshi MARUYAMA
scm: cvs: change temporary revision number from "_N" to "tmpN" (#996, #3761, #6706)....
r4681 assert_equal rev3_committed_on, rev3_commit.committed_on
latest_rev = @repository.latest_changeset
assert_equal rev3_committed_on, latest_rev.committed_on
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 @repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_fetch_changesets_incremental at unit model test...
r8896 @project.reload
Toshi MARUYAMA
scm: cvs: update test repository....
r5331 assert_equal CHANGESETS_NUM, @repository.changesets.count
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_fetch_changesets_incremental at unit model test...
r8896 assert_equal %w|7 6 5 4 3 2 1|, @repository.changesets.all.collect(&:revision)
Toshi MARUYAMA
scm: cvs: update test repository....
r5331 rev5_commit = @repository.changesets.find_by_revision('5')
Toshi MARUYAMA
scm: cvs: generate pseudo scmid for auto issue close text (#6706)....
r4682 assert_equal 'HEAD-20071213-163001', rev5_commit.scmid
Toshi MARUYAMA
scm: cvs: change temporary revision number from "_N" to "tmpN" (#996, #3761, #6706)....
r4681 # 2007-12-14 01:30:01 +0900
rev5_committed_on = Time.gm(2007, 12, 13, 16, 30, 1)
assert_equal rev5_committed_on, rev5_commit.committed_on
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 end
Toshi MARUYAMA
scm: cvs: code clean up unit model test....
r5319
Jean-Philippe Lang
Fixed: CVS browser should not show dead revisions (deleted files) (#2319)....
r2133 def test_deleted_files_should_not_be_listed
Toshi MARUYAMA
scm: cvs: add fetch_changesets at all unit app test methods....
r4671 assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_deleted_files_should_not_be_listed at unit model test...
r7012 @project.reload
Toshi MARUYAMA
scm: cvs: update test repository....
r5331 assert_equal CHANGESETS_NUM, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add fetch_changesets at all unit app test methods....
r4671
Jean-Philippe Lang
Fixed: CVS browser should not show dead revisions (deleted files) (#2319)....
r2133 entries = @repository.entries('sources')
assert entries.detect {|e| e.name == 'watchers_controller.rb'}
assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
end
Toshi MARUYAMA
scm: cvs: fix missing author, revision and comment in tree view (#4270)....
r4973
def test_entries_rev3
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_entries_rev3 at unit model test...
r7013 assert_equal 0, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: fix missing author, revision and comment in tree view (#4270)....
r4973 @repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_entries_rev3 at unit model test...
r7013 @project.reload
assert_equal CHANGESETS_NUM, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: fix missing author, revision and comment in tree view (#4270)....
r4973 entries = @repository.entries('', '3')
assert_equal 3, entries.size
assert_equal entries[2].name, "README"
assert_equal entries[2].lastrev.time, Time.gm(2007, 12, 13, 16, 27, 22)
assert_equal entries[2].lastrev.identifier, '3'
assert_equal entries[2].lastrev.revision, '3'
assert_equal entries[2].lastrev.author, 'LANG'
end
Toshi MARUYAMA
scm: cvs: add cat test in unit model test....
r5274
Toshi MARUYAMA
scm: cvs: add entries test in invalid revision in model....
r5314 def test_entries_invalid_path
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_entries_invalid_path at unit model test...
r7014 assert_equal 0, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add invalid path entries test at unit model test....
r5278 @repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_entries_invalid_path at unit model test...
r7014 @project.reload
assert_equal CHANGESETS_NUM, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add invalid path entries test at unit model test....
r5278 assert_nil @repository.entries('missing')
assert_nil @repository.entries('missing', '3')
end
Toshi MARUYAMA
scm: cvs: add entries test in invalid revision in model....
r5314 def test_entries_invalid_revision
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_entries_invalid_revision at unit model test...
r7015 assert_equal 0, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add entries test in invalid revision in model....
r5314 @repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_entries_invalid_revision at unit model test...
r7015 @project.reload
assert_equal CHANGESETS_NUM, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add entries test in invalid revision in model....
r5314 assert_nil @repository.entries('', '123')
end
Toshi MARUYAMA
scm: cvs: add cat test in unit model test....
r5274 def test_cat
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_cat at unit model test...
r7016 assert_equal 0, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add cat test in unit model test....
r5274 @repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_cat at unit model test...
r7016 @project.reload
assert_equal CHANGESETS_NUM, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add cat test in unit model test....
r5274 buf = @repository.cat('README')
assert buf
lines = buf.split("\n")
Toshi MARUYAMA
scm: cvs: update test repository....
r5331 assert_equal 3, lines.length
Toshi MARUYAMA
scm: cvs: fix unit model cat test fails on Windows....
r5320 buf = lines[1].gsub(/\r$/, "")
assert_equal 'with one change', buf
Jean-Philippe Lang
Fixes an error raised by cvs test with Postgresql (revision is varchar)....
r5295 buf = @repository.cat('README', '1')
Toshi MARUYAMA
scm: cvs: add cat test in unit model test....
r5274 assert buf
lines = buf.split("\n")
assert_equal 1, lines.length
Toshi MARUYAMA
scm: cvs: fix unit model cat test fails on Windows....
r5320 buf = lines[0].gsub(/\r$/, "")
assert_equal 'CVS test repository', buf
Toshi MARUYAMA
scm: cvs: use model instead of adapter in unit model cat test....
r5285 assert_nil @repository.cat('missing.rb')
Toshi MARUYAMA
scm: cvs: add cat test of removed file in unit model test....
r5287
# sources/welcome_controller.rb is removed at revision 5.
assert @repository.cat('sources/welcome_controller.rb', '4')
assert @repository.cat('sources/welcome_controller.rb', '5').blank?
Toshi MARUYAMA
scm: cvs: add test that cat returns nil if revision does not exist at model....
r5289
# invalid revision
assert @repository.cat('README', '123').blank?
Toshi MARUYAMA
scm: cvs: add cat test in unit model test....
r5274 end
Toshi MARUYAMA
scm: cvs: add annotate test of HEAD revision in unit model test....
r5291
def test_annotate
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_annotate at unit model test...
r7017 assert_equal 0, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add annotate test of HEAD revision in unit model test....
r5291 @repository.fetch_changesets
Toshi MARUYAMA
Rails3: scm: cvs: fix error of test_annotate at unit model test...
r7017 @project.reload
assert_equal CHANGESETS_NUM, @repository.changesets.count
Toshi MARUYAMA
scm: cvs: add annotate test of HEAD revision in unit model test....
r5291 ann = @repository.annotate('README')
assert ann
Toshi MARUYAMA
scm: cvs: update test repository....
r5331 assert_equal 3, ann.revisions.length
Toshi MARUYAMA
scm: cvs: add annotate test of HEAD revision in unit model test....
r5291 assert_equal '1.2', ann.revisions[1].revision
assert_equal 'LANG', ann.revisions[1].author
assert_equal 'with one change', ann.lines[1]
Toshi MARUYAMA
scm: cvs: add test annotate with revision in unit model test....
r5293
ann = @repository.annotate('README', '1')
assert ann
assert_equal 1, ann.revisions.length
assert_equal '1.1', ann.revisions[0].revision
assert_equal 'LANG', ann.revisions[0].author
assert_equal 'CVS test repository', ann.lines[0]
Toshi MARUYAMA
scm: cvs: add invalid revision annotate test in unit model test....
r5294
# invalid revision
assert_nil @repository.annotate('README', '123')
Toshi MARUYAMA
scm: cvs: add annotate test of HEAD revision in unit model test....
r5291 end
Jean-Philippe Lang
Added some functional tests and a CVS test repository....
r974 else
puts "CVS test repository NOT FOUND. Skipping unit tests !!!"
def test_fake; assert true end
end
end