comparison test/functional/my_controller_test.rb @ 1526:404aa68d4227

Merge from live branch
author Chris Cannam
date Thu, 11 Sep 2014 12:46:20 +0100
parents dffacf8a6908
children
comparison
equal deleted inserted replaced
1493:a5f2bdf3b486 1526:404aa68d4227
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2014 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.
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__)
19 require 'my_controller'
20
21 # Re-raise errors caught by the controller.
22 class MyController; def rescue_action(e) raise e end; end
23 19
24 class MyControllerTest < ActionController::TestCase 20 class MyControllerTest < ActionController::TestCase
25 fixtures :users, :user_preferences, :roles, :projects, :members, :member_roles, 21 fixtures :users, :user_preferences, :roles, :projects, :members, :member_roles,
26 :issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources 22 :issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources
27 23
28 def setup 24 def setup
29 @controller = MyController.new
30 @request = ActionController::TestRequest.new
31 @request.session[:user_id] = 2 25 @request.session[:user_id] = 2
32 @response = ActionController::TestResponse.new
33 end 26 end
34 27
35 def test_index 28 def test_index
36 get :index 29 get :index
37 assert_response :success 30 assert_response :success
56 assert_select 'td.subject a[href=/issues/1]' 49 assert_select 'td.subject a[href=/issues/1]'
57 assert_select 'td.hours', :text => '2.50' 50 assert_select 'td.hours', :text => '2.50'
58 end 51 end
59 end 52 end
60 53
54 def test_page_with_all_blocks
55 blocks = MyController::BLOCKS.keys
56 preferences = User.find(2).pref
57 preferences[:my_page_layout] = {'top' => blocks}
58 preferences.save!
59
60 get :page
61 assert_response :success
62 assert_select 'div.mypage-box', blocks.size
63 end
64
61 def test_my_account_should_show_editable_custom_fields 65 def test_my_account_should_show_editable_custom_fields
62 get :account 66 get :account
63 assert_response :success 67 assert_response :success
64 assert_template 'account' 68 assert_template 'account'
65 assert_equal User.find(2), assigns(:user) 69 assert_equal User.find(2), assigns(:user)
74 assert_response :success 78 assert_response :success
75 assert_template 'account' 79 assert_template 'account'
76 assert_equal User.find(2), assigns(:user) 80 assert_equal User.find(2), assigns(:user)
77 81
78 assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} 82 assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'}
83 end
84
85 def test_my_account_should_show_language_select
86 get :account
87 assert_response :success
88 assert_select 'select[name=?]', 'user[language]'
89 end
90
91 def test_my_account_should_not_show_language_select_with_force_default_language_for_loggedin
92 with_settings :force_default_language_for_loggedin => '1' do
93 get :account
94 assert_response :success
95 assert_select 'select[name=?]', 'user[language]', 0
96 end
79 end 97 end
80 98
81 def test_update_account 99 def test_update_account
82 post :account, 100 post :account,
83 :user => { 101 :user => {