Mercurial > hg > soundsoftware-site
comparison .svn/pristine/fb/fb831ceb031f77a301df0cd90da94f30274b8153.svn-base @ 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 | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
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 | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class AdminControllerTest < ActionController::TestCase | |
21 fixtures :projects, :users, :roles | |
22 | |
23 def setup | |
24 User.current = nil | |
25 @request.session[:user_id] = 1 # admin | |
26 end | |
27 | |
28 def test_index | |
29 get :index | |
30 assert_no_tag :tag => 'div', | |
31 :attributes => { :class => /nodata/ } | |
32 end | |
33 | |
34 def test_index_with_no_configuration_data | |
35 delete_configuration_data | |
36 get :index | |
37 assert_tag :tag => 'div', | |
38 :attributes => { :class => /nodata/ } | |
39 end | |
40 | |
41 def test_projects | |
42 get :projects | |
43 assert_response :success | |
44 assert_template 'projects' | |
45 assert_not_nil assigns(:projects) | |
46 # active projects only | |
47 assert_nil assigns(:projects).detect {|u| !u.active?} | |
48 end | |
49 | |
50 def test_projects_with_status_filter | |
51 get :projects, :status => 1 | |
52 assert_response :success | |
53 assert_template 'projects' | |
54 assert_not_nil assigns(:projects) | |
55 # active projects only | |
56 assert_nil assigns(:projects).detect {|u| !u.active?} | |
57 end | |
58 | |
59 def test_projects_with_name_filter | |
60 get :projects, :name => 'store', :status => '' | |
61 assert_response :success | |
62 assert_template 'projects' | |
63 projects = assigns(:projects) | |
64 assert_not_nil projects | |
65 assert_equal 1, projects.size | |
66 assert_equal 'OnlineStore', projects.first.name | |
67 end | |
68 | |
69 def test_load_default_configuration_data | |
70 delete_configuration_data | |
71 post :default_configuration, :lang => 'fr' | |
72 assert_response :redirect | |
73 assert_nil flash[:error] | |
74 assert IssueStatus.find_by_name('Nouveau') | |
75 end | |
76 | |
77 def test_load_default_configuration_data_should_rescue_error | |
78 delete_configuration_data | |
79 Redmine::DefaultData::Loader.stubs(:load).raises(Exception.new("Something went wrong")) | |
80 post :default_configuration, :lang => 'fr' | |
81 assert_response :redirect | |
82 assert_not_nil flash[:error] | |
83 assert_match /Something went wrong/, flash[:error] | |
84 end | |
85 | |
86 def test_test_email | |
87 user = User.find(1) | |
88 user.pref[:no_self_notified] = '1' | |
89 user.pref.save! | |
90 ActionMailer::Base.deliveries.clear | |
91 | |
92 get :test_email | |
93 assert_redirected_to '/settings/edit?tab=notifications' | |
94 mail = ActionMailer::Base.deliveries.last | |
95 assert_not_nil mail | |
96 user = User.find(1) | |
97 assert_equal [user.mail], mail.bcc | |
98 end | |
99 | |
100 def test_test_email_failure_should_display_the_error | |
101 Mailer.stubs(:test_email).raises(Exception, 'Some error message') | |
102 get :test_email | |
103 assert_redirected_to '/settings/edit?tab=notifications' | |
104 assert_match /Some error message/, flash[:error] | |
105 end | |
106 | |
107 def test_no_plugins | |
108 Redmine::Plugin.clear | |
109 | |
110 get :plugins | |
111 assert_response :success | |
112 assert_template 'plugins' | |
113 end | |
114 | |
115 def test_plugins | |
116 # Register a few plugins | |
117 Redmine::Plugin.register :foo do | |
118 name 'Foo plugin' | |
119 author 'John Smith' | |
120 description 'This is a test plugin' | |
121 version '0.0.1' | |
122 settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings' | |
123 end | |
124 Redmine::Plugin.register :bar do | |
125 end | |
126 | |
127 get :plugins | |
128 assert_response :success | |
129 assert_template 'plugins' | |
130 | |
131 assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' } | |
132 assert_tag :td, :child => { :tag => 'span', :content => 'Bar' } | |
133 end | |
134 | |
135 def test_info | |
136 get :info | |
137 assert_response :success | |
138 assert_template 'info' | |
139 end | |
140 | |
141 def test_admin_menu_plugin_extension | |
142 Redmine::MenuManager.map :admin_menu do |menu| | |
143 menu.push :test_admin_menu_plugin_extension, '/foo/bar', :caption => 'Test' | |
144 end | |
145 | |
146 get :index | |
147 assert_response :success | |
148 assert_tag :a, :attributes => { :href => '/foo/bar' }, | |
149 :content => 'Test' | |
150 | |
151 Redmine::MenuManager.map :admin_menu do |menu| | |
152 menu.delete :test_admin_menu_plugin_extension | |
153 end | |
154 end | |
155 | |
156 private | |
157 | |
158 def delete_configuration_data | |
159 Role.delete_all('builtin = 0') | |
160 Tracker.delete_all | |
161 IssueStatus.delete_all | |
162 Enumeration.delete_all | |
163 end | |
164 end |