##// END OF EJS Templates
Fixes broken admin menu extension (#4351)....
Jean-Philippe Lang -
r3017:174f014564b3
parent child
Show More
@@ -1,56 +1,56
1 1 <h2><%=l(:label_administration)%></h2>
2 2
3 3 <%= render :partial => 'no_data' if @no_configuration_data %>
4 4
5 5 <p class="icon22 icon22-projects">
6 6 <%= link_to l(:label_project_plural), :controller => 'admin', :action => 'projects' %> |
7 7 <%= link_to l(:label_new), :controller => 'projects', :action => 'add' %>
8 8 </p>
9 9
10 10 <p class="icon22 icon22-users">
11 11 <%= link_to l(:label_user_plural), :controller => 'users' %> |
12 12 <%= link_to l(:label_new), :controller => 'users', :action => 'add' %>
13 13 </p>
14 14
15 15 <p class="icon22 icon22-groups">
16 16 <%= link_to l(:label_group_plural), :controller => 'groups' %> |
17 17 <%= link_to l(:label_new), :controller => 'groups', :action => 'new' %>
18 18 </p>
19 19
20 20 <p class="icon22 icon22-role">
21 21 <%= link_to l(:label_role_and_permissions), :controller => 'roles' %>
22 22 </p>
23 23
24 24 <p class="icon22 icon22-tracker">
25 25 <%= link_to l(:label_tracker_plural), :controller => 'trackers' %> |
26 26 <%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses' %> |
27 27 <%= link_to l(:label_workflow), :controller => 'workflows', :action => 'edit' %>
28 28 </p>
29 29
30 30 <p class="icon22 icon22-workflow">
31 31 <%= link_to l(:label_custom_field_plural), :controller => 'custom_fields' %>
32 32 </p>
33 33
34 34 <p class="icon22 icon22-options">
35 35 <%= link_to l(:label_enumerations), :controller => 'enumerations' %>
36 36 </p>
37 37
38 38 <p class="icon22 icon22-settings">
39 39 <%= link_to l(:label_settings), :controller => 'settings' %>
40 40 </p>
41 41
42 <% menu_items_for(:admin_menu) do |item, caption, url, selected| -%>
43 <%= content_tag 'p',
44 link_to(h(caption), item.url, item.html_options),
42 <% menu_items_for(:admin_menu) do |item| -%>
43 <%= content_tag 'p',
44 link_to(h(item.caption), item.url, item.html_options),
45 45 :class => ["icon22", "icon22-#{item.name}"].join(' ') %>
46 46 <% end -%>
47 47
48 48 <p class="icon22 icon22-plugin">
49 49 <%= link_to l(:label_plugins), :controller => 'admin', :action => 'plugins' %>
50 50 </p>
51 51
52 52 <p class="icon22 icon22-info">
53 53 <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
54 54 </p>
55 55
56 56 <% html_title(l(:label_administration)) -%>
@@ -1,131 +1,146
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper'
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_projects_routing
42 42 assert_routing(
43 43 {:method => :get, :path => '/admin/projects'},
44 44 :controller => 'admin', :action => 'projects'
45 45 )
46 46 end
47 47
48 48 def test_index_with_no_configuration_data
49 49 delete_configuration_data
50 50 get :index
51 51 assert_tag :tag => 'div',
52 52 :attributes => { :class => /nodata/ }
53 53 end
54 54
55 55 def test_projects
56 56 get :projects
57 57 assert_response :success
58 58 assert_template 'projects'
59 59 assert_not_nil assigns(:projects)
60 60 # active projects only
61 61 assert_nil assigns(:projects).detect {|u| !u.active?}
62 62 end
63 63
64 64 def test_projects_with_name_filter
65 65 get :projects, :name => 'store', :status => ''
66 66 assert_response :success
67 67 assert_template 'projects'
68 68 projects = assigns(:projects)
69 69 assert_not_nil projects
70 70 assert_equal 1, projects.size
71 71 assert_equal 'OnlineStore', projects.first.name
72 72 end
73 73
74 74 def test_load_default_configuration_data
75 75 delete_configuration_data
76 76 post :default_configuration, :lang => 'fr'
77 77 assert IssueStatus.find_by_name('Nouveau')
78 78 end
79 79
80 80 def test_test_email
81 81 get :test_email
82 82 assert_redirected_to '/settings/edit?tab=notifications'
83 83 mail = ActionMailer::Base.deliveries.last
84 84 assert_kind_of TMail::Mail, mail
85 85 user = User.find(1)
86 86 assert_equal [user.mail], mail.bcc
87 87 end
88 88
89 89 def test_no_plugins
90 90 Redmine::Plugin.clear
91 91
92 92 get :plugins
93 93 assert_response :success
94 94 assert_template 'plugins'
95 95 end
96 96
97 97 def test_plugins
98 98 # Register a few plugins
99 99 Redmine::Plugin.register :foo do
100 100 name 'Foo plugin'
101 101 author 'John Smith'
102 102 description 'This is a test plugin'
103 103 version '0.0.1'
104 104 settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings'
105 105 end
106 106 Redmine::Plugin.register :bar do
107 107 end
108 108
109 109 get :plugins
110 110 assert_response :success
111 111 assert_template 'plugins'
112 112
113 113 assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' }
114 114 assert_tag :td, :child => { :tag => 'span', :content => 'Bar' }
115 115 end
116 116
117 117 def test_info
118 118 get :info
119 119 assert_response :success
120 120 assert_template 'info'
121 121 end
122 122
123 def test_admin_menu_plugin_extension
124 Redmine::MenuManager.map :admin_menu do |menu|
125 menu.push :test_admin_menu_plugin_extension, '/foo/bar', :caption => 'Test'
126 end
127
128 get :index
129 assert_response :success
130 assert_tag :a, :attributes => { :href => '/foo/bar' },
131 :content => 'Test'
132
133 Redmine::MenuManager.map :admin_menu do |menu|
134 menu.delete :test_admin_menu_plugin_extension
135 end
136 end
137
123 138 private
124 139
125 140 def delete_configuration_data
126 141 Role.delete_all('builtin = 0')
127 142 Tracker.delete_all
128 143 IssueStatus.delete_all
129 144 Enumeration.delete_all
130 145 end
131 146 end
General Comments 0
You need to be logged in to leave comments. Login now