You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repository_cvs_test.rb 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # redMine - project management software
  2. # Copyright (C) 2006-2007 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. require File.dirname(__FILE__) + '/../test_helper'
  18. require 'pp'
  19. class RepositoryCvsTest < Test::Unit::TestCase
  20. fixtures :projects
  21. # No '..' in the repository path
  22. REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
  23. REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
  24. # CVS module
  25. MODULE_NAME = 'test'
  26. def setup
  27. @project = Project.find(1)
  28. assert @repository = Repository::Cvs.create(:project => @project,
  29. :root_url => REPOSITORY_PATH,
  30. :url => MODULE_NAME)
  31. end
  32. if File.directory?(REPOSITORY_PATH)
  33. def test_fetch_changesets_from_scratch
  34. @repository.fetch_changesets
  35. @repository.reload
  36. assert_equal 5, @repository.changesets.count
  37. assert_equal 14, @repository.changes.count
  38. assert_equal 'Two files changed', @repository.changesets.find_by_revision(3).comments
  39. end
  40. def test_fetch_changesets_incremental
  41. @repository.fetch_changesets
  42. # Remove changesets with revision > 2
  43. @repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy)
  44. @repository.reload
  45. assert_equal 2, @repository.changesets.count
  46. @repository.fetch_changesets
  47. assert_equal 5, @repository.changesets.count
  48. end
  49. else
  50. puts "CVS test repository NOT FOUND. Skipping unit tests !!!"
  51. def test_fake; assert true end
  52. end
  53. end