comparison test/integration/lib/redmine/menu_manager_test.rb @ 0:513646585e45

* Import Redmine trunk SVN rev 3859
author Chris Cannam
date Fri, 23 Jul 2010 15:52:44 +0100
parents
children af80e5618e9b
comparison
equal deleted inserted replaced
-1:000000000000 0:513646585e45
1 # Redmine - project management software
2 # Copyright (C) 2006-2009 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require "#{File.dirname(__FILE__)}/../../../test_helper"
19
20 class MenuManagerTest < ActionController::IntegrationTest
21 include Redmine::I18n
22
23 fixtures :all
24
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'
27
28 assert_tag :div, :attributes => { :id => 'main-menu' },
29 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity),
30 :attributes => { :href => '/projects/ecookbook/activity',
31 :class => 'activity' } } }
32 assert_tag :div, :attributes => { :id => 'main-menu' },
33 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_issue_plural),
34 :attributes => { :href => '/projects/ecookbook/issues',
35 :class => 'issues selected' } } }
36 end
37
38 def test_project_menu_with_additional_menu_items
39 Setting.default_language = 'en'
40 assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
41 Redmine::MenuManager.map :project_menu do |menu|
42 menu.push :foo, { :controller => 'projects', :action => 'show' }, :caption => 'Foo'
43 menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity
44 menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
45 end
46
47 get 'projects/ecookbook'
48 assert_tag :div, :attributes => { :id => 'main-menu' },
49 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
50 :attributes => { :class => 'foo' } } }
51
52 assert_tag :div, :attributes => { :id => 'main-menu' },
53 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
54 :attributes => { :class => 'bar' } },
55 :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
56
57 assert_tag :div, :attributes => { :id => 'main-menu' },
58 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
59 :attributes => { :class => 'hello' } },
60 :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
61
62 # Remove the menu items
63 Redmine::MenuManager.map :project_menu do |menu|
64 menu.delete :foo
65 menu.delete :bar
66 menu.delete :hello
67 end
68 end
69 end
70 end