@@ -1,59 +1,59 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'journals_controller' |
|
19 | require 'journals_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class JournalsController; def rescue_action(e) raise e end; end |
|
22 | class JournalsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 |
class JournalsControllerTest < |
|
24 | class JournalsControllerTest < Test::Unit::TestCase | |
25 | fixtures :projects, :users, :members, :roles, :issues, :journals, :journal_details, :enabled_modules |
|
25 | fixtures :projects, :users, :members, :roles, :issues, :journals, :journal_details, :enabled_modules | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = JournalsController.new |
|
28 | @controller = JournalsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_get_edit |
|
34 | def test_get_edit | |
35 | @request.session[:user_id] = 1 |
|
35 | @request.session[:user_id] = 1 | |
36 | xhr :get, :edit, :id => 2 |
|
36 | xhr :get, :edit, :id => 2 | |
37 | assert_response :success |
|
37 | assert_response :success | |
38 | assert_select_rjs :insert, :after, 'journal-2-notes' do |
|
38 | assert_select_rjs :insert, :after, 'journal-2-notes' do | |
39 | assert_select 'form[id=journal-2-form]' |
|
39 | assert_select 'form[id=journal-2-form]' | |
40 | assert_select 'textarea' |
|
40 | assert_select 'textarea' | |
41 | end |
|
41 | end | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | def test_post_edit |
|
44 | def test_post_edit | |
45 | @request.session[:user_id] = 1 |
|
45 | @request.session[:user_id] = 1 | |
46 | xhr :post, :edit, :id => 2, :notes => 'Updated notes' |
|
46 | xhr :post, :edit, :id => 2, :notes => 'Updated notes' | |
47 | assert_response :success |
|
47 | assert_response :success | |
48 | assert_select_rjs :replace, 'journal-2-notes' |
|
48 | assert_select_rjs :replace, 'journal-2-notes' | |
49 | assert_equal 'Updated notes', Journal.find(2).notes |
|
49 | assert_equal 'Updated notes', Journal.find(2).notes | |
50 | end |
|
50 | end | |
51 |
|
51 | |||
52 | def test_post_edit_with_empty_notes |
|
52 | def test_post_edit_with_empty_notes | |
53 | @request.session[:user_id] = 1 |
|
53 | @request.session[:user_id] = 1 | |
54 | xhr :post, :edit, :id => 2, :notes => '' |
|
54 | xhr :post, :edit, :id => 2, :notes => '' | |
55 | assert_response :success |
|
55 | assert_response :success | |
56 | assert_select_rjs :remove, 'change-2' |
|
56 | assert_select_rjs :remove, 'change-2' | |
57 | assert_nil Journal.find_by_id(2) |
|
57 | assert_nil Journal.find_by_id(2) | |
58 | end |
|
58 | end | |
59 | end |
|
59 | end |
General Comments 0
You need to be logged in to leave comments.
Login now