##// END OF EJS Templates
scm: darcs: code clean up functional test....
Toshi MARUYAMA -
r6112:1a1724128baa
parent child
Show More
@@ -1,110 +1,112
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 require 'repositories_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class RepositoriesController; def rescue_action(e) raise e end; end
23 23
24 24 class RepositoriesDarcsControllerTest < ActionController::TestCase
25 25 fixtures :projects, :users, :roles, :members, :member_roles,
26 26 :repositories, :enabled_modules
27 27
28 28 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
29 29 PRJ_ID = 3
30 30
31 31 def setup
32 32 @controller = RepositoriesController.new
33 33 @request = ActionController::TestRequest.new
34 34 @response = ActionController::TestResponse.new
35 35 User.current = nil
36 36 @project = Project.find(PRJ_ID)
37 37 @repository = Repository::Darcs.create(
38 :project => @project, :url => REPOSITORY_PATH,
39 :log_encoding => 'UTF-8')
38 :project => @project,
39 :url => REPOSITORY_PATH,
40 :log_encoding => 'UTF-8'
41 )
40 42 assert @repository
41 43 end
42 44
43 45 if File.directory?(REPOSITORY_PATH)
44 46 def test_browse_root
45 47 @repository.fetch_changesets
46 48 @repository.reload
47 49 get :show, :id => PRJ_ID
48 50 assert_response :success
49 51 assert_template 'show'
50 52 assert_not_nil assigns(:entries)
51 53 assert_equal 3, assigns(:entries).size
52 54 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
53 55 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
54 56 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
55 57 end
56 58
57 59 def test_browse_directory
58 60 @repository.fetch_changesets
59 61 @repository.reload
60 62 get :show, :id => PRJ_ID, :path => ['images']
61 63 assert_response :success
62 64 assert_template 'show'
63 65 assert_not_nil assigns(:entries)
64 66 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
65 67 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
66 68 assert_not_nil entry
67 69 assert_equal 'file', entry.kind
68 70 assert_equal 'images/edit.png', entry.path
69 71 end
70 72
71 73 def test_browse_at_given_revision
72 74 @repository.fetch_changesets
73 75 @repository.reload
74 76 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
75 77 assert_response :success
76 78 assert_template 'show'
77 79 assert_not_nil assigns(:entries)
78 80 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
79 81 end
80 82
81 83 def test_changes
82 84 @repository.fetch_changesets
83 85 @repository.reload
84 86 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
85 87 assert_response :success
86 88 assert_template 'changes'
87 89 assert_tag :tag => 'h2', :content => 'edit.png'
88 90 end
89 91
90 92 def test_diff
91 93 @repository.fetch_changesets
92 94 @repository.reload
93 95 # Full diff of changeset 5
94 96 ['inline', 'sbs'].each do |dt|
95 97 get :diff, :id => PRJ_ID, :rev => 5, :type => dt
96 98 assert_response :success
97 99 assert_template 'diff'
98 100 # Line 22 removed
99 101 assert_tag :tag => 'th',
100 102 :content => '22',
101 103 :sibling => { :tag => 'td',
102 104 :attributes => { :class => /diff_out/ },
103 105 :content => /def remove/ }
104 106 end
105 107 end
106 108 else
107 109 puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
108 110 def test_fake; assert true end
109 111 end
110 112 end
General Comments 0
You need to be logged in to leave comments. Login now