comparison test/unit/.svn/text-base/repository_darcs_test.rb.svn-base @ 245:051f544170fe

* Update to SVN trunk revision 4993
author Chris Cannam
date Thu, 03 Mar 2011 11:42:28 +0000
parents 8661b858af72
children cbce1fd3b1b7
comparison
equal deleted inserted replaced
244:8972b600f4fb 245:051f544170fe
17 17
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 class RepositoryDarcsTest < ActiveSupport::TestCase 20 class RepositoryDarcsTest < ActiveSupport::TestCase
21 fixtures :projects 21 fixtures :projects
22 22
23 # No '..' in the repository path 23 # No '..' in the repository path
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository' 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository'
25 25
26 def setup 26 def setup
27 @project = Project.find(1) 27 @project = Project.find(3)
28 assert @repository = Repository::Darcs.create(:project => @project, :url => REPOSITORY_PATH) 28 @repository = Repository::Darcs.create(
29 :project => @project, :url => REPOSITORY_PATH,
30 :log_encoding => 'UTF-8')
31 assert @repository
29 end 32 end
30 33
31 if File.directory?(REPOSITORY_PATH) 34 if File.directory?(REPOSITORY_PATH)
32 def test_fetch_changesets_from_scratch 35 def test_fetch_changesets_from_scratch
33 @repository.fetch_changesets 36 @repository.fetch_changesets
34 @repository.reload 37 @repository.reload
35 38
36 assert_equal 6, @repository.changesets.count 39 assert_equal 6, @repository.changesets.count
37 assert_equal 13, @repository.changes.count 40 assert_equal 13, @repository.changes.count
38 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments 41 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
39 end 42 end
40 43
41 def test_fetch_changesets_incremental 44 def test_fetch_changesets_incremental
42 @repository.fetch_changesets 45 @repository.fetch_changesets
43 # Remove changesets with revision > 3 46 # Remove changesets with revision > 3
44 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} 47 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
45 @repository.reload 48 @repository.reload
46 assert_equal 3, @repository.changesets.count 49 assert_equal 3, @repository.changesets.count
47 50
48 @repository.fetch_changesets 51 @repository.fetch_changesets
49 assert_equal 6, @repository.changesets.count 52 assert_equal 6, @repository.changesets.count
50 end 53 end
51 54
52 def test_deleted_files_should_not_be_listed 55 def test_deleted_files_should_not_be_listed
56 @repository.fetch_changesets
57 @repository.reload
53 entries = @repository.entries('sources') 58 entries = @repository.entries('sources')
54 assert entries.detect {|e| e.name == 'watchers_controller.rb'} 59 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
55 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'} 60 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
56 end 61 end
57 62