diff test/functional/admin_controller_test.rb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42 261b3d9a4903
line wrap: on
line diff
--- a/test/functional/admin_controller_test.rb	Wed Jun 27 14:54:18 2012 +0100
+++ b/test/functional/admin_controller_test.rb	Mon Jan 07 12:01:42 2013 +0000
@@ -1,5 +1,5 @@
 # Redmine - project management software
-# Copyright (C) 2006-2011  Jean-Philippe Lang
+# Copyright (C) 2006-2012  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -16,18 +16,11 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require File.expand_path('../../test_helper', __FILE__)
-require 'admin_controller'
-
-# Re-raise errors caught by the controller.
-class AdminController; def rescue_action(e) raise e end; end
 
 class AdminControllerTest < ActionController::TestCase
   fixtures :projects, :users, :roles
 
   def setup
-    @controller = AdminController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
     User.current = nil
     @request.session[:user_id] = 1 # admin
   end
@@ -54,6 +47,15 @@
     assert_nil assigns(:projects).detect {|u| !u.active?}
   end
 
+  def test_projects_with_status_filter
+    get :projects, :status => 1
+    assert_response :success
+    assert_template 'projects'
+    assert_not_nil assigns(:projects)
+    # active projects only
+    assert_nil assigns(:projects).detect {|u| !u.active?}
+  end
+
   def test_projects_with_name_filter
     get :projects, :name => 'store', :status => ''
     assert_response :success
@@ -72,15 +74,36 @@
     assert IssueStatus.find_by_name('Nouveau')
   end
 
+  def test_load_default_configuration_data_should_rescue_error
+    delete_configuration_data
+    Redmine::DefaultData::Loader.stubs(:load).raises(Exception.new("Something went wrong"))
+    post :default_configuration, :lang => 'fr'
+    assert_response :redirect
+    assert_not_nil flash[:error]
+    assert_match /Something went wrong/, flash[:error]
+  end
+
   def test_test_email
+    user = User.find(1)
+    user.pref[:no_self_notified] = '1'
+    user.pref.save!
+    ActionMailer::Base.deliveries.clear
+
     get :test_email
     assert_redirected_to '/settings/edit?tab=notifications'
     mail = ActionMailer::Base.deliveries.last
-    assert_kind_of TMail::Mail, mail
+    assert_not_nil mail
     user = User.find(1)
     assert_equal [user.mail], mail.bcc
   end
 
+  def test_test_email_failure_should_display_the_error
+    Mailer.stubs(:test_email).raises(Exception, 'Some error message')
+    get :test_email
+    assert_redirected_to '/settings/edit?tab=notifications'
+    assert_match /Some error message/, flash[:error]
+  end
+
   def test_no_plugins
     Redmine::Plugin.clear