##// END OF EJS Templates
Moves project menu tests to a dedicated integration test....
Jean-Philippe Lang -
r2435:9c4a86d96cf0
parent child
Show More
@@ -0,0 +1,69
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 assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
40 Redmine::MenuManager.map :project_menu do |menu|
41 menu.push :foo, { :controller => 'projects', :action => 'show' }, :caption => 'Foo'
42 menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity
43 menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
44 end
45
46 get 'projects/ecookbook'
47 assert_tag :div, :attributes => { :id => 'main-menu' },
48 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
49 :attributes => { :class => 'foo' } } }
50
51 assert_tag :div, :attributes => { :id => 'main-menu' },
52 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
53 :attributes => { :class => 'bar' } },
54 :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
55
56 assert_tag :div, :attributes => { :id => 'main-menu' },
57 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
58 :attributes => { :class => 'hello' } },
59 :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
60
61 # Remove the menu items
62 Redmine::MenuManager.map :project_menu do |menu|
63 menu.delete :foo
64 menu.delete :bar
65 menu.delete :hello
66 end
67 end
68 end
69 end
@@ -480,38 +480,6 class ProjectsControllerTest < Test::Unit::TestCase
480 480 assert_template 'show'
481 481 end
482 482
483 def test_project_menu
484 assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
485 Redmine::MenuManager.map :project_menu do |menu|
486 menu.push :foo, { :controller => 'projects', :action => 'show' }, :caption => 'Foo'
487 menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity
488 menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
489 end
490
491 get :show, :id => 1
492 assert_tag :div, :attributes => { :id => 'main-menu' },
493 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
494 :attributes => { :class => 'foo' } } }
495
496 assert_tag :div, :attributes => { :id => 'main-menu' },
497 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
498 :attributes => { :class => 'bar' } },
499 :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
500
501 assert_tag :div, :attributes => { :id => 'main-menu' },
502 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
503 :attributes => { :class => 'hello' } },
504 :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
505
506 # Remove the menu items
507 Redmine::MenuManager.map :project_menu do |menu|
508 menu.delete :foo
509 menu.delete :bar
510 menu.delete :hello
511 end
512 end
513 end
514
515 483 # A hook that is manually registered later
516 484 class ProjectBasedTemplate < Redmine::Hook::ViewListener
517 485 def view_layouts_base_html_head(context)
General Comments 0
You need to be logged in to leave comments. Login now