annotate test/unit/repository_darcs_test.rb @ 1271:cf4cc816278a live last_rails2_version

Remove inner quotes from realm (workaround for #577)
author Chris Cannam
date Tue, 07 May 2013 12:45:51 +0100
parents cbb26bc654de
children 433d4f72a19b
rev   line source
Chris@909 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@119 18 require File.expand_path('../../test_helper', __FILE__)
Chris@0 19
Chris@0 20 class RepositoryDarcsTest < ActiveSupport::TestCase
Chris@0 21 fixtures :projects
Chris@245 22
Chris@909 23 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
Chris@909 24 NUM_REV = 6
Chris@245 25
Chris@0 26 def setup
Chris@245 27 @project = Project.find(3)
Chris@245 28 @repository = Repository::Darcs.create(
Chris@909 29 :project => @project,
Chris@909 30 :url => REPOSITORY_PATH,
Chris@909 31 :log_encoding => 'UTF-8'
Chris@909 32 )
Chris@245 33 assert @repository
Chris@0 34 end
Chris@245 35
Chris@909 36 if File.directory?(REPOSITORY_PATH)
Chris@0 37 def test_fetch_changesets_from_scratch
Chris@909 38 assert_equal 0, @repository.changesets.count
Chris@0 39 @repository.fetch_changesets
Chris@909 40 @project.reload
Chris@245 41
Chris@909 42 assert_equal NUM_REV, @repository.changesets.count
Chris@0 43 assert_equal 13, @repository.changes.count
Chris@0 44 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
Chris@0 45 end
Chris@245 46
Chris@0 47 def test_fetch_changesets_incremental
Chris@909 48 assert_equal 0, @repository.changesets.count
Chris@0 49 @repository.fetch_changesets
Chris@909 50 @project.reload
Chris@909 51 assert_equal NUM_REV, @repository.changesets.count
Chris@909 52
Chris@0 53 # Remove changesets with revision > 3
Chris@0 54 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
Chris@909 55 @project.reload
Chris@0 56 assert_equal 3, @repository.changesets.count
Chris@909 57
Chris@0 58 @repository.fetch_changesets
Chris@909 59 @project.reload
Chris@909 60 assert_equal NUM_REV, @repository.changesets.count
Chris@0 61 end
Chris@245 62
Chris@441 63 def test_entries_invalid_revision
Chris@909 64 assert_equal 0, @repository.changesets.count
Chris@441 65 @repository.fetch_changesets
Chris@909 66 @project.reload
Chris@909 67 assert_equal NUM_REV, @repository.changesets.count
Chris@441 68 assert_nil @repository.entries('', '123')
Chris@441 69 end
Chris@441 70
Chris@0 71 def test_deleted_files_should_not_be_listed
Chris@909 72 assert_equal 0, @repository.changesets.count
Chris@245 73 @repository.fetch_changesets
Chris@909 74 @project.reload
Chris@909 75 assert_equal NUM_REV, @repository.changesets.count
Chris@0 76 entries = @repository.entries('sources')
Chris@0 77 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
Chris@0 78 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
Chris@0 79 end
Chris@119 80
Chris@0 81 def test_cat
Chris@119 82 if @repository.scm.supports_cat?
Chris@909 83 assert_equal 0, @repository.changesets.count
Chris@119 84 @repository.fetch_changesets
Chris@909 85 @project.reload
Chris@909 86 assert_equal NUM_REV, @repository.changesets.count
Chris@119 87 cat = @repository.cat("sources/welcome_controller.rb", 2)
Chris@119 88 assert_not_nil cat
Chris@119 89 assert cat.include?('class WelcomeController < ApplicationController')
Chris@119 90 end
Chris@0 91 end
Chris@0 92 else
Chris@0 93 puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
Chris@0 94 def test_fake; assert true end
Chris@0 95 end
Chris@0 96 end