Revision 987
Added by Jean-Philippe Lang over 17 years ago
trunk/app/controllers/admin_controller.rb | ||
---|---|---|
48 | 48 |
def mail_options |
49 | 49 |
@notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted) |
50 | 50 |
if request.post? |
51 |
settings = (params[:settings] || {}).dup |
|
51 |
settings = (params[:settings] || {}).dup.symbolize_keys
|
|
52 | 52 |
settings[:notified_events] ||= [] |
53 | 53 |
settings.each { |name, value| Setting[name] = value } |
54 | 54 |
flash[:notice] = l(:notice_successful_update) |
trunk/doc/RUNNING_TESTS | ||
---|---|---|
8 | 8 |
svnadmin create tmp/test/subversion_repository |
9 | 9 |
gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load tmp/test/subversion_repository |
10 | 10 | |
11 |
CVS |
|
12 |
--- |
|
13 |
gunzip < test/fixtures/repositories/cvs_repository.tar.gz | tar -xv -C tmp/test |
|
14 | ||
11 | 15 |
Bazaar |
12 | 16 |
------ |
13 | 17 |
gunzip < test/fixtures/repositories/bazaar_repository.tar.gz | tar -xv -C tmp/test |
trunk/test/fixtures/roles.yml | ||
---|---|---|
76 | 76 |
- :edit_wiki_pages |
77 | 77 |
- :delete_wiki_pages |
78 | 78 |
- :add_messages |
79 |
- :edit_messages |
|
80 |
- :delete_messages |
|
79 | 81 |
- :manage_boards |
80 | 82 |
- :view_files |
81 | 83 |
- :manage_files |
trunk/test/functional/account_controller_test.rb | ||
---|---|---|
1 |
# redMine - project management software |
|
2 |
# Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 |
# |
|
4 |
# This program is free software; you can redistribute it and/or |
|
5 |
# modify it under the terms of the GNU General Public License |
|
6 |
# as published by the Free Software Foundation; either version 2 |
|
7 |
# of the License, or (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU General Public License |
|
15 |
# along with this program; if not, write to the Free Software |
|
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | ||
18 |
require File.dirname(__FILE__) + '/../test_helper' |
|
19 |
require 'account_controller' |
|
20 | ||
21 |
# Re-raise errors caught by the controller. |
|
22 |
class AccountController; def rescue_action(e) raise e end; end |
|
23 | ||
24 |
class AccountControllerTest < Test::Unit::TestCase |
|
25 |
fixtures :users |
|
26 |
|
|
27 |
def setup |
|
28 |
@controller = AccountController.new |
|
29 |
@request = ActionController::TestRequest.new |
|
30 |
@response = ActionController::TestResponse.new |
|
31 |
User.current = nil |
|
32 |
end |
|
33 |
|
|
34 |
def test_show |
|
35 |
get :show, :id => 2 |
|
36 |
assert_response :success |
|
37 |
assert_template 'show' |
|
38 |
assert_not_nil assigns(:user) |
|
39 |
end |
|
40 |
|
|
41 |
def test_show_inactive |
|
42 |
get :show, :id => 5 |
|
43 |
assert_response 404 |
|
44 |
assert_nil assigns(:user) |
|
45 |
end |
|
46 |
|
|
47 |
def test_login_with_wrong_password |
|
48 |
post :login, :login => 'admin', :password => 'bad' |
|
49 |
assert_response :success |
|
50 |
assert_template 'login' |
|
51 |
assert_tag 'div', |
|
52 |
:attributes => { :class => "flash error" }, |
|
53 |
:content => /Invalid user or password/ |
|
54 |
end |
|
55 |
|
|
56 |
def test_autologin |
|
57 |
Setting.autologin = "7" |
|
58 |
Token.delete_all |
|
59 |
post :login, :login => 'admin', :password => 'admin', :autologin => 1 |
|
60 |
assert_redirected_to 'my/page' |
|
61 |
token = Token.find :first |
|
62 |
assert_not_nil token |
|
63 |
assert_equal User.find_by_login('admin'), token.user |
|
64 |
assert_equal 'autologin', token.action |
|
65 |
end |
|
66 |
|
|
67 |
def test_logout |
|
68 |
@request.session[:user_id] = 2 |
|
69 |
get :logout |
|
70 |
assert_redirected_to '' |
|
71 |
assert_nil @request.session[:user_id] |
|
72 |
end |
|
73 |
end |
|
0 | 74 |
trunk/test/functional/admin_controller_test.rb | ||
---|---|---|
1 |
# redMine - project management software |
|
2 |
# Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 |
# |
|
4 |
# This program is free software; you can redistribute it and/or |
|
5 |
# modify it under the terms of the GNU General Public License |
|
6 |
# as published by the Free Software Foundation; either version 2 |
|
7 |
# of the License, or (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU General Public License |
|
15 |
# along with this program; if not, write to the Free Software |
|
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | ||
18 |
require File.dirname(__FILE__) + '/../test_helper' |
|
19 |
require 'admin_controller' |
|
20 | ||
21 |
# Re-raise errors caught by the controller. |
|
22 |
class AdminController; def rescue_action(e) raise e end; end |
|
23 | ||
24 |
class AdminControllerTest < Test::Unit::TestCase |
|
25 |
fixtures :projects, :users |
|
26 |
|
|
27 |
def setup |
|
28 |
@controller = AdminController.new |
|
29 |
@request = ActionController::TestRequest.new |
|
30 |
@response = ActionController::TestResponse.new |
|
31 |
User.current = nil |
|
32 |
@request.session[:user_id] = 1 # admin |
|
33 |
end |
|
34 |
|
|
35 |
def test_get_mail_options |
|
36 |
get :mail_options |
|
37 |
assert_response :success |
|
38 |
assert_template 'mail_options' |
|
39 |
end |
|
40 |
|
|
41 |
def test_post_mail_options |
|
42 |
post :mail_options, :settings => {'mail_from' => 'functional@test.foo'} |
|
43 |
assert_redirected_to 'admin/mail_options' |
|
44 |
assert_equal 'functional@test.foo', Setting.mail_from |
|
45 |
end |
|
46 |
|
|
47 |
def test_test_email |
|
48 |
get :test_email |
|
49 |
assert_redirected_to 'admin/mail_options' |
|
50 |
mail = ActionMailer::Base.deliveries.last |
|
51 |
assert_kind_of TMail::Mail, mail |
|
52 |
user = User.find(1) |
|
53 |
assert_equal [user.mail], mail.bcc |
|
54 |
end |
|
55 | ||
56 |
def test_info |
|
57 |
get :info |
|
58 |
assert_response :success |
|
59 |
assert_template 'info' |
|
60 |
end |
|
61 |
end |
|
0 | 62 |
trunk/test/functional/issues_controller_test.rb | ||
---|---|---|
22 | 22 |
class IssuesController; def rescue_action(e) raise e end; end |
23 | 23 | |
24 | 24 |
class IssuesControllerTest < Test::Unit::TestCase |
25 |
fixtures :projects, :users, :roles, :members, :issues, :enabled_modules, :enumerations |
|
25 |
fixtures :projects, |
|
26 |
:users, |
|
27 |
:roles, |
|
28 |
:members, |
|
29 |
:issues, |
|
30 |
:issue_statuses, |
|
31 |
:trackers, |
|
32 |
:issue_categories, |
|
33 |
:enabled_modules, |
|
34 |
:enumerations, |
|
35 |
:attachments |
|
26 | 36 |
|
27 | 37 |
def setup |
28 | 38 |
@controller = IssuesController.new |
trunk/test/functional/messages_controller_test.rb | ||
---|---|---|
40 | 40 |
assert_not_nil assigns(:topic) |
41 | 41 |
end |
42 | 42 |
|
43 |
def test_show_message_not_found |
|
44 |
get :show, :board_id => 1, :id => 99999 |
|
45 |
assert_response 404 |
|
46 |
end |
|
47 |
|
|
48 |
def test_get_new |
|
49 |
@request.session[:user_id] = 2 |
|
50 |
get :new, :board_id => 1 |
|
51 |
assert_response :success |
|
52 |
assert_template 'new' |
|
53 |
end |
|
54 |
|
|
55 |
def test_post_new |
|
56 |
@request.session[:user_id] = 2 |
|
57 |
post :new, :board_id => 1, |
|
58 |
:message => { :subject => 'Test created message', |
|
59 |
:content => 'Message body'} |
|
60 |
assert_redirected_to 'messages/show' |
|
61 |
message = Message.find_by_subject('Test created message') |
|
62 |
assert_not_nil message |
|
63 |
assert_equal 'Message body', message.content |
|
64 |
assert_equal 2, message.author_id |
|
65 |
assert_equal 1, message.board_id |
|
66 |
end |
|
67 |
|
|
68 |
def test_get_edit |
|
69 |
@request.session[:user_id] = 2 |
|
70 |
get :edit, :board_id => 1, :id => 1 |
|
71 |
assert_response :success |
|
72 |
assert_template 'edit' |
|
73 |
end |
|
74 |
|
|
75 |
def test_post_edit |
|
76 |
@request.session[:user_id] = 2 |
|
77 |
post :edit, :board_id => 1, :id => 1, |
|
78 |
:message => { :subject => 'New subject', |
|
79 |
:content => 'New body'} |
|
80 |
assert_redirected_to 'messages/show' |
|
81 |
message = Message.find(1) |
|
82 |
assert_equal 'New subject', message.subject |
|
83 |
assert_equal 'New body', message.content |
|
84 |
end |
|
85 |
|
|
43 | 86 |
def test_reply |
44 | 87 |
@request.session[:user_id] = 2 |
45 | 88 |
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } |
46 | 89 |
assert_redirected_to 'messages/show' |
47 | 90 |
assert Message.find_by_subject('Test reply') |
48 | 91 |
end |
92 |
|
|
93 |
def test_destroy_topic |
|
94 |
@request.session[:user_id] = 2 |
|
95 |
post :destroy, :board_id => 1, :id => 1 |
|
96 |
assert_redirected_to 'boards/show' |
|
97 |
assert_nil Message.find_by_id(1) |
|
98 |
end |
|
49 | 99 |
end |
trunk/test/functional/my_controller_test.rb | ||
---|---|---|
22 | 22 |
class MyController; def rescue_action(e) raise e end; end |
23 | 23 | |
24 | 24 |
class MyControllerTest < Test::Unit::TestCase |
25 |
fixtures :users |
|
25 |
fixtures :users, :issues, :issue_statuses, :trackers, :enumerations
|
|
26 | 26 |
|
27 | 27 |
def setup |
28 | 28 |
@controller = MyController.new |
trunk/test/functional/repositories_subversion_controller_test.rb | ||
---|---|---|
21 | 21 |
# Re-raise errors caught by the controller. |
22 | 22 |
class RepositoriesController; def rescue_action(e) raise e end; end |
23 | 23 | |
24 |
class RepositoriesControllerTest < Test::Unit::TestCase |
|
24 |
class RepositoriesSubversionControllerTest < Test::Unit::TestCase
|
|
25 | 25 |
fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers |
26 | 26 | |
27 | 27 |
# No '..' in the repository path for svn |
trunk/test/functional/users_controller_test.rb | ||
---|---|---|
1 |
# redMine - project management software |
|
2 |
# Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 |
# |
|
4 |
# This program is free software; you can redistribute it and/or |
|
5 |
# modify it under the terms of the GNU General Public License |
|
6 |
# as published by the Free Software Foundation; either version 2 |
|
7 |
# of the License, or (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU General Public License |
|
15 |
# along with this program; if not, write to the Free Software |
|
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | ||
18 |
require File.dirname(__FILE__) + '/../test_helper' |
|
19 |
require 'users_controller' |
|
20 | ||
21 |
# Re-raise errors caught by the controller. |
|
22 |
class UsersController; def rescue_action(e) raise e end; end |
|
23 | ||
24 |
class UsersControllerTest < Test::Unit::TestCase |
|
25 |
fixtures :users, :projects, :members |
|
26 |
|
|
27 |
def setup |
|
28 |
@controller = UsersController.new |
|
29 |
@request = ActionController::TestRequest.new |
|
30 |
@response = ActionController::TestResponse.new |
|
31 |
User.current = nil |
|
32 |
@request.session[:user_id] = 1 # admin |
|
33 |
end |
|
34 |
|
|
35 |
def test_index |
|
36 |
get :index |
|
37 |
assert_response :success |
|
38 |
assert_template 'list' |
|
39 |
end |
|
40 | ||
41 |
def test_list |
|
42 |
get :list |
|
43 |
assert_response :success |
|
44 |
assert_template 'list' |
|
45 |
assert_not_nil assigns(:users) |
|
46 |
# active users only |
|
47 |
assert_nil assigns(:users).detect {|u| !u.active?} |
|
48 |
end |
|
49 |
|
|
50 |
def test_edit_membership |
|
51 |
post :edit_membership, :id => 2, :membership_id => 1, |
|
52 |
:membership => { :role_id => 2} |
|
53 |
assert_redirected_to 'users/edit/2' |
|
54 |
assert_equal 2, Member.find(1).role_id |
|
55 |
end |
|
56 |
|
|
57 |
def test_destroy_membership |
|
58 |
post :destroy_membership, :id => 2, :membership_id => 1 |
|
59 |
assert_redirected_to 'users/edit/2' |
|
60 |
assert_nil Member.find_by_id(1) |
|
61 |
end |
|
62 |
end |
|
0 | 63 |
trunk/test/functional/versions_controller_test.rb | ||
---|---|---|
39 | 39 |
|
40 | 40 |
assert_tag :tag => 'h2', :content => /1.0/ |
41 | 41 |
end |
42 |
|
|
43 |
def test_get_edit |
|
44 |
@request.session[:user_id] = 2 |
|
45 |
get :edit, :id => 2 |
|
46 |
assert_response :success |
|
47 |
assert_template 'edit' |
|
48 |
end |
|
49 |
|
|
50 |
def test_post_edit |
|
51 |
@request.session[:user_id] = 2 |
|
52 |
post :edit, :id => 2, |
|
53 |
:version => { :name => 'New version name', |
|
54 |
:effective_date => Date.today.strftime("%Y-%m-%d")} |
|
55 |
assert_redirected_to 'projects/settings/1' |
|
56 |
version = Version.find(2) |
|
57 |
assert_equal 'New version name', version.name |
|
58 |
assert_equal Date.today, version.effective_date |
|
59 |
end |
|
60 | ||
61 |
def test_destroy |
|
62 |
@request.session[:user_id] = 2 |
|
63 |
post :destroy, :id => 2 |
|
64 |
assert_redirected_to 'projects/settings/1' |
|
65 |
assert_nil Version.find_by_id(2) |
|
66 |
end |
|
67 |
|
|
68 |
def test_issue_status_by |
|
69 |
xhr :get, :status_by, :id => 2 |
|
70 |
assert_response :success |
|
71 |
assert_template '_issue_counts' |
|
72 |
end |
|
42 | 73 |
end |
trunk/test/functional/welcome_controller_test.rb | ||
---|---|---|
1 |
# redMine - project management software |
|
2 |
# Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 |
# |
|
4 |
# This program is free software; you can redistribute it and/or |
|
5 |
# modify it under the terms of the GNU General Public License |
|
6 |
# as published by the Free Software Foundation; either version 2 |
|
7 |
# of the License, or (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU General Public License |
|
15 |
# along with this program; if not, write to the Free Software |
|
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | ||
18 |
require File.dirname(__FILE__) + '/../test_helper' |
|
19 |
require 'welcome_controller' |
|
20 | ||
21 |
# Re-raise errors caught by the controller. |
|
22 |
class WelcomeController; def rescue_action(e) raise e end; end |
|
23 | ||
24 |
class WelcomeControllerTest < Test::Unit::TestCase |
|
25 |
fixtures :projects, :news |
|
26 |
|
|
27 |
def setup |
|
28 |
@controller = WelcomeController.new |
|
29 |
@request = ActionController::TestRequest.new |
|
30 |
@response = ActionController::TestResponse.new |
|
31 |
User.current = nil |
|
32 |
end |
|
33 |
|
|
34 |
def test_index |
|
35 |
get :index |
|
36 |
assert_response :success |
|
37 |
assert_template 'index' |
|
38 |
assert_not_nil assigns(:news) |
|
39 |
assert_not_nil assigns(:projects) |
|
40 |
assert !assigns(:projects).include?(Project.find(:first, :conditions => {:is_public => false})) |
|
41 |
end |
|
42 |
|
|
43 |
def test_browser_language |
|
44 |
Setting.default_language = 'en' |
|
45 |
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' |
|
46 |
get :index |
|
47 |
assert_equal :fr, @controller.current_language |
|
48 |
end |
|
49 |
end |
|
0 | 50 |
trunk/test/unit/repository_cvs_test.rb | ||
---|---|---|
1 |
# redMine - project management software |
|
2 |
# Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 |
# |
|
4 |
# This program is free software; you can redistribute it and/or |
|
5 |
# modify it under the terms of the GNU General Public License |
|
6 |
# as published by the Free Software Foundation; either version 2 |
|
7 |
# of the License, or (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU General Public License |
|
15 |
# along with this program; if not, write to the Free Software |
|
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | ||
18 |
require File.dirname(__FILE__) + '/../test_helper' |
|
19 |
require 'pp' |
|
20 |
class RepositoryCvsTest < Test::Unit::TestCase |
|
21 |
fixtures :projects |
|
22 |
|
|
23 |
# No '..' in the repository path |
|
24 |
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository' |
|
25 |
REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/ |
|
26 |
# CVS module |
|
27 |
MODULE_NAME = 'test' |
|
28 |
|
|
29 |
def setup |
|
30 |
@project = Project.find(1) |
|
31 |
assert @repository = Repository::Cvs.create(:project => @project, |
|
32 |
:root_url => REPOSITORY_PATH, |
|
33 |
:url => MODULE_NAME) |
|
34 |
end |
|
35 |
|
|
36 |
if File.directory?(REPOSITORY_PATH) |
|
37 |
def test_fetch_changesets_from_scratch |
|
38 |
@repository.fetch_changesets |
|
39 |
@repository.reload |
|
40 |
|
|
41 |
assert_equal 5, @repository.changesets.count |
|
42 |
assert_equal 14, @repository.changes.count |
|
43 |
assert_equal 'Two files changed', @repository.changesets.find_by_revision(3).comments |
|
44 |
end |
|
45 |
|
|
46 |
def test_fetch_changesets_incremental |
|
47 |
@repository.fetch_changesets |
|
48 |
# Remove changesets with revision > 2 |
|
49 |
@repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy) |
|
50 |
@repository.reload |
|
51 |
assert_equal 2, @repository.changesets.count |
|
52 |
|
|
53 |
@repository.fetch_changesets |
|
54 |
assert_equal 5, @repository.changesets.count |
|
55 |
end |
|
56 |
else |
|
57 |
puts "CVS test repository NOT FOUND. Skipping unit tests !!!" |
|
58 |
def test_fake; assert true end |
|
59 |
end |
|
60 |
end |
|
0 | 61 |
Also available in: Unified diff
Added some functional tests and a CVS test repository.