Feature #30207 ยป 30207-cross-project-menu.patch
| lib/redmine.rb | ||
|---|---|---|
|
:caption => :label_project_plural
|
||
|
menu.push :activity, {:controller => 'activities', :action => 'index'}
|
||
|
menu.push :issues, {:controller => 'issues', :action => 'index'},
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_issues, nil, :global => true)},
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_issues, nil, :global => true) && EnabledModule.exists?(:project => Project.visible, :name => :issue_tracking)},
|
||
|
:caption => :label_issue_plural
|
||
|
menu.push :time_entries, {:controller => 'timelog', :action => 'index'},
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_time_entries, nil, :global => true)},
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_time_entries, nil, :global => true) && EnabledModule.exists?(:project => Project.visible, :name => :time_tracking)},
|
||
|
:caption => :label_spent_time
|
||
|
menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :caption => :label_gantt,
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_gantt, nil, :global => true)}
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_gantt, nil, :global => true) && EnabledModule.exists?(:project => Project.visible, :name => :gantt)}
|
||
|
menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :caption => :label_calendar,
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_calendar, nil, :global => true)}
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_calendar, nil, :global => true) && EnabledModule.exists?(:project => Project.visible, :name => :calendar)}
|
||
|
menu.push :news, {:controller => 'news', :action => 'index'},
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_news, nil, :global => true)},
|
||
|
:if => Proc.new {User.current.allowed_to?(:view_news, nil, :global => true) && EnabledModule.exists?(:project => Project.visible, :name => :news)},
|
||
|
:caption => :label_news_plural
|
||
|
end
|
||
| test/integration/lib/redmine/menu_manager_test.rb | ||
|---|---|---|
|
get '/'
|
||
|
assert_select 'body.has-main-menu', 0
|
||
|
end
|
||
|
def test_application_menu_should_show_only_enabled_modules_with_cross_projects
|
||
|
user = User.find_by_login('dlopper')
|
||
|
assert_equal [1, 3, 4, 6], Project.visible(user).ids
|
||
|
# Delete the EnabledModule with project_id in [1, 4, 6]
|
||
|
EnabledModule.where(:project_id => [1, 4, 6]).delete_all
|
||
|
assert_equal ["repository", "wiki", "time_tracking", "issue_tracking", "calendar", "gantt"], Project.find(3).enabled_module_names
|
||
|
log_user('dlopper', 'foo')
|
||
|
get '/projects'
|
||
|
assert_select '#main-menu' do
|
||
|
assert_select 'a.projects', :count => 1
|
||
|
assert_select 'a.activity', :count => 1
|
||
|
assert_select 'a.issues', :count => 1 # issue_tracking
|
||
|
assert_select 'a.time-entries', :count => 1 # time_tracking
|
||
|
assert_select 'a.gantt', :count => 1 # gantt
|
||
|
assert_select 'a.calendar', :count => 1 # calendar
|
||
|
assert_select 'a.news', :count => 0 # news
|
||
|
end
|
||
|
assert_select '#projects-index' do
|
||
|
assert_select 'a.project', :count => 4 # Project.visible(user).count
|
||
|
end
|
||
|
end
|
||
|
end
|
||