##// END OF EJS Templates
Merged r14389 (#20203)....
Jean-Philippe Lang -
r14019:a85385449878
parent child
Show More
@@ -1,42 +1,42
1 1 <% if @deliveries %>
2 2 <%= form_tag({:action => 'edit', :tab => 'notifications'}) do %>
3 3
4 4 <div class="box tabular settings">
5 5 <p><%= setting_text_field :mail_from, :size => 60 %></p>
6 6
7 7 <p><%= setting_check_box :bcc_recipients %></p>
8 8
9 9 <p><%= setting_check_box :plain_text_mail %></p>
10 10
11 11 <p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p>
12 12
13 13 </div>
14 14
15 15 <fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
16 16 <%= hidden_field_tag 'settings[notified_events][]', '' %>
17 17 <% @notifiables.each do |notifiable| %>
18 18 <%= notification_field notifiable %>
19 19 <br />
20 20 <% end %>
21 21 <p><%= check_all_links('notified_events') %></p>
22 22 </fieldset>
23 23
24 24 <fieldset class="box"><legend><%= l(:setting_emails_header) %></legend>
25 25 <%= setting_text_area :emails_header, :label => false, :class => 'wiki-edit', :rows => 5 %>
26 26 </fieldset>
27 27
28 28 <fieldset class="box"><legend><%= l(:setting_emails_footer) %></legend>
29 29 <%= setting_text_area :emails_footer, :label => false, :class => 'wiki-edit', :rows => 5 %>
30 30 </fieldset>
31 31
32 32 <div style="float:right;">
33 <%= link_to l(:label_send_test_email), :controller => 'admin', :action => 'test_email' %>
33 <%= link_to l(:label_send_test_email), { :controller => 'admin', :action => 'test_email' }, :method => :post %>
34 34 </div>
35 35
36 36 <%= submit_tag l(:button_save) %>
37 37 <% end %>
38 38 <% else %>
39 39 <div class="nodata">
40 40 <%= simple_format(l(:text_email_delivery_not_configured)) %>
41 41 </div>
42 42 <% end %>
@@ -1,361 +1,361
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 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 Rails.application.routes.draw do
19 19 root :to => 'welcome#index', :as => 'home'
20 20
21 21 match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post]
22 22 match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post]
23 23 match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register'
24 24 match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password'
25 25 match 'account/activate', :to => 'account#activate', :via => :get
26 26 get 'account/activation_email', :to => 'account#activation_email', :as => 'activation_email'
27 27
28 28 match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put, :patch]
29 29 match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put, :patch]
30 30 match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put, :patch]
31 31 match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put, :patch]
32 32
33 33 match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
34 34 match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
35 35
36 36 match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
37 37 get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
38 38 match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
39 39 get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
40 40
41 41 post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message'
42 42 post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
43 43 post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
44 44 post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
45 45
46 46 # Misc issue routes. TODO: move into resources
47 47 match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
48 48 match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post]
49 49 match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get
50 50 match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
51 51
52 52 match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
53 53 match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
54 54
55 55 get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
56 56 get '/issues/gantt', :to => 'gantts#show'
57 57
58 58 get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
59 59 get '/issues/calendar', :to => 'calendars#show'
60 60
61 61 get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
62 62 get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
63 63
64 64 match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
65 65 match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
66 66 match 'my/page', :controller => 'my', :action => 'page', :via => :get
67 67 match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
68 68 match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post
69 69 match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post
70 70 match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
71 71 match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
72 72 match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
73 73 match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
74 74 match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
75 75
76 76 resources :users do
77 77 resources :memberships, :controller => 'principal_memberships'
78 78 resources :email_addresses, :only => [:index, :create, :update, :destroy]
79 79 end
80 80
81 81 post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
82 82 delete 'watchers/watch', :to => 'watchers#unwatch'
83 83 get 'watchers/new', :to => 'watchers#new'
84 84 post 'watchers', :to => 'watchers#create'
85 85 post 'watchers/append', :to => 'watchers#append'
86 86 delete 'watchers', :to => 'watchers#destroy'
87 87 get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user'
88 88 # Specific routes for issue watchers API
89 89 post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
90 90 delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
91 91
92 92 resources :projects do
93 93 member do
94 94 get 'settings(/:tab)', :action => 'settings', :as => 'settings'
95 95 post 'modules'
96 96 post 'archive'
97 97 post 'unarchive'
98 98 post 'close'
99 99 post 'reopen'
100 100 match 'copy', :via => [:get, :post]
101 101 end
102 102
103 103 shallow do
104 104 resources :memberships, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
105 105 collection do
106 106 get 'autocomplete'
107 107 end
108 108 end
109 109 end
110 110
111 111 resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
112 112
113 113 get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue'
114 114 resources :issues, :only => [:index, :new, :create]
115 115 # Used when updating the form of a new issue
116 116 post 'issues/new', :to => 'issues#new'
117 117
118 118 resources :files, :only => [:index, :new, :create]
119 119
120 120 resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
121 121 collection do
122 122 put 'close_completed'
123 123 end
124 124 end
125 125 get 'versions.:format', :to => 'versions#index'
126 126 get 'roadmap', :to => 'versions#index', :format => false
127 127 get 'versions', :to => 'versions#index'
128 128
129 129 resources :news, :except => [:show, :edit, :update, :destroy]
130 130 resources :time_entries, :controller => 'timelog', :except => [:show, :edit, :update, :destroy] do
131 131 get 'report', :on => :collection
132 132 end
133 133 resources :queries, :only => [:new, :create]
134 134 shallow do
135 135 resources :issue_categories
136 136 end
137 137 resources :documents, :except => [:show, :edit, :update, :destroy]
138 138 resources :boards
139 139 shallow do
140 140 resources :repositories, :except => [:index, :show] do
141 141 member do
142 142 match 'committers', :via => [:get, :post]
143 143 end
144 144 end
145 145 end
146 146
147 147 match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
148 148 resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do
149 149 member do
150 150 get 'rename'
151 151 post 'rename'
152 152 get 'history'
153 153 get 'diff'
154 154 match 'preview', :via => [:post, :put, :patch]
155 155 post 'protect'
156 156 post 'add_attachment'
157 157 end
158 158 collection do
159 159 get 'export'
160 160 get 'date_index'
161 161 end
162 162 end
163 163 match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
164 164 get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/}
165 165 delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
166 166 get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
167 167 get 'wiki/:id/:version/diff', :to => 'wiki#diff'
168 168 end
169 169
170 170 resources :issues do
171 171 member do
172 172 # Used when updating the form of an existing issue
173 173 patch 'edit', :to => 'issues#edit'
174 174 end
175 175 collection do
176 176 match 'bulk_edit', :via => [:get, :post]
177 177 post 'bulk_update'
178 178 end
179 179 resources :time_entries, :controller => 'timelog', :except => [:show, :edit, :update, :destroy] do
180 180 collection do
181 181 get 'report'
182 182 end
183 183 end
184 184 shallow do
185 185 resources :relations, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
186 186 end
187 187 end
188 188 # Used when updating the form of a new issue outside a project
189 189 post '/issues/new', :to => 'issues#new'
190 190 match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
191 191
192 192 resources :queries, :except => [:show]
193 193
194 194 resources :news, :only => [:index, :show, :edit, :update, :destroy]
195 195 match '/news/:id/comments', :to => 'comments#create', :via => :post
196 196 match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
197 197
198 198 resources :versions, :only => [:show, :edit, :update, :destroy] do
199 199 post 'status_by', :on => :member
200 200 end
201 201
202 202 resources :documents, :only => [:show, :edit, :update, :destroy] do
203 203 post 'add_attachment', :on => :member
204 204 end
205 205
206 206 match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
207 207
208 208 resources :time_entries, :controller => 'timelog', :except => :destroy do
209 209 collection do
210 210 get 'report'
211 211 get 'bulk_edit'
212 212 post 'bulk_update'
213 213 end
214 214 end
215 215 match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
216 216 # TODO: delete /time_entries for bulk deletion
217 217 match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
218 218
219 219 get 'projects/:id/activity', :to => 'activities#index', :as => :project_activity
220 220 get 'activity', :to => 'activities#index'
221 221
222 222 # repositories routes
223 223 get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
224 224 get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
225 225
226 226 get 'projects/:id/repository/:repository_id/changes(/*path)',
227 227 :to => 'repositories#changes',
228 228 :format => false
229 229
230 230 get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
231 231 get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
232 232 post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
233 233 delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
234 234 get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
235 235 get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path)',
236 236 :controller => 'repositories',
237 237 :format => false,
238 238 :constraints => {
239 239 :action => /(browse|show|entry|raw|annotate|diff)/,
240 240 :rev => /[a-z0-9\.\-_]+/
241 241 }
242 242
243 243 get 'projects/:id/repository/statistics', :to => 'repositories#stats'
244 244 get 'projects/:id/repository/graph', :to => 'repositories#graph'
245 245
246 246 get 'projects/:id/repository/changes(/*path)',
247 247 :to => 'repositories#changes',
248 248 :format => false
249 249
250 250 get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
251 251 get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
252 252 get 'projects/:id/repository/revision', :to => 'repositories#revision'
253 253 post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
254 254 delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
255 255 get 'projects/:id/repository/revisions/:rev/:action(/*path)',
256 256 :controller => 'repositories',
257 257 :format => false,
258 258 :constraints => {
259 259 :action => /(browse|show|entry|raw|annotate|diff)/,
260 260 :rev => /[a-z0-9\.\-_]+/
261 261 }
262 262 get 'projects/:id/repository/:repository_id/:action(/*path)',
263 263 :controller => 'repositories',
264 264 :action => /(browse|show|entry|raw|changes|annotate|diff)/,
265 265 :format => false
266 266 get 'projects/:id/repository/:action(/*path)',
267 267 :controller => 'repositories',
268 268 :action => /(browse|show|entry|raw|changes|annotate|diff)/,
269 269 :format => false
270 270
271 271 get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
272 272 get 'projects/:id/repository', :to => 'repositories#show', :path => nil
273 273
274 274 # additional routes for having the file name at the end of url
275 275 get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
276 276 get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
277 277 get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
278 278 get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
279 279 resources :attachments, :only => [:show, :destroy]
280 280 get 'attachments/:object_type/:object_id/edit', :to => 'attachments#edit', :as => :object_attachments_edit
281 281 patch 'attachments/:object_type/:object_id', :to => 'attachments#update', :as => :object_attachments
282 282
283 283 resources :groups do
284 284 resources :memberships, :controller => 'principal_memberships'
285 285 member do
286 286 get 'autocomplete_for_user'
287 287 end
288 288 end
289 289
290 290 get 'groups/:id/users/new', :to => 'groups#new_users', :id => /\d+/, :as => 'new_group_users'
291 291 post 'groups/:id/users', :to => 'groups#add_users', :id => /\d+/, :as => 'group_users'
292 292 delete 'groups/:id/users/:user_id', :to => 'groups#remove_user', :id => /\d+/, :as => 'group_user'
293 293
294 294 resources :trackers, :except => :show do
295 295 collection do
296 296 match 'fields', :via => [:get, :post]
297 297 end
298 298 end
299 299 resources :issue_statuses, :except => :show do
300 300 collection do
301 301 post 'update_issue_done_ratio'
302 302 end
303 303 end
304 304 resources :custom_fields, :except => :show
305 305 resources :roles do
306 306 collection do
307 307 match 'permissions', :via => [:get, :post]
308 308 end
309 309 end
310 310 resources :enumerations, :except => :show
311 311 match 'enumerations/:type', :to => 'enumerations#index', :via => :get
312 312
313 313 get 'projects/:id/search', :controller => 'search', :action => 'index'
314 314 get 'search', :controller => 'search', :action => 'index'
315 315
316 316 match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post
317 317
318 318 match 'admin', :controller => 'admin', :action => 'index', :via => :get
319 319 match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
320 320 match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
321 321 match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
322 match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
322 match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :post
323 323 match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post
324 324
325 325 resources :auth_sources do
326 326 member do
327 327 get 'test_connection', :as => 'try_connection'
328 328 end
329 329 collection do
330 330 get 'autocomplete_for_new_user'
331 331 end
332 332 end
333 333
334 334 match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
335 335 match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
336 336 match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]
337 337 match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
338 338 match 'settings', :controller => 'settings', :action => 'index', :via => :get
339 339 match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
340 340 match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings'
341 341
342 342 match 'sys/projects', :to => 'sys#projects', :via => :get
343 343 match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
344 344 match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => [:get, :post]
345 345
346 346 match 'uploads', :to => 'attachments#upload', :via => :post
347 347
348 348 get 'robots.txt', :to => 'welcome#robots'
349 349
350 350 Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
351 351 file = File.join(plugin_dir, "config/routes.rb")
352 352 if File.exists?(file)
353 353 begin
354 354 instance_eval File.read(file)
355 355 rescue Exception => e
356 356 puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
357 357 exit 1
358 358 end
359 359 end
360 360 end
361 361 end
@@ -1,168 +1,168
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 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
20 20 class AdminControllerTest < ActionController::TestCase
21 21 fixtures :projects, :users, :email_addresses, :roles
22 22
23 23 def setup
24 24 User.current = nil
25 25 @request.session[:user_id] = 1 # admin
26 26 end
27 27
28 28 def test_index
29 29 get :index
30 30 assert_select 'div.nodata', 0
31 31 end
32 32
33 33 def test_index_with_no_configuration_data
34 34 delete_configuration_data
35 35 get :index
36 36 assert_select 'div.nodata'
37 37 end
38 38
39 39 def test_projects
40 40 get :projects
41 41 assert_response :success
42 42 assert_template 'projects'
43 43 assert_not_nil assigns(:projects)
44 44 # active projects only
45 45 assert_nil assigns(:projects).detect {|u| !u.active?}
46 46 end
47 47
48 48 def test_projects_with_status_filter
49 49 get :projects, :status => 1
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_load_default_configuration_data_should_rescue_error
76 76 delete_configuration_data
77 77 Redmine::DefaultData::Loader.stubs(:load).raises(Exception.new("Something went wrong"))
78 78 post :default_configuration, :lang => 'fr'
79 79 assert_response :redirect
80 80 assert_not_nil flash[:error]
81 81 assert_match /Something went wrong/, flash[:error]
82 82 end
83 83
84 84 def test_test_email
85 85 user = User.find(1)
86 86 user.pref.no_self_notified = '1'
87 87 user.pref.save!
88 88 ActionMailer::Base.deliveries.clear
89 89
90 get :test_email
90 post :test_email
91 91 assert_redirected_to '/settings?tab=notifications'
92 92 mail = ActionMailer::Base.deliveries.last
93 93 assert_not_nil mail
94 94 user = User.find(1)
95 95 assert_equal [user.mail], mail.bcc
96 96 end
97 97
98 98 def test_test_email_failure_should_display_the_error
99 99 Mailer.stubs(:test_email).raises(Exception, 'Some error message')
100 get :test_email
100 post :test_email
101 101 assert_redirected_to '/settings?tab=notifications'
102 102 assert_match /Some error message/, flash[:error]
103 103 end
104 104
105 105 def test_no_plugins
106 106 Redmine::Plugin.stubs(:registered_plugins).returns({})
107 107
108 108 get :plugins
109 109 assert_response :success
110 110 assert_template 'plugins'
111 111 assert_equal [], assigns(:plugins)
112 112 end
113 113
114 114 def test_plugins
115 115 # Register a few plugins
116 116 Redmine::Plugin.register :foo do
117 117 name 'Foo plugin'
118 118 author 'John Smith'
119 119 description 'This is a test plugin'
120 120 version '0.0.1'
121 121 settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings'
122 122 end
123 123 Redmine::Plugin.register :bar do
124 124 end
125 125
126 126 get :plugins
127 127 assert_response :success
128 128 assert_template 'plugins'
129 129
130 130 assert_select 'tr#plugin-foo' do
131 131 assert_select 'td span.name', :text => 'Foo plugin'
132 132 assert_select 'td.configure a[href="/settings/plugin/foo"]'
133 133 end
134 134 assert_select 'tr#plugin-bar' do
135 135 assert_select 'td span.name', :text => 'Bar'
136 136 assert_select 'td.configure a', 0
137 137 end
138 138 end
139 139
140 140 def test_info
141 141 get :info
142 142 assert_response :success
143 143 assert_template 'info'
144 144 end
145 145
146 146 def test_admin_menu_plugin_extension
147 147 Redmine::MenuManager.map :admin_menu do |menu|
148 148 menu.push :test_admin_menu_plugin_extension, '/foo/bar', :caption => 'Test'
149 149 end
150 150
151 151 get :index
152 152 assert_response :success
153 153 assert_select 'div#admin-menu a[href="/foo/bar"]', :text => 'Test'
154 154
155 155 Redmine::MenuManager.map :admin_menu do |menu|
156 156 menu.delete :test_admin_menu_plugin_extension
157 157 end
158 158 end
159 159
160 160 private
161 161
162 162 def delete_configuration_data
163 163 Role.delete_all('builtin = 0')
164 164 Tracker.delete_all
165 165 IssueStatus.delete_all
166 166 Enumeration.delete_all
167 167 end
168 168 end
@@ -1,29 +1,29
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2015 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
20 20 class RoutingAdminTest < Redmine::RoutingTest
21 21 def test_administration_panel
22 22 should_route 'GET /admin' => 'admin#index'
23 23 should_route 'GET /admin/projects' => 'admin#projects'
24 24 should_route 'GET /admin/plugins' => 'admin#plugins'
25 25 should_route 'GET /admin/info' => 'admin#info'
26 should_route 'GET /admin/test_email' => 'admin#test_email'
26 should_route 'POST /admin/test_email' => 'admin#test_email'
27 27 should_route 'POST /admin/default_configuration' => 'admin#default_configuration'
28 28 end
29 29 end
General Comments 0
You need to be logged in to leave comments. Login now