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