Added some functional tests (projects and repositories).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@981 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-12-12 20:56:22 +00:00
parent 3539bef96b
commit 76ed8cc200
6 changed files with 171 additions and 5 deletions

View File

@ -1,11 +1,12 @@
---
repositories_001:
project_id: 1
url: svn://localhost/test
url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository
id: 10
root_url: svn://localhost
root_url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository
password: ""
login: ""
type: Subversion
repositories_002:
project_id: 2
url: svn://localhost/test
@ -13,3 +14,4 @@ repositories_002:
root_url: svn://localhost
password: ""
login: ""
type: Subversion

View 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
def test_show
@ -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

View 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

View File

@ -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

View 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

View 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