2009-02-21 15:28:19 +03:00
|
|
|
# Redmine - project management software
|
2013-01-12 13:29:31 +04:00
|
|
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
2009-02-21 15:28:19 +03:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-08-27 12:45:56 +04:00
|
|
|
#
|
2009-02-21 15:28:19 +03:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2011-08-27 12:45:56 +04:00
|
|
|
#
|
2009-02-21 15:28:19 +03:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2010-12-13 02:24:34 +03:00
|
|
|
require File.expand_path('../../../../test_helper', __FILE__)
|
2009-02-21 15:28:19 +03:00
|
|
|
|
|
|
|
class MenuManagerTest < ActionController::IntegrationTest
|
|
|
|
include Redmine::I18n
|
2011-08-27 12:45:56 +04:00
|
|
|
|
2011-09-25 10:11:35 +04:00
|
|
|
fixtures :projects, :trackers, :issue_statuses, :issues,
|
|
|
|
:enumerations, :users, :issue_categories,
|
|
|
|
:projects_trackers,
|
|
|
|
:roles,
|
|
|
|
:member_roles,
|
|
|
|
:members,
|
|
|
|
:enabled_modules,
|
|
|
|
:workflows
|
2011-08-27 12:45:56 +04:00
|
|
|
|
2009-02-21 15:28:19 +03:00
|
|
|
def test_project_menu_with_specific_locale
|
2012-02-25 20:33:00 +04:00
|
|
|
get 'projects/ecookbook/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
|
2011-08-27 12:45:56 +04:00
|
|
|
|
2009-02-21 15:28:19 +03:00
|
|
|
assert_tag :div, :attributes => { :id => 'main-menu' },
|
|
|
|
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity),
|
|
|
|
:attributes => { :href => '/projects/ecookbook/activity',
|
|
|
|
:class => 'activity' } } }
|
|
|
|
assert_tag :div, :attributes => { :id => 'main-menu' },
|
|
|
|
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_issue_plural),
|
|
|
|
:attributes => { :href => '/projects/ecookbook/issues',
|
|
|
|
:class => 'issues selected' } } }
|
|
|
|
end
|
2011-08-27 12:45:56 +04:00
|
|
|
|
2009-02-21 15:28:19 +03:00
|
|
|
def test_project_menu_with_additional_menu_items
|
2009-09-04 07:24:20 +04:00
|
|
|
Setting.default_language = 'en'
|
2009-02-21 15:28:19 +03:00
|
|
|
assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
|
|
|
|
Redmine::MenuManager.map :project_menu do |menu|
|
|
|
|
menu.push :foo, { :controller => 'projects', :action => 'show' }, :caption => 'Foo'
|
|
|
|
menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity
|
|
|
|
menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
|
|
|
|
end
|
2011-08-27 12:45:56 +04:00
|
|
|
|
2009-02-21 15:28:19 +03:00
|
|
|
get 'projects/ecookbook'
|
|
|
|
assert_tag :div, :attributes => { :id => 'main-menu' },
|
|
|
|
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
|
|
|
|
:attributes => { :class => 'foo' } } }
|
2011-08-27 12:45:56 +04:00
|
|
|
|
2009-02-21 15:28:19 +03:00
|
|
|
assert_tag :div, :attributes => { :id => 'main-menu' },
|
|
|
|
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
|
|
|
|
:attributes => { :class => 'bar' } },
|
|
|
|
:before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
|
|
|
|
|
|
|
|
assert_tag :div, :attributes => { :id => 'main-menu' },
|
|
|
|
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
|
|
|
|
:attributes => { :class => 'hello' } },
|
|
|
|
:before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
|
2011-08-27 12:45:56 +04:00
|
|
|
|
2009-02-21 15:28:19 +03:00
|
|
|
# Remove the menu items
|
|
|
|
Redmine::MenuManager.map :project_menu do |menu|
|
|
|
|
menu.delete :foo
|
|
|
|
menu.delete :bar
|
|
|
|
menu.delete :hello
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|