summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-08-30 19:24:03 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-08-30 19:24:03 +0000
commitd5ca4a3593de4f997c3caa10ed3cd74f95307571 (patch)
tree831ddded4e67987a0b6ecb042956bcc63baba249 /test
parent650a64cb0020ac849eaefb20abbbb090abcb6b3d (diff)
downloadredmine-d5ca4a3593de4f997c3caa10ed3cd74f95307571.tar.gz
redmine-d5ca4a3593de4f997c3caa10ed3cd74f95307571.zip
Fixed that restricted custom permissions on for non member/anonymous does not work (#23655).
git-svn-id: http://svn.redmine.org/redmine/trunk@15750 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/issue_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 78a06556e..8c95023e7 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -319,6 +319,28 @@ class IssueTest < ActiveSupport::TestCase
assert_equal false, Issue.where(:project_id => 1).first.visible?(user)
end
+ def test_visible_scope_with_custom_non_member_role_having_restricted_permission
+ role = Role.generate!(:permissions => [:view_project])
+ assert Role.non_member.has_permission?(:view_issues)
+ user = User.generate!
+ Member.create!(:principal => Group.non_member, :project_id => 1, :roles => [role])
+
+ issues = Issue.visible(user).to_a
+ assert issues.any?
+ assert_nil issues.detect {|issue| issue.project_id == 1}
+ end
+
+ def test_visible_scope_with_custom_non_member_role_having_extended_permission
+ role = Role.generate!(:permissions => [:view_project, :view_issues])
+ Role.non_member.remove_permission!(:view_issues)
+ user = User.generate!
+ Member.create!(:principal => Group.non_member, :project_id => 1, :roles => [role])
+
+ issues = Issue.visible(user).to_a
+ assert issues.any?
+ assert_not_nil issues.detect {|issue| issue.project_id == 1}
+ end
+
def test_visible_scope_for_member_with_groups_should_return_assigned_issues
user = User.find(8)
assert user.groups.any?
href='#n79'>79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212