comparison test/functional/.svn/text-base/repositories_git_controller_test.rb.svn-base @ 119:8661b858af72

* Update to Redmine trunk rev 4705
author Chris Cannam
date Thu, 13 Jan 2011 14:12:06 +0000
parents 94944d00e43c
children 07fa8a8b56a8
comparison
equal deleted inserted replaced
39:150ceac17a8d 119:8661b858af72
13 # 13 #
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.dirname(__FILE__) + '/../test_helper' 18 require File.expand_path('../../test_helper', __FILE__)
19 require 'repositories_controller' 19 require 'repositories_controller'
20 20
21 # Re-raise errors caught by the controller. 21 # Re-raise errors caught by the controller.
22 class RepositoriesController; def rescue_action(e) raise e end; end 22 class RepositoriesController; def rescue_action(e) raise e end; end
23 23
31 def setup 31 def setup
32 @controller = RepositoriesController.new 32 @controller = RepositoriesController.new
33 @request = ActionController::TestRequest.new 33 @request = ActionController::TestRequest.new
34 @response = ActionController::TestResponse.new 34 @response = ActionController::TestResponse.new
35 User.current = nil 35 User.current = nil
36 Repository::Git.create(:project => Project.find(3), :url => REPOSITORY_PATH) 36 @repository = Repository::Git.create(:project => Project.find(3), :url => REPOSITORY_PATH)
37 assert @repository
37 end 38 end
38 39
39 if File.directory?(REPOSITORY_PATH) 40 if File.directory?(REPOSITORY_PATH)
40 def test_show 41 def test_show
41 get :show, :id => 3 42 get :show, :id => 3
42 assert_response :success 43 assert_response :success
43 assert_template 'show' 44 assert_template 'show'
124 assert_response :success 125 assert_response :success
125 assert_template 'show' 126 assert_template 'show'
126 assert_not_nil assigns(:entry) 127 assert_not_nil assigns(:entry)
127 assert_equal 'sources', assigns(:entry).name 128 assert_equal 'sources', assigns(:entry).name
128 end 129 end
129 130
130 def test_diff 131 def test_diff
132 @repository.fetch_changesets
133 @repository.reload
134
131 # Full diff of changeset 2f9c0091 135 # Full diff of changeset 2f9c0091
132 get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' 136 get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
133 assert_response :success 137 assert_response :success
134 assert_template 'diff' 138 assert_template 'diff'
135 # Line 22 removed 139 # Line 22 removed
136 assert_tag :tag => 'th', 140 assert_tag :tag => 'th',
137 :content => /22/, 141 :content => /22/,
138 :sibling => { :tag => 'td', 142 :sibling => { :tag => 'td',
139 :attributes => { :class => /diff_out/ }, 143 :attributes => { :class => /diff_out/ },
140 :content => /def remove/ } 144 :content => /def remove/ }
145 assert_tag :tag => 'h2', :content => /2f9c0091/
146 end
147
148 def test_diff_two_revs
149 @repository.fetch_changesets
150 @repository.reload
151
152 get :diff, :id => 3, :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
153 :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
154 assert_response :success
155 assert_template 'diff'
156
157 diff = assigns(:diff)
158 assert_not_nil diff
159 assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/
141 end 160 end
142 161
143 def test_annotate 162 def test_annotate
144 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb'] 163 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
145 assert_response :success 164 assert_response :success
148 assert_tag :tag => 'th', :content => /24/, 167 assert_tag :tag => 'th', :content => /24/,
149 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /2f9c0091/ } }, 168 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /2f9c0091/ } },
150 :sibling => { :tag => 'td', :content => /jsmith/ }, 169 :sibling => { :tag => 'td', :content => /jsmith/ },
151 :sibling => { :tag => 'td', :content => /watcher =/ } 170 :sibling => { :tag => 'td', :content => /watcher =/ }
152 end 171 end
153 172
154 def test_annotate_binary_file 173 def test_annotate_binary_file
155 get :annotate, :id => 3, :path => ['images', 'edit.png'] 174 get :annotate, :id => 3, :path => ['images', 'edit.png']
156 assert_response 500 175 assert_response 500
157 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, 176 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
158 :content => /can not be annotated/ 177 :content => /can not be annotated/
159 end 178 end
179
180 def test_revision
181 @repository.fetch_changesets
182 @repository.reload
183 ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
184 get :revision, :id => 3, :rev => r
185 assert_response :success
186 assert_template 'revision'
187 end
188 end
189
190 def test_empty_revision
191 @repository.fetch_changesets
192 @repository.reload
193 ['', ' ', nil].each do |r|
194 get :revision, :id => 1, :rev => r
195 assert_response 500
196 assert_error_tag :content => /was not found/
197 end
198 end
160 else 199 else
161 puts "Git test repository NOT FOUND. Skipping functional tests !!!" 200 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
162 def test_fake; assert true end 201 def test_fake; assert true end
163 end 202 end
164 end 203 end