##// END OF EJS Templates
Rails3: scm: darcs: fix error of test_browse_root at functional test...
Toshi MARUYAMA -
r7028:435886e1a1fb
parent child
Show More
@@ -1,152 +1,154
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 NUM_REV = 6
31 31
32 32 def setup
33 33 @controller = RepositoriesController.new
34 34 @request = ActionController::TestRequest.new
35 35 @response = ActionController::TestResponse.new
36 36 User.current = nil
37 37 @project = Project.find(PRJ_ID)
38 38 @repository = Repository::Darcs.create(
39 39 :project => @project,
40 40 :url => REPOSITORY_PATH,
41 41 :log_encoding => 'UTF-8'
42 42 )
43 43 assert @repository
44 44 end
45 45
46 46 if File.directory?(REPOSITORY_PATH)
47 47 def test_browse_root
48 assert_equal 0, @repository.changesets.count
48 49 @repository.fetch_changesets
49 @repository.reload
50 @project.reload
51 assert_equal NUM_REV, @repository.changesets.count
50 52 get :show, :id => PRJ_ID
51 53 assert_response :success
52 54 assert_template 'show'
53 55 assert_not_nil assigns(:entries)
54 56 assert_equal 3, assigns(:entries).size
55 57 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
56 58 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
57 59 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
58 60 end
59 61
60 62 def test_browse_directory
61 63 @repository.fetch_changesets
62 64 @repository.reload
63 65 get :show, :id => PRJ_ID, :path => ['images']
64 66 assert_response :success
65 67 assert_template 'show'
66 68 assert_not_nil assigns(:entries)
67 69 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
68 70 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
69 71 assert_not_nil entry
70 72 assert_equal 'file', entry.kind
71 73 assert_equal 'images/edit.png', entry.path
72 74 end
73 75
74 76 def test_browse_at_given_revision
75 77 @repository.fetch_changesets
76 78 @repository.reload
77 79 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
78 80 assert_response :success
79 81 assert_template 'show'
80 82 assert_not_nil assigns(:entries)
81 83 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
82 84 end
83 85
84 86 def test_changes
85 87 @repository.fetch_changesets
86 88 @repository.reload
87 89 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
88 90 assert_response :success
89 91 assert_template 'changes'
90 92 assert_tag :tag => 'h2', :content => 'edit.png'
91 93 end
92 94
93 95 def test_diff
94 96 @repository.fetch_changesets
95 97 @repository.reload
96 98 # Full diff of changeset 5
97 99 ['inline', 'sbs'].each do |dt|
98 100 get :diff, :id => PRJ_ID, :rev => 5, :type => dt
99 101 assert_response :success
100 102 assert_template 'diff'
101 103 # Line 22 removed
102 104 assert_tag :tag => 'th',
103 105 :content => '22',
104 106 :sibling => { :tag => 'td',
105 107 :attributes => { :class => /diff_out/ },
106 108 :content => /def remove/ }
107 109 end
108 110 end
109 111
110 112 def test_destroy_valid_repository
111 113 @request.session[:user_id] = 1 # admin
112 114 @repository.fetch_changesets
113 115 @repository.reload
114 116 assert @repository.changesets.count > 0
115 117
116 118 get :destroy, :id => PRJ_ID
117 119 assert_response 302
118 120 @project.reload
119 121 assert_nil @project.repository
120 122 end
121 123
122 124 def test_destroy_invalid_repository
123 125 @request.session[:user_id] = 1 # admin
124 126 @repository.fetch_changesets
125 127 @repository.reload
126 128 assert @repository.changesets.count > 0
127 129
128 130 get :destroy, :id => PRJ_ID
129 131 assert_response 302
130 132 @project.reload
131 133 assert_nil @project.repository
132 134
133 135 @repository = Repository::Darcs.create(
134 136 :project => @project,
135 137 :url => "/invalid",
136 138 :log_encoding => 'UTF-8'
137 139 )
138 140 assert @repository
139 141 @repository.fetch_changesets
140 142 @repository.reload
141 143 assert_equal 0, @repository.changesets.count
142 144
143 145 get :destroy, :id => PRJ_ID
144 146 assert_response 302
145 147 @project.reload
146 148 assert_nil @project.repository
147 149 end
148 150 else
149 151 puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
150 152 def test_fake; assert true end
151 153 end
152 154 end
General Comments 0
You need to be logged in to leave comments. Login now