2011-05-30 00:11:52 +04:00
|
|
|
#-- copyright
|
|
|
|
# ChiliProject is a project management system.
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# Copyright (C) 2010-2011 the ChiliProject Team
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# 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.
|
2011-05-30 22:52:25 +04:00
|
|
|
#
|
2011-05-30 00:11:52 +04:00
|
|
|
# See doc/COPYRIGHT.rdoc for more details.
|
|
|
|
#++
|
|
|
|
|
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
|
|
|
|
fixtures :all
|
|
|
|
|
|
|
|
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',
|
2010-09-03 23:54:24 +04:00
|
|
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&issue%5Bstatus_id%5D=5',
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Immediate',
|
|
|
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&issue%5Bpriority_id%5D=8',
|
|
|
|
:class => '' }
|
|
|
|
# Versions
|
|
|
|
assert_tag :tag => 'a', :content => '2.0',
|
|
|
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3',
|
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'eCookbook Subproject 1 - 2.0',
|
|
|
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4',
|
|
|
|
:class => '' }
|
|
|
|
|
|
|
|
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
|
|
|
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3',
|
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Duplicate',
|
|
|
|
:attributes => { :href => '/projects/ecookbook/issues/1/copy',
|
|
|
|
:class => 'icon-duplicate' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Copy',
|
|
|
|
:attributes => { :href => '/issues/move/new?copy_options%5Bcopy%5D=t&ids%5B%5D=1',
|
|
|
|
:class => 'icon-copy' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Move',
|
|
|
|
:attributes => { :href => '/issues/move/new?ids%5B%5D=1',
|
|
|
|
:class => 'icon-move' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Delete',
|
|
|
|
:attributes => { :href => '/issues/destroy?ids%5B%5D=1',
|
|
|
|
: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-05-30 22:52:25 +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-05-30 22:52:25 +04:00
|
|
|
|
2011-01-10 00:01:40 +03:00
|
|
|
ids = assigns(:issues).map(&:id).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-01-10 00:01:40 +03:00
|
|
|
:attributes => { :href => "/issues/bulk_edit?#{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-01-10 00:01:40 +03:00
|
|
|
:attributes => { :href => "/issues/bulk_edit?#{ids}&issue%5Bpriority_id%5D=8",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Dave Lopper',
|
2011-01-10 00:01:40 +03:00
|
|
|
:attributes => { :href => "/issues/bulk_edit?#{ids}&issue%5Bassigned_to_id%5D=3",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Copy',
|
2011-01-10 00:01:40 +03:00
|
|
|
:attributes => { :href => "/issues/move/new?copy_options%5Bcopy%5D=t&#{ids}",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => 'icon-copy' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Move',
|
2011-01-10 00:01:40 +03:00
|
|
|
:attributes => { :href => "/issues/move/new?#{ids}",
|
2010-08-19 22:16:54 +04:00
|
|
|
:class => 'icon-move' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Delete',
|
2011-01-10 00:01:40 +03:00
|
|
|
:attributes => { :href => "/issues/destroy?#{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-05-30 22:52:25 +04:00
|
|
|
|
2011-01-10 00:01:40 +03:00
|
|
|
ids = assigns(:issues).map(&:id).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',
|
|
|
|
:attributes => { :href => "/issues/bulk_edit?#{ids}&issue%5Bstatus_id%5D=5",
|
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'Immediate',
|
|
|
|
:attributes => { :href => "/issues/bulk_edit?#{ids}&issue%5Bpriority_id%5D=8",
|
|
|
|
:class => '' }
|
|
|
|
assert_tag :tag => 'a', :content => 'John Smith',
|
|
|
|
:attributes => { :href => "/issues/bulk_edit?#{ids}&issue%5Bassigned_to_id%5D=2",
|
|
|
|
:class => '' }
|
2010-08-19 22:16:54 +04:00
|
|
|
assert_tag :tag => 'a', :content => 'Delete',
|
2010-10-07 09:11:28 +04:00
|
|
|
:attributes => { :href => "/issues/destroy?#{ids}",
|
|
|
|
:class => 'icon-del' }
|
2010-08-19 22:16:54 +04:00
|
|
|
end
|
2011-05-30 22:52:25 +04:00
|
|
|
|
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
|
2010-08-19 22:16:54 +04:00
|
|
|
end
|