comparison test/functional/welcome_controller_test.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 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 'welcome_controller'
20
21 # Re-raise errors caught by the controller.
22 class WelcomeController; def rescue_action(e) raise e end; end
23 19
24 class WelcomeControllerTest < ActionController::TestCase 20 class WelcomeControllerTest < ActionController::TestCase
25 fixtures :projects, :news, :users, :members 21 fixtures :projects, :news, :users, :members
26 22
27 def setup 23 def setup
28 @controller = WelcomeController.new
29 @request = ActionController::TestRequest.new
30 @response = ActionController::TestResponse.new
31 User.current = nil 24 User.current = nil
32 end 25 end
33 26
34 def test_index 27 def test_index
35 get :index 28 get :index
36 assert_response :success 29 assert_response :success
37 assert_template 'index' 30 assert_template 'index'
38 assert_not_nil assigns(:news) 31 assert_not_nil assigns(:news)
39 assert_not_nil assigns(:projects) 32 assert_not_nil assigns(:projects)
40 assert !assigns(:projects).include?(Project.find(:first, :conditions => {:is_public => false})) 33 assert !assigns(:projects).include?(Project.where(:is_public => false).first)
41 end 34 end
42 35
43 def test_browser_language 36 def test_browser_language
44 Setting.default_language = 'en' 37 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' 38 @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
88 81
89 get :index 82 get :index
90 assert_no_tag 'script', 83 assert_no_tag 'script',
91 :attributes => {:type => "text/javascript"}, 84 :attributes => {:type => "text/javascript"},
92 :content => %r{warnLeavingUnsaved} 85 :content => %r{warnLeavingUnsaved}
86 end
87
88 def test_logout_link_should_post
89 @request.session[:user_id] = 2
90
91 get :index
92 assert_select 'a[href=/logout][data-method=post]', :text => 'Sign out'
93 end 93 end
94 94
95 def test_call_hook_mixed_in 95 def test_call_hook_mixed_in
96 assert @controller.respond_to?(:call_hook) 96 assert @controller.respond_to?(:call_hook)
97 end 97 end