diff test/functional/repositories_cvs_controller_test.rb @ 210:0579821a129a

Update to Redmine trunk rev 4802
author Chris Cannam
date Tue, 08 Feb 2011 13:51:46 +0000
parents 8661b858af72
children 051f544170fe
line wrap: on
line diff
--- a/test/functional/repositories_cvs_controller_test.rb	Wed Jan 19 15:04:22 2011 +0000
+++ b/test/functional/repositories_cvs_controller_test.rb	Tue Feb 08 13:51:46 2011 +0000
@@ -29,7 +29,8 @@
   REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
   # CVS module
   MODULE_NAME = 'test'
-  
+  PRJ_ID = 3
+
   def setup
     @controller = RepositoriesController.new
     @request    = ActionController::TestRequest.new
@@ -37,14 +38,18 @@
     Setting.default_language = 'en'
     User.current = nil
 
-    @project = Project.find(1)
-    @project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH,
-                                                 :url => MODULE_NAME)
+    @project = Project.find(PRJ_ID)
+    @repository  = Repository::Cvs.create(:project => Project.find(PRJ_ID),
+                                          :root_url => REPOSITORY_PATH,
+                                          :url => MODULE_NAME)
+    assert @repository
   end
   
   if File.directory?(REPOSITORY_PATH)
     def test_show
-      get :show, :id => 1
+      @repository.fetch_changesets
+      @repository.reload
+      get :show, :id => PRJ_ID
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entries)
@@ -52,7 +57,9 @@
     end
     
     def test_browse_root
-      get :show, :id => 1
+      @repository.fetch_changesets
+      @repository.reload
+      get :show, :id => PRJ_ID
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entries)
@@ -66,7 +73,9 @@
     end
     
     def test_browse_directory
-      get :show, :id => 1, :path => ['images']
+      @repository.fetch_changesets
+      @repository.reload
+      get :show, :id => PRJ_ID, :path => ['images']
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entries)
@@ -78,8 +87,9 @@
     end
     
     def test_browse_at_given_revision
-      Project.find(1).repository.fetch_changesets
-      get :show, :id => 1, :path => ['images'], :rev => 1
+      @repository.fetch_changesets
+      @repository.reload
+      get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entries)
@@ -87,7 +97,9 @@
     end
   
     def test_entry
-      get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
       assert_response :success
       assert_template 'entry'
       assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
@@ -96,8 +108,9 @@
     
     def test_entry_at_given_revision
       # changesets must be loaded
-      Project.find(1).repository.fetch_changesets
-      get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2
       assert_response :success
       assert_template 'entry'
       # this line was removed in r3
@@ -106,18 +119,24 @@
     end
     
     def test_entry_not_found
-      get :entry, :id => 1, :path => ['sources', 'zzz.c']
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c']
       assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
                                 :content => /The entry or revision was not found in the repository/
     end
   
     def test_entry_download
-      get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
       assert_response :success
     end
 
     def test_directory_entry
-      get :entry, :id => 1, :path => ['sources']
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['sources']
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entry)
@@ -125,8 +144,9 @@
     end
     
     def test_diff
-      Project.find(1).repository.fetch_changesets
-      get :diff, :id => 1, :rev => 3, :type => 'inline'
+      @repository.fetch_changesets
+      @repository.reload
+      get :diff, :id => PRJ_ID, :rev => 3, :type => 'inline'
       assert_response :success
       assert_template 'diff'
       assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
@@ -136,8 +156,9 @@
     end
 
     def test_annotate
-      Project.find(1).repository.fetch_changesets
-      get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb']
+      @repository.fetch_changesets
+      @repository.reload
+      get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
       assert_response :success
       assert_template 'annotate'
       # 1.1 line