@@ -567,7 +567,11 class User < Principal | |||||
567 |
|
567 | |||
568 | # Is the user allowed to do the specified action on any project? |
|
568 | # Is the user allowed to do the specified action on any project? | |
569 | # See allowed_to? for the actions and valid options. |
|
569 | # See allowed_to? for the actions and valid options. | |
570 | def allowed_to_globally?(action, options, &block) |
|
570 | # | |
|
571 | # NB: this method is not used anywhere in the core codebase as of | |||
|
572 | # 2.5.2, but it's used by many plugins so if we ever want to remove | |||
|
573 | # it it has to be carefully deprecated for a version or two. | |||
|
574 | def allowed_to_globally?(action, options={}, &block) | |||
571 | allowed_to?(action, nil, options.reverse_merge(:global => true), &block) |
|
575 | allowed_to?(action, nil, options.reverse_merge(:global => true), &block) | |
572 | end |
|
576 | end | |
573 |
|
577 |
@@ -1019,6 +1019,19 class UserTest < ActiveSupport::TestCase | |||||
1019 | end |
|
1019 | end | |
1020 | end |
|
1020 | end | |
1021 |
|
1021 | |||
|
1022 | # this is just a proxy method, the test only calls it to ensure it doesn't break trivially | |||
|
1023 | context "#allowed_to_globally?" do | |||
|
1024 | should "proxy to #allowed_to? and reflect global permissions" do | |||
|
1025 | @dlopper2 = User.find(5) #only Developper on a project, not Manager anywhere | |||
|
1026 | @anonymous = User.find(6) | |||
|
1027 | assert_equal true, @jsmith.allowed_to_globally?(:delete_issue_watchers) | |||
|
1028 | assert_equal false, @dlopper2.allowed_to_globally?(:delete_issue_watchers) | |||
|
1029 | assert_equal true, @dlopper2.allowed_to_globally?(:add_issues) | |||
|
1030 | assert_equal false, @anonymous.allowed_to_globally?(:add_issues) | |||
|
1031 | assert_equal true, @anonymous.allowed_to_globally?(:view_issues) | |||
|
1032 | end | |||
|
1033 | end | |||
|
1034 | ||||
1022 | context "User#notify_about?" do |
|
1035 | context "User#notify_about?" do | |
1023 | context "Issues" do |
|
1036 | context "Issues" do | |
1024 | setup do |
|
1037 | setup do |
General Comments 0
You need to be logged in to leave comments.
Login now