comparison test/functional/journals_controller_test.rb @ 442:753f1380d6bc cannam

Merge from branch "redmine-1.2"
author Chris Cannam
date Mon, 06 Jun 2011 14:41:04 +0100
parents cbce1fd3b1b7
children 433d4f72a19b
comparison
equal deleted inserted replaced
252:adc8466df404 442:753f1380d6bc
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.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
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 < ActionController::TestCase 24 class JournalsControllerTest < ActionController::TestCase
25 fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :journal_details, :enabled_modules 25 fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :journal_details, :enabled_modules,
26 26 :trackers, :issue_statuses, :enumerations, :custom_fields, :custom_values, :custom_fields_projects
27
27 def setup 28 def setup
28 @controller = JournalsController.new 29 @controller = JournalsController.new
29 @request = ActionController::TestRequest.new 30 @request = ActionController::TestRequest.new
30 @response = ActionController::TestResponse.new 31 @response = ActionController::TestResponse.new
31 User.current = nil 32 User.current = nil
32 end 33 end
33 34
34 def test_index 35 def test_index
35 get :index, :project_id => 1 36 get :index, :project_id => 1
36 assert_response :success 37 assert_response :success
37 assert_not_nil assigns(:journals) 38 assert_not_nil assigns(:journals)
38 assert_equal 'application/atom+xml', @response.content_type 39 assert_equal 'application/atom+xml', @response.content_type
39 end 40 end
40 41
41 def test_diff 42 def test_diff
42 get :diff, :id => 3, :detail_id => 4 43 get :diff, :id => 3, :detail_id => 4
43 assert_response :success 44 assert_response :success
44 assert_template 'diff' 45 assert_template 'diff'
45 46
46 assert_tag 'span', 47 assert_tag 'span',
47 :attributes => {:class => 'diff_out'}, 48 :attributes => {:class => 'diff_out'},
48 :content => /removed/ 49 :content => /removed/
49 assert_tag 'span', 50 assert_tag 'span',
50 :attributes => {:class => 'diff_in'}, 51 :attributes => {:class => 'diff_in'},
51 :content => /added/ 52 :content => /added/
52 end 53 end
53 54
54 def test_reply_to_issue 55 def test_reply_to_issue
55 @request.session[:user_id] = 2 56 @request.session[:user_id] = 2
56 get :new, :id => 6 57 get :new, :id => 6
57 assert_response :success 58 assert_response :success
58 assert_select_rjs :show, "update" 59 assert_select_rjs :show, "update"
59 end 60 end
60 61
61 def test_reply_to_issue_without_permission 62 def test_reply_to_issue_without_permission
62 @request.session[:user_id] = 7 63 @request.session[:user_id] = 7
63 get :new, :id => 6 64 get :new, :id => 6
64 assert_response 403 65 assert_response 403
65 end 66 end
78 assert_select_rjs :insert, :after, 'journal-2-notes' do 79 assert_select_rjs :insert, :after, 'journal-2-notes' do
79 assert_select 'form[id=journal-2-form]' 80 assert_select 'form[id=journal-2-form]'
80 assert_select 'textarea' 81 assert_select 'textarea'
81 end 82 end
82 end 83 end
83 84
84 def test_post_edit 85 def test_post_edit
85 @request.session[:user_id] = 1 86 @request.session[:user_id] = 1
86 xhr :post, :edit, :id => 2, :notes => 'Updated notes' 87 xhr :post, :edit, :id => 2, :notes => 'Updated notes'
87 assert_response :success 88 assert_response :success
88 assert_select_rjs :replace, 'journal-2-notes' 89 assert_select_rjs :replace, 'journal-2-notes'
89 assert_equal 'Updated notes', Journal.find(2).notes 90 assert_equal 'Updated notes', Journal.find(2).notes
90 end 91 end
91 92
92 def test_post_edit_with_empty_notes 93 def test_post_edit_with_empty_notes
93 @request.session[:user_id] = 1 94 @request.session[:user_id] = 1
94 xhr :post, :edit, :id => 2, :notes => '' 95 xhr :post, :edit, :id => 2, :notes => ''
95 assert_response :success 96 assert_response :success
96 assert_select_rjs :remove, 'change-2' 97 assert_select_rjs :remove, 'change-2'