git-svn-id: http://redmine.rubyforge.org/svn/trunk@987 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/0.6.2
@@ -48,7 +48,7 @@ class AdminController < ApplicationController | |||
def mail_options | |||
@notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted) | |||
if request.post? | |||
settings = (params[:settings] || {}).dup | |||
settings = (params[:settings] || {}).dup.symbolize_keys | |||
settings[:notified_events] ||= [] | |||
settings.each { |name, value| Setting[name] = value } | |||
flash[:notice] = l(:notice_successful_update) |
@@ -8,6 +8,10 @@ Subversion | |||
svnadmin create tmp/test/subversion_repository | |||
gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load tmp/test/subversion_repository | |||
CVS | |||
--- | |||
gunzip < test/fixtures/repositories/cvs_repository.tar.gz | tar -xv -C tmp/test | |||
Bazaar | |||
------ | |||
gunzip < test/fixtures/repositories/bazaar_repository.tar.gz | tar -xv -C tmp/test |
@@ -76,6 +76,8 @@ roles_001: | |||
- :edit_wiki_pages | |||
- :delete_wiki_pages | |||
- :add_messages | |||
- :edit_messages | |||
- :delete_messages | |||
- :manage_boards | |||
- :view_files | |||
- :manage_files |
@@ -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 '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_with_wrong_password | |||
post :login, :login => '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, :login => '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 |
@@ -0,0 +1,61 @@ | |||
# 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 | |||
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_get_mail_options | |||
get :mail_options | |||
assert_response :success | |||
assert_template 'mail_options' | |||
end | |||
def test_post_mail_options | |||
post :mail_options, :settings => {'mail_from' => 'functional@test.foo'} | |||
assert_redirected_to 'admin/mail_options' | |||
assert_equal 'functional@test.foo', Setting.mail_from | |||
end | |||
def test_test_email | |||
get :test_email | |||
assert_redirected_to 'admin/mail_options' | |||
mail = ActionMailer::Base.deliveries.last | |||
assert_kind_of TMail::Mail, mail | |||
user = User.find(1) | |||
assert_equal [user.mail], mail.bcc | |||
end | |||
def test_info | |||
get :info | |||
assert_response :success | |||
assert_template 'info' | |||
end | |||
end |
@@ -22,7 +22,17 @@ require 'issues_controller' | |||
class IssuesController; def rescue_action(e) raise e end; end | |||
class IssuesControllerTest < Test::Unit::TestCase | |||
fixtures :projects, :users, :roles, :members, :issues, :enabled_modules, :enumerations | |||
fixtures :projects, | |||
:users, | |||
:roles, | |||
:members, | |||
:issues, | |||
:issue_statuses, | |||
:trackers, | |||
:issue_categories, | |||
:enabled_modules, | |||
:enumerations, | |||
:attachments | |||
def setup | |||
@controller = IssuesController.new |
@@ -40,10 +40,60 @@ class MessagesControllerTest < Test::Unit::TestCase | |||
assert_not_nil assigns(:topic) | |||
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 | |||
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 | |||
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 | |||
end |
@@ -22,7 +22,7 @@ require 'my_controller' | |||
class MyController; def rescue_action(e) raise e end; end | |||
class MyControllerTest < Test::Unit::TestCase | |||
fixtures :users | |||
fixtures :users, :issues, :issue_statuses, :trackers, :enumerations | |||
def setup | |||
@controller = MyController.new |
@@ -21,7 +21,7 @@ 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 | |||
class RepositoriesSubversionControllerTest < Test::Unit::TestCase | |||
fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |||
# No '..' in the repository path for svn |
@@ -0,0 +1,62 @@ | |||
# 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_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 |
@@ -39,4 +39,35 @@ class VersionsControllerTest < Test::Unit::TestCase | |||
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/1' | |||
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 => 2 | |||
assert_redirected_to 'projects/settings/1' | |||
assert_nil Version.find_by_id(2) | |||
end | |||
def test_issue_status_by | |||
xhr :get, :status_by, :id => 2 | |||
assert_response :success | |||
assert_template '_issue_counts' | |||
end | |||
end |
@@ -0,0 +1,49 @@ | |||
# 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 | |||
end |
@@ -0,0 +1,60 @@ | |||
# 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 'pp' | |||
class RepositoryCvsTest < Test::Unit::TestCase | |||
fixtures :projects | |||
# No '..' in the repository path | |||
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository' | |||
REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/ | |||
# CVS module | |||
MODULE_NAME = 'test' | |||
def setup | |||
@project = Project.find(1) | |||
assert @repository = Repository::Cvs.create(:project => @project, | |||
:root_url => REPOSITORY_PATH, | |||
:url => MODULE_NAME) | |||
end | |||
if File.directory?(REPOSITORY_PATH) | |||
def test_fetch_changesets_from_scratch | |||
@repository.fetch_changesets | |||
@repository.reload | |||
assert_equal 5, @repository.changesets.count | |||
assert_equal 14, @repository.changes.count | |||
assert_equal 'Two files changed', @repository.changesets.find_by_revision(3).comments | |||
end | |||
def test_fetch_changesets_incremental | |||
@repository.fetch_changesets | |||
# Remove changesets with revision > 2 | |||
@repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy) | |||
@repository.reload | |||
assert_equal 2, @repository.changesets.count | |||
@repository.fetch_changesets | |||
assert_equal 5, @repository.changesets.count | |||
end | |||
else | |||
puts "CVS test repository NOT FOUND. Skipping unit tests !!!" | |||
def test_fake; assert true end | |||
end | |||
end |