2012-12-04 02:23:23 +04:00
|
|
|
# Redmine - project management software
|
|
|
|
# Copyright (C) 2006-2012 Jean-Philippe Lang
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2010-12-13 02:24:34 +03:00
|
|
|
require File.expand_path('../../test_helper', __FILE__)
|
2010-08-19 22:16:54 +04:00
|
|
|
|
|
|
|
class ContextMenusControllerTest < ActionController::TestCase
|
2011-09-24 11:07:35 +04:00
|
|
|
fixtures :projects,
|
|
|
|
:trackers,
|
|
|
|
:projects_trackers,
|
|
|
|
:roles,
|
|
|
|
:member_roles,
|
|
|
|
:members,
|
|
|
|
:enabled_modules,
|
|
|
|
:workflows,
|
|
|
|
:journals, :journal_details,
|
|
|
|
:versions,
|
|
|
|
:issues, :issue_statuses, :issue_categories,
|
|
|
|
:users,
|
2011-12-01 23:04:13 +04:00
|
|
|
:enumerations,
|
|
|
|
:time_entries
|
2010-08-19 22:16:54 +04:00
|
|
|
|
|
|
|
def test_context_menu_one_issue
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
get :issues, :ids => [1]
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'context_menu'
|
|
|
|
assert_tag :tag => 'a', :content => 'Edit',
|
|
|
|
:attributes => { :href => '/issues/1/edit',
|
|
|
|
:class => 'icon-edit' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Closed',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5',
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Immediate',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8',
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
2011-06-13 23:43:40 +04:00
|
|
|
assert_no_tag :tag => 'a', :content => 'Inactive Priority'
|
2010-08-19 22:16:54 +04:00
|
|
|
# Versions
|
|
|
|
assert_tag :tag => 'a', :content => '2.0',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3',
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'eCookbook Subproject 1 - 2.0',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4',
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
|
|
|
|
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3',
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Copy',
|
2012-01-08 15:16:54 +04:00
|
|
|
:attributes => { :href => '/projects/ecookbook/issues/1/copy',
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => 'icon-copy' }
|
2012-01-07 16:46:36 +04:00
|
|
|
assert_no_tag :tag => 'a', :content => 'Move'
|
2010-08-19 22:16:54 +04:00
|
|
|
assert_tag :tag => 'a', :content => 'Delete',
|
2011-12-10 15:44:25 +04:00
|
|
|
:attributes => { :href => '/issues?ids%5B%5D=1',
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => 'icon-del' }
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_context_menu_one_issue_by_anonymous
|
|
|
|
get :issues, :ids => [1]
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'context_menu'
|
|
|
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
|
|
:attributes => { :href => '#',
|
|
|
|
:class => 'icon-del disabled' }
|
|
|
|
end
|
2011-08-30 19:55:54 +04:00
|
|
|
|
2010-08-19 22:16:54 +04:00
|
|
|
def test_context_menu_multiple_issues_of_same_project
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
get :issues, :ids => [1, 2]
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'context_menu'
|
2011-01-10 00:01:40 +03:00
|
|
|
assert_not_nil assigns(:issues)
|
|
|
|
assert_equal [1, 2], assigns(:issues).map(&:id).sort
|
2011-08-30 19:55:54 +04:00
|
|
|
|
2012-07-08 21:10:58 +04:00
|
|
|
ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&')
|
2010-08-19 22:16:54 +04:00
|
|
|
assert_tag :tag => 'a', :content => 'Edit',
|
2011-01-10 00:01:40 +03:00
|
|
|
:attributes => { :href => "/issues/bulk_edit?#{ids}",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => 'icon-edit' }
|
2010-09-03 23:54:24 +04:00
|
|
|
assert_tag :tag => 'a', :content => 'Closed',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5",
|
2010-09-03 23:54:24 +04:00
|
|
|
:class => '' }
|
2010-08-19 22:16:54 +04:00
|
|
|
assert_tag :tag => 'a', :content => 'Immediate',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=3",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Copy',
|
2012-01-07 21:27:47 +04:00
|
|
|
:attributes => { :href => "/issues/bulk_edit?copy=1&#{ids}",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => 'icon-copy' }
|
2012-01-07 20:26:12 +04:00
|
|
|
assert_no_tag :tag => 'a', :content => 'Move'
|
2010-08-19 22:16:54 +04:00
|
|
|
assert_tag :tag => 'a', :content => 'Delete',
|
2011-12-10 15:44:25 +04:00
|
|
|
:attributes => { :href => "/issues?#{ids}",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => 'icon-del' }
|
|
|
|
end
|
|
|
|
|
2010-10-07 09:11:28 +04:00
|
|
|
def test_context_menu_multiple_issues_of_different_projects
|
2010-08-19 22:16:54 +04:00
|
|
|
@request.session[:user_id] = 2
|
2010-10-07 09:11:28 +04:00
|
|
|
get :issues, :ids => [1, 2, 6]
|
2010-08-19 22:16:54 +04:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'context_menu'
|
2011-01-10 00:01:40 +03:00
|
|
|
assert_not_nil assigns(:issues)
|
|
|
|
assert_equal [1, 2, 6], assigns(:issues).map(&:id).sort
|
2011-08-30 19:55:54 +04:00
|
|
|
|
2012-07-08 21:10:58 +04:00
|
|
|
ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&')
|
2010-10-08 07:09:51 +04:00
|
|
|
assert_tag :tag => 'a', :content => 'Edit',
|
|
|
|
:attributes => { :href => "/issues/bulk_edit?#{ids}",
|
|
|
|
:class => 'icon-edit' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Closed',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5",
|
2010-10-08 07:09:51 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Immediate',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8",
|
2010-10-08 07:09:51 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'John Smith',
|
2011-12-15 00:23:46 +04:00
|
|
|
:attributes => { :href => "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=2",
|
2010-10-08 07:09:51 +04:00
|
|
|
:class => '' }
|
2010-08-19 22:16:54 +04:00
|
|
|
assert_tag :tag => 'a', :content => 'Delete',
|
2011-12-10 15:44:25 +04:00
|
|
|
:attributes => { :href => "/issues?#{ids}",
|
2010-10-07 09:11:28 +04:00
|
|
|
:class => 'icon-del' }
|
2010-08-19 22:16:54 +04:00
|
|
|
end
|
2011-08-30 19:55:54 +04:00
|
|
|
|
2012-02-09 22:22:11 +04:00
|
|
|
def test_context_menu_should_include_list_custom_fields
|
|
|
|
field = IssueCustomField.create!(:name => 'List', :field_format => 'list',
|
|
|
|
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
|
|
|
@request.session[:user_id] = 2
|
2012-02-11 18:53:31 +04:00
|
|
|
get :issues, :ids => [1]
|
2012-02-09 22:22:11 +04:00
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'List',
|
|
|
|
:attributes => {:href => '#'},
|
|
|
|
:sibling => {:tag => 'ul', :children => {:count => 3}}
|
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'Foo',
|
2012-02-11 18:53:31 +04:00
|
|
|
:attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo"}
|
2012-02-09 22:22:11 +04:00
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'none',
|
2012-02-11 18:53:31 +04:00
|
|
|
:attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D="}
|
2012-02-09 22:22:11 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_context_menu_should_not_include_null_value_for_required_custom_fields
|
|
|
|
field = IssueCustomField.create!(:name => 'List', :is_required => true, :field_format => 'list',
|
|
|
|
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
get :issues, :ids => [1, 2]
|
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'List',
|
|
|
|
:attributes => {:href => '#'},
|
|
|
|
:sibling => {:tag => 'ul', :children => {:count => 2}}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_context_menu_on_single_issue_should_select_current_custom_field_value
|
|
|
|
field = IssueCustomField.create!(:name => 'List', :field_format => 'list',
|
|
|
|
:possible_values => ['Foo', 'Bar'], :is_for_all => true, :tracker_ids => [1, 2, 3])
|
|
|
|
issue = Issue.find(1)
|
|
|
|
issue.custom_field_values = {field.id => 'Bar'}
|
|
|
|
issue.save!
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
get :issues, :ids => [1]
|
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'List',
|
|
|
|
:attributes => {:href => '#'},
|
|
|
|
:sibling => {:tag => 'ul', :children => {:count => 3}}
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'Bar',
|
|
|
|
:attributes => {:class => /icon-checked/}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_context_menu_should_include_bool_custom_fields
|
|
|
|
field = IssueCustomField.create!(:name => 'Bool', :field_format => 'bool',
|
|
|
|
:is_for_all => true, :tracker_ids => [1, 2, 3])
|
|
|
|
@request.session[:user_id] = 2
|
2012-02-11 18:53:31 +04:00
|
|
|
get :issues, :ids => [1]
|
2012-02-09 22:22:11 +04:00
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'Bool',
|
|
|
|
:attributes => {:href => '#'},
|
|
|
|
:sibling => {:tag => 'ul', :children => {:count => 3}}
|
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'Yes',
|
2012-02-11 18:53:31 +04:00
|
|
|
:attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1"}
|
2012-02-09 22:22:11 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_context_menu_should_include_user_custom_fields
|
|
|
|
field = IssueCustomField.create!(:name => 'User', :field_format => 'user',
|
|
|
|
:is_for_all => true, :tracker_ids => [1, 2, 3])
|
|
|
|
@request.session[:user_id] = 2
|
2012-02-11 18:53:31 +04:00
|
|
|
get :issues, :ids => [1]
|
2012-02-09 22:22:11 +04:00
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'User',
|
|
|
|
:attributes => {:href => '#'},
|
|
|
|
:sibling => {:tag => 'ul', :children => {:count => Project.find(1).members.count + 1}}
|
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'John Smith',
|
2012-02-11 18:53:31 +04:00
|
|
|
:attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2"}
|
2012-02-09 22:22:11 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_context_menu_should_include_version_custom_fields
|
|
|
|
field = IssueCustomField.create!(:name => 'Version', :field_format => 'version', :is_for_all => true, :tracker_ids => [1, 2, 3])
|
|
|
|
@request.session[:user_id] = 2
|
2012-02-11 18:53:31 +04:00
|
|
|
get :issues, :ids => [1]
|
2012-02-09 22:22:11 +04:00
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => 'Version',
|
|
|
|
:attributes => {:href => '#'},
|
|
|
|
:sibling => {:tag => 'ul', :children => {:count => Project.find(1).shared_versions.count + 1}}
|
|
|
|
|
|
|
|
assert_tag 'a',
|
|
|
|
:content => '2.0',
|
2012-02-11 18:53:31 +04:00
|
|
|
:attributes => {:href => "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3"}
|
2012-02-09 22:22:11 +04:00
|
|
|
end
|
|
|
|
|
2012-01-21 15:11:13 +04:00
|
|
|
def test_context_menu_by_assignable_user_should_include_assigned_to_me_link
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
get :issues, :ids => [1]
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'context_menu'
|
|
|
|
|
|
|
|
assert_tag :tag => 'a', :content => / me /,
|
|
|
|
:attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2',
|
|
|
|
:class => '' }
|
|
|
|
end
|
|
|
|
|
2012-07-08 17:19:46 +04:00
|
|
|
def test_context_menu_should_propose_shared_versions_for_issues_from_different_projects
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
version = Version.create!(:name => 'Shared', :sharing => 'system', :project_id => 1)
|
|
|
|
|
|
|
|
get :issues, :ids => [1, 4]
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'context_menu'
|
|
|
|
|
|
|
|
assert_include version, assigns(:versions)
|
|
|
|
assert_tag :tag => 'a', :content => 'eCookbook - Shared'
|
|
|
|
end
|
|
|
|
|
2010-12-29 22:55:52 +03:00
|
|
|
def test_context_menu_issue_visibility
|
|
|
|
get :issues, :ids => [1, 4]
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'context_menu'
|
|
|
|
assert_equal [1], assigns(:issues).collect(&:id)
|
|
|
|
end
|
2011-11-25 01:31:21 +04:00
|
|
|
|
|
|
|
def test_time_entries_context_menu
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
get :time_entries, :ids => [1, 2]
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'time_entries'
|
|
|
|
assert_tag 'a', :content => 'Edit'
|
|
|
|
assert_no_tag 'a', :content => 'Edit', :attributes => {:class => /disabled/}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_time_entries_context_menu_without_edit_permission
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
Role.find_by_name('Manager').remove_permission! :edit_time_entries
|
|
|
|
|
|
|
|
get :time_entries, :ids => [1, 2]
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'time_entries'
|
|
|
|
assert_tag 'a', :content => 'Edit', :attributes => {:class => /disabled/}
|
|
|
|
end
|
2010-08-19 22:16:54 +04:00
|
|
|
end
|