]> source.dussan.org Git - redmine.git/commitdiff
Added some functional tests (projects and repositories).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 12 Dec 2007 20:56:22 +0000 (20:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 12 Dec 2007 20:56:22 +0000 (20:56 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@981 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/fixtures/repositories.yml
test/functional/projects_controller_test.rb
test/functional/repositories_controller_test.rb
test/functional/repositories_subversion_controller_test.rb [new file with mode: 0644]
test/unit/repository_bazaar_test.rb
test/unit/repository_subversion_test.rb

index 46afed2457bb2b62f9b744f2cd9d9baf1ca31690..d86e301c9c24dd4525342feaa0f5dd90c8476d9a 100644 (file)
@@ -1,11 +1,12 @@
 --- \r
 repositories_001: \r
   project_id: 1\r
-  url: svn://localhost/test\r
+  url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository\r
   id: 10\r
-  root_url: svn://localhost\r
+  root_url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository\r
   password: ""\r
   login: ""\r
+  type: Subversion\r
 repositories_002: \r
   project_id: 2\r
   url: svn://localhost/test\r
@@ -13,3 +14,4 @@ repositories_002:
   root_url: svn://localhost\r
   password: ""\r
   login: ""\r
+  type: Subversion\r
index d98e0d97b3eaa73e3dbab436a5509c64fc371e85..52c33ddd7772c4588a86a87cc941fb436bd3b193 100644 (file)
@@ -22,7 +22,7 @@ require 'projects_controller'
 class ProjectsController; def rescue_action(e) raise e end; end
 
 class ProjectsControllerTest < Test::Unit::TestCase
-  fixtures :projects, :users, :roles, :members, :issues, :journals, :journal_details, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations
+  fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations
 
   def setup
     @controller = ProjectsController.new
@@ -41,6 +41,10 @@ class ProjectsControllerTest < Test::Unit::TestCase
     assert_response :success
     assert_template 'list'
     assert_not_nil assigns(:project_tree)
+    # Root project as hash key
+    assert assigns(:project_tree).has_key?(Project.find(1))
+    # Subproject in corresponding value
+    assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
   end\r
   \r
   def test_show\r
@@ -86,6 +90,21 @@ class ProjectsControllerTest < Test::Unit::TestCase
     assert_response :success
     assert_template 'roadmap'
     assert_not_nil assigns(:versions)
+    # Version with no date set appears
+    assert assigns(:versions).include?(Version.find(3))
+    # Completed version doesn't appear
+    assert !assigns(:versions).include?(Version.find(1))
+  end
+  
+  def test_roadmap_with_completed_versions
+    get :roadmap, :id => 1, :completed => 1
+    assert_response :success
+    assert_template 'roadmap'
+    assert_not_nil assigns(:versions)
+    # Version with no date set appears
+    assert assigns(:versions).include?(Version.find(3))
+    # Completed version appears
+    assert assigns(:versions).include?(Version.find(1))
   end
 
   def test_activity
@@ -120,6 +139,42 @@ class ProjectsControllerTest < Test::Unit::TestCase
                }
   end
   
+  def test_calendar
+    get :calendar, :id => 1
+    assert_response :success
+    assert_template 'calendar'
+    assert_not_nil assigns(:calendar)
+  end
+
+  def test_calendar_with_subprojects
+    get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
+    assert_response :success
+    assert_template 'calendar'
+    assert_not_nil assigns(:calendar)
+  end
+
+  def test_gantt
+    get :gantt, :id => 1
+    assert_response :success
+    assert_template 'gantt.rhtml'
+    assert_not_nil assigns(:events)
+  end
+
+  def test_gantt_with_subprojects
+    get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
+    assert_response :success
+    assert_template 'gantt.rhtml'
+    assert_not_nil assigns(:events)
+  end
+  
+  def test_gantt_export_to_pdf
+    get :gantt, :id => 1, :format => 'pdf'
+    assert_response :success
+    assert_template 'gantt.rfpdf'
+    assert_equal 'application/pdf', @response.content_type
+    assert_not_nil assigns(:events)
+  end
+  
   def test_archive    
     @request.session[:user_id] = 1 # admin
     post :archive, :id => 1
index d5ccc660ddbefeee5cfaa0509b02d317e1c0962a..2f04595059fdb9ff3372ef2a2d9e7fc762931719 100644 (file)
@@ -31,6 +31,13 @@ class RepositoriesControllerTest < Test::Unit::TestCase
     User.current = nil
   end
   
+  def test_revisions
+    get :revisions, :id => 1
+    assert_response :success
+    assert_template 'revisions'
+    assert_not_nil assigns(:changesets)
+  end
+  
   def test_revision_with_before_nil_and_afer_normal
     get :revision, {:id => 1, :rev => 1}
     assert_response :success
@@ -43,4 +50,15 @@ class RepositoriesControllerTest < Test::Unit::TestCase
     }
   end
 
