From 156eca4d223efce4abd67c9ef7b129a3d07d83e6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Barth Date: Fri, 8 Oct 2010 03:09:51 +0000 Subject: Added ability to edit issues from different project through contextual menu (#5332) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4242 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/functional/context_menus_controller_test.rb | 12 +++++++ test/functional/issues_controller_test.rb | 46 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+) (limited to 'test/functional') diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb index 0202cf2c7..6d2b45bad 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/context_menus_controller_test.rb @@ -85,6 +85,18 @@ class ContextMenusControllerTest < ActionController::TestCase assert_response :success assert_template 'context_menu' ids = "ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=6" + 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 => '' } assert_tag :tag => 'a', :content => 'Delete', :attributes => { :href => "/issues/destroy?#{ids}", :class => 'icon-del' } diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 4db2dae86..59b16c32c 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -911,6 +911,19 @@ class IssuesControllerTest < ActionController::TestCase assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'} end + def test_get_bulk_edit_on_different_projects + @request.session[:user_id] = 2 + get :bulk_edit, :ids => [1, 2, 6] + assert_response :success + assert_template 'bulk_edit' + + # Project specific custom field, date type + field = CustomField.find(9) + assert !field.is_for_all? + assert !field.project_ids.include?(Issue.find(6).project_id) + assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'} + end + def test_bulk_update @request.session[:user_id] = 2 # update issues priority @@ -930,6 +943,39 @@ class IssuesControllerTest < ActionController::TestCase assert_equal 1, journal.details.size end + def test_bulk_update_on_different_projects + @request.session[:user_id] = 2 + # update issues priority + post :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing', + :issue => {:priority_id => 7, + :assigned_to_id => '', + :custom_field_values => {'2' => ''}} + + assert_response 302 + # check that the issues were updated + assert_equal [7, 7, 7], Issue.find([1,2,6]).map(&:priority_id) + + issue = Issue.find(1) + journal = issue.journals.find(:first, :order => 'created_on DESC') + assert_equal '125', issue.custom_value_for(2).value + assert_equal 'Bulk editing', journal.notes + assert_equal 1, journal.details.size + end + + def test_bulk_update_on_different_projects_without_rights + @request.session[:user_id] = 3 + user = User.find(3) + action = { :controller => "issues", :action => "bulk_update" } + assert user.allowed_to?(action, Issue.find(1).project) + assert ! user.allowed_to?(action, Issue.find(6).project) + post :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail', + :issue => {:priority_id => 7, + :assigned_to_id => '', + :custom_field_values => {'2' => ''}} + assert_response 403 + assert_not_equal "Bulk should fail", Journal.last.notes + end + def test_bullk_update_should_send_a_notification @request.session[:user_id] = 2 ActionMailer::Base.deliveries.clear -- cgit v1.2.3