annotate .svn/pristine/98/9804b3e3abfd00a58dec9be4b531677efbf34d66.svn-base @ 1464:261b3d9a4903 redmine-2.4

Update to Redmine 2.4 branch rev 12663
author Chris Cannam
date Tue, 14 Jan 2014 14:37:42 +0000
parents
children
rev   line source
Chris@1464 1 # Redmine - project management software
Chris@1464 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
Chris@1464 3 #
Chris@1464 4 # This program is free software; you can redistribute it and/or
Chris@1464 5 # modify it under the terms of the GNU General Public License
Chris@1464 6 # as published by the Free Software Foundation; either version 2
Chris@1464 7 # of the License, or (at your option) any later version.
Chris@1464 8 #
Chris@1464 9 # This program is distributed in the hope that it will be useful,
Chris@1464 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1464 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1464 12 # GNU General Public License for more details.
Chris@1464 13 #
Chris@1464 14 # You should have received a copy of the GNU General Public License
Chris@1464 15 # along with this program; if not, write to the Free Software
Chris@1464 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1464 17
Chris@1464 18 require File.expand_path('../../../../test_helper', __FILE__)
Chris@1464 19
Chris@1464 20 class MenuManagerTest < ActionController::IntegrationTest
Chris@1464 21 include Redmine::I18n
Chris@1464 22
Chris@1464 23 fixtures :projects, :trackers, :issue_statuses, :issues,
Chris@1464 24 :enumerations, :users, :issue_categories,
Chris@1464 25 :projects_trackers,
Chris@1464 26 :roles,
Chris@1464 27 :member_roles,
Chris@1464 28 :members,
Chris@1464 29 :enabled_modules
Chris@1464 30
Chris@1464 31 def test_project_menu_with_specific_locale
Chris@1464 32 get 'projects/ecookbook/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
Chris@1464 33
Chris@1464 34 assert_tag :div, :attributes => { :id => 'main-menu' },
Chris@1464 35 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity),
Chris@1464 36 :attributes => { :href => '/projects/ecookbook/activity',
Chris@1464 37 :class => 'activity' } } }
Chris@1464 38 assert_tag :div, :attributes => { :id => 'main-menu' },
Chris@1464 39 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_issue_plural),
Chris@1464 40 :attributes => { :href => '/projects/ecookbook/issues',
Chris@1464 41 :class => 'issues selected' } } }
Chris@1464 42 end
Chris@1464 43
Chris@1464 44 def test_project_menu_with_additional_menu_items
Chris@1464 45 Setting.default_language = 'en'
Chris@1464 46 assert_no_difference 'Redmine::MenuManager.items(:project_menu).size' do
Chris@1464 47 Redmine::MenuManager.map :project_menu do |menu|
Chris@1464 48 menu.push :foo, { :controller => 'projects', :action => 'show' }, :caption => 'Foo'
Chris@1464 49 menu.push :bar, { :controller => 'projects', :action => 'show' }, :before => :activity
Chris@1464 50 menu.push :hello, { :controller => 'projects', :action => 'show' }, :caption => Proc.new {|p| p.name.upcase }, :after => :bar
Chris@1464 51 end
Chris@1464 52
Chris@1464 53 get 'projects/ecookbook'
Chris@1464 54 assert_tag :div, :attributes => { :id => 'main-menu' },
Chris@1464 55 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
Chris@1464 56 :attributes => { :class => 'foo' } } }
Chris@1464 57
Chris@1464 58 assert_tag :div, :attributes => { :id => 'main-menu' },
Chris@1464 59 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
Chris@1464 60 :attributes => { :class => 'bar' } },
Chris@1464 61 :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
Chris@1464 62
Chris@1464 63 assert_tag :div, :attributes => { :id => 'main-menu' },
Chris@1464 64 :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
Chris@1464 65 :attributes => { :class => 'hello' } },
Chris@1464 66 :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
Chris@1464 67
Chris@1464 68 # Remove the menu items
Chris@1464 69 Redmine::MenuManager.map :project_menu do |menu|
Chris@1464 70 menu.delete :foo
Chris@1464 71 menu.delete :bar
Chris@1464 72 menu.delete :hello
Chris@1464 73 end
Chris@1464 74 end
Chris@1464 75 end
Chris@1464 76 end