+  def test_graph_commits_per_month
+    get :graph, :id => 1, :graph => 'commits_per_month'
+    assert_response :success
+    assert_equal 'image/svg+xml', @response.content_type
+  end
+  
+  def test_graph_commits_per_author
+    get :graph, :id => 1, :graph => 'commits_per_author'
+    assert_response :success
+    assert_equal 'image/svg+xml', @response.content_type
+  end
 end
diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb
new file mode 100644 (file)
index 0000000..9cc7048
--- /dev/null
@@ -0,0 +1,91 @@
+# redMine - project management software
+# Copyright (C) 2006-2007  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'repositories_controller'
+
+# Re-raise errors caught by the controller.
+class RepositoriesController; def rescue_action(e) raise e end; end
+
+class RepositoriesControllerTest < Test::Unit::TestCase
+  fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
+
+  # No '..' in the repository path for svn
+  REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository'
+
+  def setup
+    @controller = RepositoriesController.new
+    @request    = ActionController::TestRequest.new
+    @response   = ActionController::TestResponse.new
+    User.current = nil
+  end
+
+  if File.directory?(REPOSITORY_PATH)
+    def test_show
+      get :show, :id => 1
+      assert_response :success
+      assert_template 'show'
+      assert_not_nil assigns(:entries)
+      assert_not_nil assigns(:changesets)
+    end
+    
+    def test_browse_root
+      get :browse, :id => 1
+      assert_response :success
+      assert_template 'browse'
+      assert_not_nil assigns(:entries)
+      entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
+      assert_equal 'dir', entry.kind
+    end
+    
+    def test_browse_directory
+      get :browse, :id => 1, :path => ['subversion_test']
+      assert_response :success
+      assert_template 'browse'
+      assert_not_nil assigns(:entries)
+      entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
+      assert_equal 'file', entry.kind
+      assert_equal 'subversion_test/helloworld.c', entry.path
+    end
+  
+    def test_entry
+      get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
+      assert_response :success
+      assert_template 'entry'
+    end
+  
+    def test_entry_download
+      get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
+      assert_response :success
+    end
+    
+    def test_diff
+      get :diff, :id => 1, :rev => 3
+      assert_response :success
+      assert_template 'diff'
+    end
+    
+    def test_annotate
+      get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c']
+      assert_response :success
+      assert_template 'annotate'
+    end
+  else
+    puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
+    def test_fake; assert true end
+  end
+end
index 68a1ef5e345fc80a3d6f02a49896580bf37adb06..22a1909908a602d14ac4c8ef0d3e89afd9356c24 100644 (file)
@@ -81,7 +81,7 @@ class RepositoryBazaarTest < Test::Unit::TestCase
       assert_equal 'mkdir', annotate.lines[0]
     end
   else
-    puts "Bazaar test repository NOT FOUND. Skipping tests !!!"
+    puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
     def test_fake; assert true end
   end
 end
index 592eb4ffa4cd76311ba1cc2aa30b7e74589023e7..879feece894f3724e4d5ae6feb40f0a922ec20d5 100644 (file)
@@ -49,7 +49,7 @@ class RepositorySubversionTest < Test::Unit::TestCase
       assert_equal 8, @repository.changesets.count
     end
   else
-    puts "Subversion test repository NOT FOUND. Skipping tests !!!"
+    puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
     def test_fake; assert true end
   end
 end