menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
:if => Proc.new { |p| p.shared_versions.any? }
menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
+ menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
+ :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) },
+ :if => Proc.new { |p| Setting.new_project_issue_tab_enabled? && p.trackers.any? },
+ :permission => :add_issues
menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
def test_index_should_include_new_issue_link
@request.session[:user_id] = 2
get :index, :project_id => 1
- assert_select 'a.new-issue[href="/projects/ecookbook/issues/new"]', :text => 'New issue'
+ assert_select '#content a.new-issue[href="/projects/ecookbook/issues/new"]', :text => 'New issue'
end
def test_index_should_not_include_new_issue_link_for_project_without_trackers
@request.session[:user_id] = 2
get :index, :project_id => 1
- assert_select 'a.new-issue', 0
+ assert_select '#content a.new-issue', 0
end
def test_index_should_not_include_new_issue_link_for_users_with_copy_issues_permission_only
@request.session[:user_id] = 2
get :index, :project_id => 1
- assert_select 'a.new-issue', 0
+ assert_select '#content a.new-issue', 0
end
def test_index_without_project_should_include_new_issue_link
@request.session[:user_id] = 2
get :index
- assert_select 'a.new-issue[href="/issues/new"]', :text => 'New issue'
+ assert_select '#content a.new-issue[href="/issues/new"]', :text => 'New issue'
+ end
+
+ def test_index_should_not_include_new_issue_tab_when_disabled
+ with_settings :new_project_issue_tab_enabled => '0' do
+ @request.session[:user_id] = 2
+ get :index, :project_id => 1
+ assert_select '#main-menu a.new-issue', 0
+ end
+ end
+
+ def test_index_should_include_new_issue_tab_when_enabled
+ with_settings :new_project_issue_tab_enabled => '1' do
+ @request.session[:user_id] = 2
+ get :index, :project_id => 1
+ assert_select '#main-menu a.new-issue[href="/projects/ecookbook/issues/new"]', :text => 'New issue'
+ end
+ end
+
+ def test_new_should_have_new_issue_tab_as_current_menu_item
+ with_settings :new_project_issue_tab_enabled => '1' do
+ @request.session[:user_id] = 2
+ get :new, :project_id => 1
+ assert_select '#main-menu a.new-issue.selected'
+ end
+ end
+
+ def test_index_should_not_include_new_issue_tab_for_project_without_trackers
+ with_settings :new_project_issue_tab_enabled => '1' do
+ Project.find(1).trackers.clear
+
+ @request.session[:user_id] = 2
+ get :index, :project_id => 1
+ assert_select '#main-menu a.new-issue', 0
+ end
+ end
+
+ def test_index_should_not_include_new_issue_tab_for_users_with_copy_issues_permission_only
+ with_settings :new_project_issue_tab_enabled => '1' do
+ role = Role.find(1)
+ role.remove_permission! :add_issues
+ role.add_permission! :copy_issues
+
+ @request.session[:user_id] = 2
+ get :index, :project_id => 1
+ assert_select '#main-menu a.new-issue', 0
+ end
end
def test_show_by_anonymous