##// END OF EJS Templates
Fixed: User#allowed_to? returning true in any case if array of projects had only one item (#5332)...
Jean-Baptiste Barth -
r4119:e59c927ee52d
parent child
Show More
@@ -368,8 +368,10 class User < Principal
368
368
369 elsif project && project.is_a?(Array)
369 elsif project && project.is_a?(Array)
370 # Authorize if user is authorized on every element of the array
370 # Authorize if user is authorized on every element of the array
371 project.inject do |memo,p|
371 project.map do |p|
372 memo && allowed_to?(action,p,options)
372 allowed_to?(action,p,options)
373 end.inject do |memo,p|
374 memo && p
373 end
375 end
374 elsif options[:global]
376 elsif options[:global]
375 # Admin users are always authorized
377 # Admin users are always authorized
@@ -408,6 +408,10 class UserTest < ActiveSupport::TestCase
408 assert @jsmith.allowed_to?(:edit_issues, @jsmith.projects) #Manager or Developer everywhere
408 assert @jsmith.allowed_to?(:edit_issues, @jsmith.projects) #Manager or Developer everywhere
409 assert ! @jsmith.allowed_to?(:delete_issue_watchers, @jsmith.projects) #Dev cannot delete_issue_watchers
409 assert ! @jsmith.allowed_to?(:delete_issue_watchers, @jsmith.projects) #Dev cannot delete_issue_watchers
410 end
410 end
411
412 should "behave correctly with arrays of 1 project" do
413 assert ! User.anonymous.allowed_to?(:delete_issues, [Project.first])
414 end
411 end
415 end
412
416
413 context "with options[:global]" do
417 context "with options[:global]" do
General Comments 0
You need to be logged in to leave comments. Login now