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