@@ -1,69 +1,70 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2009 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2009 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 |
|
19 | |||
20 | class MenuManagerTest < ActionController::IntegrationTest |
|
20 | class MenuManagerTest < ActionController::IntegrationTest | |
21 | include Redmine::I18n |
|
21 | include Redmine::I18n | |
22 |
|
22 | |||
23 | fixtures :all |
|
23 | fixtures :all | |
24 |
|
24 | |||
25 | def test_project_menu_with_specific_locale |
|
25 | def test_project_menu_with_specific_locale | |
26 | get 'projects/ecookbook/issues', { }, 'Accept-Language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' |
|
26 | get 'projects/ecookbook/issues', { }, 'Accept-Language' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' | |
27 |
|
27 | |||
28 | assert_tag :div, :attributes => { :id => 'main-menu' }, |
|
28 | assert_tag :div, :attributes => { :id => 'main-menu' }, | |
29 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity), |
|
29 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity), | |
30 | :attributes => { :href => '/projects/ecookbook/activity', |
|
30 | :attributes => { :href => '/projects/ecookbook/activity', | |
31 | :class => 'activity' } } } |
|
31 | :class => 'activity' } } } | |
32 | assert_tag :div, :attributes => { :id => 'main-menu' }, |
|
32 | assert_tag :div, :attributes => { :id => 'main-menu' }, | |
33 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_issue_plural), |
|
33 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_issue_plural), | |
34 | :attributes => { :href => '/projects/ecookbook/issues', |
|
34 | :attributes => { :href => '/projects/ecookbook/issues', | |
35 | :class => 'issues selected' } } } |
|
35 | :class => 'issues selected' } } } | |
36 | end |
|
36 | end | |
37 |
|
37 | |||
38 | def test_project_menu_with_additional_menu_items |
|
38 | def test_project_menu_with_additional_menu_items | |
|
39 | Setting.default_language = 'en' | |||
39 | assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do |
|
40 | assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do | |
40 | Redmine::MenuManager.map :project_menu do |menu| |
|
41 | Redmine::MenuManager.map :project_menu do |menu| | |
41 | menu.push :foo, { :controller => 'projects', :action => 'show' }, :caption => 'Foo' |
|
42 | menu.push :foo, { :controller => 'projects', :action => 'show' }, :caption => 'Foo' | |
42 | menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity |
|
43 | menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity | |
43 | menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar |
|
44 | menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar | |
44 | end |
|
45 | end | |
45 |
|
46 | |||
46 | get 'projects/ecookbook' |
|
47 | get 'projects/ecookbook' | |
47 | assert_tag :div, :attributes => { :id => 'main-menu' }, |
|
48 | assert_tag :div, :attributes => { :id => 'main-menu' }, | |
48 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo', |
|
49 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo', | |
49 | :attributes => { :class => 'foo' } } } |
|
50 | :attributes => { :class => 'foo' } } } | |
50 |
|
51 | |||
51 | assert_tag :div, :attributes => { :id => 'main-menu' }, |
|
52 | assert_tag :div, :attributes => { :id => 'main-menu' }, | |
52 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar', |
|
53 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar', | |
53 | :attributes => { :class => 'bar' } }, |
|
54 | :attributes => { :class => 'bar' } }, | |
54 | :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } } |
|
55 | :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } } | |
55 |
|
56 | |||
56 | assert_tag :div, :attributes => { :id => 'main-menu' }, |
|
57 | assert_tag :div, :attributes => { :id => 'main-menu' }, | |
57 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK', |
|
58 | :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK', | |
58 | :attributes => { :class => 'hello' } }, |
|
59 | :attributes => { :class => 'hello' } }, | |
59 | :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } } |
|
60 | :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } } | |
60 |
|
61 | |||
61 | # Remove the menu items |
|
62 | # Remove the menu items | |
62 | Redmine::MenuManager.map :project_menu do |menu| |
|
63 | Redmine::MenuManager.map :project_menu do |menu| | |
63 | menu.delete :foo |
|
64 | menu.delete :foo | |
64 | menu.delete :bar |
|
65 | menu.delete :bar | |
65 | menu.delete :hello |
|
66 | menu.delete :hello | |
66 | end |
|
67 | end | |
67 | end |
|
68 | end | |
68 | end |
|
69 | end | |
69 | end |
|
70 | end |
General Comments 0
You need to be logged in to leave comments.
Login now