@@ -1,56 +1,56 | |||||
1 | <h2><%=l(:label_administration)%></h2> |
|
1 | <h2><%=l(:label_administration)%></h2> | |
2 |
|
2 | |||
3 | <%= render :partial => 'no_data' if @no_configuration_data %> |
|
3 | <%= render :partial => 'no_data' if @no_configuration_data %> | |
4 |
|
4 | |||
5 | <p class="icon22 icon22-projects"> |
|
5 | <p class="icon22 icon22-projects"> | |
6 | <%= link_to l(:label_project_plural), :controller => 'admin', :action => 'projects' %> | |
|
6 | <%= link_to l(:label_project_plural), :controller => 'admin', :action => 'projects' %> | | |
7 | <%= link_to l(:label_new), :controller => 'projects', :action => 'add' %> |
|
7 | <%= link_to l(:label_new), :controller => 'projects', :action => 'add' %> | |
8 | </p> |
|
8 | </p> | |
9 |
|
9 | |||
10 | <p class="icon22 icon22-users"> |
|
10 | <p class="icon22 icon22-users"> | |
11 | <%= link_to l(:label_user_plural), :controller => 'users' %> | |
|
11 | <%= link_to l(:label_user_plural), :controller => 'users' %> | | |
12 | <%= link_to l(:label_new), :controller => 'users', :action => 'add' %> |
|
12 | <%= link_to l(:label_new), :controller => 'users', :action => 'add' %> | |
13 | </p> |
|
13 | </p> | |
14 |
|
14 | |||
15 | <p class="icon22 icon22-groups"> |
|
15 | <p class="icon22 icon22-groups"> | |
16 | <%= link_to l(:label_group_plural), :controller => 'groups' %> | |
|
16 | <%= link_to l(:label_group_plural), :controller => 'groups' %> | | |
17 | <%= link_to l(:label_new), :controller => 'groups', :action => 'new' %> |
|
17 | <%= link_to l(:label_new), :controller => 'groups', :action => 'new' %> | |
18 | </p> |
|
18 | </p> | |
19 |
|
19 | |||
20 | <p class="icon22 icon22-role"> |
|
20 | <p class="icon22 icon22-role"> | |
21 | <%= link_to l(:label_role_and_permissions), :controller => 'roles' %> |
|
21 | <%= link_to l(:label_role_and_permissions), :controller => 'roles' %> | |
22 | </p> |
|
22 | </p> | |
23 |
|
23 | |||
24 | <p class="icon22 icon22-tracker"> |
|
24 | <p class="icon22 icon22-tracker"> | |
25 | <%= link_to l(:label_tracker_plural), :controller => 'trackers' %> | |
|
25 | <%= link_to l(:label_tracker_plural), :controller => 'trackers' %> | | |
26 | <%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses' %> | |
|
26 | <%= link_to l(:label_issue_status_plural), :controller => 'issue_statuses' %> | | |
27 | <%= link_to l(:label_workflow), :controller => 'workflows', :action => 'edit' %> |
|
27 | <%= link_to l(:label_workflow), :controller => 'workflows', :action => 'edit' %> | |
28 | </p> |
|
28 | </p> | |
29 |
|
29 | |||
30 | <p class="icon22 icon22-workflow"> |
|
30 | <p class="icon22 icon22-workflow"> | |
31 | <%= link_to l(:label_custom_field_plural), :controller => 'custom_fields' %> |
|
31 | <%= link_to l(:label_custom_field_plural), :controller => 'custom_fields' %> | |
32 | </p> |
|
32 | </p> | |
33 |
|
33 | |||
34 | <p class="icon22 icon22-options"> |
|
34 | <p class="icon22 icon22-options"> | |
35 | <%= link_to l(:label_enumerations), :controller => 'enumerations' %> |
|
35 | <%= link_to l(:label_enumerations), :controller => 'enumerations' %> | |
36 | </p> |
|
36 | </p> | |
37 |
|
37 | |||
38 | <p class="icon22 icon22-settings"> |
|
38 | <p class="icon22 icon22-settings"> | |
39 | <%= link_to l(:label_settings), :controller => 'settings' %> |
|
39 | <%= link_to l(:label_settings), :controller => 'settings' %> | |
40 | </p> |
|
40 | </p> | |
41 |
|
41 | |||
42 |
<% menu_items_for(:admin_menu) do |item |
|
42 | <% menu_items_for(:admin_menu) do |item| -%> | |
43 |
<%= content_tag 'p', |
|
43 | <%= content_tag 'p', | |
44 | link_to(h(caption), item.url, item.html_options), |
|
44 | link_to(h(item.caption), item.url, item.html_options), | |
45 | :class => ["icon22", "icon22-#{item.name}"].join(' ') %> |
|
45 | :class => ["icon22", "icon22-#{item.name}"].join(' ') %> | |
46 | <% end -%> |
|
46 | <% end -%> | |
47 |
|
47 | |||
48 | <p class="icon22 icon22-plugin"> |
|
48 | <p class="icon22 icon22-plugin"> | |
49 | <%= link_to l(:label_plugins), :controller => 'admin', :action => 'plugins' %> |
|
49 | <%= link_to l(:label_plugins), :controller => 'admin', :action => 'plugins' %> | |
50 | </p> |
|
50 | </p> | |
51 |
|
51 | |||
52 | <p class="icon22 icon22-info"> |
|
52 | <p class="icon22 icon22-info"> | |
53 | <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %> |
|
53 | <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %> | |
54 | </p> |
|
54 | </p> | |
55 |
|
55 | |||
56 | <% html_title(l(:label_administration)) -%> |
|
56 | <% html_title(l(:label_administration)) -%> |
@@ -1,131 +1,146 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'admin_controller' |
|
19 | require 'admin_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class AdminController; def rescue_action(e) raise e end; end |
|
22 | class AdminController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class AdminControllerTest < ActionController::TestCase |
|
24 | class AdminControllerTest < ActionController::TestCase | |
25 | fixtures :projects, :users, :roles |
|
25 | fixtures :projects, :users, :roles | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = AdminController.new |
|
28 | @controller = AdminController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | @request.session[:user_id] = 1 # admin |
|
32 | @request.session[:user_id] = 1 # admin | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def test_index |
|
35 | def test_index | |
36 | get :index |
|
36 | get :index | |
37 | assert_no_tag :tag => 'div', |
|
37 | assert_no_tag :tag => 'div', | |
38 | :attributes => { :class => /nodata/ } |
|
38 | :attributes => { :class => /nodata/ } | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def test_projects_routing |
|
41 | def test_projects_routing | |
42 | assert_routing( |
|
42 | assert_routing( | |
43 | {:method => :get, :path => '/admin/projects'}, |
|
43 | {:method => :get, :path => '/admin/projects'}, | |
44 | :controller => 'admin', :action => 'projects' |
|
44 | :controller => 'admin', :action => 'projects' | |
45 | ) |
|
45 | ) | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | def test_index_with_no_configuration_data |
|
48 | def test_index_with_no_configuration_data | |
49 | delete_configuration_data |
|
49 | delete_configuration_data | |
50 | get :index |
|
50 | get :index | |
51 | assert_tag :tag => 'div', |
|
51 | assert_tag :tag => 'div', | |
52 | :attributes => { :class => /nodata/ } |
|
52 | :attributes => { :class => /nodata/ } | |
53 | end |
|
53 | end | |
54 |
|
54 | |||
55 | def test_projects |
|
55 | def test_projects | |
56 | get :projects |
|
56 | get :projects | |
57 | assert_response :success |
|
57 | assert_response :success | |
58 | assert_template 'projects' |
|
58 | assert_template 'projects' | |
59 | assert_not_nil assigns(:projects) |
|
59 | assert_not_nil assigns(:projects) | |
60 | # active projects only |
|
60 | # active projects only | |
61 | assert_nil assigns(:projects).detect {|u| !u.active?} |
|
61 | assert_nil assigns(:projects).detect {|u| !u.active?} | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | def test_projects_with_name_filter |
|
64 | def test_projects_with_name_filter | |
65 | get :projects, :name => 'store', :status => '' |
|
65 | get :projects, :name => 'store', :status => '' | |
66 | assert_response :success |
|
66 | assert_response :success | |
67 | assert_template 'projects' |
|
67 | assert_template 'projects' | |
68 | projects = assigns(:projects) |
|
68 | projects = assigns(:projects) | |
69 | assert_not_nil projects |
|
69 | assert_not_nil projects | |
70 | assert_equal 1, projects.size |
|
70 | assert_equal 1, projects.size | |
71 | assert_equal 'OnlineStore', projects.first.name |
|
71 | assert_equal 'OnlineStore', projects.first.name | |
72 | end |
|
72 | end | |
73 |
|
73 | |||
74 | def test_load_default_configuration_data |
|
74 | def test_load_default_configuration_data | |
75 | delete_configuration_data |
|
75 | delete_configuration_data | |
76 | post :default_configuration, :lang => 'fr' |
|
76 | post :default_configuration, :lang => 'fr' | |
77 | assert IssueStatus.find_by_name('Nouveau') |
|
77 | assert IssueStatus.find_by_name('Nouveau') | |
78 | end |
|
78 | end | |
79 |
|
79 | |||
80 | def test_test_email |
|
80 | def test_test_email | |
81 | get :test_email |
|
81 | get :test_email | |
82 | assert_redirected_to '/settings/edit?tab=notifications' |
|
82 | assert_redirected_to '/settings/edit?tab=notifications' | |
83 | mail = ActionMailer::Base.deliveries.last |
|
83 | mail = ActionMailer::Base.deliveries.last | |
84 | assert_kind_of TMail::Mail, mail |
|
84 | assert_kind_of TMail::Mail, mail | |
85 | user = User.find(1) |
|
85 | user = User.find(1) | |
86 | assert_equal [user.mail], mail.bcc |
|
86 | assert_equal [user.mail], mail.bcc | |
87 | end |
|
87 | end | |
88 |
|
88 | |||
89 | def test_no_plugins |
|
89 | def test_no_plugins | |
90 | Redmine::Plugin.clear |
|
90 | Redmine::Plugin.clear | |
91 |
|
91 | |||
92 | get :plugins |
|
92 | get :plugins | |
93 | assert_response :success |
|
93 | assert_response :success | |
94 | assert_template 'plugins' |
|
94 | assert_template 'plugins' | |
95 | end |
|
95 | end | |
96 |
|
96 | |||
97 | def test_plugins |
|
97 | def test_plugins | |
98 | # Register a few plugins |
|
98 | # Register a few plugins | |
99 | Redmine::Plugin.register :foo do |
|
99 | Redmine::Plugin.register :foo do | |
100 | name 'Foo plugin' |
|
100 | name 'Foo plugin' | |
101 | author 'John Smith' |
|
101 | author 'John Smith' | |
102 | description 'This is a test plugin' |
|
102 | description 'This is a test plugin' | |
103 | version '0.0.1' |
|
103 | version '0.0.1' | |
104 | settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings' |
|
104 | settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings' | |
105 | end |
|
105 | end | |
106 | Redmine::Plugin.register :bar do |
|
106 | Redmine::Plugin.register :bar do | |
107 | end |
|
107 | end | |
108 |
|
108 | |||
109 | get :plugins |
|
109 | get :plugins | |
110 | assert_response :success |
|
110 | assert_response :success | |
111 | assert_template 'plugins' |
|
111 | assert_template 'plugins' | |
112 |
|
112 | |||
113 | assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' } |
|
113 | assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' } | |
114 | assert_tag :td, :child => { :tag => 'span', :content => 'Bar' } |
|
114 | assert_tag :td, :child => { :tag => 'span', :content => 'Bar' } | |
115 | end |
|
115 | end | |
116 |
|
116 | |||
117 | def test_info |
|
117 | def test_info | |
118 | get :info |
|
118 | get :info | |
119 | assert_response :success |
|
119 | assert_response :success | |
120 | assert_template 'info' |
|
120 | assert_template 'info' | |
121 | end |
|
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 | private |
|
138 | private | |
124 |
|
139 | |||
125 | def delete_configuration_data |
|
140 | def delete_configuration_data | |
126 | Role.delete_all('builtin = 0') |
|
141 | Role.delete_all('builtin = 0') | |
127 | Tracker.delete_all |
|
142 | Tracker.delete_all | |
128 | IssueStatus.delete_all |
|
143 | IssueStatus.delete_all | |
129 | Enumeration.delete_all |
|
144 | Enumeration.delete_all | |
130 | end |
|
145 | end | |
131 | end |
|
146 | end |
General Comments 0
You need to be logged in to leave comments.
Login now