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