mirror of
https://github.com/redmine/redmine.git
synced 2026-05-07 01:56:12 +02:00
Adds a branch for unlimited project hierarchy.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2148 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
84
nested_projects/test/functional/account_controller_test.rb
Normal file
84
nested_projects/test/functional/account_controller_test.rb
Normal file
@@ -0,0 +1,84 @@
|
||||
# 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 'account_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class AccountController; def rescue_action(e) raise e end; end
|
||||
|
||||
class AccountControllerTest < Test::Unit::TestCase
|
||||
fixtures :users
|
||||
|
||||
def setup
|
||||
@controller = AccountController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :id => 2
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:user)
|
||||
end
|
||||
|
||||
def test_show_inactive
|
||||
get :show, :id => 5
|
||||
assert_response 404
|
||||
assert_nil assigns(:user)
|
||||
end
|
||||
|
||||
def test_login_should_redirect_to_back_url_param
|
||||
# request.uri is "test.host" in test environment
|
||||
post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http%3A%2F%2Ftest.host%2Fissues%2Fshow%2F1'
|
||||
assert_redirected_to '/issues/show/1'
|
||||
end
|
||||
|
||||
def test_login_should_not_redirect_to_another_host
|
||||
post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http%3A%2F%2Ftest.foo%2Ffake'
|
||||
assert_redirected_to '/my/page'
|
||||
end
|
||||
|
||||
def test_login_with_wrong_password
|
||||
post :login, :username => 'admin', :password => 'bad'
|
||||
assert_response :success
|
||||
assert_template 'login'
|
||||
assert_tag 'div',
|
||||
:attributes => { :class => "flash error" },
|
||||
:content => /Invalid user or password/
|
||||
end
|
||||
|
||||
def test_autologin
|
||||
Setting.autologin = "7"
|
||||
Token.delete_all
|
||||
post :login, :username => 'admin', :password => 'admin', :autologin => 1
|
||||
assert_redirected_to 'my/page'
|
||||
token = Token.find :first
|
||||
assert_not_nil token
|
||||
assert_equal User.find_by_login('admin'), token.user
|
||||
assert_equal 'autologin', token.action
|
||||
end
|
||||
|
||||
def test_logout
|
||||
@request.session[:user_id] = 2
|
||||
get :logout
|
||||
assert_redirected_to ''
|
||||
assert_nil @request.session[:user_id]
|
||||
end
|
||||
end
|
||||
124
nested_projects/test/functional/admin_controller_test.rb
Normal file
124
nested_projects/test/functional/admin_controller_test.rb
Normal file
@@ -0,0 +1,124 @@
|
||||
# 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 'admin_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class AdminController; def rescue_action(e) raise e end; end
|
||||
|
||||
class AdminControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles
|
||||
|
||||
def setup
|
||||
@controller = AdminController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
@request.session[:user_id] = 1 # admin
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_no_tag :tag => 'div',
|
||||
:attributes => { :class => /nodata/ }
|
||||
end
|
||||
|
||||
def test_index_with_no_configuration_data
|
||||
delete_configuration_data
|
||||
get :index
|
||||
assert_tag :tag => 'div',
|
||||
:attributes => { :class => /nodata/ }
|
||||
end
|
||||
|
||||
def test_projects
|
||||
get :projects
|
||||
assert_response :success
|
||||
assert_template 'projects'
|
||||
assert_not_nil assigns(:projects)
|
||||
# active projects only
|
||||
assert_nil assigns(:projects).detect {|u| !u.active?}
|
||||
end
|
||||
|
||||
def test_projects_with_name_filter
|
||||
get :projects, :name => 'store', :status => ''
|
||||
assert_response :success
|
||||
assert_template 'projects'
|
||||
projects = assigns(:projects)
|
||||
assert_not_nil projects
|
||||
assert_equal 1, projects.size
|
||||
assert_equal 'OnlineStore', projects.first.name
|
||||
end
|
||||
|
||||
def test_load_default_configuration_data
|
||||
delete_configuration_data
|
||||
post :default_configuration, :lang => 'fr'
|
||||
assert IssueStatus.find_by_name('Nouveau')
|
||||
end
|
||||
|
||||
def test_test_email
|
||||
get :test_email
|
||||
assert_redirected_to 'settings/edit'
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_kind_of TMail::Mail, mail
|
||||
user = User.find(1)
|
||||
assert_equal [user.mail], mail.bcc
|
||||
end
|
||||
|
||||
def test_no_plugins
|
||||
Redmine::Plugin.clear
|
||||
|
||||
get :plugins
|
||||
assert_response :success
|
||||
assert_template 'plugins'
|
||||
end
|
||||
|
||||
def test_plugins
|
||||
# Register a few plugins
|
||||
Redmine::Plugin.register :foo do
|
||||
name 'Foo plugin'
|
||||
author 'John Smith'
|
||||
description 'This is a test plugin'
|
||||
version '0.0.1'
|
||||
settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings'
|
||||
end
|
||||
Redmine::Plugin.register :bar do
|
||||
end
|
||||
|
||||
get :plugins
|
||||
assert_response :success
|
||||
assert_template 'plugins'
|
||||
|
||||
assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' }
|
||||
assert_tag :td, :child => { :tag => 'span', :content => 'Bar' }
|
||||
end
|
||||
|
||||
def test_info
|
||||
get :info
|
||||
assert_response :success
|
||||
assert_template 'info'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def delete_configuration_data
|
||||
Role.delete_all('builtin = 0')
|
||||
Tracker.delete_all
|
||||
IssueStatus.delete_all
|
||||
Enumeration.delete_all
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,44 @@
|
||||
# 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 'application'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class ApplicationController; def rescue_action(e) raise e end; end
|
||||
|
||||
class ApplicationControllerTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@controller = ApplicationController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
# check that all language files are valid
|
||||
def test_localization
|
||||
lang_files_count = Dir["#{RAILS_ROOT}/lang/*.yml"].size
|
||||
assert_equal lang_files_count, GLoc.valid_languages.size
|
||||
GLoc.valid_languages.each do |lang|
|
||||
assert set_language_if_valid(lang)
|
||||
end
|
||||
set_language_if_valid('en')
|
||||
end
|
||||
|
||||
def test_call_hook_mixed_in
|
||||
assert @controller.respond_to?(:call_hook)
|
||||
end
|
||||
end
|
||||
125
nested_projects/test/functional/attachments_controller_test.rb
Normal file
125
nested_projects/test/functional/attachments_controller_test.rb
Normal file
@@ -0,0 +1,125 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 'attachments_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class AttachmentsController; def rescue_action(e) raise e end; end
|
||||
|
||||
|
||||
class AttachmentsControllerTest < Test::Unit::TestCase
|
||||
fixtures :users, :projects, :roles, :members, :enabled_modules, :issues, :attachments
|
||||
|
||||
def setup
|
||||
@controller = AttachmentsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
Attachment.storage_path = "#{RAILS_ROOT}/test/fixtures/files"
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_routing
|
||||
assert_routing('/attachments/1', :controller => 'attachments', :action => 'show', :id => '1')
|
||||
assert_routing('/attachments/1/filename.ext', :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext')
|
||||
assert_routing('/attachments/download/1', :controller => 'attachments', :action => 'download', :id => '1')
|
||||
assert_routing('/attachments/download/1/filename.ext', :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext')
|
||||
end
|
||||
|
||||
def test_recognizes
|
||||
assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1'}, '/attachments/1')
|
||||
assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1'}, '/attachments/show/1')
|
||||
assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'}, '/attachments/1/filename.ext')
|
||||
assert_recognizes({:controller => 'attachments', :action => 'download', :id => '1'}, '/attachments/download/1')
|
||||
assert_recognizes({:controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'},'/attachments/download/1/filename.ext')
|
||||
end
|
||||
|
||||
def test_show_diff
|
||||
get :show, :id => 5
|
||||
assert_response :success
|
||||
assert_template 'diff'
|
||||
end
|
||||
|
||||
def test_show_text_file
|
||||
get :show, :id => 4
|
||||
assert_response :success
|
||||
assert_template 'file'
|
||||
end
|
||||
|
||||
def test_show_other
|
||||
get :show, :id => 6
|
||||
assert_response :success
|
||||
assert_equal 'application/octet-stream', @response.content_type
|
||||
end
|
||||
|
||||
def test_download_text_file
|
||||
get :download, :id => 4
|
||||
assert_response :success
|
||||
assert_equal 'application/x-ruby', @response.content_type
|
||||
end
|
||||
|
||||
def test_anonymous_on_private_private
|
||||
get :download, :id => 7
|
||||
assert_redirected_to 'account/login'
|
||||
end
|
||||
|
||||
def test_destroy_issue_attachment
|
||||
issue = Issue.find(3)
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_difference 'issue.attachments.count', -1 do
|
||||
post :destroy, :id => 1
|
||||
end
|
||||
# no referrer
|
||||
assert_redirected_to 'projects/show/ecookbook'
|
||||
assert_nil Attachment.find_by_id(1)
|
||||
j = issue.journals.find(:first, :order => 'created_on DESC')
|
||||
assert_equal 'attachment', j.details.first.property
|
||||
assert_equal '1', j.details.first.prop_key
|
||||
assert_equal 'error281.txt', j.details.first.old_value
|
||||
end
|
||||
|
||||
def test_destroy_wiki_page_attachment
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
post :destroy, :id => 3
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
|
||||
def test_destroy_project_attachment
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
post :destroy, :id => 8
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
|
||||
def test_destroy_version_attachment
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Attachment.count', -1 do
|
||||
post :destroy, :id => 9
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
|
||||
def test_destroy_without_permission
|
||||
post :destroy, :id => 3
|
||||
assert_redirected_to '/login'
|
||||
assert Attachment.find_by_id(3)
|
||||
end
|
||||
end
|
||||
50
nested_projects/test/functional/boards_controller_test.rb
Normal file
50
nested_projects/test/functional/boards_controller_test.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
# 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 'boards_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class BoardsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class BoardsControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :members, :roles, :boards, :messages, :enabled_modules
|
||||
|
||||
def setup
|
||||
@controller = BoardsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:boards)
|
||||
assert_not_nil assigns(:project)
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :project_id => 1, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:board)
|
||||
assert_not_nil assigns(:project)
|
||||
assert_not_nil assigns(:topics)
|
||||
end
|
||||
end
|
||||
75
nested_projects/test/functional/documents_controller_test.rb
Normal file
75
nested_projects/test/functional/documents_controller_test.rb
Normal file
@@ -0,0 +1,75 @@
|
||||
# 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 'documents_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class DocumentsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class DocumentsControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :enabled_modules, :documents, :enumerations
|
||||
|
||||
def setup
|
||||
@controller = DocumentsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_index
|
||||
# Sets a default category
|
||||
e = Enumeration.find_by_name('Technical documentation')
|
||||
e.update_attributes(:is_default => true)
|
||||
|
||||
get :index, :project_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:grouped)
|
||||
|
||||
# Default category selected in the new document form
|
||||
assert_tag :select, :attributes => {:name => 'document[category_id]'},
|
||||
:child => {:tag => 'option', :attributes => {:selected => 'selected'},
|
||||
:content => 'Technical documentation'}
|
||||
end
|
||||
|
||||
def test_new_with_one_attachment
|
||||
@request.session[:user_id] = 2
|
||||
set_tmp_attachments_directory
|
||||
|
||||
post :new, :project_id => 'ecookbook',
|
||||
:document => { :title => 'DocumentsControllerTest#test_post_new',
|
||||
:description => 'This is a new document',
|
||||
:category_id => 2},
|
||||
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
||||
|
||||
assert_redirected_to 'projects/ecookbook/documents'
|
||||
|
||||
document = Document.find_by_title('DocumentsControllerTest#test_post_new')
|
||||
assert_not_nil document
|
||||
assert_equal Enumeration.find(2), document.category
|
||||
assert_equal 1, document.attachments.size
|
||||
assert_equal 'testfile.txt', document.attachments.first.filename
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :id => 1
|
||||
assert_redirected_to 'projects/ecookbook/documents'
|
||||
assert_nil Document.find_by_id(1)
|
||||
end
|
||||
end
|
||||
61
nested_projects/test/functional/enumerations_controller.rb
Normal file
61
nested_projects/test/functional/enumerations_controller.rb
Normal file
@@ -0,0 +1,61 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 'enumerations_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class EnumerationsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class EnumerationsControllerTest < Test::Unit::TestCase
|
||||
fixtures :enumerations, :issues, :users
|
||||
|
||||
def setup
|
||||
@controller = EnumerationsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@request.session[:user_id] = 1 # admin
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'list'
|
||||
end
|
||||
|
||||
def test_destroy_enumeration_not_in_use
|
||||
post :destroy, :id => 7
|
||||
assert_redirected_to :controller => 'enumerations', :action => 'index'
|
||||
assert_nil Enumeration.find_by_id(7)
|
||||
end
|
||||
|
||||
def test_destroy_enumeration_in_use
|
||||
post :destroy, :id => 4
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
assert_not_nil Enumeration.find_by_id(4)
|
||||
end
|
||||
|
||||
def test_destroy_enumeration_in_use_with_reassignment
|
||||
issue = Issue.find(:first, :conditions => {:priority_id => 4})
|
||||
post :destroy, :id => 4, :reassign_to_id => 6
|
||||
assert_redirected_to :controller => 'enumerations', :action => 'index'
|
||||
assert_nil Enumeration.find_by_id(4)
|
||||
# check that the issue was reassign
|
||||
assert_equal 6, issue.reload.priority_id
|
||||
end
|
||||
end
|
||||
716
nested_projects/test/functional/issues_controller_test.rb
Normal file
716
nested_projects/test/functional/issues_controller_test.rb
Normal file
@@ -0,0 +1,716 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2008 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 'issues_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class IssuesController; def rescue_action(e) raise e end; end
|
||||
|
||||
class IssuesControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details
|
||||
|
||||
def setup
|
||||
@controller = IssuesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index.rhtml'
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_nil assigns(:project)
|
||||
assert_tag :tag => 'a', :content => /Can't print recipes/
|
||||
assert_tag :tag => 'a', :content => /Subproject issue/
|
||||
# private projects hidden
|
||||
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
||||
assert_no_tag :tag => 'a', :content => /Issue on project 2/
|
||||
end
|
||||
|
||||
def test_index_should_not_list_issues_when_module_disabled
|
||||
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index.rhtml'
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_nil assigns(:project)
|
||||
assert_no_tag :tag => 'a', :content => /Can't print recipes/
|
||||
assert_tag :tag => 'a', :content => /Subproject issue/
|
||||
end
|
||||
|
||||
def test_index_with_project
|
||||
Setting.display_subprojects_issues = 0
|
||||
get :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'index.rhtml'
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_tag :tag => 'a', :content => /Can't print recipes/
|
||||
assert_no_tag :tag => 'a', :content => /Subproject issue/
|
||||
end
|
||||
|
||||
def test_index_with_project_and_subprojects
|
||||
Setting.display_subprojects_issues = 1
|
||||
get :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'index.rhtml'
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_tag :tag => 'a', :content => /Can't print recipes/
|
||||
assert_tag :tag => 'a', :content => /Subproject issue/
|
||||
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
|
||||
end
|
||||
|
||||
def test_index_with_project_and_subprojects_should_show_private_subprojects
|
||||
@request.session[:user_id] = 2
|
||||
Setting.display_subprojects_issues = 1
|
||||
get :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'index.rhtml'
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_tag :tag => 'a', :content => /Can't print recipes/
|
||||
assert_tag :tag => 'a', :content => /Subproject issue/
|
||||
assert_tag :tag => 'a', :content => /Issue of a private subproject/
|
||||
end
|
||||
|
||||
def test_index_with_project_and_filter
|
||||
get :index, :project_id => 1, :set_filter => 1
|
||||
assert_response :success
|
||||
assert_template 'index.rhtml'
|
||||
assert_not_nil assigns(:issues)
|
||||
end
|
||||
|
||||
def test_index_csv_with_project
|
||||
get :index, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
|
||||
get :index, :project_id => 1, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
end
|
||||
|
||||
def test_index_pdf
|
||||
get :index, :format => 'pdf'
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_equal 'application/pdf', @response.content_type
|
||||
|
||||
get :index, :project_id => 1, :format => 'pdf'
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:issues)
|
||||
assert_equal 'application/pdf', @response.content_type
|
||||
end
|
||||
|
||||
def test_gantt
|
||||
get :gantt, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'gantt.rhtml'
|
||||
assert_not_nil assigns(:gantt)
|
||||
events = assigns(:gantt).events
|
||||
assert_not_nil events
|
||||
# Issue with start and due dates
|
||||
i = Issue.find(1)
|
||||
assert_not_nil i.due_date
|
||||
assert events.include?(Issue.find(1))
|
||||
# Issue with without due date but targeted to a version with date
|
||||
i = Issue.find(2)
|
||||
assert_nil i.due_date
|
||||
assert events.include?(i)
|
||||
end
|
||||
|
||||
def test_cross_project_gantt
|
||||
get :gantt
|
||||
assert_response :success
|
||||
assert_template 'gantt.rhtml'
|
||||
assert_not_nil assigns(:gantt)
|
||||
events = assigns(:gantt).events
|
||||
assert_not_nil events
|
||||
end
|
||||
|
||||
def test_gantt_export_to_pdf
|
||||
get :gantt, :project_id => 1, :format => 'pdf'
|
||||
assert_response :success
|
||||
assert_template 'gantt.rfpdf'
|
||||
assert_equal 'application/pdf', @response.content_type
|
||||
assert_not_nil assigns(:gantt)
|
||||
end
|
||||
|
||||
def test_cross_project_gantt_export_to_pdf
|
||||
get :gantt, :format => 'pdf'
|
||||
assert_response :success
|
||||
assert_template 'gantt.rfpdf'
|
||||
assert_equal 'application/pdf', @response.content_type
|
||||
assert_not_nil assigns(:gantt)
|
||||
end
|
||||
|
||||
if Object.const_defined?(:Magick)
|
||||
def test_gantt_image
|
||||
get :gantt, :project_id => 1, :format => 'png'
|
||||
assert_response :success
|
||||
assert_equal 'image/png', @response.content_type
|
||||
end
|
||||
else
|
||||
puts "RMagick not installed. Skipping tests !!!"
|
||||
end
|
||||
|
||||
def test_calendar
|
||||
get :calendar, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'calendar'
|
||||
assert_not_nil assigns(:calendar)
|
||||
end
|
||||
|
||||
def test_cross_project_calendar
|
||||
get :calendar
|
||||
assert_response :success
|
||||
assert_template 'calendar'
|
||||
assert_not_nil assigns(:calendar)
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :project_id => 1
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:journals)
|
||||
assert_equal 'application/atom+xml', @response.content_type
|
||||
end
|
||||
|
||||
def test_show_by_anonymous
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show.rhtml'
|
||||
assert_not_nil assigns(:issue)
|
||||
assert_equal Issue.find(1), assigns(:issue)
|
||||
|
||||
# anonymous role is allowed to add a note
|
||||
assert_tag :tag => 'form',
|
||||
:descendant => { :tag => 'fieldset',
|
||||
:child => { :tag => 'legend',
|
||||
:content => /Notes/ } }
|
||||
end
|
||||
|
||||
def test_show_by_manager
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
|
||||
assert_tag :tag => 'form',
|
||||
:descendant => { :tag => 'fieldset',
|
||||
:child => { :tag => 'legend',
|
||||
:content => /Change properties/ } },
|
||||
:descendant => { :tag => 'fieldset',
|
||||
:child => { :tag => 'legend',
|
||||
:content => /Log time/ } },
|
||||
:descendant => { :tag => 'fieldset',
|
||||
:child => { :tag => 'legend',
|
||||
:content => /Notes/ } }
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1, :tracker_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_tag :tag => 'input', :attributes => { :name => 'issue[custom_field_values][2]',
|
||||
:value => 'Default string' }
|
||||
end
|
||||
|
||||
def test_get_new_without_tracker_id
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
issue = assigns(:issue)
|
||||
assert_not_nil issue
|
||||
assert_equal Project.find(1).trackers.first, issue.tracker
|
||||
end
|
||||
|
||||
def test_update_new_form
|
||||
@request.session[:user_id] = 2
|
||||
xhr :post, :new, :project_id => 1,
|
||||
:issue => {:tracker_id => 2,
|
||||
:subject => 'This is the test_new issue',
|
||||
:description => 'This is the description',
|
||||
:priority_id => 5}
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
end
|
||||
|
||||
def test_post_new
|
||||
@request.session[:user_id] = 2
|
||||
post :new, :project_id => 1,
|
||||
:issue => {:tracker_id => 3,
|
||||
:subject => 'This is the test_new issue',
|
||||
:description => 'This is the description',
|
||||
:priority_id => 5,
|
||||
:estimated_hours => '',
|
||||
:custom_field_values => {'2' => 'Value for field 2'}}
|
||||
assert_redirected_to 'issues/show'
|
||||
|
||||
issue = Issue.find_by_subject('This is the test_new issue')
|
||||
assert_not_nil issue
|
||||
assert_equal 2, issue.author_id
|
||||
assert_equal 3, issue.tracker_id
|
||||
assert_nil issue.estimated_hours
|
||||
v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
|
||||
assert_not_nil v
|
||||
assert_equal 'Value for field 2', v.value
|
||||
end
|
||||
|
||||
def test_post_new_without_custom_fields_param
|
||||
@request.session[:user_id] = 2
|
||||
post :new, :project_id => 1,
|
||||
:issue => {:tracker_id => 1,
|
||||
:subject => 'This is the test_new issue',
|
||||
:description => 'This is the description',
|
||||
:priority_id => 5}
|
||||
assert_redirected_to 'issues/show'
|
||||
end
|
||||
|
||||
def test_post_new_with_required_custom_field_and_without_custom_fields_param
|
||||
field = IssueCustomField.find_by_name('Database')
|
||||
field.update_attribute(:is_required, true)
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
post :new, :project_id => 1,
|
||||
:issue => {:tracker_id => 1,
|
||||
:subject => 'This is the test_new issue',
|
||||
:description => 'This is the description',
|
||||
:priority_id => 5}
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
issue = assigns(:issue)
|
||||
assert_not_nil issue
|
||||
assert_equal 'activerecord_error_invalid', issue.errors.on(:custom_values)
|
||||
end
|
||||
|
||||
def test_post_should_preserve_fields_values_on_validation_failure
|
||||
@request.session[:user_id] = 2
|
||||
post :new, :project_id => 1,
|
||||
:issue => {:tracker_id => 1,
|
||||
:subject => 'This is the test_new issue',
|
||||
# empty description
|
||||
:description => '',
|
||||
:priority_id => 6,
|
||||
:custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}}
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
|
||||
assert_tag :input, :attributes => { :name => 'issue[subject]',
|
||||
:value => 'This is the test_new issue' }
|
||||
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
||||
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
||||
:value => '6' },
|
||||
:content => 'High' }
|
||||
# Custom fields
|
||||
assert_tag :select, :attributes => { :name => 'issue[custom_field_values][1]' },
|
||||
:child => { :tag => 'option', :attributes => { :selected => 'selected',
|
||||
:value => 'Oracle' },
|
||||
:content => 'Oracle' }
|
||||
assert_tag :input, :attributes => { :name => 'issue[custom_field_values][2]',
|
||||
:value => 'Value for field 2'}
|
||||
end
|
||||
|
||||
def test_copy_issue
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1, :copy_from => 1
|
||||
assert_template 'new'
|
||||
assert_not_nil assigns(:issue)
|
||||
orig = Issue.find(1)
|
||||
assert_equal orig.subject, assigns(:issue).subject
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_not_nil assigns(:issue)
|
||||
assert_equal Issue.find(1), assigns(:issue)
|
||||
end
|
||||
|
||||
def test_get_edit_with_params
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
|
||||
issue = assigns(:issue)
|
||||
assert_not_nil issue
|
||||
|
||||
assert_equal 5, issue.status_id
|
||||
assert_tag :select, :attributes => { :name => 'issue[status_id]' },
|
||||
:child => { :tag => 'option',
|
||||
:content => 'Closed',
|
||||
:attributes => { :selected => 'selected' } }
|
||||
|
||||
assert_equal 7, issue.priority_id
|
||||
assert_tag :select, :attributes => { :name => 'issue[priority_id]' },
|
||||
:child => { :tag => 'option',
|
||||
:content => 'Urgent',
|
||||
:attributes => { :selected => 'selected' } }
|
||||
end
|
||||
|
||||
def test_reply_to_issue
|
||||
@request.session[:user_id] = 2
|
||||
get :reply, :id => 1
|
||||
assert_response :success
|
||||
assert_select_rjs :show, "update"
|
||||
end
|
||||
|
||||
def test_reply_to_note
|
||||
@request.session[:user_id] = 2
|
||||
get :reply, :id => 1, :journal_id => 2
|
||||
assert_response :success
|
||||
assert_select_rjs :show, "update"
|
||||
end
|
||||
|
||||
def test_post_edit_without_custom_fields_param
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
issue = Issue.find(1)
|
||||
assert_equal '125', issue.custom_value_for(2).value
|
||||
old_subject = issue.subject
|
||||
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
||||
|
||||
assert_difference('Journal.count') do
|
||||
assert_difference('JournalDetail.count', 2) do
|
||||
post :edit, :id => 1, :issue => {:subject => new_subject,
|
||||
:priority_id => '6',
|
||||
:category_id => '1' # no change
|
||||
}
|
||||
end
|
||||
end
|
||||
assert_redirected_to 'issues/show/1'
|
||||
issue.reload
|
||||
assert_equal new_subject, issue.subject
|
||||
# Make sure custom fields were not cleared
|
||||
assert_equal '125', issue.custom_value_for(2).value
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_kind_of TMail::Mail, mail
|
||||
assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
|
||||
assert mail.body.include?("Subject changed from #{old_subject} to #{new_subject}")
|
||||
end
|
||||
|
||||
def test_post_edit_with_custom_field_change
|
||||
@request.session[:user_id] = 2
|
||||
issue = Issue.find(1)
|
||||
assert_equal '125', issue.custom_value_for(2).value
|
||||
|
||||
assert_difference('Journal.count') do
|
||||
assert_difference('JournalDetail.count', 3) do
|
||||
post :edit, :id => 1, :issue => {:subject => 'Custom field change',
|
||||
:priority_id => '6',
|
||||
:category_id => '1', # no change
|
||||
:custom_field_values => { '2' => 'New custom value' }
|
||||
}
|
||||
end
|
||||
end
|
||||
assert_redirected_to 'issues/show/1'
|
||||
issue.reload
|
||||
assert_equal 'New custom value', issue.custom_value_for(2).value
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_kind_of TMail::Mail, mail
|
||||
assert mail.body.include?("Searchable field changed from 125 to New custom value")
|
||||
end
|
||||
|
||||
def test_post_edit_with_status_and_assignee_change
|
||||
issue = Issue.find(1)
|
||||
assert_equal 1, issue.status_id
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference('TimeEntry.count', 0) do
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:issue => { :status_id => 2, :assigned_to_id => 3 },
|
||||
:notes => 'Assigned to dlopper',
|
||||
:time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
||||
end
|
||||
assert_redirected_to 'issues/show/1'
|
||||
issue.reload
|
||||
assert_equal 2, issue.status_id
|
||||
j = issue.journals.find(:first, :order => 'id DESC')
|
||||
assert_equal 'Assigned to dlopper', j.notes
|
||||
assert_equal 2, j.details.size
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert mail.body.include?("Status changed from New to Assigned")
|
||||
end
|
||||
|
||||
def test_post_edit_with_note_only
|
||||
notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
|
||||
# anonymous user
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:notes => notes
|
||||
assert_redirected_to 'issues/show/1'
|
||||
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
||||
assert_equal notes, j.notes
|
||||
assert_equal 0, j.details.size
|
||||
assert_equal User.anonymous, j.user
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert mail.body.include?(notes)
|
||||
end
|
||||
|
||||
def test_post_edit_with_note_and_spent_time
|
||||
@request.session[:user_id] = 2
|
||||
spent_hours_before = Issue.find(1).spent_hours
|
||||
assert_difference('TimeEntry.count') do
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:notes => '2.5 hours added',
|
||||
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
||||
end
|
||||
assert_redirected_to 'issues/show/1'
|
||||
|
||||
issue = Issue.find(1)
|
||||
|
||||
j = issue.journals.find(:first, :order => 'id DESC')
|
||||
assert_equal '2.5 hours added', j.notes
|
||||
assert_equal 0, j.details.size
|
||||
|
||||
t = issue.time_entries.find(:first, :order => 'id DESC')
|
||||
assert_not_nil t
|
||||
assert_equal 2.5, t.hours
|
||||
assert_equal spent_hours_before + 2.5, issue.spent_hours
|
||||
end
|
||||
|
||||
def test_post_edit_with_attachment_only
|
||||
set_tmp_attachments_directory
|
||||
|
||||
# Delete all fixtured journals, a race condition can occur causing the wrong
|
||||
# journal to get fetched in the next find.
|
||||
Journal.delete_all
|
||||
|
||||
# anonymous user
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:notes => '',
|
||||
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
||||
assert_redirected_to 'issues/show/1'
|
||||
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
|
||||
assert j.notes.blank?
|
||||
assert_equal 1, j.details.size
|
||||
assert_equal 'testfile.txt', j.details.first.value
|
||||
assert_equal User.anonymous, j.user
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert mail.body.include?('testfile.txt')
|
||||
end
|
||||
|
||||
def test_post_edit_with_no_change
|
||||
issue = Issue.find(1)
|
||||
issue.journals.clear
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:notes => ''
|
||||
assert_redirected_to 'issues/show/1'
|
||||
|
||||
issue.reload
|
||||
assert issue.journals.empty?
|
||||
# No email should be sent
|
||||
assert ActionMailer::Base.deliveries.empty?
|
||||
end
|
||||
|
||||
def test_bulk_edit
|
||||
@request.session[:user_id] = 2
|
||||
# update issues priority
|
||||
post :bulk_edit, :ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
|
||||
assert_response 302
|
||||
# check that the issues were updated
|
||||
assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
|
||||
assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
|
||||
end
|
||||
|
||||
def test_bulk_unassign
|
||||
assert_not_nil Issue.find(2).assigned_to
|
||||
@request.session[:user_id] = 2
|
||||
# unassign issues
|
||||
post :bulk_edit, :ids => [1, 2], :notes => 'Bulk unassigning', :assigned_to_id => 'none'
|
||||
assert_response 302
|
||||
# check that the issues were updated
|
||||
assert_nil Issue.find(2).assigned_to
|
||||
end
|
||||
|
||||
def test_move_one_issue_to_another_project
|
||||
@request.session[:user_id] = 1
|
||||
post :move, :id => 1, :new_project_id => 2
|
||||
assert_redirected_to 'projects/ecookbook/issues'
|
||||
assert_equal 2, Issue.find(1).project_id
|
||||
end
|
||||
|
||||
def test_bulk_move_to_another_project
|
||||
@request.session[:user_id] = 1
|
||||
post :move, :ids => [1, 2], :new_project_id => 2
|
||||
assert_redirected_to 'projects/ecookbook/issues'
|
||||
# Issues moved to project 2
|
||||
assert_equal 2, Issue.find(1).project_id
|
||||
assert_equal 2, Issue.find(2).project_id
|
||||
# No tracker change
|
||||
assert_equal 1, Issue.find(1).tracker_id
|
||||
assert_equal 2, Issue.find(2).tracker_id
|
||||
end
|
||||
|
||||
def test_bulk_move_to_another_tracker
|
||||
@request.session[:user_id] = 1
|
||||
post :move, :ids => [1, 2], :new_tracker_id => 2
|
||||
assert_redirected_to 'projects/ecookbook/issues'
|
||||
assert_equal 2, Issue.find(1).tracker_id
|
||||
assert_equal 2, Issue.find(2).tracker_id
|
||||
end
|
||||
|
||||
def test_context_menu_one_issue
|
||||
@request.session[:user_id] = 2
|
||||
get :context_menu, :ids => [1]
|
||||
assert_response :success
|
||||
assert_template 'context_menu'
|
||||
assert_tag :tag => 'a', :content => 'Edit',
|
||||
:attributes => { :href => '/issues/edit/1',
|
||||
:class => 'icon-edit' }
|
||||
assert_tag :tag => 'a', :content => 'Closed',
|
||||
:attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
|
||||
:class => '' }
|
||||
assert_tag :tag => 'a', :content => 'Immediate',
|
||||
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&priority_id=8',
|
||||
:class => '' }
|
||||
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
||||
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1',
|
||||
:class => '' }
|
||||
assert_tag :tag => 'a', :content => 'Copy',
|
||||
:attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
|
||||
:class => 'icon-copy' }
|
||||
assert_tag :tag => 'a', :content => 'Move',
|
||||
:attributes => { :href => '/issues/move?ids%5B%5D=1',
|
||||
:class => 'icon-move' }
|
||||
assert_tag :tag => 'a', :content => 'Delete',
|
||||
:attributes => { :href => '/issues/destroy?ids%5B%5D=1',
|
||||
:class => 'icon-del' }
|
||||
end
|
||||
|
||||
def test_context_menu_one_issue_by_anonymous
|
||||
get :context_menu, :ids => [1]
|
||||
assert_response :success
|
||||
assert_template 'context_menu'
|
||||
assert_tag :tag => 'a', :content => 'Delete',
|
||||
:attributes => { :href => '#',
|
||||
:class => 'icon-del disabled' }
|
||||
end
|
||||
|
||||
def test_context_menu_multiple_issues_of_same_project
|
||||
@request.session[:user_id] = 2
|
||||
get :context_menu, :ids => [1, 2]
|
||||
assert_response :success
|
||||
assert_template 'context_menu'
|
||||
assert_tag :tag => 'a', :content => 'Edit',
|
||||
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2',
|
||||
:class => 'icon-edit' }
|
||||
assert_tag :tag => 'a', :content => 'Immediate',
|
||||
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2&priority_id=8',
|
||||
:class => '' }
|
||||
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
||||
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&ids%5B%5D=1&ids%5B%5D=2',
|
||||
:class => '' }
|
||||
assert_tag :tag => 'a', :content => 'Move',
|
||||
:attributes => { :href => '/issues/move?ids%5B%5D=1&ids%5B%5D=2',
|
||||
:class => 'icon-move' }
|
||||
assert_tag :tag => 'a', :content => 'Delete',
|
||||
:attributes => { :href => '/issues/destroy?ids%5B%5D=1&ids%5B%5D=2',
|
||||
:class => 'icon-del' }
|
||||
end
|
||||
|
||||
def test_context_menu_multiple_issues_of_different_project
|
||||
@request.session[:user_id] = 2
|
||||
get :context_menu, :ids => [1, 2, 4]
|
||||
assert_response :success
|
||||
assert_template 'context_menu'
|
||||
assert_tag :tag => 'a', :content => 'Delete',
|
||||
:attributes => { :href => '#',
|
||||
:class => 'icon-del disabled' }
|
||||
end
|
||||
|
||||
def test_destroy_issue_with_no_time_entries
|
||||
assert_nil TimeEntry.find_by_issue_id(2)
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :id => 2
|
||||
assert_redirected_to 'projects/ecookbook/issues'
|
||||
assert_nil Issue.find_by_id(2)
|
||||
end
|
||||
|
||||
def test_destroy_issues_with_time_entries
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :ids => [1, 3]
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
assert_not_nil assigns(:hours)
|
||||
assert Issue.find_by_id(1) && Issue.find_by_id(3)
|
||||
end
|
||||
|
||||
def test_destroy_issues_and_destroy_time_entries
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :ids => [1, 3], :todo => 'destroy'
|
||||
assert_redirected_to 'projects/ecookbook/issues'
|
||||
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
||||
assert_nil TimeEntry.find_by_id([1, 2])
|
||||
end
|
||||
|
||||
def test_destroy_issues_and_assign_time_entries_to_project
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :ids => [1, 3], :todo => 'nullify'
|
||||
assert_redirected_to 'projects/ecookbook/issues'
|
||||
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
||||
assert_nil TimeEntry.find(1).issue_id
|
||||
assert_nil TimeEntry.find(2).issue_id
|
||||
end
|
||||
|
||||
def test_destroy_issues_and_reassign_time_entries_to_another_issue
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
|
||||
assert_redirected_to 'projects/ecookbook/issues'
|
||||
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
|
||||
assert_equal 2, TimeEntry.find(1).issue_id
|
||||
assert_equal 2, TimeEntry.find(2).issue_id
|
||||
end
|
||||
end
|
||||
59
nested_projects/test/functional/journals_controller_test.rb
Normal file
59
nested_projects/test/functional/journals_controller_test.rb
Normal file
@@ -0,0 +1,59 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 'journals_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class JournalsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class JournalsControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :members, :roles, :issues, :journals, :journal_details, :enabled_modules
|
||||
|
||||
def setup
|
||||
@controller = JournalsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 1
|
||||
xhr :get, :edit, :id => 2
|
||||
assert_response :success
|
||||
assert_select_rjs :insert, :after, 'journal-2-notes' do
|
||||
assert_select 'form[id=journal-2-form]'
|
||||
assert_select 'textarea'
|
||||
end
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
@request.session[:user_id] = 1
|
||||
xhr :post, :edit, :id => 2, :notes => 'Updated notes'
|
||||
assert_response :success
|
||||
assert_select_rjs :replace, 'journal-2-notes'
|
||||
assert_equal 'Updated notes', Journal.find(2).notes
|
||||
end
|
||||
|
||||
def test_post_edit_with_empty_notes
|
||||
@request.session[:user_id] = 1
|
||||
xhr :post, :edit, :id => 2, :notes => ''
|
||||
assert_response :success
|
||||
assert_select_rjs :remove, 'change-2'
|
||||
assert_nil Journal.find_by_id(2)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,53 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 'mail_handler_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class MailHandlerController; def rescue_action(e) raise e end; end
|
||||
|
||||
class MailHandlerControllerTest < Test::Unit::TestCase
|
||||
fixtures :users, :projects, :enabled_modules, :roles, :members, :issues, :issue_statuses, :trackers, :enumerations
|
||||
|
||||
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
|
||||
|
||||
def test_should_create_issue
|
||||
# Enable API and set a key
|
||||
Setting.mail_handler_api_enabled = 1
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||
assert_response 201
|
||||
end
|
||||
|
||||
def test_should_not_allow
|
||||
# Disable API
|
||||
Setting.mail_handler_api_enabled = 0
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
post :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'ticket_on_given_project.eml'))
|
||||
assert_response 403
|
||||
end
|
||||
end
|
||||
127
nested_projects/test/functional/messages_controller_test.rb
Normal file
127
nested_projects/test/functional/messages_controller_test.rb
Normal file
@@ -0,0 +1,127 @@
|
||||
# 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 'messages_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class MessagesController; def rescue_action(e) raise e end; end
|
||||
|
||||
class MessagesControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :members, :roles, :boards, :messages, :enabled_modules
|
||||
|
||||
def setup
|
||||
@controller = MessagesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :board_id => 1, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:board)
|
||||
assert_not_nil assigns(:project)
|
||||
assert_not_nil assigns(:topic)
|
||||
end
|
||||
|
||||
def test_show_with_reply_permission
|
||||
@request.session[:user_id] = 2
|
||||
get :show, :board_id => 1, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_tag :div, :attributes => { :id => 'reply' },
|
||||
:descendant => { :tag => 'textarea', :attributes => { :id => 'message_content' } }
|
||||
end
|
||||
|
||||
def test_show_message_not_found
|
||||
get :show, :board_id => 1, :id => 99999
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :board_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
end
|
||||
|
||||
def test_post_new
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Setting.notified_events << 'message_posted'
|
||||
|
||||
post :new, :board_id => 1,
|
||||
:message => { :subject => 'Test created message',
|
||||
:content => 'Message body'}
|
||||
assert_redirected_to 'messages/show'
|
||||
message = Message.find_by_subject('Test created message')
|
||||
assert_not_nil message
|
||||
assert_equal 'Message body', message.content
|
||||
assert_equal 2, message.author_id
|
||||
assert_equal 1, message.board_id
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_kind_of TMail::Mail, mail
|
||||
assert_equal "[#{message.board.project.name} - #{message.board.name}] Test created message", mail.subject
|
||||
assert mail.body.include?('Message body')
|
||||
# author
|
||||
assert mail.bcc.include?('jsmith@somenet.foo')
|
||||
# project member
|
||||
assert mail.bcc.include?('dlopper@somenet.foo')
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :board_id => 1, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :board_id => 1, :id => 1,
|
||||
:message => { :subject => 'New subject',
|
||||
:content => 'New body'}
|
||||
assert_redirected_to 'messages/show'
|
||||
message = Message.find(1)
|
||||
assert_equal 'New subject', message.subject
|
||||
assert_equal 'New body', message.content
|
||||
end
|
||||
|
||||
def test_reply
|
||||
@request.session[:user_id] = 2
|
||||
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
|
||||
assert_redirected_to 'messages/show'
|
||||
assert Message.find_by_subject('Test reply')
|
||||
end
|
||||
|
||||
def test_destroy_topic
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :board_id => 1, :id => 1
|
||||
assert_redirected_to 'boards/show'
|
||||
assert_nil Message.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_quote
|
||||
@request.session[:user_id] = 2
|
||||
xhr :get, :quote, :board_id => 1, :id => 3
|
||||
assert_response :success
|
||||
assert_select_rjs :show, 'reply'
|
||||
end
|
||||
end
|
||||
91
nested_projects/test/functional/my_controller_test.rb
Normal file
91
nested_projects/test/functional/my_controller_test.rb
Normal 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 'my_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class MyController; def rescue_action(e) raise e end; end
|
||||
|
||||
class MyControllerTest < Test::Unit::TestCase
|
||||
fixtures :users, :issues, :issue_statuses, :trackers, :enumerations
|
||||
|
||||
def setup
|
||||
@controller = MyController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@request.session[:user_id] = 2
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'page'
|
||||
end
|
||||
|
||||
def test_page
|
||||
get :page
|
||||
assert_response :success
|
||||
assert_template 'page'
|
||||
end
|
||||
|
||||
def test_get_account
|
||||
get :account
|
||||
assert_response :success
|
||||
assert_template 'account'
|
||||
assert_equal User.find(2), assigns(:user)
|
||||
end
|
||||
|
||||
def test_update_account
|
||||
post :account, :user => {:firstname => "Joe", :login => "root", :admin => 1}
|
||||
assert_redirected_to 'my/account'
|
||||
user = User.find(2)
|
||||
assert_equal user, assigns(:user)
|
||||
assert_equal "Joe", user.firstname
|
||||
assert_equal "jsmith", user.login
|
||||
assert !user.admin?
|
||||
end
|
||||
|
||||
def test_change_password
|
||||
get :password
|
||||
assert_response :success
|
||||
assert_template 'password'
|
||||
|
||||
# non matching password confirmation
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'hello',
|
||||
:new_password_confirmation => 'hello2'
|
||||
assert_response :success
|
||||
assert_template 'password'
|
||||
assert_tag :tag => "div", :attributes => { :class => "errorExplanation" }
|
||||
|
||||
# wrong password
|
||||
post :password, :password => 'wrongpassword',
|
||||
:new_password => 'hello',
|
||||
:new_password_confirmation => 'hello'
|
||||
assert_response :success
|
||||
assert_template 'password'
|
||||
assert_equal 'Wrong password', flash[:error]
|
||||
|
||||
# good password
|
||||
post :password, :password => 'jsmith',
|
||||
:new_password => 'hello',
|
||||
:new_password_confirmation => 'hello'
|
||||
assert_redirected_to 'my/account'
|
||||
assert User.try_to_login('jsmith', 'hello')
|
||||
end
|
||||
end
|
||||
147
nested_projects/test/functional/news_controller_test.rb
Normal file
147
nested_projects/test/functional/news_controller_test.rb
Normal file
@@ -0,0 +1,147 @@
|
||||
# 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 'news_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class NewsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class NewsControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :enabled_modules, :news, :comments
|
||||
|
||||
def setup
|
||||
@controller = NewsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:newss)
|
||||
assert_nil assigns(:project)
|
||||
end
|
||||
|
||||
def test_index_with_project
|
||||
get :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:newss)
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_tag :tag => 'h2', :content => /eCookbook first release/
|
||||
end
|
||||
|
||||
def test_show_not_found
|
||||
get :show, :id => 999
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
end
|
||||
|
||||
def test_post_new
|
||||
@request.session[:user_id] = 2
|
||||
post :new, :project_id => 1, :news => { :title => 'NewsControllerTest',
|
||||
:description => 'This is the description',
|
||||
:summary => '' }
|
||||
assert_redirected_to 'projects/ecookbook/news'
|
||||
|
||||
news = News.find_by_title('NewsControllerTest')
|
||||
assert_not_nil news
|
||||
assert_equal 'This is the description', news.description
|
||||
assert_equal User.find(2), news.author
|
||||
assert_equal Project.find(1), news.project
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :id => 1, :news => { :description => 'Description changed by test_post_edit' }
|
||||
assert_redirected_to 'news/show/1'
|
||||
news = News.find(1)
|
||||
assert_equal 'Description changed by test_post_edit', news.description
|
||||
end
|
||||
|
||||
def test_post_new_with_validation_failure
|
||||
@request.session[:user_id] = 2
|
||||
post :new, :project_id => 1, :news => { :title => '',
|
||||
:description => 'This is the description',
|
||||
:summary => '' }
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_not_nil assigns(:news)
|
||||
assert assigns(:news).new_record?
|
||||
assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' },
|
||||
:content => /1 error/
|
||||
end
|
||||
|
||||
def test_add_comment
|
||||
@request.session[:user_id] = 2
|
||||
post :add_comment, :id => 1, :comment => { :comments => 'This is a NewsControllerTest comment' }
|
||||
assert_redirected_to 'news/show/1'
|
||||
|
||||
comment = News.find(1).comments.find(:first, :order => 'created_on DESC')
|
||||
assert_not_nil comment
|
||||
assert_equal 'This is a NewsControllerTest comment', comment.comments
|
||||
assert_equal User.find(2), comment.author
|
||||
end
|
||||
|
||||
def test_destroy_comment
|
||||
comments_count = News.find(1).comments.size
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy_comment, :id => 1, :comment_id => 2
|
||||
assert_redirected_to 'news/show/1'
|
||||
assert_nil Comment.find_by_id(2)
|
||||
assert_equal comments_count - 1, News.find(1).comments.size
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :id => 1
|
||||
assert_redirected_to 'projects/ecookbook/news'
|
||||
assert_nil News.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_preview
|
||||
get :preview, :project_id => 1,
|
||||
:news => {:title => '',
|
||||
:description => 'News description',
|
||||
:summary => ''}
|
||||
assert_response :success
|
||||
assert_template 'common/_preview'
|
||||
assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' },
|
||||
:content => /News description/
|
||||
end
|
||||
end
|
||||
340
nested_projects/test/functional/projects_controller_test.rb
Normal file
340
nested_projects/test/functional/projects_controller_test.rb
Normal file
@@ -0,0 +1,340 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2008 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 'projects_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class ProjectsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class ProjectsControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details,
|
||||
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
|
||||
:attachments
|
||||
|
||||
def setup
|
||||
@controller = ProjectsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@request.session[:user_id] = nil
|
||||
Setting.default_language = 'en'
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:project_tree)
|
||||
# Root project as hash key
|
||||
assert assigns(:project_tree).keys.include?(Project.find(1))
|
||||
# Subproject in corresponding value
|
||||
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
|
||||
end
|
||||
|
||||
def test_index_atom
|
||||
get :index, :format => 'atom'
|
||||
assert_response :success
|
||||
assert_template 'common/feed.atom.rxml'
|
||||
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
||||
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
|
||||
end
|
||||
|
||||
def test_show_by_id
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
end
|
||||
|
||||
def test_show_by_identifier
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
|
||||
end
|
||||
|
||||
def test_private_subprojects_hidden
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_no_tag :tag => 'a', :content => /Private child/
|
||||
end
|
||||
|
||||
def test_private_subprojects_visible
|
||||
@request.session[:user_id] = 2 # manager who is a member of the private subproject
|
||||
get :show, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_tag :tag => 'a', :content => /Private child/
|
||||
end
|
||||
|
||||
def test_settings
|
||||
@request.session[:user_id] = 2 # manager
|
||||
get :settings, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'settings'
|
||||
end
|
||||
|
||||
def test_edit
|
||||
@request.session[:user_id] = 2 # manager
|
||||
post :edit, :id => 1, :project => {:name => 'Test changed name',
|
||||
:issue_custom_field_ids => ['']}
|
||||
assert_redirected_to 'projects/settings/ecookbook'
|
||||
project = Project.find(1)
|
||||
assert_equal 'Test changed name', project.name
|
||||
end
|
||||
|
||||
def test_get_destroy
|
||||
@request.session[:user_id] = 1 # admin
|
||||
get :destroy, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
assert_not_nil Project.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_post_destroy
|
||||
@request.session[:user_id] = 1 # admin
|
||||
post :destroy, :id => 1, :confirm => 1
|
||||
assert_redirected_to 'admin/projects'
|
||||
assert_nil Project.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_add_file
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
Setting.notified_events << 'file_added'
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
assert_difference 'Attachment.count' do
|
||||
post :add_file, :id => 1, :version_id => '',
|
||||
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
||||
end
|
||||
assert_redirected_to 'projects/list_files/ecookbook'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Project.find(1), a.container
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_kind_of TMail::Mail, mail
|
||||
assert_equal "[eCookbook] New file", mail.subject
|
||||
assert mail.body.include?('testfile.txt')
|
||||
end
|
||||
|
||||
def test_add_version_file
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
Setting.notified_events << 'file_added'
|
||||
|
||||
assert_difference 'Attachment.count' do
|
||||
post :add_file, :id => 1, :version_id => '2',
|
||||
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
|
||||
end
|
||||
assert_redirected_to 'projects/list_files/ecookbook'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Version.find(2), a.container
|
||||
end
|
||||
|
||||
def test_list_files
|
||||
get :list_files, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'list_files'
|
||||
assert_not_nil assigns(:containers)
|
||||
|
||||
# file attached to the project
|
||||
assert_tag :a, :content => 'project_file.zip',
|
||||
:attributes => { :href => '/attachments/download/8/project_file.zip' }
|
||||
|
||||
# file attached to a project's version
|
||||
assert_tag :a, :content => 'version_file.zip',
|
||||
:attributes => { :href => '/attachments/download/9/version_file.zip' }
|
||||
end
|
||||
|
||||
def test_changelog
|
||||
get :changelog, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'changelog'
|
||||
assert_not_nil assigns(:versions)
|
||||
end
|
||||
|
||||
def test_roadmap
|
||||
get :roadmap, :id => 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 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_project_activity
|
||||
get :activity, :id => 1, :with_subprojects => 0
|
||||
assert_response :success
|
||||
assert_template 'activity'
|
||||
assert_not_nil assigns(:events_by_day)
|
||||
|
||||
assert_tag :tag => "h3",
|
||||
:content => /#{2.days.ago.to_date.day}/,
|
||||
:sibling => { :tag => "dl",
|
||||
:child => { :tag => "dt",
|
||||
:attributes => { :class => /issue-edit/ },
|
||||
:child => { :tag => "a",
|
||||
:content => /(#{IssueStatus.find(2).name})/,
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def test_previous_project_activity
|
||||
get :activity, :id => 1, :from => 3.days.ago.to_date
|
||||
assert_response :success
|
||||
assert_template 'activity'
|
||||
assert_not_nil assigns(:events_by_day)
|
||||
|
||||
assert_tag :tag => "h3",
|
||||
:content => /#{3.day.ago.to_date.day}/,
|
||||
:sibling => { :tag => "dl",
|
||||
:child => { :tag => "dt",
|
||||
:attributes => { :class => /issue/ },
|
||||
:child => { :tag => "a",
|
||||
:content => /#{Issue.find(1).subject}/,
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def test_global_activity
|
||||
get :activity
|
||||
assert_response :success
|
||||
assert_template 'activity'
|
||||
assert_not_nil assigns(:events_by_day)
|
||||
|
||||
assert_tag :tag => "h3",
|
||||
:content => /#{5.day.ago.to_date.day}/,
|
||||
:sibling => { :tag => "dl",
|
||||
:child => { :tag => "dt",
|
||||
:attributes => { :class => /issue/ },
|
||||
:child => { :tag => "a",
|
||||
:content => /#{Issue.find(5).subject}/,
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def test_user_activity
|
||||
get :activity, :user_id => 2
|
||||
assert_response :success
|
||||
assert_template 'activity'
|
||||
assert_not_nil assigns(:events_by_day)
|
||||
|
||||
assert_tag :tag => "h3",
|
||||
:content => /#{3.day.ago.to_date.day}/,
|
||||
:sibling => { :tag => "dl",
|
||||
:child => { :tag => "dt",
|
||||
:attributes => { :class => /issue/ },
|
||||
:child => { :tag => "a",
|
||||
:content => /#{Issue.find(1).subject}/,
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def test_activity_atom_feed
|
||||
get :activity, :format => 'atom'
|
||||
assert_response :success
|
||||
assert_template 'common/feed.atom.rxml'
|
||||
end
|
||||
|
||||
def test_archive
|
||||
@request.session[:user_id] = 1 # admin
|
||||
post :archive, :id => 1
|
||||
assert_redirected_to 'admin/projects'
|
||||
assert !Project.find(1).active?
|
||||
end
|
||||
|
||||
def test_unarchive
|
||||
@request.session[:user_id] = 1 # admin
|
||||
Project.find(1).archive
|
||||
post :unarchive, :id => 1
|
||||
assert_redirected_to 'admin/projects'
|
||||
assert Project.find(1).active?
|
||||
end
|
||||
|
||||
def test_project_menu
|
||||
assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
|
||||
Redmine::MenuManager.map :project_menu do |menu|
|
||||
menu.push :foo, { :controller => 'projects', :action => 'show' }, :cation => 'Foo'
|
||||
menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity
|
||||
menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
|
||||
end
|
||||
|
||||
get :show, :id => 1
|
||||
assert_tag :div, :attributes => { :id => 'main-menu' },
|
||||
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
|
||||
:attributes => { :class => 'foo' } } }
|
||||
|
||||
assert_tag :div, :attributes => { :id => 'main-menu' },
|
||||
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
|
||||
:attributes => { :class => 'bar' } },
|
||||
:before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
|
||||
|
||||
assert_tag :div, :attributes => { :id => 'main-menu' },
|
||||
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
|
||||
:attributes => { :class => 'hello' } },
|
||||
:before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
|
||||
|
||||
# Remove the menu items
|
||||
Redmine::MenuManager.map :project_menu do |menu|
|
||||
menu.delete :foo
|
||||
menu.delete :bar
|
||||
menu.delete :hello
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# A hook that is manually registered later
|
||||
class ProjectBasedTemplate < Redmine::Hook::ViewListener
|
||||
def view_layouts_base_html_head(context)
|
||||
# Adds a project stylesheet
|
||||
stylesheet_link_tag(context[:project].identifier) if context[:project]
|
||||
end
|
||||
end
|
||||
# Don't use this hook now
|
||||
Redmine::Hook.clear_listeners
|
||||
|
||||
def test_hook_response
|
||||
Redmine::Hook.add_listener(ProjectBasedTemplate)
|
||||
get :show, :id => 1
|
||||
assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
|
||||
:parent => {:tag => 'head'}
|
||||
|
||||
Redmine::Hook.clear_listeners
|
||||
end
|
||||
end
|
||||
211
nested_projects/test/functional/queries_controller_test.rb
Normal file
211
nested_projects/test/functional/queries_controller_test.rb
Normal file
@@ -0,0 +1,211 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 'queries_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class QueriesController; def rescue_action(e) raise e end; end
|
||||
|
||||
class QueriesControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :members, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries
|
||||
|
||||
def setup
|
||||
@controller = QueriesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_get_new_project_query
|
||||
@request.session[:user_id] = 2
|
||||
get :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query[is_public]',
|
||||
:checked => nil }
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query_is_for_all',
|
||||
:checked => nil,
|
||||
:disabled => nil }
|
||||
end
|
||||
|
||||
def test_get_new_global_query
|
||||
@request.session[:user_id] = 2
|
||||
get :new
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query[is_public]' }
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query_is_for_all',
|
||||
:checked => 'checked',
|
||||
:disabled => nil }
|
||||
end
|
||||
|
||||
def test_new_project_public_query
|
||||
@request.session[:user_id] = 2
|
||||
post :new,
|
||||
:project_id => 'ecookbook',
|
||||
:confirm => '1',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_new_project_public_query", "is_public" => "1"}
|
||||
|
||||
q = Query.find_by_name('test_new_project_public_query')
|
||||
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => q
|
||||
assert q.is_public?
|
||||
assert q.has_default_columns?
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_new_project_private_query
|
||||
@request.session[:user_id] = 3
|
||||
post :new,
|
||||
:project_id => 'ecookbook',
|
||||
:confirm => '1',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_new_project_private_query", "is_public" => "1"}
|
||||
|
||||
q = Query.find_by_name('test_new_project_private_query')
|
||||
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => q
|
||||
assert !q.is_public?
|
||||
assert q.has_default_columns?
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_new_global_private_query_with_custom_columns
|
||||
@request.session[:user_id] = 3
|
||||
post :new,
|
||||
:confirm => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_new_global_private_query", "is_public" => "1", "column_names" => ["", "tracker", "subject", "priority", "category"]}
|
||||
|
||||
q = Query.find_by_name('test_new_global_private_query')
|
||||
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => q
|
||||
assert !q.is_public?
|
||||
assert !q.has_default_columns?
|
||||
assert_equal [:tracker, :subject, :priority, :category], q.columns.collect {|c| c.name}
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_get_edit_global_public_query
|
||||
@request.session[:user_id] = 1
|
||||
get :edit, :id => 4
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query[is_public]',
|
||||
:checked => 'checked' }
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query_is_for_all',
|
||||
:checked => 'checked',
|
||||
:disabled => 'disabled' }
|
||||
end
|
||||
|
||||
def test_edit_global_public_query
|
||||
@request.session[:user_id] = 1
|
||||
post :edit,
|
||||
:id => 4,
|
||||
:confirm => '1',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["1"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_edit_global_public_query", "is_public" => "1"}
|
||||
|
||||
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4
|
||||
q = Query.find_by_name('test_edit_global_public_query')
|
||||
assert q.is_public?
|
||||
assert q.has_default_columns?
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_get_edit_global_private_query
|
||||
@request.session[:user_id] = 3
|
||||
get :edit, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query[is_public]' }
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query_is_for_all',
|
||||
:checked => 'checked',
|
||||
:disabled => 'disabled' }
|
||||
end
|
||||
|
||||
def test_edit_global_private_query
|
||||
@request.session[:user_id] = 3
|
||||
post :edit,
|
||||
:id => 3,
|
||||
:confirm => '1',
|
||||
:default_columns => '1',
|
||||
:fields => ["status_id", "assigned_to_id"],
|
||||
:operators => {"assigned_to_id" => "=", "status_id" => "o"},
|
||||
:values => { "assigned_to_id" => ["me"], "status_id" => ["1"]},
|
||||
:query => {"name" => "test_edit_global_private_query", "is_public" => "1"}
|
||||
|
||||
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3
|
||||
q = Query.find_by_name('test_edit_global_private_query')
|
||||
assert !q.is_public?
|
||||
assert q.has_default_columns?
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_get_edit_project_private_query
|
||||
@request.session[:user_id] = 3
|
||||
get :edit, :id => 2
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_no_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query[is_public]' }
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query_is_for_all',
|
||||
:checked => nil,
|
||||
:disabled => nil }
|
||||
end
|
||||
|
||||
def test_get_edit_project_public_query
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query[is_public]',
|
||||
:checked => 'checked'
|
||||
}
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'query_is_for_all',
|
||||
:checked => nil,
|
||||
:disabled => 'disabled' }
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :id => 1
|
||||
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil
|
||||
assert_nil Query.find_by_id(1)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,137 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 RepositoriesBazaarControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules
|
||||
|
||||
# No '..' in the repository path
|
||||
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository'
|
||||
|
||||
def setup
|
||||
@controller = RepositoriesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
Repository::Bazaar.create(:project => Project.find(3), :url => REPOSITORY_PATH)
|
||||
end
|
||||
|
||||
if File.directory?(REPOSITORY_PATH)
|
||||
def test_show
|
||||
get :show, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_not_nil assigns(:changesets)
|
||||
end
|
||||
|
||||
def test_browse_root
|
||||
get :browse, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal 2, assigns(:entries).size
|
||||
assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'}
|
||||
assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'}
|
||||
end
|
||||
|
||||
def test_browse_directory
|
||||
get :browse, :id => 3, :path => ['directory']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name)
|
||||
entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
|
||||
assert_not_nil entry
|
||||
assert_equal 'file', entry.kind
|
||||
assert_equal 'directory/edit.png', entry.path
|
||||
end
|
||||
|
||||
def test_browse_at_given_revision
|
||||
get :browse, :id => 3, :path => [], :rev => 3
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'], assigns(:entries).collect(&:name)
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :id => 3, :path => ['doc-mkdir.txt']
|
||||
assert_response :success
|
||||
assert_template 'changes'
|
||||
assert_tag :tag => 'h2', :content => 'doc-mkdir.txt'
|
||||
end
|
||||
|
||||
def test_entry_show
|
||||
get :entry, :id => 3, :path => ['directory', 'doc-ls.txt']
|
||||
assert_response :success
|
||||
assert_template 'entry'
|
||||
# Line 19
|
||||
assert_tag :tag => 'th',
|
||||
:content => /29/,
|
||||
:attributes => { :class => /line-num/ },
|
||||
:sibling => { :tag => 'td', :content => /Show help message/ }
|
||||
end
|
||||
|
||||
def test_entry_download
|
||||
get :entry, :id => 3, :path => ['directory', 'doc-ls.txt'], :format => 'raw'
|
||||
assert_response :success
|
||||
# File content
|
||||
assert @response.body.include?('Show help message')
|
||||
end
|
||||
|
||||
def test_directory_entry
|
||||
get :entry, :id => 3, :path => ['directory']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entry)
|
||||
assert_equal 'directory', assigns(:entry).name
|
||||
end
|
||||
|
||||
def test_diff
|
||||
# Full diff of changeset 3
|
||||
get :diff, :id => 3, :rev => 3
|
||||
assert_response :success
|
||||
assert_template 'diff'
|
||||
# Line 22 removed
|
||||
assert_tag :tag => 'th',
|
||||
:content => /2/,
|
||||
:sibling => { :tag => 'td',
|
||||
:attributes => { :class => /diff_in/ },
|
||||
:content => /Main purpose/ }
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
get :annotate, :id => 3, :path => ['doc-mkdir.txt']
|
||||
assert_response :success
|
||||
assert_template 'annotate'
|
||||
# Line 2, revision 3
|
||||
assert_tag :tag => 'th', :content => /2/,
|
||||
:sibling => { :tag => 'td', :child => { :tag => 'a', :content => /3/ } },
|
||||
:sibling => { :tag => 'td', :content => /jsmith/ },
|
||||
:sibling => { :tag => 'td', :content => /Main purpose/ }
|
||||
end
|
||||
else
|
||||
puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!"
|
||||
def test_fake; assert true end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,98 @@
|
||||
# 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
|
||||
|
||||
def setup
|
||||
@controller = RepositoriesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
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
|
||||
assert_template 'revision'
|
||||
assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
|
||||
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook/0'}
|
||||
}
|
||||
assert_tag :tag => "div", :attributes => { :class => "contextual" },
|
||||
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook/2'}
|
||||
}
|
||||
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
|
||||
|
||||
def test_committers
|
||||
@request.session[:user_id] = 2
|
||||
# add a commit with an unknown user
|
||||
Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
|
||||
|
||||
get :committers, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'committers'
|
||||
|
||||
assert_tag :td, :content => 'dlopper',
|
||||
:sibling => { :tag => 'td',
|
||||
:child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} },
|
||||
:child => { :tag => 'option', :content => 'Dave Lopper',
|
||||
:attributes => { :value => '3', :selected => 'selected' }}}}
|
||||
assert_tag :td, :content => 'foo',
|
||||
:sibling => { :tag => 'td',
|
||||
:child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}}
|
||||
assert_no_tag :td, :content => 'foo',
|
||||
:sibling => { :tag => 'td',
|
||||
:descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
|
||||
end
|
||||
|
||||
def test_map_committers
|
||||
@request.session[:user_id] = 2
|
||||
# add a commit with an unknown user
|
||||
c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
|
||||
|
||||
assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
|
||||
post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
|
||||
assert_redirected_to '/repositories/committers/ecookbook'
|
||||
assert_equal User.find(2), c.reload.user
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,165 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 RepositoriesCvsControllerTest < Test::Unit::TestCase
|
||||
|
||||
# No '..' in the repository path
|
||||
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
|
||||
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||||
# CVS module
|
||||
MODULE_NAME = 'test'
|
||||
|
||||
def setup
|
||||
@controller = RepositoriesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
Setting.default_language = 'en'
|
||||
User.current = nil
|
||||
|
||||
@project = Project.find(1)
|
||||
@project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH,
|
||||
:url => MODULE_NAME)
|
||||
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)
|
||||
assert_equal 3, assigns(:entries).size
|
||||
|
||||
entry = assigns(:entries).detect {|e| e.name == 'images'}
|
||||
assert_equal 'dir', entry.kind
|
||||
|
||||
entry = assigns(:entries).detect {|e| e.name == 'README'}
|
||||
assert_equal 'file', entry.kind
|
||||
end
|
||||
|
||||
def test_browse_directory
|
||||
get :browse, :id => 1, :path => ['images']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name)
|
||||
entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
|
||||
assert_not_nil entry
|
||||
assert_equal 'file', entry.kind
|
||||
assert_equal 'images/edit.png', entry.path
|
||||
end
|
||||
|
||||
def test_browse_at_given_revision
|
||||
Project.find(1).repository.fetch_changesets
|
||||
get :browse, :id => 1, :path => ['images'], :rev => 1
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
|
||||
end
|
||||
|
||||
def test_entry
|
||||
get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
|
||||
assert_response :success
|
||||
assert_template 'entry'
|
||||
assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
|
||||
:content => /before_filter/
|
||||
end
|
||||
|
||||
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
|
||||
assert_response :success
|
||||
assert_template 'entry'
|
||||
# this line was removed in r3
|
||||
assert_tag :tag => 'td', :attributes => { :class => /line-code/},
|
||||
:content => /before_filter/
|
||||
end
|
||||
|
||||
def test_entry_not_found
|
||||
get :entry, :id => 1, :path => ['sources', 'zzz.c']
|
||||
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
||||
: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'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_directory_entry
|
||||
get :entry, :id => 1, :path => ['sources']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entry)
|
||||
assert_equal 'sources', assigns(:entry).name
|
||||
end
|
||||
|
||||
def test_diff
|
||||
Project.find(1).repository.fetch_changesets
|
||||
get :diff, :id => 1, :rev => 3, :type => 'inline'
|
||||
assert_response :success
|
||||
assert_template 'diff'
|
||||
assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
|
||||
:content => /watched.remove_watcher/
|
||||
assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
|
||||
:content => /watched.remove_all_watcher/
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
Project.find(1).repository.fetch_changesets
|
||||
get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb']
|
||||
assert_response :success
|
||||
assert_template 'annotate'
|
||||
# 1.1 line
|
||||
assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
|
||||
:content => '18',
|
||||
:sibling => { :tag => 'td', :attributes => { :class => 'revision' },
|
||||
:content => /1.1/,
|
||||
:sibling => { :tag => 'td', :attributes => { :class => 'author' },
|
||||
:content => /LANG/
|
||||
}
|
||||
}
|
||||
# 1.2 line
|
||||
assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
|
||||
:content => '32',
|
||||
:sibling => { :tag => 'td', :attributes => { :class => 'revision' },
|
||||
:content => /1.2/,
|
||||
:sibling => { :tag => 'td', :attributes => { :class => 'author' },
|
||||
:content => /LANG/
|
||||
}
|
||||
}
|
||||
end
|
||||
else
|
||||
puts "CVS test repository NOT FOUND. Skipping functional tests !!!"
|
||||
def test_fake; assert true end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,103 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 RepositoriesDarcsControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules
|
||||
|
||||
# No '..' in the repository path
|
||||
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository'
|
||||
|
||||
def setup
|
||||
@controller = RepositoriesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
Repository::Darcs.create(:project => Project.find(3), :url => REPOSITORY_PATH)
|
||||
end
|
||||
|
||||
if File.directory?(REPOSITORY_PATH)
|
||||
def test_show
|
||||
get :show, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_not_nil assigns(:changesets)
|
||||
end
|
||||
|
||||
def test_browse_root
|
||||
get :browse, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal 3, assigns(:entries).size
|
||||
assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
|
||||
assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
|
||||
assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
|
||||
end
|
||||
|
||||
def test_browse_directory
|
||||
get :browse, :id => 3, :path => ['images']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
|
||||
entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
|
||||
assert_not_nil entry
|
||||
assert_equal 'file', entry.kind
|
||||
assert_equal 'images/edit.png', entry.path
|
||||
end
|
||||
|
||||
def test_browse_at_given_revision
|
||||
Project.find(3).repository.fetch_changesets
|
||||
get :browse, :id => 3, :path => ['images'], :rev => 1
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['delete.png'], assigns(:entries).collect(&:name)
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :id => 3, :path => ['images', 'edit.png']
|
||||
assert_response :success
|
||||
assert_template 'changes'
|
||||
assert_tag :tag => 'h2', :content => 'edit.png'
|
||||
end
|
||||
|
||||
def test_diff
|
||||
Project.find(3).repository.fetch_changesets
|
||||
# Full diff of changeset 5
|
||||
get :diff, :id => 3, :rev => 5
|
||||
assert_response :success
|
||||
assert_template 'diff'
|
||||
# Line 22 removed
|
||||
assert_tag :tag => 'th',
|
||||
:content => /22/,
|
||||
:sibling => { :tag => 'td',
|
||||
:attributes => { :class => /diff_out/ },
|
||||
:content => /def remove/ }
|
||||
end
|
||||
else
|
||||
puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
|
||||
def test_fake; assert true end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,146 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 RepositoriesGitControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules
|
||||
|
||||
# No '..' in the repository path
|
||||
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
|
||||
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||||
|
||||
def setup
|
||||
@controller = RepositoriesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
Repository::Git.create(:project => Project.find(3), :url => REPOSITORY_PATH)
|
||||
end
|
||||
|
||||
if File.directory?(REPOSITORY_PATH)
|
||||
def test_show
|
||||
get :show, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_not_nil assigns(:changesets)
|
||||
end
|
||||
|
||||
def test_browse_root
|
||||
get :browse, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal 3, assigns(:entries).size
|
||||
assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
|
||||
assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
|
||||
assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
|
||||
end
|
||||
|
||||
def test_browse_directory
|
||||
get :browse, :id => 3, :path => ['images']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
|
||||
entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
|
||||
assert_not_nil entry
|
||||
assert_equal 'file', entry.kind
|
||||
assert_equal 'images/edit.png', entry.path
|
||||
end
|
||||
|
||||
def test_browse_at_given_revision
|
||||
get :browse, :id => 3, :path => ['images'], :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['delete.png'], assigns(:entries).collect(&:name)
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :id => 3, :path => ['images', 'edit.png']
|
||||
assert_response :success
|
||||
assert_template 'changes'
|
||||
assert_tag :tag => 'h2', :content => 'edit.png'
|
||||
end
|
||||
|
||||
def test_entry_show
|
||||
get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
|
||||
assert_response :success
|
||||
assert_template 'entry'
|
||||
# Line 19
|
||||
assert_tag :tag => 'th',
|
||||
:content => /10/,
|
||||
:attributes => { :class => /line-num/ },
|
||||
:sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
|
||||
end
|
||||
|
||||
def test_entry_download
|
||||
get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
|
||||
assert_response :success
|
||||
# File content
|
||||
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
||||
end
|
||||
|
||||
def test_directory_entry
|
||||
get :entry, :id => 3, :path => ['sources']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entry)
|
||||
assert_equal 'sources', assigns(:entry).name
|
||||
end
|
||||
|
||||
def test_diff
|
||||
# Full diff of changeset 2f9c0091
|
||||
get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
assert_response :success
|
||||
assert_template 'diff'
|
||||
# Line 22 removed
|
||||
assert_tag :tag => 'th',
|
||||
:content => /22/,
|
||||
:sibling => { :tag => 'td',
|
||||
:attributes => { :class => /diff_out/ },
|
||||
:content => /def remove/ }
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
|
||||
assert_response :success
|
||||
assert_template 'annotate'
|
||||
# Line 23, changeset 2f9c0091
|
||||
assert_tag :tag => 'th', :content => /23/,
|
||||
:sibling => { :tag => 'td', :child => { :tag => 'a', :content => /2f9c0091/ } },
|
||||
:sibling => { :tag => 'td', :content => /jsmith/ },
|
||||
:sibling => { :tag => 'td', :content => /watcher =/ }
|
||||
end
|
||||
|
||||
def test_annotate_binary_file
|
||||
get :annotate, :id => 3, :path => ['images', 'delete.png']
|
||||
assert_response 500
|
||||
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
||||
:content => /can not be annotated/
|
||||
end
|
||||
else
|
||||
puts "Git test repository NOT FOUND. Skipping functional tests !!!"
|
||||
def test_fake; assert true end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,138 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 RepositoriesMercurialControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules
|
||||
|
||||
# No '..' in the repository path
|
||||
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
|
||||
|
||||
def setup
|
||||
@controller = RepositoriesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH)
|
||||
end
|
||||
|
||||
if File.directory?(REPOSITORY_PATH)
|
||||
def test_show
|
||||
get :show, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_not_nil assigns(:changesets)
|
||||
end
|
||||
|
||||
def test_browse_root
|
||||
get :browse, :id => 3
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal 3, assigns(:entries).size
|
||||
assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
|
||||
assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
|
||||
assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
|
||||
end
|
||||
|
||||
def test_browse_directory
|
||||
get :browse, :id => 3, :path => ['images']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
|
||||
entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
|
||||
assert_not_nil entry
|
||||
assert_equal 'file', entry.kind
|
||||
assert_equal 'images/edit.png', entry.path
|
||||
end
|
||||
|
||||
def test_browse_at_given_revision
|
||||
get :browse, :id => 3, :path => ['images'], :rev => 0
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['delete.png'], assigns(:entries).collect(&:name)
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :id => 3, :path => ['images', 'edit.png']
|
||||
assert_response :success
|
||||
assert_template 'changes'
|
||||
assert_tag :tag => 'h2', :content => 'edit.png'
|
||||
end
|
||||
|
||||
def test_entry_show
|
||||
get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
|
||||
assert_response :success
|
||||
assert_template 'entry'
|
||||
# Line 19
|
||||
assert_tag :tag => 'th',
|
||||
:content => /10/,
|
||||
:attributes => { :class => /line-num/ },
|
||||
:sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
|
||||
end
|
||||
|
||||
def test_entry_download
|
||||
get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
|
||||
assert_response :success
|
||||
# File content
|
||||
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
||||
end
|
||||
|
||||
def test_directory_entry
|
||||
get :entry, :id => 3, :path => ['sources']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entry)
|
||||
assert_equal 'sources', assigns(:entry).name
|
||||
end
|
||||
|
||||
def test_diff
|
||||
# Full diff of changeset 4
|
||||
get :diff, :id => 3, :rev => 4
|
||||
assert_response :success
|
||||
assert_template 'diff'
|
||||
# Line 22 removed
|
||||
assert_tag :tag => 'th',
|
||||
:content => /22/,
|
||||
:sibling => { :tag => 'td',
|
||||
:attributes => { :class => /diff_out/ },
|
||||
:content => /def remove/ }
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
|
||||
assert_response :success
|
||||
assert_template 'annotate'
|
||||
# Line 23, revision 4
|
||||
assert_tag :tag => 'th', :content => /23/,
|
||||
:sibling => { :tag => 'td', :child => { :tag => 'a', :content => /4/ } },
|
||||
:sibling => { :tag => 'td', :content => /jsmith/ },
|
||||
:sibling => { :tag => 'td', :content => /watcher =/ }
|
||||
end
|
||||
else
|
||||
puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
|
||||
def test_fake; assert true end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,179 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2008 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 RepositoriesSubversionControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :enabled_modules,
|
||||
: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
|
||||
Setting.default_language = 'en'
|
||||
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)
|
||||
assert_equal ['folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name)
|
||||
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_browse_at_given_revision
|
||||
get :browse, :id => 1, :path => ['subversion_test'], :rev => 4
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], assigns(:entries).collect(&:name)
|
||||
end
|
||||
|
||||
def test_changes
|
||||
get :changes, :id => 1, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
|
||||
assert_response :success
|
||||
assert_template 'changes'
|
||||
# svn properties
|
||||
assert_not_nil assigns(:properties)
|
||||
assert_equal 'native', assigns(:properties)['svn:eol-style']
|
||||
assert_tag :ul,
|
||||
:child => { :tag => 'li',
|
||||
:child => { :tag => 'b', :content => 'svn:eol-style' },
|
||||
:child => { :tag => 'span', :content => 'native' } }
|
||||
end
|
||||
|
||||
def test_entry
|
||||
get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
|
||||
assert_response :success
|
||||
assert_template 'entry'
|
||||
end
|
||||
|
||||
def test_entry_at_given_revision
|
||||
get :entry, :id => 1, :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
|
||||
assert_tag :tag => 'td', :attributes => { :class => /line-code/},
|
||||
:content => /Here's the code/
|
||||
end
|
||||
|
||||
def test_entry_not_found
|
||||
get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
|
||||
assert_tag :tag => 'div', :attributes => { :class => /error/ },
|
||||
: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'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_directory_entry
|
||||
get :entry, :id => 1, :path => ['subversion_test', 'folder']
|
||||
assert_response :success
|
||||
assert_template 'browse'
|
||||
assert_not_nil assigns(:entry)
|
||||
assert_equal 'folder', assigns(:entry).name
|
||||
end
|
||||
|
||||
def test_revision
|
||||
get :revision, :id => 1, :rev => 2
|
||||
assert_response :success
|
||||
assert_template 'revision'
|
||||
assert_tag :tag => 'ul',
|
||||
:child => { :tag => 'li',
|
||||
# link to the entry at rev 2
|
||||
:child => { :tag => 'a',
|
||||
:attributes => {:href => '/repositories/entry/ecookbook/test/some/path/in/the/repo?rev=2'},
|
||||
:content => 'repo',
|
||||
# link to partial diff
|
||||
:sibling => { :tag => 'a',
|
||||
:attributes => { :href => '/repositories/diff/ecookbook/test/some/path/in/the/repo?rev=2' }
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def test_revision_with_repository_pointing_to_a_subdirectory
|
||||
r = Project.find(1).repository
|
||||
# Changes repository url to a subdirectory
|
||||
r.update_attribute :url, (r.url + '/test/some')
|
||||
|
||||
get :revision, :id => 1, :rev => 2
|
||||
assert_response :success
|
||||
assert_template 'revision'
|
||||
assert_tag :tag => 'ul',
|
||||
:child => { :tag => 'li',
|
||||
# link to the entry at rev 2
|
||||
:child => { :tag => 'a',
|
||||
:attributes => {:href => '/repositories/entry/ecookbook/path/in/the/repo?rev=2'},
|
||||
:content => 'repo',
|
||||
# link to partial diff
|
||||
:sibling => { :tag => 'a',
|
||||
:attributes => { :href => '/repositories/diff/ecookbook/path/in/the/repo?rev=2' }
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
180
nested_projects/test/functional/roles_controller_test.rb
Normal file
180
nested_projects/test/functional/roles_controller_test.rb
Normal file
@@ -0,0 +1,180 @@
|
||||
# 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 'roles_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class RolesController; def rescue_action(e) raise e end; end
|
||||
|
||||
class RolesControllerTest < Test::Unit::TestCase
|
||||
fixtures :roles, :users, :members, :workflows
|
||||
|
||||
def setup
|
||||
@controller = RolesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
@request.session[:user_id] = 1 # admin
|
||||
end
|
||||
|
||||
def test_get_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'list'
|
||||
|
||||
assert_not_nil assigns(:roles)
|
||||
assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles)
|
||||
|
||||
assert_tag :tag => 'a', :attributes => { :href => '/roles/edit/1' },
|
||||
:content => 'Manager'
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
get :new
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
end
|
||||
|
||||
def test_post_new_with_validaton_failure
|
||||
post :new, :role => {:name => '',
|
||||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''],
|
||||
:assignable => '0'}
|
||||
|
||||
assert_response :success
|
||||
assert_template 'new'
|
||||
assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' }
|
||||
end
|
||||
|
||||
def test_post_new_without_workflow_copy
|
||||
post :new, :role => {:name => 'RoleWithoutWorkflowCopy',
|
||||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''],
|
||||
:assignable => '0'}
|
||||
|
||||
assert_redirected_to 'roles/list'
|
||||
role = Role.find_by_name('RoleWithoutWorkflowCopy')
|
||||
assert_not_nil role
|
||||
assert_equal [:add_issues, :edit_issues, :log_time], role.permissions
|
||||
assert !role.assignable?
|
||||
end
|
||||
|
||||
def test_post_new_with_workflow_copy
|
||||
post :new, :role => {:name => 'RoleWithWorkflowCopy',
|
||||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''],
|
||||
:assignable => '0'},
|
||||
:copy_workflow_from => '1'
|
||||
|
||||
assert_redirected_to 'roles/list'
|
||||
role = Role.find_by_name('RoleWithWorkflowCopy')
|
||||
assert_not_nil role
|
||||
assert_equal Role.find(1).workflows.size, role.workflows.size
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
get :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_equal Role.find(1), assigns(:role)
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
post :edit, :id => 1,
|
||||
:role => {:name => 'Manager',
|
||||
:permissions => ['edit_project', ''],
|
||||
:assignable => '0'}
|
||||
|
||||
assert_redirected_to 'roles/list'
|
||||
role = Role.find(1)
|
||||
assert_equal [:edit_project], role.permissions
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
r = Role.new(:name => 'ToBeDestroyed', :permissions => [:view_wiki_pages])
|
||||
assert r.save
|
||||
|
||||
post :destroy, :id => r
|
||||
assert_redirected_to 'roles/list'
|
||||
assert_nil Role.find_by_id(r.id)
|
||||
end
|
||||
|
||||
def test_destroy_role_in_use
|
||||
post :destroy, :id => 1
|
||||
assert_redirected_to 'roles'
|
||||
assert flash[:error] == 'This role is in use and can not be deleted.'
|
||||
assert_not_nil Role.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_get_report
|
||||
get :report
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
|
||||
assert_not_nil assigns(:roles)
|
||||
assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles)
|
||||
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'permissions[3][]',
|
||||
:value => 'add_issues',
|
||||
:checked => 'checked' }
|
||||
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'permissions[3][]',
|
||||
:value => 'delete_issues',
|
||||
:checked => nil }
|
||||
end
|
||||
|
||||
def test_post_report
|
||||
post :report, :permissions => { '0' => '', '1' => ['edit_issues'], '3' => ['add_issues', 'delete_issues']}
|
||||
assert_redirected_to 'roles/list'
|
||||
|
||||
assert_equal [:edit_issues], Role.find(1).permissions
|
||||
assert_equal [:add_issues, :delete_issues], Role.find(3).permissions
|
||||
assert Role.find(2).permissions.empty?
|
||||
end
|
||||
|
||||
def test_clear_all_permissions
|
||||
post :report, :permissions => { '0' => '' }
|
||||
assert_redirected_to 'roles/list'
|
||||
assert Role.find(1).permissions.empty?
|
||||
end
|
||||
|
||||
def test_move_highest
|
||||
post :move, :id => 3, :position => 'highest'
|
||||
assert_redirected_to 'roles/list'
|
||||
assert_equal 1, Role.find(3).position
|
||||
end
|
||||
|
||||
def test_move_higher
|
||||
position = Role.find(3).position
|
||||
post :move, :id => 3, :position => 'higher'
|
||||
assert_redirected_to 'roles/list'
|
||||
assert_equal position - 1, Role.find(3).position
|
||||
end
|
||||
|
||||
def test_move_lower
|
||||
position = Role.find(2).position
|
||||
post :move, :id => 2, :position => 'lower'
|
||||
assert_redirected_to 'roles/list'
|
||||
assert_equal position + 1, Role.find(2).position
|
||||
end
|
||||
|
||||
def test_move_lowest
|
||||
post :move, :id => 2, :position => 'lowest'
|
||||
assert_redirected_to 'roles/list'
|
||||
assert_equal Role.count, Role.find(2).position
|
||||
end
|
||||
end
|
||||
130
nested_projects/test/functional/search_controller_test.rb
Normal file
130
nested_projects/test/functional/search_controller_test.rb
Normal file
@@ -0,0 +1,130 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'search_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class SearchController; def rescue_action(e) raise e end; end
|
||||
|
||||
class SearchControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :enabled_modules, :roles, :users,
|
||||
:issues, :trackers, :issue_statuses,
|
||||
:custom_fields, :custom_values,
|
||||
:repositories, :changesets
|
||||
|
||||
def setup
|
||||
@controller = SearchController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_search_for_projects
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
|
||||
get :index, :q => "cook"
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert assigns(:results).include?(Project.find(1))
|
||||
end
|
||||
|
||||
def test_search_all_projects
|
||||
get :index, :q => 'recipe subproject commit', :submit => 'Search'
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
|
||||
assert assigns(:results).include?(Issue.find(2))
|
||||
assert assigns(:results).include?(Issue.find(5))
|
||||
assert assigns(:results).include?(Changeset.find(101))
|
||||
assert_tag :dt, :attributes => { :class => /issue/ },
|
||||
:child => { :tag => 'a', :content => /Add ingredients categories/ },
|
||||
:sibling => { :tag => 'dd', :content => /should be classified by categories/ }
|
||||
|
||||
assert assigns(:results_by_type).is_a?(Hash)
|
||||
assert_equal 4, assigns(:results_by_type)['changesets']
|
||||
assert_tag :a, :content => 'Changesets (4)'
|
||||
end
|
||||
|
||||
def test_search_project_and_subprojects
|
||||
get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :submit => 'Search'
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert assigns(:results).include?(Issue.find(1))
|
||||
assert assigns(:results).include?(Issue.find(5))
|
||||
end
|
||||
|
||||
def test_search_without_searchable_custom_fields
|
||||
CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
|
||||
|
||||
get :index, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:project)
|
||||
|
||||
get :index, :id => 1, :q => "can"
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
end
|
||||
|
||||
def test_search_with_searchable_custom_fields
|
||||
get :index, :id => 1, :q => "stringforcustomfield"
|
||||
assert_response :success
|
||||
results = assigns(:results)
|
||||
assert_not_nil results
|
||||
assert_equal 1, results.size
|
||||
assert results.include?(Issue.find(3))
|
||||
end
|
||||
|
||||
def test_search_all_words
|
||||
# 'all words' is on by default
|
||||
get :index, :id => 1, :q => 'recipe updating saving'
|
||||
results = assigns(:results)
|
||||
assert_not_nil results
|
||||
assert_equal 1, results.size
|
||||
assert results.include?(Issue.find(3))
|
||||
end
|
||||
|
||||
def test_search_one_of_the_words
|
||||
get :index, :id => 1, :q => 'recipe updating saving', :submit => 'Search'
|
||||
results = assigns(:results)
|
||||
assert_not_nil results
|
||||
assert_equal 3, results.size
|
||||
assert results.include?(Issue.find(3))
|
||||
end
|
||||
|
||||
def test_search_titles_only_without_result
|
||||
get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1', :titles_only => '1', :submit => 'Search'
|
||||
results = assigns(:results)
|
||||
assert_not_nil results
|
||||
assert_equal 0, results.size
|
||||
end
|
||||
|
||||
def test_search_titles_only
|
||||
get :index, :id => 1, :q => 'recipe', :titles_only => '1', :submit => 'Search'
|
||||
results = assigns(:results)
|
||||
assert_not_nil results
|
||||
assert_equal 2, results.size
|
||||
end
|
||||
|
||||
def test_search_with_invalid_project_id
|
||||
get :index, :id => 195, :q => 'recipe'
|
||||
assert_response 404
|
||||
assert_nil assigns(:results)
|
||||
end
|
||||
|
||||
def test_quick_jump_to_issue
|
||||
# issue of a public project
|
||||
get :index, :q => "3"
|
||||
assert_redirected_to 'issues/show/3'
|
||||
|
||||
# issue of a private project
|
||||
get :index, :q => "4"
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
end
|
||||
|
||||
def test_tokens_with_quotes
|
||||
get :index, :id => 1, :q => '"good bye" hello "bye bye"'
|
||||
assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens)
|
||||
end
|
||||
end
|
||||
53
nested_projects/test/functional/settings_controller_test.rb
Normal file
53
nested_projects/test/functional/settings_controller_test.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
# 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 'settings_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class SettingsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class SettingsControllerTest < Test::Unit::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
|
||||
|
||||
def test_get_edit
|
||||
get :edit
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
end
|
||||
|
||||
def test_post_edit_notifications
|
||||
post :edit, :settings => {:mail_from => 'functional@test.foo',
|
||||
:bcc_recipients => '0',
|
||||
:notified_events => %w(issue_added issue_updated news_added),
|
||||
:emails_footer => 'Test footer'
|
||||
}
|
||||
assert_redirected_to 'settings/edit'
|
||||
assert_equal 'functional@test.foo', Setting.mail_from
|
||||
assert !Setting.bcc_recipients?
|
||||
assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
|
||||
assert_equal 'Test footer', Setting.emails_footer
|
||||
end
|
||||
end
|
||||
50
nested_projects/test/functional/sys_api_test.rb
Normal file
50
nested_projects/test/functional/sys_api_test.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'sys_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class SysController; def rescue_action(e) raise e end; end
|
||||
|
||||
class SysControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :enabled_modules, :repositories
|
||||
|
||||
def setup
|
||||
@controller = SysController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
# Enable WS
|
||||
Setting.sys_api_enabled = 1
|
||||
end
|
||||
|
||||
def test_projects_with_repository_enabled
|
||||
result = invoke :projects_with_repository_enabled
|
||||
assert_equal EnabledModule.count(:all, :conditions => {:name => 'repository'}), result.size
|
||||
|
||||
project = result.first
|
||||
assert project.is_a?(AWSProjectWithRepository)
|
||||
|
||||
assert project.respond_to?(:id)
|
||||
assert_equal 1, project.id
|
||||
|
||||
assert project.respond_to?(:identifier)
|
||||
assert_equal 'ecookbook', project.identifier
|
||||
|
||||
assert project.respond_to?(:name)
|
||||
assert_equal 'eCookbook', project.name
|
||||
|
||||
assert project.respond_to?(:is_public)
|
||||
assert project.is_public
|
||||
|
||||
assert project.respond_to?(:repository)
|
||||
assert project.repository.is_a?(Repository)
|
||||
end
|
||||
|
||||
def test_repository_created
|
||||
project = Project.find(3)
|
||||
assert_nil project.repository
|
||||
assert invoke(:repository_created, project.identifier, 'Subversion', 'http://localhost/svn')
|
||||
project.reload
|
||||
assert_not_nil project.repository
|
||||
assert project.repository.is_a?(Repository::Subversion)
|
||||
assert_equal 'http://localhost/svn', project.repository.url
|
||||
end
|
||||
end
|
||||
278
nested_projects/test/functional/timelog_controller_test.rb
Normal file
278
nested_projects/test/functional/timelog_controller_test.rb
Normal file
@@ -0,0 +1,278 @@
|
||||
# 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 'timelog_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class TimelogController; def rescue_action(e) raise e end; end
|
||||
|
||||
class TimelogControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :enabled_modules, :roles, :members, :issues, :time_entries, :users, :trackers, :enumerations, :issue_statuses, :custom_fields, :custom_values
|
||||
|
||||
def setup
|
||||
@controller = TimelogController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 3
|
||||
get :edit, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
# Default activity selected
|
||||
assert_tag :tag => 'option', :attributes => { :selected => 'selected' },
|
||||
:content => 'Development'
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
@request.session[:user_id] = 3
|
||||
post :edit, :project_id => 1,
|
||||
:time_entry => {:comments => 'Some work on TimelogControllerTest',
|
||||
# Not the default activity
|
||||
:activity_id => '11',
|
||||
:spent_on => '2008-03-14',
|
||||
:issue_id => '1',
|
||||
:hours => '7.3'}
|
||||
assert_redirected_to 'projects/ecookbook/timelog/details'
|
||||
|
||||
i = Issue.find(1)
|
||||
t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
|
||||
assert_not_nil t
|
||||
assert_equal 11, t.activity_id
|
||||
assert_equal 7.3, t.hours
|
||||
assert_equal 3, t.user_id
|
||||
assert_equal i, t.issue
|
||||
assert_equal i.project, t.project
|
||||
end
|
||||
|
||||
def test_update
|
||||
entry = TimeEntry.find(1)
|
||||
assert_equal 1, entry.issue_id
|
||||
assert_equal 2, entry.user_id
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
post :edit, :id => 1,
|
||||
:time_entry => {:issue_id => '2',
|
||||
:hours => '8'}
|
||||
assert_redirected_to 'projects/ecookbook/timelog/details'
|
||||
entry.reload
|
||||
|
||||
assert_equal 8, entry.hours
|
||||
assert_equal 2, entry.issue_id
|
||||
assert_equal 2, entry.user_id
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :id => 1
|
||||
assert_redirected_to 'projects/ecookbook/timelog/details'
|
||||
assert_nil TimeEntry.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_report_no_criteria
|
||||
get :report, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
end
|
||||
|
||||
def test_report_all_projects
|
||||
get :report
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
end
|
||||
|
||||
def test_report_all_projects_denied
|
||||
r = Role.anonymous
|
||||
r.permissions.delete(:view_time_entries)
|
||||
r.permissions_will_change!
|
||||
r.save
|
||||
get :report
|
||||
assert_redirected_to '/account/login'
|
||||
end
|
||||
|
||||
def test_report_all_projects_one_criteria
|
||||
get :report, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criterias => ['project']
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "8.65", "%.2f" % assigns(:total_hours)
|
||||
end
|
||||
|
||||
def test_report_all_time
|
||||
get :report, :project_id => 1, :criterias => ['project', 'issue']
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "162.90", "%.2f" % assigns(:total_hours)
|
||||
end
|
||||
|
||||
def test_report_all_time_by_day
|
||||
get :report, :project_id => 1, :criterias => ['project', 'issue'], :columns => 'day'
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "162.90", "%.2f" % assigns(:total_hours)
|
||||
assert_tag :tag => 'th', :content => '2007-03-12'
|
||||
end
|
||||
|
||||
def test_report_one_criteria
|
||||
get :report, :project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criterias => ['project']
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "8.65", "%.2f" % assigns(:total_hours)
|
||||
end
|
||||
|
||||
def test_report_two_criterias
|
||||
get :report, :project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criterias => ["member", "activity"]
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "162.90", "%.2f" % assigns(:total_hours)
|
||||
end
|
||||
|
||||
def test_report_custom_field_criteria
|
||||
get :report, :project_id => 1, :criterias => ['project', 'cf_1']
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_not_nil assigns(:criterias)
|
||||
assert_equal 2, assigns(:criterias).size
|
||||
assert_equal "162.90", "%.2f" % assigns(:total_hours)
|
||||
# Custom field column
|
||||
assert_tag :tag => 'th', :content => 'Database'
|
||||
# Custom field row
|
||||
assert_tag :tag => 'td', :content => 'MySQL',
|
||||
:sibling => { :tag => 'td', :attributes => { :class => 'hours' },
|
||||
:child => { :tag => 'span', :attributes => { :class => 'hours hours-int' },
|
||||
:content => '1' }}
|
||||
end
|
||||
|
||||
def test_report_one_criteria_no_result
|
||||
get :report, :project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criterias => ['project']
|
||||
assert_response :success
|
||||
assert_template 'report'
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "0.00", "%.2f" % assigns(:total_hours)
|
||||
end
|
||||
|
||||
def test_report_all_projects_csv_export
|
||||
get :report, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30", :criterias => ["project", "member", "activity"], :format => "csv"
|
||||
assert_response :success
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
# Headers
|
||||
assert_equal 'Project,Member,Activity,2007-1,2007-2,2007-3,2007-4,2007-5,2007-6,Total', lines.first
|
||||
# Total row
|
||||
assert_equal 'Total,"","","","",154.25,8.65,"","",162.90', lines.last
|
||||
end
|
||||
|
||||
def test_report_csv_export
|
||||
get :report, :project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30", :criterias => ["project", "member", "activity"], :format => "csv"
|
||||
assert_response :success
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
lines = @response.body.chomp.split("\n")
|
||||
# Headers
|
||||
assert_equal 'Project,Member,Activity,2007-1,2007-2,2007-3,2007-4,2007-5,2007-6,Total', lines.first
|
||||
# Total row
|
||||
assert_equal 'Total,"","","","",154.25,8.65,"","",162.90', lines.last
|
||||
end
|
||||
|
||||
def test_details_all_projects
|
||||
get :details
|
||||
assert_response :success
|
||||
assert_template 'details'
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "162.90", "%.2f" % assigns(:total_hours)
|
||||
end
|
||||
|
||||
def test_details_at_project_level
|
||||
get :details, :project_id => 1
|
||||
assert_response :success
|
||||
assert_template 'details'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal 4, assigns(:entries).size
|
||||
# project and subproject
|
||||
assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "162.90", "%.2f" % assigns(:total_hours)
|
||||
# display all time by default
|
||||
assert_equal '2007-03-11'.to_date, assigns(:from)
|
||||
assert_equal '2007-04-22'.to_date, assigns(:to)
|
||||
end
|
||||
|
||||
def test_details_at_project_level_with_date_range
|
||||
get :details, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30'
|
||||
assert_response :success
|
||||
assert_template 'details'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal 3, assigns(:entries).size
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal "12.90", "%.2f" % assigns(:total_hours)
|
||||
assert_equal '2007-03-20'.to_date, assigns(:from)
|
||||
assert_equal '2007-04-30'.to_date, assigns(:to)
|
||||
end
|
||||
|
||||
def test_details_at_project_level_with_period
|
||||
get :details, :project_id => 1, :period => '7_days'
|
||||
assert_response :success
|
||||
assert_template 'details'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal Date.today - 7, assigns(:from)
|
||||
assert_equal Date.today, assigns(:to)
|
||||
end
|
||||
|
||||
def test_details_at_issue_level
|
||||
get :details, :issue_id => 1
|
||||
assert_response :success
|
||||
assert_template 'details'
|
||||
assert_not_nil assigns(:entries)
|
||||
assert_equal 2, assigns(:entries).size
|
||||
assert_not_nil assigns(:total_hours)
|
||||
assert_equal 154.25, assigns(:total_hours)
|
||||
# display all time by default
|
||||
assert_equal '2007-03-11'.to_date, assigns(:from)
|
||||
assert_equal '2007-04-22'.to_date, assigns(:to)
|
||||
end
|
||||
|
||||
def test_details_atom_feed
|
||||
get :details, :project_id => 1, :format => 'atom'
|
||||
assert_response :success
|
||||
assert_equal 'application/atom+xml', @response.content_type
|
||||
assert_not_nil assigns(:items)
|
||||
assert assigns(:items).first.is_a?(TimeEntry)
|
||||
end
|
||||
|
||||
def test_details_all_projects_csv_export
|
||||
get :details, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
|
||||
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
|
||||
end
|
||||
|
||||
def test_details_csv_export
|
||||
get :details, :project_id => 1, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
|
||||
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
|
||||
end
|
||||
end
|
||||
72
nested_projects/test/functional/users_controller_test.rb
Normal file
72
nested_projects/test/functional/users_controller_test.rb
Normal file
@@ -0,0 +1,72 @@
|
||||
# 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 'users_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class UsersController; def rescue_action(e) raise e end; end
|
||||
|
||||
class UsersControllerTest < Test::Unit::TestCase
|
||||
fixtures :users, :projects, :members
|
||||
|
||||
def setup
|
||||
@controller = UsersController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
@request.session[:user_id] = 1 # admin
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'list'
|
||||
end
|
||||
|
||||
def test_list
|
||||
get :list
|
||||
assert_response :success
|
||||
assert_template 'list'
|
||||
assert_not_nil assigns(:users)
|
||||
# active users only
|
||||
assert_nil assigns(:users).detect {|u| !u.active?}
|
||||
end
|
||||
|
||||
def test_list_with_name_filter
|
||||
get :list, :name => 'john'
|
||||
assert_response :success
|
||||
assert_template 'list'
|
||||
users = assigns(:users)
|
||||
assert_not_nil users
|
||||
assert_equal 1, users.size
|
||||
assert_equal 'John', users.first.firstname
|
||||
end
|
||||
|
||||
def test_edit_membership
|
||||
post :edit_membership, :id => 2, :membership_id => 1,
|
||||
:membership => { :role_id => 2}
|
||||
assert_redirected_to 'users/edit/2'
|
||||
assert_equal 2, Member.find(1).role_id
|
||||
end
|
||||
|
||||
def test_destroy_membership
|
||||
post :destroy_membership, :id => 2, :membership_id => 1
|
||||
assert_redirected_to 'users/edit/2'
|
||||
assert_nil Member.find_by_id(1)
|
||||
end
|
||||
end
|
||||
73
nested_projects/test/functional/versions_controller_test.rb
Normal file
73
nested_projects/test/functional/versions_controller_test.rb
Normal file
@@ -0,0 +1,73 @@
|
||||
# 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 'versions_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class VersionsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class VersionsControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :versions, :issues, :users, :roles, :members, :enabled_modules
|
||||
|
||||
def setup
|
||||
@controller = VersionsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_show
|
||||
get :show, :id => 2
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:version)
|
||||
|
||||
assert_tag :tag => 'h2', :content => /1.0/
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 2
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :id => 2,
|
||||
:version => { :name => 'New version name',
|
||||
:effective_date => Date.today.strftime("%Y-%m-%d")}
|
||||
assert_redirected_to 'projects/settings/ecookbook'
|
||||
version = Version.find(2)
|
||||
assert_equal 'New version name', version.name
|
||||
assert_equal Date.today, version.effective_date
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :id => 3
|
||||
assert_redirected_to 'projects/settings/ecookbook'
|
||||
assert_nil Version.find_by_id(3)
|
||||
end
|
||||
|
||||
def test_issue_status_by
|
||||
xhr :get, :status_by, :id => 2
|
||||
assert_response :success
|
||||
assert_template '_issue_counts'
|
||||
end
|
||||
end
|
||||
70
nested_projects/test/functional/watchers_controller_test.rb
Normal file
70
nested_projects/test/functional/watchers_controller_test.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2008 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 'watchers_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class WatchersController; def rescue_action(e) raise e end; end
|
||||
|
||||
class WatchersControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :enabled_modules,
|
||||
:issues, :trackers, :projects_trackers, :issue_statuses, :enumerations, :watchers
|
||||
|
||||
def setup
|
||||
@controller = WatchersController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_get_watch_should_be_invalid
|
||||
@request.session[:user_id] = 3
|
||||
get :watch, :object_type => 'issue', :object_id => '1'
|
||||
assert_response 405
|
||||
end
|
||||
|
||||
def test_watch
|
||||
@request.session[:user_id] = 3
|
||||
assert_difference('Watcher.count') do
|
||||
xhr :post, :watch, :object_type => 'issue', :object_id => '1'
|
||||
assert_response :success
|
||||
assert_select_rjs :replace_html, 'watcher'
|
||||
end
|
||||
assert Issue.find(1).watched_by?(User.find(3))
|
||||
end
|
||||
|
||||
def test_unwatch
|
||||
@request.session[:user_id] = 3
|
||||
assert_difference('Watcher.count', -1) do
|
||||
xhr :post, :unwatch, :object_type => 'issue', :object_id => '2'
|
||||
assert_response :success
|
||||
assert_select_rjs :replace_html, 'watcher'
|
||||
end
|
||||
assert !Issue.find(1).watched_by?(User.find(3))
|
||||
end
|
||||
|
||||
def test_new_watcher
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference('Watcher.count') do
|
||||
xhr :post, :new, :object_type => 'issue', :object_id => '2', :watcher => {:user_id => '4'}
|
||||
assert_response :success
|
||||
assert_select_rjs :replace_html, 'watchers'
|
||||
end
|
||||
assert Issue.find(2).watched_by?(User.find(4))
|
||||
end
|
||||
end
|
||||
63
nested_projects/test/functional/welcome_controller_test.rb
Normal file
63
nested_projects/test/functional/welcome_controller_test.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
# 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 'welcome_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class WelcomeController; def rescue_action(e) raise e end; end
|
||||
|
||||
class WelcomeControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :news
|
||||
|
||||
def setup
|
||||
@controller = WelcomeController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
assert_not_nil assigns(:news)
|
||||
assert_not_nil assigns(:projects)
|
||||
assert !assigns(:projects).include?(Project.find(:first, :conditions => {:is_public => false}))
|
||||
end
|
||||
|
||||
def test_browser_language
|
||||
Setting.default_language = 'en'
|
||||
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
|
||||
get :index
|
||||
assert_equal :fr, @controller.current_language
|
||||
end
|
||||
|
||||
def test_browser_language_alternate
|
||||
Setting.default_language = 'en'
|
||||
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'zh-TW'
|
||||
get :index
|
||||
assert_equal :"zh-tw", @controller.current_language
|
||||
end
|
||||
|
||||
def test_browser_language_alternate_not_valid
|
||||
Setting.default_language = 'en'
|
||||
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr-CA'
|
||||
get :index
|
||||
assert_equal :fr, @controller.current_language
|
||||
end
|
||||
end
|
||||
259
nested_projects/test/functional/wiki_controller_test.rb
Normal file
259
nested_projects/test/functional/wiki_controller_test.rb
Normal file
@@ -0,0 +1,259 @@
|
||||
# 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 'wiki_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class WikiController; def rescue_action(e) raise e end; end
|
||||
|
||||
class WikiControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments
|
||||
|
||||
def setup
|
||||
@controller = WikiController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_show_start_page
|
||||
get :index, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_tag :tag => 'h1', :content => /CookBook documentation/
|
||||
|
||||
# child_pages macro
|
||||
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
||||
:child => { :tag => 'li',
|
||||
:child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
|
||||
:content => 'Page with an inline image' } }
|
||||
end
|
||||
|
||||
def test_show_page_with_name
|
||||
get :index, :id => 1, :page => 'Another_page'
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_tag :tag => 'h1', :content => /Another page/
|
||||
# Included page with an inline image
|
||||
assert_tag :tag => 'p', :content => /This is an inline image/
|
||||
assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
|
||||
:alt => 'This is a logo' }
|
||||
end
|
||||
|
||||
def test_show_unexistent_page_without_edit_right
|
||||
get :index, :id => 1, :page => 'Unexistent page'
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_show_unexistent_page_with_edit_right
|
||||
@request.session[:user_id] = 2
|
||||
get :index, :id => 1, :page => 'Unexistent page'
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
end
|
||||
|
||||
def test_create_page
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :id => 1,
|
||||
:page => 'New page',
|
||||
:content => {:comments => 'Created the page',
|
||||
:text => "h1. New page\n\nThis is a new page",
|
||||
:version => 0}
|
||||
assert_redirected_to 'wiki/ecookbook/New_page'
|
||||
page = Project.find(1).wiki.find_page('New page')
|
||||
assert !page.new_record?
|
||||
assert_not_nil page.content
|
||||
assert_equal 'Created the page', page.content.comments
|
||||
end
|
||||
|
||||
def test_preview
|
||||
@request.session[:user_id] = 2
|
||||
xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
|
||||
:content => { :comments => '',
|
||||
:text => 'this is a *previewed text*',
|
||||
:version => 3 }
|
||||
assert_response :success
|
||||
assert_template 'common/_preview'
|
||||
assert_tag :tag => 'strong', :content => /previewed text/
|
||||
end
|
||||
|
||||
def test_preview_new_page
|
||||
@request.session[:user_id] = 2
|
||||
xhr :post, :preview, :id => 1, :page => 'New page',
|
||||
:content => { :text => 'h1. New page',
|
||||
:comments => '',
|
||||
:version => 0 }
|
||||
assert_response :success
|
||||
assert_template 'common/_preview'
|
||||
assert_tag :tag => 'h1', :content => /New page/
|
||||
end
|
||||
|
||||
def test_history
|
||||
get :history, :id => 1, :page => 'CookBook_documentation'
|
||||
assert_response :success
|
||||
assert_template 'history'
|
||||
assert_not_nil assigns(:versions)
|
||||
assert_equal 3, assigns(:versions).size
|
||||
assert_select "input[type=submit][name=commit]"
|
||||
end
|
||||
|
||||
def test_history_with_one_version
|
||||
get :history, :id => 1, :page => 'Another_page'
|
||||
assert_response :success
|
||||
assert_template 'history'
|
||||
assert_not_nil assigns(:versions)
|
||||
assert_equal 1, assigns(:versions).size
|
||||
assert_select "input[type=submit][name=commit]", false
|
||||
end
|
||||
|
||||
def test_diff
|
||||
get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
|
||||
assert_response :success
|
||||
assert_template 'diff'
|
||||
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
|
||||
:content => /updated/
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2
|
||||
assert_response :success
|
||||
assert_template 'annotate'
|
||||
# Line 1
|
||||
assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1' },
|
||||
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/ },
|
||||
:child => { :tag => 'td', :content => /h1\. CookBook documentation/ }
|
||||
# Line 2
|
||||
assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '2' },
|
||||
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
|
||||
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
|
||||
end
|
||||
|
||||
def test_rename_with_redirect
|
||||
@request.session[:user_id] = 2
|
||||
post :rename, :id => 1, :page => 'Another_page',
|
||||
:wiki_page => { :title => 'Another renamed page',
|
||||
:redirect_existing_links => 1 }
|
||||
assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
|
||||
wiki = Project.find(1).wiki
|
||||
# Check redirects
|
||||
assert_not_nil wiki.find_page('Another page')
|
||||
assert_nil wiki.find_page('Another page', :with_redirect => false)
|
||||
end
|
||||
|
||||
def test_rename_without_redirect
|
||||
@request.session[:user_id] = 2
|
||||
post :rename, :id => 1, :page => 'Another_page',
|
||||
:wiki_page => { :title => 'Another renamed page',
|
||||
:redirect_existing_links => "0" }
|
||||
assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
|
||||
wiki = Project.find(1).wiki
|
||||
# Check that there's no redirects
|
||||
assert_nil wiki.find_page('Another page')
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :id => 1, :page => 'CookBook_documentation'
|
||||
assert_redirected_to 'wiki/ecookbook/Page_index/special'
|
||||
end
|
||||
|
||||
def test_page_index
|
||||
get :special, :id => 'ecookbook', :page => 'Page_index'
|
||||
assert_response :success
|
||||
assert_template 'special_page_index'
|
||||
pages = assigns(:pages)
|
||||
assert_not_nil pages
|
||||
assert_equal Project.find(1).wiki.pages.size, pages.size
|
||||
|
||||
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
|
||||
:content => 'CookBook documentation' },
|
||||
:child => { :tag => 'ul',
|
||||
:child => { :tag => 'li',
|
||||
:child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
|
||||
:content => 'Page with an inline image' } } } },
|
||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Another_page' },
|
||||
:content => 'Another page' } }
|
||||
end
|
||||
|
||||
def test_not_found
|
||||
get :index, :id => 999
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_protect_page
|
||||
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
|
||||
assert !page.protected?
|
||||
@request.session[:user_id] = 2
|
||||
post :protect, :id => 1, :page => page.title, :protected => '1'
|
||||
assert_redirected_to 'wiki/ecookbook/Another_page'
|
||||
assert page.reload.protected?
|
||||
end
|
||||
|
||||
def test_unprotect_page
|
||||
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
|
||||
assert page.protected?
|
||||
@request.session[:user_id] = 2
|
||||
post :protect, :id => 1, :page => page.title, :protected => '0'
|
||||
assert_redirected_to 'wiki/ecookbook'
|
||||
assert !page.reload.protected?
|
||||
end
|
||||
|
||||
def test_show_page_with_edit_link
|
||||
@request.session[:user_id] = 2
|
||||
get :index, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
|
||||
end
|
||||
|
||||
def test_show_page_without_edit_link
|
||||
@request.session[:user_id] = 4
|
||||
get :index, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_no_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
|
||||
end
|
||||
|
||||
def test_edit_unprotected_page
|
||||
# Non members can edit unprotected wiki pages
|
||||
@request.session[:user_id] = 4
|
||||
get :edit, :id => 1, :page => 'Another_page'
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
end
|
||||
|
||||
def test_edit_protected_page_by_nonmember
|
||||
# Non members can't edit protected wiki pages
|
||||
@request.session[:user_id] = 4
|
||||
get :edit, :id => 1, :page => 'CookBook_documentation'
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_edit_protected_page_by_member
|
||||
@request.session[:user_id] = 2
|
||||
get :edit, :id => 1, :page => 'CookBook_documentation'
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
end
|
||||
|
||||
def test_history_of_non_existing_page_should_return_404
|
||||
get :history, :id => 1, :page => 'Unknown_page'
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
56
nested_projects/test/functional/wikis_controller_test.rb
Normal file
56
nested_projects/test/functional/wikis_controller_test.rb
Normal file
@@ -0,0 +1,56 @@
|
||||
# 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 'wikis_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class WikisController; def rescue_action(e) raise e end; end
|
||||
|
||||
class WikisControllerTest < Test::Unit::TestCase
|
||||
fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis
|
||||
|
||||
def setup
|
||||
@controller = WikisController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create
|
||||
@request.session[:user_id] = 1
|
||||
assert_nil Project.find(3).wiki
|
||||
post :edit, :id => 3, :wiki => { :start_page => 'Start page' }
|
||||
assert_response :success
|
||||
wiki = Project.find(3).wiki
|
||||
assert_not_nil wiki
|
||||
assert_equal 'Start page', wiki.start_page
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 1
|
||||
post :destroy, :id => 1, :confirm => 1
|
||||
assert_redirected_to 'projects/settings/ecookbook'
|
||||
assert_nil Project.find(1).wiki
|
||||
end
|
||||
|
||||
def test_not_found
|
||||
@request.session[:user_id] = 1
|
||||
post :destroy, :id => 999, :confirm => 1
|
||||
assert_response 404
|
||||
end
|
||||
end
|
||||
84
nested_projects/test/functional/workflows_controller_test.rb
Normal file
84
nested_projects/test/functional/workflows_controller_test.rb
Normal file
@@ -0,0 +1,84 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2008 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 'workflows_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class WorkflowsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class WorkflowsControllerTest < Test::Unit::TestCase
|
||||
fixtures :roles, :trackers, :workflows
|
||||
|
||||
def setup
|
||||
@controller = WorkflowsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
User.current = nil
|
||||
@request.session[:user_id] = 1 # admin
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_template 'index'
|
||||
|
||||
count = Workflow.count(:all, :conditions => 'role_id = 1 AND tracker_id = 2')
|
||||
assert_tag :tag => 'a', :content => count.to_s,
|
||||
:attributes => { :href => '/workflows/edit?role_id=1&tracker_id=2' }
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
get :edit
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
assert_not_nil assigns(:roles)
|
||||
assert_not_nil assigns(:trackers)
|
||||
end
|
||||
|
||||
def test_get_edit_with_role_and_tracker
|
||||
get :edit, :role_id => 2, :tracker_id => 1
|
||||
assert_response :success
|
||||
assert_template 'edit'
|
||||
# allowed transitions
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'issue_status[2][]',
|
||||
:value => '1',
|
||||
:checked => 'checked' }
|
||||
# not allowed
|
||||
assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
|
||||
:name => 'issue_status[2][]',
|
||||
:value => '3',
|
||||
:checked => nil }
|
||||
end
|
||||
|
||||
def test_post_edit
|
||||
post :edit, :role_id => 2, :tracker_id => 1, :issue_status => {'4' => ['5'], '3' => ['1', '2']}
|
||||
assert_redirected_to 'workflows/edit'
|
||||
|
||||
assert_equal 3, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
assert_not_nil Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2})
|
||||
assert_nil Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4})
|
||||
end
|
||||
|
||||
def test_clear_workflow
|
||||
assert Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2}) > 0
|
||||
|
||||
post :edit, :role_id => 2, :tracker_id => 1
|
||||
assert_equal 0, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2})
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user