##// END OF EJS Templates
scm: darcs: replace RAILS_ROOT to Rails.root in unit model test....
Toshi MARUYAMA -
r5928:ea9847bb37c7
parent child
Show More
@@ -1,81 +1,82
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class RepositoryDarcsTest < ActiveSupport::TestCase
21 21 fixtures :projects
22 22
23 # No '..' in the repository path
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository'
23 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
25 24
26 25 def setup
27 26 @project = Project.find(3)
28 27 @repository = Repository::Darcs.create(
29 :project => @project, :url => REPOSITORY_PATH,
30 :log_encoding => 'UTF-8')
28 :project => @project,
29 :url => REPOSITORY_PATH,
30 :log_encoding => 'UTF-8'
31 )
31 32 assert @repository
32 33 end
33 34
34 35 if File.directory?(REPOSITORY_PATH)
35 36 def test_fetch_changesets_from_scratch
36 37 @repository.fetch_changesets
37 38 @repository.reload
38 39
39 40 assert_equal 6, @repository.changesets.count
40 41 assert_equal 13, @repository.changes.count
41 42 assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
42 43 end
43 44
44 45 def test_fetch_changesets_incremental
45 46 @repository.fetch_changesets
46 47 # Remove changesets with revision > 3
47 48 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
48 49 @repository.reload
49 50 assert_equal 3, @repository.changesets.count
50 51
51 52 @repository.fetch_changesets
52 53 assert_equal 6, @repository.changesets.count
53 54 end
54 55
55 56 def test_entries_invalid_revision
56 57 @repository.fetch_changesets
57 58 @repository.reload
58 59 assert_nil @repository.entries('', '123')
59 60 end
60 61
61 62 def test_deleted_files_should_not_be_listed
62 63 @repository.fetch_changesets
63 64 @repository.reload
64 65 entries = @repository.entries('sources')
65 66 assert entries.detect {|e| e.name == 'watchers_controller.rb'}
66 67 assert_nil entries.detect {|e| e.name == 'welcome_controller.rb'}
67 68 end
68 69
69 70 def test_cat
70 71 if @repository.scm.supports_cat?
71 72 @repository.fetch_changesets
72 73 cat = @repository.cat("sources/welcome_controller.rb", 2)
73 74 assert_not_nil cat
74 75 assert cat.include?('class WelcomeController < ApplicationController')
75 76 end
76 77 end
77 78 else
78 79 puts "Darcs test repository NOT FOUND. Skipping unit tests !!!"
79 80 def test_fake; assert true end
80 81 end
81 82 end
General Comments 0
You need to be logged in to leave comments. Login now