diff test/functional/.svn/text-base/repositories_cvs_controller_test.rb.svn-base @ 246:eeebe205a056 cannam

* Merge from default branch, bringing us up to SVN trunk rev 4993
author Chris Cannam
date Thu, 03 Mar 2011 12:02:03 +0000
parents 051f544170fe
children cbce1fd3b1b7
line wrap: on
line diff
--- a/test/functional/.svn/text-base/repositories_cvs_controller_test.rb.svn-base	Thu Jan 20 09:59:02 2011 +0000
+++ b/test/functional/.svn/text-base/repositories_cvs_controller_test.rb.svn-base	Thu Mar 03 12:02:03 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,19 @@
     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,
+                                          :log_encoding => 'UTF-8')
+    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 +58,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 +74,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 +88,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 +98,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 +109,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 +120,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 +145,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' },
@@ -134,10 +155,29 @@
       assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
                                :content => /watched.remove_all_watcher/
     end
+                               
+    def test_diff_new_files
+      @repository.fetch_changesets
+      @repository.reload
+      get :diff, :id => PRJ_ID, :rev => 1, :type => 'inline'
+      assert_response :success
+      assert_template 'diff'
+      assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
+                               :content => /watched.remove_watcher/
+      assert_tag :tag => 'th', :attributes => { :class => 'filename' },
+                               :content => /test\/README/
+      assert_tag :tag => 'th', :attributes => { :class => 'filename' },
+                               :content => /test\/images\/delete.png	/
+      assert_tag :tag => 'th', :attributes => { :class => 'filename' },
+                               :content => /test\/images\/edit.png/
+      assert_tag :tag => 'th', :attributes => { :class => 'filename' },
+                               :content => /test\/sources\/watchers_controller.rb/                        
+    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