Skip to content

Commit

Permalink
Fixed: User#allowed_to? returning true in any case if array of projec…
Browse files Browse the repository at this point in the history
…ts had only one item (#5332)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4233 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jbbarth committed Oct 6, 2010
1 parent e13790c commit e59c927
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,10 @@ def allowed_to?(action, project, options={})

elsif project && project.is_a?(Array)
# Authorize if user is authorized on every element of the array
project.inject do |memo,p|
memo && allowed_to?(action,p,options)
project.map do |p|
allowed_to?(action,p,options)
end.inject do |memo,p|
memo && p
end
elsif options[:global]
# Admin users are always authorized
Expand Down
4 changes: 4 additions & 0 deletions test/unit/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ def denied_auth_source.allow_password_changes?; false; end
assert @jsmith.allowed_to?(:edit_issues, @jsmith.projects) #Manager or Developer everywhere
assert ! @jsmith.allowed_to?(:delete_issue_watchers, @jsmith.projects) #Dev cannot delete_issue_watchers
end

should "behave correctly with arrays of 1 project" do
assert ! User.anonymous.allowed_to?(:delete_issues, [Project.first])
end
end

context "with options[:global]" do
Expand Down

0 comments on commit e59c927

Please sign in to comment.