Commit 989a3429 authored by jplang's avatar jplang

Functional tests cleanup.

git-svn-id: https://svn.redmine.org/redmine/trunk@10936 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 21e838ed
......@@ -16,18 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'account_controller'
# Re-raise errors caught by the controller.
class AccountController; def rescue_action(e) raise e end; end
class AccountControllerTest < ActionController::TestCase
fixtures :users, :roles
def setup
@controller = AccountController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
# Redmine - project management software
# Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
class ActivitiesControllerTest < ActionController::TestCase
......
......@@ -18,10 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'attachments_controller'
# Re-raise errors caught by the controller.
class AttachmentsController; def rescue_action(e) raise e end; end
class AttachmentsControllerTest < ActionController::TestCase
fixtures :users, :projects, :roles, :members, :member_roles,
......@@ -29,9 +25,6 @@ class AttachmentsControllerTest < ActionController::TestCase
:versions, :wiki_pages, :wikis, :documents
def setup
@controller = AttachmentsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
set_fixtures_attachments_directory
end
......
# Redmine - project management software
# Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
class AutoCompletesControllerTest < ActionController::TestCase
......
# Redmine - project management software
# Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
class CalendarsControllerTest < ActionController::TestCase
......
# Redmine - project management software
# Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
class ContextMenusControllerTest < ActionController::TestCase
......
# Redmine - project management software
# Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
class FilesControllerTest < ActionController::TestCase
......@@ -14,9 +31,6 @@ class FilesControllerTest < ActionController::TestCase
:versions
def setup
@controller = FilesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.session[:user_id] = nil
Setting.default_language = 'en'
end
......
......@@ -28,80 +28,80 @@ class GanttsControllerTest < ActionController::TestCase
:workflows,
:versions
def test_gantt_should_work
i2 = Issue.find(2)
i2.update_attribute(:due_date, 1.month.from_now)
get :show, :project_id => 1
assert_response :success
assert_template 'gantts/show'
assert_not_nil assigns(:gantt)
# Issue with start and due dates
i = Issue.find(1)
assert_not_nil i.due_date
assert_select "div a.issue", /##{i.id}/
# Issue with on a targeted version should not be in the events but loaded in the html
i = Issue.find(2)
assert_select "div a.issue", /##{i.id}/
end
def test_gantt_should_work
i2 = Issue.find(2)
i2.update_attribute(:due_date, 1.month.from_now)
get :show, :project_id => 1
assert_response :success
assert_template 'gantts/show'
assert_not_nil assigns(:gantt)
# Issue with start and due dates
i = Issue.find(1)
assert_not_nil i.due_date
assert_select "div a.issue", /##{i.id}/
# Issue with on a targeted version should not be in the events but loaded in the html
i = Issue.find(2)
assert_select "div a.issue", /##{i.id}/
end
def test_gantt_should_work_without_issue_due_dates
Issue.update_all("due_date = NULL")
get :show, :project_id => 1
assert_response :success
assert_template 'gantts/show'
assert_not_nil assigns(:gantt)
end
def test_gantt_should_work_without_issue_due_dates
Issue.update_all("due_date = NULL")
get :show, :project_id => 1
assert_response :success
assert_template 'gantts/show'
assert_not_nil assigns(:gantt)
end
def test_gantt_should_work_without_issue_and_version_due_dates
Issue.update_all("due_date = NULL")
Version.update_all("effective_date = NULL")
get :show, :project_id => 1
assert_response :success
assert_template 'gantts/show'
assert_not_nil assigns(:gantt)
end
def test_gantt_should_work_without_issue_and_version_due_dates
Issue.update_all("due_date = NULL")
Version.update_all("effective_date = NULL")
get :show, :project_id => 1
assert_response :success
assert_template 'gantts/show'
assert_not_nil assigns(:gantt)
end
def test_gantt_should_work_cross_project
get :show
assert_response :success
assert_template 'gantts/show'
assert_not_nil assigns(:gantt)
assert_not_nil assigns(:gantt).query
assert_nil assigns(:gantt).project
end
def test_gantt_should_work_cross_project
get :show
assert_response :success
assert_template 'gantts/show'
assert_not_nil assigns(:gantt)
assert_not_nil assigns(:gantt).query
assert_nil assigns(:gantt).project
end
def test_gantt_should_not_disclose_private_projects
get :show
assert_response :success
assert_template 'gantts/show'
assert_tag 'a', :content => /eCookbook/
# Root private project
assert_no_tag 'a', {:content => /OnlineStore/}
# Private children of a public project
assert_no_tag 'a', :content => /Private child of eCookbook/
end
def test_gantt_should_not_disclose_private_projects
get :show
assert_response :success
assert_template 'gantts/show'
assert_tag 'a', :content => /eCookbook/
# Root private project
assert_no_tag 'a', {:content => /OnlineStore/}
# Private children of a public project
assert_no_tag 'a', :content => /Private child of eCookbook/
end
def test_gantt_should_export_to_pdf
get :show, :project_id => 1, :format => 'pdf'
assert_response :success
assert_equal 'application/pdf', @response.content_type
assert @response.body.starts_with?('%PDF')
assert_not_nil assigns(:gantt)
end
def test_gantt_should_export_to_pdf
get :show, :project_id => 1, :format => 'pdf'
assert_response :success
assert_equal 'application/pdf', @response.content_type
assert @response.body.starts_with?('%PDF')
assert_not_nil assigns(:gantt)
end
def test_gantt_should_export_to_pdf_cross_project
get :show, :format => 'pdf'
assert_response :success
assert_equal 'application/pdf', @response.content_type
assert @response.body.starts_with?('%PDF')
assert_not_nil assigns(:gantt)
end
def test_gantt_should_export_to_pdf_cross_project
get :show, :format => 'pdf'
assert_response :success
assert_equal 'application/pdf', @response.content_type
assert @response.body.starts_with?('%PDF')
assert_not_nil assigns(:gantt)
end
if Object.const_defined?(:Magick)
def test_gantt_should_export_to_png
get :show, :project_id => 1, :format => 'png'
assert_response :success
assert_equal 'image/png', @response.content_type
end
if Object.const_defined?(:Magick)
def test_gantt_should_export_to_png
get :show, :project_id => 1, :format => 'png'
assert_response :success
assert_equal 'image/png', @response.content_type
end
end
end
......@@ -16,19 +16,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'issue_categories_controller'
# Re-raise errors caught by the controller.
class IssueCategoriesController; def rescue_action(e) raise e end; end
class IssueCategoriesControllerTest < ActionController::TestCase
fixtures :projects, :users, :members, :member_roles, :roles, :enabled_modules, :issue_categories,
:issues
def setup
@controller = IssueCategoriesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
@request.session[:user_id] = 2
end
......
require File.expand_path('../../test_helper', __FILE__)
require 'issue_statuses_controller'
# Re-raise errors caught by the controller.
class IssueStatusesController; def rescue_action(e) raise e end; end
# Redmine - project management software
# Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
class IssueStatusesControllerTest < ActionController::TestCase
fixtures :issue_statuses, :issues, :users
def setup
@controller = IssueStatusesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
@request.session[:user_id] = 1 # admin
end
......
......@@ -16,7 +16,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'issues_controller'
class IssuesControllerTest < ActionController::TestCase
fixtures :projects,
......@@ -48,9 +47,6 @@ class IssuesControllerTest < ActionController::TestCase
include Redmine::I18n
def setup
@controller = IssuesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
......@@ -19,6 +19,7 @@ require File.expand_path('../../test_helper', __FILE__)
require 'issues_controller'
class IssuesControllerTransactionTest < ActionController::TestCase
tests IssuesController
fixtures :projects,
:users,
:roles,
......@@ -46,9 +47,6 @@ class IssuesControllerTransactionTest < ActionController::TestCase
self.use_transactional_fixtures = false
def setup
@controller = IssuesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
......@@ -16,19 +16,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'journals_controller'
# Re-raise errors caught by the controller.
class JournalsController; def rescue_action(e) raise e end; end
class JournalsControllerTest < ActionController::TestCase
fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :journal_details, :enabled_modules,
:trackers, :issue_statuses, :enumerations, :custom_fields, :custom_values, :custom_fields_projects
def setup
@controller = JournalsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
......@@ -16,10 +16,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'mail_handler_controller'
# Re-raise errors caught by the controller.
class MailHandlerController; def rescue_action(e) raise e end; end
class MailHandlerControllerTest < ActionController::TestCase
fixtures :users, :projects, :enabled_modules, :roles, :members, :member_roles, :issues, :issue_statuses,
......@@ -28,9 +24,6 @@ class MailHandlerControllerTest < ActionController::TestCase
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler'
def setup
@controller = MailHandlerController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
......@@ -16,19 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'members_controller'
# Re-raise errors caught by the controller.
class MembersController; def rescue_action(e) raise e end; end
class MembersControllerTest < ActionController::TestCase
fixtures :projects, :members, :member_roles, :roles, :users
def setup
@controller = MembersController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
@request.session[:user_id] = 2
end
......
......@@ -16,18 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'messages_controller'
# Re-raise errors caught by the controller.
class MessagesController; def rescue_action(e) raise e end; end
class MessagesControllerTest < ActionController::TestCase
fixtures :projects, :users, :members, :member_roles, :roles, :boards, :messages, :enabled_modules
def setup
@controller = MessagesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
......@@ -16,18 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'news_controller'
# Re-raise errors caught by the controller.
class NewsController; def rescue_action(e) raise e end; end
class NewsControllerTest < ActionController::TestCase
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :news, :comments
def setup
@controller = NewsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
# Redmine - project management software
# Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
class ProjectEnumerationsControllerTest < ActionController::TestCase
......
......@@ -16,10 +16,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'projects_controller'
# Re-raise errors caught by the controller.
class ProjectsController; def rescue_action(e) raise e end; end
class ProjectsControllerTest < ActionController::TestCase
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
......@@ -27,9 +23,6 @@ class ProjectsControllerTest < ActionController::TestCase
:attachments, :custom_fields, :custom_values, :time_entries
def setup
@controller = ProjectsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.session[:user_id] = nil
Setting.default_language = 'en'
end
......
......@@ -28,9 +28,6 @@ class ReportsControllerTest < ActionController::TestCase
:workflows,
:versions
def setup
end
def test_get_issue_report
get :issue_report, :id => 1
......
......@@ -16,10 +16,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'repositories_controller'
# Re-raise errors caught by the controller.
class RepositoriesController; def rescue_action(e) raise e end; end
class RepositoriesControllerTest < ActionController::TestCase
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules,
......@@ -27,9 +23,6 @@ class RepositoriesControllerTest < ActionController::TestCase
:issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
def setup
@controller = RepositoriesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
......@@ -21,9 +21,6 @@ class RolesControllerTest < ActionController::TestCase
fixtures :roles, :users, :members, :member_roles, :workflows, :trackers
def setup
@controller = RolesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
@request.session[:user_id] = 1 # admin
end
......
require File.expand_path('../../test_helper', __FILE__)
require 'search_controller'
# Redmine - project management software
# Copyright (C) 2006-2012 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.
# Re-raise errors caught by the controller.
class SearchController; def rescue_action(e) raise e end; end
require File.expand_path('../../test_helper', __FILE__)
class SearchControllerTest < ActionController::TestCase
fixtures :projects, :enabled_modules, :roles, :users, :members, :member_roles,
......@@ -11,9 +24,6 @@ class SearchControllerTest < ActionController::TestCase
:repositories, :changesets
def setup
@controller = SearchController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
end
......
......@@ -16,18 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'settings_controller'
# Re-raise errors caught by the controller.
class SettingsController; def rescue_action(e) raise e end; end
class SettingsControllerTest < ActionController::TestCase
fixtures :users
def setup
@controller = SettingsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
@request.session[:user_id] = 1 # admin
end
......
......@@ -16,19 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'sys_controller'
require 'mocha'
# Re-raise errors caught by the controller.
class SysController; def rescue_action(e) raise e end; end
class SysControllerTest < ActionController::TestCase
fixtures :projects, :repositories, :enabled_modules
def setup
@controller = SysController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
Setting.sys_api_enabled = '1'
Setting.enabled_scm = %w(Subversion Git)
end
......
# -*- coding: utf-8 -*-
# Redmine - project management software
# Copyright (C) 2006-2012 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.expand_path('../../test_helper', __FILE__)
class TimeEntryReportsControllerTest < ActionController::TestCase
......
......@@ -17,10 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../../test_helper', __FILE__)
require 'timelog_controller'
# Re-raise errors caught by the controller.
class TimelogController; def rescue_action(e) raise e end; end
class TimelogControllerTest < ActionController::TestCase
fixtures :projects, :enabled_modules, :roles, :members,
......@@ -30,12 +26,6 @@ class TimelogControllerTest < ActionController::TestCase
include Redmine::I18n
def setup
@controller = TimelogController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_new_with_project_id
@request.session[:user_id] = 3
get :new, :project_id => 1
......
......@@ -16,18 +16,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.