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