mirror of
https://github.com/redmine/redmine.git
synced 2026-05-06 05:06:00 +02:00
Menu mapper: add support for :before, :after and :last options to #push method and add #delete method.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1660 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -312,4 +312,33 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
assert_redirected_to 'admin/projects'
|
||||
assert Project.find(1).active?
|
||||
end
|
||||
|
||||
def test_project_menu
|
||||
assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
|
||||
Redmine::MenuManager.map :project_menu do |menu|
|
||||
menu.push :foo, { :controller => 'projects', :action => 'show' }, :cation => '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
|
||||
|
||||
get :show, :id => 1
|
||||
assert_tag :div, :attributes => { :id => 'main-menu' },
|
||||
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo' } }
|
||||
|
||||
assert_tag :div, :attributes => { :id => 'main-menu' },
|
||||
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar' },
|
||||
:before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
|
||||
|
||||
assert_tag :div, :attributes => { :id => 'main-menu' },
|
||||
:descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' },
|
||||
:before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
|
||||
|
||||
# Remove the menu items
|
||||
Redmine::MenuManager.map :project_menu do |menu|
|
||||
menu.delete :foo
|
||||
menu.delete :bar
|
||||
menu.delete :hello
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user