diff options
-rw-r--r-- | app/models/user.rb | 6 | ||||
-rw-r--r-- | test/unit/user_test.rb | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 2993cc152..5f9674d2d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -567,7 +567,11 @@ class User < Principal # Is the user allowed to do the specified action on any project? # See allowed_to? for the actions and valid options. - def allowed_to_globally?(action, options, &block) + # + # NB: this method is not used anywhere in the core codebase as of + # 2.5.2, but it's used by many plugins so if we ever want to remove + # it it has to be carefully deprecated for a version or two. + def allowed_to_globally?(action, options={}, &block) allowed_to?(action, nil, options.reverse_merge(:global => true), &block) end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index aa930a7a9..847c25c3b 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -1019,6 +1019,19 @@ class UserTest < ActiveSupport::TestCase end end + # this is just a proxy method, the test only calls it to ensure it doesn't break trivially + context "#allowed_to_globally?" do + should "proxy to #allowed_to? and reflect global permissions" do + @dlopper2 = User.find(5) #only Developper on a project, not Manager anywhere + @anonymous = User.find(6) + assert_equal true, @jsmith.allowed_to_globally?(:delete_issue_watchers) + assert_equal false, @dlopper2.allowed_to_globally?(:delete_issue_watchers) + assert_equal true, @dlopper2.allowed_to_globally?(:add_issues) + assert_equal false, @anonymous.allowed_to_globally?(:add_issues) + assert_equal true, @anonymous.allowed_to_globally?(:view_issues) + end + end + context "User#notify_about?" do context "Issues" do setup do |