annotate .svn/pristine/1f/1fb867d43b925bd44b6fa06a149ecabad4787c36.svn-base @ 1327:287f201c2802 redmine-2.2-integration

Add italic
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 19 Jun 2013 20:56:22 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@909 3 #
Chris@909 4 # This program is free software; you can redistribute it and/or
Chris@909 5 # modify it under the terms of the GNU General Public License
Chris@909 6 # as published by the Free Software Foundation; either version 2
Chris@909 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@909 9 # This program is distributed in the hope that it will be useful,
Chris@909 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@909 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@909 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@909 14 # You should have received a copy of the GNU General Public License
Chris@909 15 # along with this program; if not, write to the Free Software
Chris@909 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@909 17
Chris@909 18 require File.expand_path('../../test_helper', __FILE__)
Chris@909 19 require 'admin_controller'
Chris@909 20
Chris@909 21 # Re-raise errors caught by the controller.
Chris@909 22 class AdminController; def rescue_action(e) raise e end; end
Chris@909 23
Chris@909 24 class AdminControllerTest < ActionController::TestCase
Chris@909 25 fixtures :projects, :users, :roles
Chris@909 26
Chris@909 27 def setup
Chris@909 28 @controller = AdminController.new
Chris@909 29 @request = ActionController::TestRequest.new
Chris@909 30 @response = ActionController::TestResponse.new
Chris@909 31 User.current = nil
Chris@909 32 @request.session[:user_id] = 1 # admin
Chris@909 33 end
Chris@909 34
Chris@909 35 def test_index
Chris@909 36 get :index
Chris@909 37 assert_no_tag :tag => 'div',
Chris@909 38 :attributes => { :class => /nodata/ }
Chris@909 39 end
Chris@909 40
Chris@909 41 def test_index_with_no_configuration_data
Chris@909 42 delete_configuration_data
Chris@909 43 get :index
Chris@909 44 assert_tag :tag => 'div',
Chris@909 45 :attributes => { :class => /nodata/ }
Chris@909 46 end
Chris@909 47
Chris@909 48 def test_projects
Chris@909 49 get :projects
Chris@909 50 assert_response :success
Chris@909 51 assert_template 'projects'
Chris@909 52 assert_not_nil assigns(:projects)
Chris@909 53 # active projects only
Chris@909 54 assert_nil assigns(:projects).detect {|u| !u.active?}
Chris@909 55 end
Chris@909 56
Chris@909 57 def test_projects_with_name_filter
Chris@909 58 get :projects, :name => 'store', :status => ''
Chris@909 59 assert_response :success
Chris@909 60 assert_template 'projects'
Chris@909 61 projects = assigns(:projects)
Chris@909 62 assert_not_nil projects
Chris@909 63 assert_equal 1, projects.size
Chris@909 64 assert_equal 'OnlineStore', projects.first.name
Chris@909 65 end
Chris@909 66
Chris@909 67 def test_load_default_configuration_data
Chris@909 68 delete_configuration_data
Chris@909 69 post :default_configuration, :lang => 'fr'
Chris@909 70 assert_response :redirect
Chris@909 71 assert_nil flash[:error]
Chris@909 72 assert IssueStatus.find_by_name('Nouveau')
Chris@909 73 end
Chris@909 74
Chris@909 75 def test_test_email
Chris@909 76 get :test_email
Chris@909 77 assert_redirected_to '/settings/edit?tab=notifications'
Chris@909 78 mail = ActionMailer::Base.deliveries.last
Chris@909 79 assert_kind_of TMail::Mail, mail
Chris@909 80 user = User.find(1)
Chris@909 81 assert_equal [user.mail], mail.bcc
Chris@909 82 end
Chris@909 83
Chris@909 84 def test_no_plugins
Chris@909 85 Redmine::Plugin.clear
Chris@909 86
Chris@909 87 get :plugins
Chris@909 88 assert_response :success
Chris@909 89 assert_template 'plugins'
Chris@909 90 end
Chris@909 91
Chris@909 92 def test_plugins
Chris@909 93 # Register a few plugins
Chris@909 94 Redmine::Plugin.register :foo do
Chris@909 95 name 'Foo plugin'
Chris@909 96 author 'John Smith'
Chris@909 97 description 'This is a test plugin'
Chris@909 98 version '0.0.1'
Chris@909 99 settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings'
Chris@909 100 end
Chris@909 101 Redmine::Plugin.register :bar do
Chris@909 102 end
Chris@909 103
Chris@909 104 get :plugins
Chris@909 105 assert_response :success
Chris@909 106 assert_template 'plugins'
Chris@909 107
Chris@909 108 assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' }
Chris@909 109 assert_tag :td, :child => { :tag => 'span', :content => 'Bar' }
Chris@909 110 end
Chris@909 111
Chris@909 112 def test_info
Chris@909 113 get :info
Chris@909 114 assert_response :success
Chris@909 115 assert_template 'info'
Chris@909 116 end
Chris@909 117
Chris@909 118 def test_admin_menu_plugin_extension
Chris@909 119 Redmine::MenuManager.map :admin_menu do |menu|
Chris@909 120 menu.push :test_admin_menu_plugin_extension, '/foo/bar', :caption => 'Test'
Chris@909 121 end
Chris@909 122
Chris@909 123 get :index
Chris@909 124 assert_response :success
Chris@909 125 assert_tag :a, :attributes => { :href => '/foo/bar' },
Chris@909 126 :content => 'Test'
Chris@909 127
Chris@909 128 Redmine::MenuManager.map :admin_menu do |menu|
Chris@909 129 menu.delete :test_admin_menu_plugin_extension
Chris@909 130 end
Chris@909 131 end
Chris@909 132
Chris@909 133 private
Chris@909 134
Chris@909 135 def delete_configuration_data
Chris@909 136 Role.delete_all('builtin = 0')
Chris@909 137 Tracker.delete_all
Chris@909 138 IssueStatus.delete_all
Chris@909 139 Enumeration.delete_all
Chris@909 140 end
Chris@909 141 end