To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / test / integration / lib / redmine / menu_manager_test.rb @ 442:753f1380d6bc

History | View | Annotate | Download (3.81 KB)

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.expand_path('../../../../test_helper', __FILE__)
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