diff test/functional/repositories_subversion_controller_test.rb @ 245:051f544170fe

* Update to SVN trunk revision 4993
author Chris Cannam
date Thu, 03 Mar 2011 11:42:28 +0000
parents 0579821a129a
children cbce1fd3b1b7
line wrap: on
line diff
--- a/test/functional/repositories_subversion_controller_test.rb	Thu Mar 03 11:40:10 2011 +0000
+++ b/test/functional/repositories_subversion_controller_test.rb	Thu Mar 03 11:42:28 2011 +0000
@@ -26,17 +26,26 @@
            :repositories, :issues, :issue_statuses, :changesets, :changes,
            :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
 
+  PRJ_ID = 3
+
   def setup
     @controller = RepositoriesController.new
     @request    = ActionController::TestRequest.new
     @response   = ActionController::TestResponse.new
     Setting.default_language = 'en'
     User.current = nil
+
+    @project = Project.find(PRJ_ID)
+    @repository = Repository::Subversion.create(:project => @project,
+               :url => "file://#{self.class.repository_path('subversion')}")
+    assert @repository
   end
 
   if repository_configured?('subversion')
     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)
@@ -44,7 +53,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)
@@ -53,7 +64,9 @@
     end
     
     def test_browse_directory
-      get :show, :id => 1, :path => ['subversion_test']
+      @repository.fetch_changesets
+      @repository.reload
+      get :show, :id => PRJ_ID, :path => ['subversion_test']
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entries)
@@ -65,7 +78,9 @@
     end
 
     def test_browse_at_given_revision
-      get :show, :id => 1, :path => ['subversion_test'], :rev => 4
+      @repository.fetch_changesets
+      @repository.reload
+      get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entries)
@@ -73,7 +88,9 @@
     end
     
     def test_file_changes
-      get :changes, :id => 1, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
+      @repository.fetch_changesets
+      @repository.reload
+      get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
       assert_response :success
       assert_template 'changes'
       
@@ -93,7 +110,9 @@
     end
 
     def test_directory_changes
-      get :changes, :id => 1, :path => ['subversion_test', 'folder' ]
+      @repository.fetch_changesets
+      @repository.reload
+      get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ]
       assert_response :success
       assert_template 'changes'
       
@@ -103,15 +122,19 @@
     end
       
     def test_entry
-      get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
       assert_response :success
       assert_template 'entry'
     end
       
     def test_entry_should_send_if_too_big
+      @repository.fetch_changesets
+      @repository.reload
       # no files in the test repo is larger than 1KB...
       with_settings :file_max_size_displayed => 0 do
-        get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
+        get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
         assert_response :success
         assert_template ''
         assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
@@ -119,7 +142,9 @@
     end
     
     def test_entry_at_given_revision
-      get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
       assert_response :success
       assert_template 'entry'
       # this line was removed in r3 and file was moved in r6
@@ -128,27 +153,36 @@
     end
     
     def test_entry_not_found
-      get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['subversion_test', '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 => ['subversion_test', 'helloworld.c'], :format => 'raw'
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
       assert_response :success
       assert_template ''
       assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
     end
     
     def test_directory_entry
-      get :entry, :id => 1, :path => ['subversion_test', 'folder']
+      @repository.fetch_changesets
+      @repository.reload
+      get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder']
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entry)
       assert_equal 'folder', assigns(:entry).name
     end
     
+    # TODO: this test needs fixtures.
     def test_revision
+      @repository.fetch_changesets
+      @repository.reload
       get :revision, :id => 1, :rev => 2
       assert_response :success
       assert_template 'revision'
@@ -167,19 +201,30 @@
     end
     
     def test_invalid_revision
-      get :revision, :id => 1, :rev => 'something_weird'
+      @repository.fetch_changesets
+      @repository.reload
+      get :revision, :id => PRJ_ID, :rev => 'something_weird'
+      assert_response 404
+      assert_error_tag :content => /was not found/
+    end
+
+    def test_invalid_revision_diff
+      get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird'
       assert_response 404
       assert_error_tag :content => /was not found/
     end
 
     def test_empty_revision
+      @repository.fetch_changesets
+      @repository.reload
       ['', ' ', nil].each do |r|
-        get :revision, :id => 1, :rev => r
+        get :revision, :id => PRJ_ID, :rev => r
         assert_response 404
         assert_error_tag :content => /was not found/
       end
     end
 
+    # TODO: this test needs fixtures.
     def test_revision_with_repository_pointing_to_a_subdirectory
       r = Project.find(1).repository
       # Changes repository url to a subdirectory
@@ -203,7 +248,9 @@
     end
     
     def test_revision_diff
-      get :diff, :id => 1, :rev => 3
+      @repository.fetch_changesets
+      @repository.reload
+      get :diff, :id => PRJ_ID, :rev => 3
       assert_response :success
       assert_template 'diff'
 
@@ -211,7 +258,9 @@
     end
 
     def test_directory_diff
-      get :diff, :id => 1, :rev => 6, :rev_to => 2, :path => ['subversion_test', 'folder']
+      @repository.fetch_changesets
+      @repository.reload
+      get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, :path => ['subversion_test', 'folder']
       assert_response :success
       assert_template 'diff'
       
@@ -224,13 +273,17 @@
     end
     
     def test_annotate
-      get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c']
+      @repository.fetch_changesets
+      @repository.reload
+      get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
       assert_response :success
       assert_template 'annotate'
     end
 
     def test_annotate_at_given_revision
-      get :annotate, :id => 1, :rev => 8, :path => ['subversion_test', 'helloworld.c']
+      @repository.fetch_changesets
+      @repository.reload
+      get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c']
       assert_response :success
       assert_template 'annotate'
       assert_tag :tag => 'h2', :content => /@ 8/